mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-05 05:05:43 +01:00
LV2: apply offset to MIDI events
This commit is contained in:
parent
8558b1f99e
commit
64e2f16e06
3 changed files with 13 additions and 15 deletions
|
|
@ -123,10 +123,10 @@ public:
|
|||
void ensure_lv2_bufsize(bool input, size_t i, size_t buffer_capacity);
|
||||
|
||||
/** Flush modified LV2 event output buffers back to Ardour buffers */
|
||||
void flush_lv2_midi(bool input, size_t i);
|
||||
void flush_lv2_midi(bool input, size_t i, pframes_t, samplecnt_t);
|
||||
|
||||
/** Forward plugin MIDI output to to Ardour buffers */
|
||||
void forward_lv2_midi(LV2_Evbuf*, size_t, bool purge_ardour_buffer = true);
|
||||
void forward_lv2_midi(LV2_Evbuf*, size_t, pframes_t, samplecnt_t);
|
||||
|
||||
#if defined WINDOWS_VST_SUPPORT || defined LXVST_SUPPORT || defined MACVST_SUPPORT
|
||||
VstEvents* get_vst_midi (size_t);
|
||||
|
|
|
|||
|
|
@ -285,12 +285,10 @@ BufferSet::get_lv2_midi(bool input, size_t i)
|
|||
}
|
||||
|
||||
void
|
||||
BufferSet::forward_lv2_midi(LV2_Evbuf* buf, size_t i, bool purge_ardour_buffer)
|
||||
BufferSet::forward_lv2_midi(LV2_Evbuf* buf, size_t i, pframes_t n_samples, samplecnt_t offset)
|
||||
{
|
||||
MidiBuffer& mbuf = get_midi(i);
|
||||
if (purge_ardour_buffer) {
|
||||
mbuf.silence(0, 0);
|
||||
}
|
||||
mbuf.silence (n_samples, offset);
|
||||
for (LV2_Evbuf_Iterator i = lv2_evbuf_begin(buf);
|
||||
lv2_evbuf_is_valid(i);
|
||||
i = lv2_evbuf_next(i)) {
|
||||
|
|
@ -298,19 +296,19 @@ BufferSet::forward_lv2_midi(LV2_Evbuf* buf, size_t i, bool purge_ardour_buffer)
|
|||
uint8_t* data;
|
||||
lv2_evbuf_get(i, &samples, &subframes, &type, &size, &data);
|
||||
if (type == URIMap::instance().urids.midi_MidiEvent) {
|
||||
mbuf.push_back(samples, Evoral::MIDI_EVENT, size, data);
|
||||
mbuf.push_back(samples + offset, Evoral::MIDI_EVENT, size, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BufferSet::flush_lv2_midi(bool input, size_t i)
|
||||
BufferSet::flush_lv2_midi(bool input, size_t i, pframes_t n_samples, samplecnt_t offset)
|
||||
{
|
||||
MidiBuffer& mbuf = get_midi(i);
|
||||
LV2Buffers::value_type b = _lv2_buffers.at(i * 2 + (input ? 0 : 1));
|
||||
LV2_Evbuf* evbuf = b.second;
|
||||
|
||||
mbuf.silence(0, 0);
|
||||
mbuf.silence (n_samples, offset);
|
||||
for (LV2_Evbuf_Iterator i = lv2_evbuf_begin(evbuf);
|
||||
lv2_evbuf_is_valid(i);
|
||||
i = lv2_evbuf_next(i)) {
|
||||
|
|
@ -328,7 +326,7 @@ BufferSet::flush_lv2_midi(bool input, size_t i)
|
|||
#endif
|
||||
if (type == URIMap::instance().urids.midi_MidiEvent) {
|
||||
// TODO: Make Ardour event buffers generic so plugins can communicate
|
||||
mbuf.push_back(samples, Evoral::MIDI_EVENT, size, data);
|
||||
mbuf.push_back(samples + offset, Evoral::MIDI_EVENT, size, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2912,13 +2912,13 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
|
|||
|
||||
while (m != m_end || ((tempo_map_point != tempo_map_points.end()) && ((*tempo_map_point).sample(TEMPORAL_SAMPLE_RATE) < tend))) {
|
||||
|
||||
if (m != m_end && ((tempo_map_point == tempo_map_points.end()) || (*tempo_map_point).sample(TEMPORAL_SAMPLE_RATE) > (*m).time())) {
|
||||
if (m != m_end && ((tempo_map_point == tempo_map_points.end()) || (*tempo_map_point).sample(TEMPORAL_SAMPLE_RATE) > (*m).time() + offset)) {
|
||||
|
||||
const Evoral::Event<samplepos_t> ev (*m, false);
|
||||
|
||||
if (ev.time() < nframes) {
|
||||
if (ev.time() >= offset && ev.time() < offset + nframes) {
|
||||
LV2_Evbuf_Iterator eend = lv2_evbuf_end(_ev_buffers[port_index]);
|
||||
lv2_evbuf_write(&eend, ev.time(), 0, type, ev.size(), ev.buffer());
|
||||
lv2_evbuf_write(&eend, ev.time() - offset, 0, type, ev.size(), ev.buffer());
|
||||
}
|
||||
|
||||
++m;
|
||||
|
|
@ -3041,7 +3041,7 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
|
|||
const uint32_t buf_index = out_map.get(
|
||||
DataType::MIDI, midi_out_index++, &valid);
|
||||
if (valid) {
|
||||
bufs.forward_lv2_midi(_ev_buffers[port_index], buf_index);
|
||||
bufs.forward_lv2_midi(_ev_buffers[port_index], buf_index, nframes, offset);
|
||||
}
|
||||
}
|
||||
// Flush MIDI (write back to Ardour MIDI buffers) -- MIDI THRU
|
||||
|
|
@ -3049,7 +3049,7 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
|
|||
const uint32_t buf_index = out_map.get(
|
||||
DataType::MIDI, midi_out_index++, &valid);
|
||||
if (valid) {
|
||||
bufs.flush_lv2_midi(true, buf_index);
|
||||
bufs.flush_lv2_midi (true, buf_index, nframes, offset);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue