summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour/midi_source.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-01-21 06:00:15 +0000
committerDavid Robillard <d@drobilla.net>2013-01-21 06:00:15 +0000
commite781c1cf0d4d16cd08b8dc2d9aedb2b6b9d8cf71 (patch)
tree7c0cce1bef5968dfef0ca666344a61a58e415f05 /libs/ardour/ardour/midi_source.h
parent76547b5c4b7fb2d4fbb7db9f12427b439da34a43 (diff)
Fix MIDI loop recording.
This changes how things work a bit, but I am committing it for 3.0 since the previous revision often crashed (and never worked), this one seems to work fine, and the code is quite a bit more cogent. I have tested the following use cases with live input and audible output: * Non-loop recording, armed before roll * Non-loop recording, arm while rolling * Loop recording, armed before roll * Loop recording, arm during roll In the last case, the source/region is created starting at the loop start rather than the current transport frame as usual so time makes sense when it wraps around. See the documentation added to the code for details, but the basic idea here is to simply push MIDI events to the source with increasing monotonic time, ignoring looping altogether. Essentially we pretend the loop does not exist, but the source knows all the details so it can implement whatever behaviour is appropriate. Currently, this is simply recording a complete non-destructive copy of the input, which is a good thing. Perhaps not what the user expects of loop recording, but at least it works and is one sensible option. We will need to add more later. Display while recording is a little bit wacky, but whatever. git-svn-id: svn://localhost/ardour2/branches/3.0@13940 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour/midi_source.h')
-rw-r--r--libs/ardour/ardour/midi_source.h34
1 files changed, 27 insertions, 7 deletions
diff --git a/libs/ardour/ardour/midi_source.h b/libs/ardour/ardour/midi_source.h
index ed2950e9e5..a5aac8859b 100644
--- a/libs/ardour/ardour/midi_source.h
+++ b/libs/ardour/ardour/midi_source.h
@@ -88,7 +88,20 @@ class MidiSource : virtual public Source, public boost::enable_shared_from_this<
virtual void mark_streaming_midi_write_started (NoteMode mode);
virtual void mark_streaming_write_started ();
virtual void mark_streaming_write_completed ();
- void mark_write_starting_now ();
+
+ /** Mark write starting with the given time parameters.
+ *
+ * This is called by MidiDiskStream::process before writing to the capture
+ * buffer which will be later read by midi_read().
+ *
+ * @param position The timeline position the source now starts at.
+ * @param capture_length The current length of the capture, which may not
+ * be zero if record is armed while rolling.
+ * @param loop_length The loop length if looping, otherwise zero.
+ */
+ void mark_write_starting_now (framecnt_t position,
+ framecnt_t capture_length,
+ framecnt_t loop_length);
/* like ::mark_streaming_write_completed() but with more arguments to
* allow control over MIDI-specific behaviour. Expected to be used only
@@ -104,9 +117,6 @@ class MidiSource : virtual public Source, public boost::enable_shared_from_this<
std::string captured_for() const { return _captured_for; }
void set_captured_for (std::string str) { _captured_for = str; }
- framepos_t last_write_end() const { return _last_write_end; }
- void set_last_write_end (framepos_t pos) { _last_write_end = pos; }
-
static PBD::Signal1<void,MidiSource*> MidiSourceCreated;
XMLNode& get_state ();
@@ -157,11 +167,16 @@ class MidiSource : virtual public Source, public boost::enable_shared_from_this<
framecnt_t cnt,
MidiStateTracker* tracker) const = 0;
- virtual framecnt_t write_unlocked (MidiRingBuffer<framepos_t>& dst,
+ /** Write data to this source from a MidiRingBuffer.
+ * @param source Buffer to read from.
+ * @param position This source's start position in session frames.
+ * @param cnt The duration of this block to write for.
+ */
+ virtual framecnt_t write_unlocked (MidiRingBuffer<framepos_t>& source,
framepos_t position,
framecnt_t cnt) = 0;
- std::string _captured_for;
+ std::string _captured_for;
boost::shared_ptr<MidiModel> _model;
bool _writing;
@@ -171,7 +186,12 @@ class MidiSource : virtual public Source, public boost::enable_shared_from_this<
mutable double _length_beats;
mutable framepos_t _last_read_end;
- framepos_t _last_write_end;
+
+ /** The total duration of the current capture. */
+ framepos_t _capture_length;
+
+ /** Length of transport loop during current capture, or zero. */
+ framepos_t _capture_loop_length;
/** Map of interpolation styles to use for Parameters; if they are not in this map,
* the correct interpolation style can be obtained from EventTypeMap::interpolation_of ()