diff options
author | David Robillard <d@drobilla.net> | 2008-10-10 00:39:29 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-10-10 00:39:29 +0000 |
commit | 15cdf454ea5a1460b41cb462c35f1ffb853a0764 (patch) | |
tree | d2e2dfec11c3a661d30c18fb4a9d40c7dbcb2326 /libs/ardour/ardour | |
parent | c64e96b6a8f6782a5ad0bc41b7200ec94408aaa5 (diff) |
Apply MIDI looping patch from torbenh, with minor changes.
General idea: use internal events to mark loop boundaries in MIDI buffers so readers can make sense of timestamps.
git-svn-id: svn://localhost/ardour2/branches/3.0@3905 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r-- | libs/ardour/ardour/event_type_map.h | 4 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_diskstream.h | 8 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_ring_buffer.h | 14 |
3 files changed, 24 insertions, 2 deletions
diff --git a/libs/ardour/ardour/event_type_map.h b/libs/ardour/ardour/event_type_map.h index 99911121c5..dfa11d6408 100644 --- a/libs/ardour/ardour/event_type_map.h +++ b/libs/ardour/ardour/event_type_map.h @@ -46,6 +46,10 @@ private: static EventTypeMap event_type_map; }; +enum InternalEventType { + LoopEventType = 1000 +}; + } // namespace ARDOUR #endif /* __ardour_event_type_map_h__ */ diff --git a/libs/ardour/ardour/midi_diskstream.h b/libs/ardour/ardour/midi_diskstream.h index 28e80816a8..a3d4d6d0a4 100644 --- a/libs/ardour/ardour/midi_diskstream.h +++ b/libs/ardour/ardour/midi_diskstream.h @@ -46,6 +46,7 @@ #include <ardour/diskstream.h> #include <ardour/midi_playlist.h> #include <ardour/midi_ring_buffer.h> +#include <ardour/midi_state_tracker.h> struct tm; @@ -68,7 +69,7 @@ class MidiDiskstream : public Diskstream float playback_buffer_load() const; float capture_buffer_load() const; - void get_playback(MidiBuffer& dst, nframes_t start, nframes_t end); + void get_playback(MidiBuffer& dst, nframes_t start, nframes_t end, nframes_t offset); void set_record_enabled (bool yn); @@ -170,13 +171,16 @@ class MidiDiskstream : public Diskstream void engage_record_enable (); void disengage_record_enable (); - + void check_note_onoffs(Evoral::MIDIEvent &event); + void emit_pending_note_offs(MidiBuffer &dst, nframes_t time); + MidiRingBuffer* _playback_buf; MidiRingBuffer* _capture_buf; MidiPort* _source_port; boost::shared_ptr<SMFSource> _write_source; nframes_t _last_flush_frame; NoteMode _note_mode; + MidiStateTracker _midistate_tracker; }; }; /* namespace ARDOUR */ diff --git a/libs/ardour/ardour/midi_ring_buffer.h b/libs/ardour/ardour/midi_ring_buffer.h index d1acb9b235..6e827d2852 100644 --- a/libs/ardour/ardour/midi_ring_buffer.h +++ b/libs/ardour/ardour/midi_ring_buffer.h @@ -23,6 +23,7 @@ #include <algorithm> #include <ardour/types.h> #include <ardour/buffer.h> +#include <ardour/event_type_map.h> #include <evoral/EventSink.hpp> #include <evoral/EventRingBuffer.hpp> @@ -148,6 +149,18 @@ MidiRingBuffer::read(MidiBuffer& dst, nframes_t start, nframes_t end, nframes_t continue; } + // This event marks a loop happening. this means that + // the next events timestamp will be non-monotonic. + if (ev_type == LoopEventType) { + ev_time -= start; + Evoral::MIDIEvent loopevent(LoopEventType, ev_time); + dst.push_back(loopevent); + + // We can safely return, without reading the data, because + // a LoopEvent does not have data. + return count + 1; + } + uint8_t status; success = full_peek(sizeof(uint8_t), &status); assert(success); // If this failed, buffer is corrupt, all hope is lost @@ -168,6 +181,7 @@ MidiRingBuffer::read(MidiBuffer& dst, nframes_t start, nframes_t end, nframes_t assert(ev_time >= start); ev_time -= start; + ev_time += offset; uint8_t* write_loc = dst.reserve(ev_time, ev_size); if (write_loc == NULL) { |