+ 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 Evoral::MIDIEvent& ev = *i;
+ 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);
+ if (this_vel > val)
+ val = this_vel;
+ } else {
+ val += 1.0 / bufs.get_midi(n).capacity();
+ if (val > 1.0)
+ val = 1.0;
+ }
+ }
+
+ _peak_power[n] = val;
+
+ }
+
+ // Meter what we have (audio)
+ for ( ; n < meterable && n < bufs.count().n_audio(); ++n) {