Trim include dependency tree (particularly on evoral/Sequence.hpp).
[ardour.git] / libs / ardour / meter.cc
index 6ea5a30920a8ddafc82edba8907e58718644034c..af6b5a0a361f7390de0fab36a282bcbe94fe049c 100644 (file)
@@ -23,6 +23,9 @@
 #include <ardour/peak.h>
 #include <ardour/dB.h>
 #include <ardour/session.h>
+#include <ardour/midi_buffer.h>
+#include <ardour/audio_buffer.h>
+#include <ardour/runtime_functions.h>
 
 namespace ARDOUR {
 
@@ -33,21 +36,20 @@ namespace ARDOUR {
  * be set to 0.
  */
 void
-PeakMeter::run (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset)
+PeakMeter::run_in_place (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset)
 {
-       size_t meterable = std::min((size_t)bufs.count().n_total(), _peak_power.size());
-
-       size_t n = 0;
+       uint32_t n = 0;
+       uint32_t meterable = std::min(bufs.count().n_total(), (uint32_t)_peak_power.size());
+       uint32_t limit = std::min (meterable, (uint32_t)bufs.count().n_midi());
 
        // Meter what we have (midi)
-       for ( ; n < meterable && n < bufs.count().n_midi(); ++n) {
-               
+       for ( ; n < limit; ++n) {
                float val = 0;
                
                // GUI needs a better MIDI meter, not much information can be
                // expressed through peaks alone
                for (MidiBuffer::iterator i = bufs.get_midi(n).begin(); i != bufs.get_midi(n).end(); ++i) {
-                       const MidiEvent& ev = *i;
+                       const Evoral::MIDIEvent<nframes_t> ev(*i, false);
                        if (ev.is_note_on()) {
                                const float this_vel = log(ev.buffer()[2] / 127.0 * (M_E*M_E-M_E) + M_E) - 1.0;
                                //printf("V %d -> %f\n", (int)((Byte)ev.buffer[2]), this_vel);
@@ -64,8 +66,10 @@ PeakMeter::run (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, nfr
 
        }
        
+       limit = std::min (meterable, bufs.count().n_audio());
+
        // Meter what we have (audio)
-       for ( ; n < meterable && n < bufs.count().n_audio(); ++n) {
+       for ( ; n < limit; ++n) {
                _peak_power[n] = compute_peak (bufs.get_audio(n).data(nframes, offset), nframes, _peak_power[n]); 
        }
 
@@ -95,8 +99,9 @@ bool
 PeakMeter::configure_io (ChanCount in, ChanCount out)
 {
        /* we're transparent no matter what.  fight the power. */
-       if (out != in)
+       if (out != in) {
                return false;
+       }
 
        uint32_t limit = in.n_total();
 
@@ -116,9 +121,7 @@ PeakMeter::configure_io (ChanCount in, ChanCount out)
        assert(_visible_peak_power.size() == limit);
        assert(_max_peak_power.size() == limit);
 
-       Processor::configure_io(in, out);
-
-       return true;
+       return Processor::configure_io (in, out);
 }
 
 /** To be driven by the Meter signal from IO.