-
- /* Stub Readable interface */
- virtual nframes64_t read (Sample*, nframes64_t pos, nframes64_t cnt, int channel) const { return 0; }
- virtual nframes64_t readable_length() const { return length(); }
- virtual uint32_t n_channels () const { return 1; }
-
- // FIXME: integrate this with the Readable::read interface somehow
- virtual nframes_t midi_read (MidiRingBuffer<nframes_t>& dst, nframes_t start, nframes_t cnt,
- nframes_t stamp_offset, nframes_t negative_stamp_offset) const;
- virtual nframes_t midi_write (MidiRingBuffer<nframes_t>& src, nframes_t cnt);
-
- virtual void append_event_unlocked_beats(const Evoral::Event<double>& ev) = 0;
- virtual void append_event_unlocked_frames(const Evoral::Event<nframes_t>& ev) = 0;
-
- virtual void mark_for_remove() = 0;
- virtual void mark_streaming_midi_write_started (NoteMode mode, nframes_t start_time);
- virtual void mark_streaming_write_started ();
- virtual void mark_streaming_write_completed ();
-
- uint64_t timeline_position () { return _timeline_position; }
- void set_timeline_position (nframes_t when) { _timeline_position = when; }
-
+
+ /** Write the data in the given time range to another MidiSource
+ * \param newsrc MidiSource to which data will be written. Should be a
+ * new, empty source. If it already has contents, the results are
+ * undefined. Source must be writable.
+ * \param begin time of earliest event that can be written.
+ * \param end time of latest event that can be written.
+ * \return zero on success, non-zero if the write failed for any reason.
+ */
+ int write_to (const Lock& lock,
+ boost::shared_ptr<MidiSource> newsrc,
+ Evoral::Beats begin = Evoral::MinBeats,
+ Evoral::Beats end = Evoral::MaxBeats);
+
+ /** Read the data in a given time range from the MIDI source.
+ * All time stamps in parameters are in audio frames (even if the source has tempo time).
+ * \param dst Ring buffer where read events are written.
+ * \param source_start Start position of the SOURCE in this read context.
+ * \param start Start of range to be read.
+ * \param cnt Length of range to be read (in audio frames).
+ * \param tracker an optional pointer to MidiStateTracker object, for note on/off tracking.
+ * \param filtered Parameters whose MIDI messages will not be returned.
+ */
+ virtual framecnt_t midi_read (const Lock& lock,
+ Evoral::EventSink<framepos_t>& dst,
+ framepos_t source_start,
+ framepos_t start,
+ framecnt_t cnt,
+ MidiStateTracker* tracker,
+ MidiChannelFilter* filter,
+ const std::set<Evoral::Parameter>& filtered) const;
+
+ /** Write data from a MidiRingBuffer to this source.
+ * @param source Source to read from.
+ * @param source_start This source's start position in session frames.
+ * @param cnt The length of time to write.
+ */
+ virtual framecnt_t midi_write (const Lock& lock,
+ MidiRingBuffer<framepos_t>& src,
+ framepos_t source_start,
+ framecnt_t cnt);
+
+ /** Append a single event with a timestamp in beats.
+ *
+ * Caller must ensure that the event is later than the last written event.
+ */
+ virtual void append_event_beats(const Lock& lock,
+ const Evoral::Event<Evoral::Beats>& ev) = 0;
+
+ /** Append a single event with a timestamp in frames.
+ *
+ * Caller must ensure that the event is later than the last written event.
+ */
+ virtual void append_event_frames(const Lock& lock,
+ const Evoral::Event<framepos_t>& ev,
+ framepos_t source_start) = 0;
+
+ virtual bool empty () const;
+ virtual framecnt_t length (framepos_t pos) const;
+ virtual void update_length (framecnt_t);
+
+ virtual void mark_streaming_midi_write_started (const Lock& lock, NoteMode mode);
+ virtual void mark_streaming_write_started (const Lock& lock);
+ virtual void mark_streaming_write_completed (const Lock& lock);
+
+ /** 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
+ * when recording actual MIDI input, rather then when importing files
+ * etc.
+ */
+ virtual void mark_midi_streaming_write_completed (
+ const Lock& lock,
+ Evoral::Sequence<Evoral::Beats>::StuckNoteOption stuck_option,
+ Evoral::Beats when = Evoral::Beats());
+