make i18n build work ; add mackie dir back to build ; token work on amp for MIDI...
[ardour.git] / libs / ardour / amp.cc
index 9aa88068a95052b419fdbf50798775e5c1b725b2..0efaaa35358bd1c20ee9eaf8b625278037608060 100644 (file)
@@ -28,6 +28,7 @@
 #include "ardour/buffer_set.h"
 #include "ardour/configuration.h"
 #include "ardour/io.h"
+#include "ardour/midi_buffer.h"
 #include "ardour/mute_master.h"
 #include "ardour/session.h"
 
@@ -71,11 +72,11 @@ Amp::configure_io (ChanCount in, ChanCount out)
 }
 
 void
-Amp::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t nframes)
+Amp::run (BufferSet& bufs, sframes_t /*start_frame*/, sframes_t /*end_frame*/, nframes_t nframes)
 {
        gain_t mute_gain;
 
-       if (!_active) {
+       if (!_active && !_pending_active) {
                return;
        }
 
@@ -159,6 +160,8 @@ Amp::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nframes_t
                        } 
                }
        }
+
+       _active = _pending_active;
 }
 
 void
@@ -191,9 +194,26 @@ Amp::apply_gain (BufferSet& bufs, nframes_t nframes, gain_t initial, gain_t targ
                delta = target - initial;
        }
 
+       /* MIDI Gain */
+
+       for (BufferSet::midi_iterator i = bufs.midi_begin(); i != bufs.midi_end(); ++i) {
+#if 0
+               MidiBuffer& mb (*i);
+
+               for (MidiBuffer::iterator m = mb.begin(); m != mb.end(); ++m) {
+                       Evoral::MIDIEvent<MidiBuffer::TimeType> ev (*m);
+                       if (ev.buffer()[0] == MIDI_CMD_NOTE_ON) {
+                               ev.buffer()[2] = (uint8_t) rint (ev.buffer()[2] * 1.0);
+                       }
+               }
+#endif
+       }
+
+       /* Audio Gain */
+
        for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
                Sample* const buffer = i->data();
-
+               
                fractional_pos = 1.0;
 
                for (nframes_t nx = 0; nx < declick; ++nx) {