- size_t meterable = std::min((size_t)bufs.count().n_total(), _peak_power.size());
-
- size_t n = 0;
-
- // Meter what we have (midi)
- for ( ; n < meterable && n < bufs.count().n_midi(); ++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;
- if ((ev.buffer[0] & 0xF0) == MIDI_CMD_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);
- if (this_vel > val)
+ if (!_active && !_pending_active) {
+ return;
+ }
+
+ // cerr << "meter " << name() << " runs with " << bufs.available() << " inputs\n";
+
+ const uint32_t n_audio = min (current_meters.n_audio(), bufs.count().n_audio());
+ const uint32_t n_midi = min (current_meters.n_midi(), bufs.count().n_midi());
+
+ uint32_t n = 0;
+
+ // Meter MIDI in to the first n_midi peaks
+ for (uint32_t i = 0; i < n_midi; ++i, ++n) {
+ float val = 0.0f;
+ for (MidiBuffer::iterator e = bufs.get_midi(i).begin(); e != bufs.get_midi(i).end(); ++e) {
+ const Evoral::MIDIEvent<framepos_t> ev(*e, 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;
+ if (this_vel > val) {