Fix MIDI delay-line (amend 25098ed
)
Events in the delay-buffer must be shifted back every cycle. Also in case of fixed-delay-lines events may not be in sequence since events are only sorted at backend port-level.
This commit is contained in:
parent
576f10b6f1
commit
ae0aa50b6f
@ -231,20 +231,18 @@ DelayLine::run (BufferSet& bufs, samplepos_t /* start_sample */, samplepos_t /*
|
||||
dly->silence (n_samples);
|
||||
}
|
||||
|
||||
if (delay_diff != 0) {
|
||||
/* If the delay time changes, iterate over all events in the dly-buffer
|
||||
* and adjust the time in-place. <= 0 becomes 0.
|
||||
*
|
||||
* iterate over all events in dly-buffer and subtract one cycle
|
||||
* (n_samples) from the timestamp, bringing them closer to de-queue.
|
||||
*/
|
||||
for (MidiBuffer::iterator m = dly->begin (); m != dly->end (); ++m) {
|
||||
MidiBuffer::TimeType *t = m.timeptr ();
|
||||
if (*t > n_samples + delay_diff) {
|
||||
*t -= n_samples + delay_diff;
|
||||
} else {
|
||||
*t = 0;
|
||||
}
|
||||
/* If the delay time changes, iterate over all events in the dly-buffer
|
||||
* and adjust the time in-place. <= 0 becomes 0.
|
||||
*
|
||||
* iterate over all events in dly-buffer and subtract one cycle
|
||||
* (n_samples) from the timestamp, bringing them closer to de-queue.
|
||||
*/
|
||||
for (MidiBuffer::iterator m = dly->begin (); m != dly->end (); ++m) {
|
||||
MidiBuffer::TimeType *t = m.timeptr ();
|
||||
if (*t > n_samples + delay_diff) {
|
||||
*t -= n_samples + delay_diff;
|
||||
} else {
|
||||
*t = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ FixedDelay::delay (
|
||||
if (ev.time () < n_samples) {
|
||||
mout->push_back (ev);
|
||||
} else {
|
||||
mdly->push_back (ev);
|
||||
mdly->insert_event (ev);
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,9 +158,16 @@ FixedDelay::delay (
|
||||
if (ev.time () >= n_samples) {
|
||||
break;
|
||||
}
|
||||
mout->push_back (ev);
|
||||
mout->insert_event (ev);
|
||||
m = mdly->erase (m);
|
||||
}
|
||||
|
||||
/* prepare for next cycle */
|
||||
for (MidiBuffer::iterator m = mdly->begin (); m != mdly->end (); ++m) {
|
||||
MidiBuffer::TimeType *t = m.timeptr ();
|
||||
assert (*t >= n_samples);
|
||||
*t -= n_samples;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user