Logarithmic MIDI metering.

git-svn-id: svn://localhost/ardour2/trunk@1978 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2007-06-07 21:04:37 +00:00
parent bc60785ea5
commit b17a003d0a

View file

@ -51,11 +51,14 @@ PeakMeter::run (BufferSet& bufs, nframes_t nframes, nframes_t offset)
for (size_t i=0; i < n_events; ++i) {
const MidiEvent& ev = bufs.get_midi(n)[i];
if ((ev.buffer[0] & 0xF0) == MIDI_CMD_NOTE_ON) {
const float normal_vel = ev.buffer[2] / 127.0;
if (normal_vel > val)
val = normal_vel;
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;
}
}