diff options
Diffstat (limited to 'src/libs/engine')
-rw-r--r-- | src/libs/engine/InputPort.cpp | 1 | ||||
-rw-r--r-- | src/libs/engine/JackAudioDriver.cpp | 8 | ||||
-rw-r--r-- | src/libs/engine/JackMidiDriver.cpp | 6 | ||||
-rw-r--r-- | src/libs/engine/MidiNoteNode.cpp | 20 | ||||
-rw-r--r-- | src/libs/engine/MidiNoteNode.h | 4 |
5 files changed, 20 insertions, 19 deletions
diff --git a/src/libs/engine/InputPort.cpp b/src/libs/engine/InputPort.cpp index 178a111c..6fbd500f 100644 --- a/src/libs/engine/InputPort.cpp +++ b/src/libs/engine/InputPort.cpp @@ -248,7 +248,6 @@ InputPort<MidiMessage>::process(SampleCount nframes, FrameTime start, FrameTime do_mixdown = true; } else { // zero-copy - assert(m_buffers.at(0)->is_joined()); m_buffers.at(0)->join((*m_connections.begin())->buffer(0)); //if (m_is_tied) // m_tied_port->buffer(0)->join(m_buffers.at(0)); diff --git a/src/libs/engine/JackAudioDriver.cpp b/src/libs/engine/JackAudioDriver.cpp index 45269b7d..d148a549 100644 --- a/src/libs/engine/JackAudioDriver.cpp +++ b/src/libs/engine/JackAudioDriver.cpp @@ -297,14 +297,16 @@ JackAudioDriver::_process_cb(jack_nframes_t nframes) if (_engine.event_source()) _engine.event_source()->process(*_engine.post_processor(), nframes, start_of_last_cycle, start_of_current_cycle); - assert(_engine.midi_driver()); - _engine.midi_driver()->prepare_block(start_of_last_cycle, start_of_current_cycle); - // Set buffers of patch ports to Jack port buffers (zero-copy processing) for (List<JackAudioPort*>::iterator i = _ports.begin(); i != _ports.end(); ++i) { assert(*i); (*i)->prepare_buffer(nframes); } + + assert(_engine.midi_driver()); + //_engine.midi_driver()->prepare_block(start_of_last_cycle, start_of_current_cycle); + _engine.midi_driver()->prepare_block(start_of_current_cycle, start_of_current_cycle + nframes); + // Run root patch if (_root_patch) diff --git a/src/libs/engine/JackMidiDriver.cpp b/src/libs/engine/JackMidiDriver.cpp index c21484e3..a976464e 100644 --- a/src/libs/engine/JackMidiDriver.cpp +++ b/src/libs/engine/JackMidiDriver.cpp @@ -64,10 +64,6 @@ JackMidiPort::~JackMidiPort() * * This is basically trivial (as opposed to AlsaMidiPort) since Jack MIDI * data is in-band with the audio thread. - * - * Prepares all events that occurred during the time interval passed - * (which ideally are the events from the previous cycle with an exact - * 1 cycle delay). */ void JackMidiPort::prepare_block(const SampleCount block_start, const SampleCount block_end) @@ -94,6 +90,8 @@ JackMidiPort::prepare_block(const SampleCount block_start, const SampleCount blo message->time = ev->time; message->size = ev->size; message->buffer = ev->buffer; + + assert(message->time < nframes); } //cerr << "Jack MIDI got " << event_count << " events." << endl; diff --git a/src/libs/engine/MidiNoteNode.cpp b/src/libs/engine/MidiNoteNode.cpp index 956c1494..bc6a344a 100644 --- a/src/libs/engine/MidiNoteNode.cpp +++ b/src/libs/engine/MidiNoteNode.cpp @@ -80,27 +80,29 @@ MidiNoteNode::process(SampleCount nframes, FrameTime start, FrameTime end) for (size_t i=0; i < _midi_in_port->buffer(0)->filled_size(); ++i) { ev = _midi_in_port->buffer(0)->value_at(i); + const FrameTime time = ev.time + start; + switch (ev.buffer[0] & 0xF0) { case MIDI_CMD_NOTE_ON: if (ev.buffer[2] == 0) - note_off(ev.buffer[1], ev.time, nframes, start, end); + note_off(ev.buffer[1], time, nframes, start, end); else - note_on(ev.buffer[1], ev.buffer[2], ev.time, nframes, start, end); + note_on(ev.buffer[1], ev.buffer[2], time, nframes, start, end); break; case MIDI_CMD_NOTE_OFF: - note_off(ev.buffer[1], ev.time, nframes, start, end); + note_off(ev.buffer[1], time, nframes, start, end); break; case MIDI_CMD_CONTROL: switch (ev.buffer[1]) { case MIDI_CTL_ALL_NOTES_OFF: case MIDI_CTL_ALL_SOUNDS_OFF: - all_notes_off(ev.time, nframes, start, end); + all_notes_off(time, nframes, start, end); break; case MIDI_CTL_SUSTAIN: if (ev.buffer[2] > 63) - sustain_on(ev.time, nframes, start, end); + sustain_on(time, nframes, start, end); else - sustain_off(ev.time, nframes, start, end); + sustain_off(time, nframes, start, end); break; case MIDI_CMD_BENDER: @@ -114,7 +116,7 @@ MidiNoteNode::process(SampleCount nframes, FrameTime start, FrameTime end) void -MidiNoteNode::note_on(uchar note_num, uchar velocity, SampleCount nframes, FrameTime time, FrameTime start, FrameTime end) +MidiNoteNode::note_on(uchar note_num, uchar velocity, FrameTime time, SampleCount nframes, FrameTime start, FrameTime end) { assert(time >= start && time <= end); assert(time - start < _buffer_size); @@ -210,7 +212,7 @@ MidiNoteNode::note_off(uchar note_num, FrameTime time, SampleCount nframes, Fram key->state = Key::OFF; if ( ! _sustain) - free_voice(key->voice, time - start, nframes, start, end); + free_voice(key->voice, time, nframes, start, end); else _voices[key->voice].state = Voice::HOLDING; } @@ -260,7 +262,7 @@ MidiNoteNode::free_voice(size_t voice, FrameTime time, SampleCount nframes, Fram void -MidiNoteNode::all_notes_off(SampleCount nframes, FrameTime time, FrameTime start, FrameTime end) +MidiNoteNode::all_notes_off(FrameTime time, SampleCount nframes, FrameTime start, FrameTime end) { assert(time >= start && time <= end); assert(time - start < _buffer_size); diff --git a/src/libs/engine/MidiNoteNode.h b/src/libs/engine/MidiNoteNode.h index ba86455d..2a44d55f 100644 --- a/src/libs/engine/MidiNoteNode.h +++ b/src/libs/engine/MidiNoteNode.h @@ -44,9 +44,9 @@ public: void process(SampleCount nframes, FrameTime start, FrameTime end); - void note_on(uchar note_num, uchar velocity, SampleCount nframes, FrameTime time, FrameTime start, FrameTime end); + void note_on(uchar note_num, uchar velocity, FrameTime time, SampleCount nframes, FrameTime start, FrameTime end); void note_off(uchar note_num, FrameTime time, SampleCount nframes, FrameTime start, FrameTime end); - void all_notes_off(SampleCount nframes, FrameTime time, FrameTime start, FrameTime end); + void all_notes_off(FrameTime time, SampleCount nframes, FrameTime start, FrameTime end); void sustain_on(FrameTime time, SampleCount nframes, FrameTime start, FrameTime end); void sustain_off(FrameTime time, SampleCount nframes, FrameTime start, FrameTime end); |