mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-17 04:06:26 +01:00
Logarithmic MIDI metering.
git-svn-id: svn://localhost/ardour2/trunk@1978 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
bc60785ea5
commit
b17a003d0a
1 changed files with 6 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue