Ardour  9.0-pre0-582-g084a23a80d
ARDOUR::MidiSource Class Referenceabstract

#include <midi_source.h>

Inheritance diagram for ARDOUR::MidiSource:
[legend]

Public Types

typedef Temporal::Beats TimeType
 
- Public Types inherited from ARDOUR::Source
enum  Flag {
  Writable = 0x1 , CanRename = 0x2 , Broadcast = 0x4 , Removable = 0x8 ,
  RemovableIfEmpty = 0x10 , RemoveAtDestroy = 0x20 , NoPeakFile = 0x40 , Destructive = 0x80 ,
  Empty = 0x100 , RF64_RIFF = 0x200 , Missing = 0x400
}
 
typedef Glib::Threads::RWLock::ReaderLock ReaderLock
 
typedef Glib::Threads::RWLock::WriterLock WriterLock
 

Public Member Functions

 MidiSource (Session &session, std::string name, Source::Flag flags=Source::Flag(0))
 
 MidiSource (Session &session, const XMLNode &)
 
virtual ~MidiSource ()
 
int write_to (const ReaderLock &lock, std::shared_ptr< MidiSource > newsrc, Temporal::Beats begin=Temporal::Beats(), Temporal::Beats end=std::numeric_limits< Temporal::Beats >::max())
 
int export_write_to (const ReaderLock &lock, std::shared_ptr< MidiSource > newsrc, Temporal::Beats begin, Temporal::Beats end)
 
virtual timecnt_t midi_read (const ReaderLock &lock, Evoral::EventSink< samplepos_t > &dst, timepos_t const &source_start, timepos_t const &start, timecnt_t const &cnt, Temporal::Range *loop_range, MidiCursor &cursor, MidiNoteTracker *tracker, MidiChannelFilter *filter, const std::set< Evoral::Parameter > &filtered)
 
virtual void render (const ReaderLock &lock, Evoral::EventSink< Temporal::Beats > &dst)=0
 
virtual timecnt_t midi_write (const WriterLock &lock, MidiRingBuffer< samplepos_t > &source, timepos_t const &source_start, timecnt_t const &cnt)
 
virtual void append_event_beats (const WriterLock &lock, const Evoral::Event< Temporal::Beats > &ev)=0
 
virtual void append_event_samples (const WriterLock &lock, const Evoral::Event< samplepos_t > &ev, samplepos_t source_start)=0
 
virtual void mark_streaming_midi_write_started (const WriterLock &lock, NoteMode mode)
 
virtual void mark_streaming_write_started (const WriterLock &lock)
 
virtual void mark_streaming_write_completed (const WriterLock &lock, Temporal::timecnt_t const &duration)
 
void mark_write_starting_now (timepos_t const &position, samplecnt_t capture_length)
 
virtual void mark_midi_streaming_write_completed (const WriterLock &lock, Evoral::Sequence< Temporal::Beats >::StuckNoteOption stuck_option, Temporal::timecnt_t const &when)
 
virtual void session_saved ()
 
XMLNodeget_state () const
 
int set_state (const XMLNode &, int version)
 
bool length_mutable () const
 
virtual void load_model (const WriterLock &lock, bool force_reload=false)=0
 
virtual void destroy_model (const WriterLock &lock)=0
 
void invalidate (const WriterLock &lock)
 
void set_note_mode (const WriterLock &lock, NoteMode mode)
 
std::shared_ptr< MidiModelmodel ()
 
void set_model (const WriterLock &lock, std::shared_ptr< MidiModel >)
 
void drop_model (const WriterLock &lock)
 
AutomationList::InterpolationStyle interpolation_of (Evoral::Parameter const &) const
 
void set_interpolation_of (Evoral::Parameter const &, AutomationList::InterpolationStyle)
 
void copy_interpolation_from (std::shared_ptr< MidiSource >)
 
void copy_interpolation_from (MidiSource *)
 
AutoState automation_state_of (Evoral::Parameter const &) const
 
void set_automation_state_of (Evoral::Parameter const &, AutoState)
 
void copy_automation_state_from (std::shared_ptr< MidiSource >)
 
void copy_automation_state_from (MidiSource *)
 
- Public Member Functions inherited from ARDOUR::Source
 Source (Session &, DataType type, const std::string &name, Flag flags=Flag(0))
 
 Source (Session &, const XMLNode &)
 
virtual ~Source ()
 
DataType type ()
 
time_t timestamp () const
 
void stamp (time_t when)
 
virtual timepos_t length () const
 
virtual bool empty () const
 
virtual void update_length (timepos_t const &dur)
 
void set_take_id (std::string id)
 
const std::string & take_id () const
 
void mark_for_remove ()
 
XMLNodeget_state () const
 
int set_state (XMLNode const &, int version)
 
bool writable () const
 
bool has_been_analysed () const
 
virtual bool can_be_analysed () const
 
virtual void set_been_analysed (bool yn)
 
virtual bool check_for_analysis_data_on_disk ()
 
std::string get_transients_path () const
 
int load_transients (const std::string &)
 
size_t n_captured_xruns () const
 
XrunPositions const & captured_xruns () const
 
void set_captured_xruns (XrunPositions const &xruns)
 
void set_captured_marks (CueMarkers const &marks)
 
CueMarkers const & cue_markers () const
 
bool add_cue_marker (CueMarker const &)
 
bool move_cue_marker (CueMarker const &, timepos_t const &source_relative_position)
 
bool remove_cue_marker (CueMarker const &)
 
bool rename_cue_marker (CueMarker &, std::string const &)
 
bool clear_cue_markers ()
 
virtual timepos_t natural_position () const
 
virtual void set_natural_position (timepos_t const &pos)
 
bool have_natural_position () const
 
timecnt_t time_since_capture_start (timepos_t const &pos)
 
void set_allow_remove_if_empty (bool yn)
 
Glib::Threads::RWLock & mutex ()
 
Flag flags () const
 
virtual void inc_use_count ()
 
virtual void dec_use_count ()
 
int use_count () const
 
bool used () const
 
uint32_t level () const
 
std::string ancestor_name ()
 
void set_ancestor_name (const std::string &name)
 
void set_captured_for (std::string str)
 
std::string captured_for () const
 
bool get_segment_descriptor (TimelineRange const &, SegmentDescriptor &)
 
int set_segment_descriptor (SegmentDescriptor const &)
 
- Public Member Functions inherited from ARDOUR::SessionObject
 SessionObject (Session &session, const std::string &name)
 
Sessionsession () const
 
std::string name () const
 
virtual bool set_name (const std::string &str)
 
- Public Member Functions inherited from ARDOUR::SessionHandleRef
 SessionHandleRef (ARDOUR::Session &s)
 
virtual ~SessionHandleRef ()
 
- Public Member Functions inherited from PBD::ScopedConnectionList
 ScopedConnectionList ()
 
 ScopedConnectionList (const ScopedConnectionList &)=delete
 
ScopedConnectionListoperator= (const ScopedConnectionList &)=delete
 
virtual ~ScopedConnectionList ()
 
void add_connection (const UnscopedConnection &c)
 
void drop_connections ()
 
- Public Member Functions inherited from PBD::Stateful
 Stateful ()
 
virtual ~Stateful ()
 
virtual bool apply_change (PropertyBase const &)
 
PropertyChange apply_changes (PropertyList const &)
 
const OwnedPropertyListproperties () const
 
void add_property (PropertyBase &s)
 
void add_extra_xml (XMLNode &)
 
XMLNodeextra_xml (const std::string &str, bool add_if_missing=false)
 
void save_extra_xml (const XMLNode &)
 
const PBD::IDid () const
 
bool set_id (const XMLNode &)
 
void set_id (const std::string &)
 
void reset_id ()
 
void clear_changes ()
 
virtual void clear_owned_changes ()
 
PropertyListget_changes_as_properties (PBD::Command *) const
 
virtual void rdiff (std::vector< PBD::Command * > &) const
 
bool changed () const
 
virtual PropertyListproperty_factory (const XMLNode &) const
 
virtual void suspend_property_changes ()
 
virtual void resume_property_changes ()
 
bool property_changes_suspended () const
 
- Public Member Functions inherited from PBD::Destructible
virtual ~Destructible ()
 
virtual void drop_references ()
 

Public Attributes

PBD::Signal< void(bool)> Invalidated
 
PBD::Signal< void()> ModelChanged
 
PBD::Signal< void(Evoral::Parameter, AutomationList::InterpolationStyle)> InterpolationChanged
 
PBD::Signal< void(Evoral::Parameter, AutoState)> AutomationStateChanged
 
- Public Attributes inherited from ARDOUR::Source
PBD::Signal< void()> AnalysisChanged
 
AnalysisFeatureList transients
 
PBD::Signal< void()> CueMarkersChanged
 
- Public Attributes inherited from PBD::Stateful
PBD::Signal< void(const PropertyChange &)> PropertyChanged
 
- Public Attributes inherited from PBD::Destructible
PBD::Signal< void()> Destroyed
 
PBD::Signal< void()> DropReferences
 

Protected Types

typedef std::map< Evoral::Parameter, AutomationList::InterpolationStyleInterpolationStyleMap
 
typedef std::map< Evoral::Parameter, AutoStateAutomationStateMap
 
- Protected Types inherited from ARDOUR::Source
typedef std::vector< SegmentDescriptorSegmentDescriptors
 

Protected Member Functions

virtual void flush_midi (const WriterLock &lock)=0
 
virtual timecnt_t read_unlocked (const ReaderLock &lock, Evoral::EventSink< samplepos_t > &dst, timepos_t const &position, timepos_t const &start, timecnt_t const &cnt, Temporal::Range *loop_range, MidiNoteTracker *tracker, MidiChannelFilter *filter) const =0
 
virtual timecnt_t write_unlocked (const WriterLock &lock, MidiRingBuffer< samplepos_t > &source, timepos_t const &position, timecnt_t const &cnt)=0
 
- Protected Member Functions inherited from ARDOUR::SessionHandleRef
virtual void session_going_away ()
 
virtual void insanity_check ()
 
- Protected Member Functions inherited from PBD::Stateful
void add_instant_xml (XMLNode &, const std::string &directory_path)
 
XMLNodeinstant_xml (const std::string &str, const std::string &directory_path)
 
void add_properties (XMLNode &) const
 
PropertyChange set_values (XMLNode const &)
 
virtual void post_set (const PropertyChange &)
 
virtual void send_change (const PropertyChange &)
 
virtual void mid_thaw (const PropertyChange &)
 
bool regenerate_xml_or_string_ids () const
 

Protected Attributes

std::shared_ptr< MidiModel_model
 
bool _writing
 
samplecnt_t _capture_length
 
InterpolationStyleMap _interpolation_style
 
AutomationStateMap _automation_state
 
- Protected Attributes inherited from ARDOUR::Source
DataType _type
 
Flag _flags
 
time_t _timestamp
 
std::string _take_id
 
timepos_t _natural_position
 
bool _have_natural_position
 
bool _analysed
 
std::atomic< int > _use_count
 
uint32_t _level
 
std::string _ancestor_name
 
std::string _captured_for
 
timepos_t _length
 
XrunPositions _xruns
 
CueMarkers _cue_markers
 
SegmentDescriptors segment_descriptors
 
Glib::Threads::RWLock _lock
 
Glib::Threads::Mutex _analysis_lock
 
- Protected Attributes inherited from ARDOUR::SessionObject
PBD::Property< std::string > _name
 
- Protected Attributes inherited from ARDOUR::SessionHandleRef
ARDOUR::Session_session
 
- Protected Attributes inherited from PBD::Stateful
XMLNode_extra_xml
 
XMLNode_instant_xml
 
PBD::PropertyChange _pending_changed
 
Glib::Threads::Mutex _lock
 
std::string _xml_node_name
 name of node to use for this object in XML More...
 
OwnedPropertyList_properties
 

Additional Inherited Members

- Static Public Member Functions inherited from ARDOUR::SessionObject
static void make_property_quarks ()
 
- Static Public Attributes inherited from ARDOUR::Source
static PBD::Signal< void(Source *)> SourceCreated
 
- Static Public Attributes inherited from PBD::Stateful
static int current_state_version
 
static int loading_state_version
 

Detailed Description

Source for MIDI data

Definition at line 51 of file midi_source.h.

Member Typedef Documentation

◆ AutomationStateMap

Map of automation states to use for Parameters; if they are not in this map, the correct automation state is Off.

Definition at line 244 of file midi_source.h.

◆ InterpolationStyleMap

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 ()

Definition at line 238 of file midi_source.h.

◆ TimeType

Definition at line 54 of file midi_source.h.

Constructor & Destructor Documentation

◆ MidiSource() [1/2]

ARDOUR::MidiSource::MidiSource ( Session session,
std::string  name,
Source::Flag  flags = Source::Flag(0) 
)

◆ MidiSource() [2/2]

ARDOUR::MidiSource::MidiSource ( Session session,
const XMLNode  
)

◆ ~MidiSource()

virtual ARDOUR::MidiSource::~MidiSource ( )
virtual

Member Function Documentation

◆ append_event_beats()

virtual void ARDOUR::MidiSource::append_event_beats ( const WriterLock lock,
const Evoral::Event< Temporal::Beats > &  ev 
)
pure virtual

Append a single event with a timestamp in beats.

Caller must ensure that the event is later than the last written event.

Implemented in ARDOUR::SMFSource.

◆ append_event_samples()

virtual void ARDOUR::MidiSource::append_event_samples ( const WriterLock lock,
const Evoral::Event< samplepos_t > &  ev,
samplepos_t  source_start 
)
pure virtual

Append a single event with a timestamp in samples.

Caller must ensure that the event is later than the last written event.

Implemented in ARDOUR::SMFSource.

◆ automation_state_of()

AutoState ARDOUR::MidiSource::automation_state_of ( Evoral::Parameter const &  ) const

◆ copy_automation_state_from() [1/2]

void ARDOUR::MidiSource::copy_automation_state_from ( MidiSource )

◆ copy_automation_state_from() [2/2]

void ARDOUR::MidiSource::copy_automation_state_from ( std::shared_ptr< MidiSource )

◆ copy_interpolation_from() [1/2]

void ARDOUR::MidiSource::copy_interpolation_from ( MidiSource )

◆ copy_interpolation_from() [2/2]

void ARDOUR::MidiSource::copy_interpolation_from ( std::shared_ptr< MidiSource )

◆ destroy_model()

virtual void ARDOUR::MidiSource::destroy_model ( const WriterLock lock)
pure virtual

Implemented in ARDOUR::SMFSource.

◆ drop_model()

void ARDOUR::MidiSource::drop_model ( const WriterLock lock)

◆ export_write_to()

int ARDOUR::MidiSource::export_write_to ( const ReaderLock lock,
std::shared_ptr< MidiSource newsrc,
Temporal::Beats  begin,
Temporal::Beats  end 
)

Export the midi data in the given time range to another MidiSource

Parameters
lockReference to the Mutex to lock before modification
newsrcMidiSource 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.
begintime of earliest event that can be written.
endtime of latest event that can be written.
Returns
zero on success, non-zero if the write failed for any reason.

◆ flush_midi()

virtual void ARDOUR::MidiSource::flush_midi ( const WriterLock lock)
protectedpure virtual

Implemented in ARDOUR::SMFSource.

◆ get_state()

XMLNode& ARDOUR::MidiSource::get_state ( ) const
virtual

Implements PBD::Stateful.

Reimplemented in ARDOUR::SMFSource.

◆ interpolation_of()

AutomationList::InterpolationStyle ARDOUR::MidiSource::interpolation_of ( Evoral::Parameter const &  ) const

◆ invalidate()

void ARDOUR::MidiSource::invalidate ( const WriterLock lock)

Reset cached information (like iterators) when things have changed.

Parameters
lockSource lock, which must be held by caller.

◆ length_mutable()

bool ARDOUR::MidiSource::length_mutable ( ) const
inlinevirtual

Reimplemented from ARDOUR::Source.

Definition at line 170 of file midi_source.h.

◆ load_model()

virtual void ARDOUR::MidiSource::load_model ( const WriterLock lock,
bool  force_reload = false 
)
pure virtual

Implemented in ARDOUR::SMFSource.

◆ mark_midi_streaming_write_completed()

virtual void ARDOUR::MidiSource::mark_midi_streaming_write_completed ( const WriterLock lock,
Evoral::Sequence< Temporal::Beats >::StuckNoteOption  stuck_option,
Temporal::timecnt_t const &  when 
)
virtual

Reimplemented in ARDOUR::SMFSource.

◆ mark_streaming_midi_write_started()

virtual void ARDOUR::MidiSource::mark_streaming_midi_write_started ( const WriterLock lock,
NoteMode  mode 
)
virtual

Reimplemented in ARDOUR::SMFSource.

◆ mark_streaming_write_completed()

virtual void ARDOUR::MidiSource::mark_streaming_write_completed ( const WriterLock lock,
Temporal::timecnt_t const &  duration 
)
virtual

Implements ARDOUR::Source.

Reimplemented in ARDOUR::SMFSource.

◆ mark_streaming_write_started()

virtual void ARDOUR::MidiSource::mark_streaming_write_started ( const WriterLock lock)
virtual

Reimplemented from ARDOUR::Source.

◆ mark_write_starting_now()

void ARDOUR::MidiSource::mark_write_starting_now ( timepos_t const &  position,
samplecnt_t  capture_length 
)

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().

Parameters
positionThe timeline position the source now starts at.
capture_lengthThe current length of the capture, which may not be zero if record is armed while rolling. In samples because we record using timestamps derived from the audio engine.

◆ midi_read()

virtual timecnt_t ARDOUR::MidiSource::midi_read ( const ReaderLock lock,
Evoral::EventSink< samplepos_t > &  dst,
timepos_t const &  source_start,
timepos_t const &  start,
timecnt_t const &  cnt,
Temporal::Range loop_range,
MidiCursor cursor,
MidiNoteTracker tracker,
MidiChannelFilter filter,
const std::set< Evoral::Parameter > &  filtered 
)
virtual

Read the data in a given time range from the MIDI source. All time stamps in parameters are in audio samples (even if the source has tempo time).

Parameters
lockReference to the Mutex to lock before modification
dstRing buffer where read events are written.
source_startStart position of the SOURCE in this read context.
startStart of range to be read.
cntLength of range to be read (in audio samples).
loop_rangeIf non-null, all event times will be mapped into this loop range.
cursorCached iterator to start copying events
filterChannel filter to apply or NULL to disable filter
trackeran optional pointer to MidiNoteTracker object, for note on/off tracking.
filteredParameters whose MIDI messages will not be returned.

◆ midi_write()

virtual timecnt_t ARDOUR::MidiSource::midi_write ( const WriterLock lock,
MidiRingBuffer< samplepos_t > &  source,
timepos_t const &  source_start,
timecnt_t const &  cnt 
)
virtual

Write data from a MidiRingBuffer to this source.

Parameters
lockReference to the Mutex to lock before modification
sourceSource to read from.
source_startThis source's start position in session samples.
cntThe length of time to write.

◆ model()

std::shared_ptr<MidiModel> ARDOUR::MidiSource::model ( )
inline

Definition at line 185 of file midi_source.h.

◆ read_unlocked()

virtual timecnt_t ARDOUR::MidiSource::read_unlocked ( const ReaderLock lock,
Evoral::EventSink< samplepos_t > &  dst,
timepos_t const &  position,
timepos_t const &  start,
timecnt_t const &  cnt,
Temporal::Range loop_range,
MidiNoteTracker tracker,
MidiChannelFilter filter 
) const
protectedpure virtual

Implemented in ARDOUR::SMFSource.

◆ render()

virtual void ARDOUR::MidiSource::render ( const ReaderLock lock,
Evoral::EventSink< Temporal::Beats > &  dst 
)
pure virtual

Implemented in ARDOUR::SMFSource.

◆ session_saved()

virtual void ARDOUR::MidiSource::session_saved ( )
virtual

Reimplemented from ARDOUR::Source.

◆ set_automation_state_of()

void ARDOUR::MidiSource::set_automation_state_of ( Evoral::Parameter const &  ,
AutoState   
)

◆ set_interpolation_of()

void ARDOUR::MidiSource::set_interpolation_of ( Evoral::Parameter const &  ,
AutomationList::InterpolationStyle   
)

◆ set_model()

void ARDOUR::MidiSource::set_model ( const WriterLock lock,
std::shared_ptr< MidiModel  
)

◆ set_note_mode()

void ARDOUR::MidiSource::set_note_mode ( const WriterLock lock,
NoteMode  mode 
)

◆ set_state()

int ARDOUR::MidiSource::set_state ( const XMLNode ,
int  version 
)
virtual

Implements PBD::Stateful.

Reimplemented in ARDOUR::SMFSource.

◆ write_to()

int ARDOUR::MidiSource::write_to ( const ReaderLock lock,
std::shared_ptr< MidiSource newsrc,
Temporal::Beats  begin = Temporal::Beats(),
Temporal::Beats  end = std::numeric_limits< Temporal::Beats >::max() 
)

Write the data in the given time range to another MidiSource

Parameters
lockReference to the Mutex to lock before modification
newsrcMidiSource 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.
begintime of earliest event that can be written.
endtime of latest event that can be written.
Returns
zero on success, non-zero if the write failed for any reason.

◆ write_unlocked()

virtual timecnt_t ARDOUR::MidiSource::write_unlocked ( const WriterLock lock,
MidiRingBuffer< samplepos_t > &  source,
timepos_t const &  position,
timecnt_t const &  cnt 
)
protectedpure virtual

Write data to this source from a MidiRingBuffer.

Parameters
lockReference to the Mutex to lock before modification
sourceBuffer to read from.
positionThis source's start position in session samples.
cntThe duration of this block to write for.

Implemented in ARDOUR::SMFSource.

Member Data Documentation

◆ _automation_state

AutomationStateMap ARDOUR::MidiSource::_automation_state
protected

Definition at line 245 of file midi_source.h.

◆ _capture_length

samplecnt_t ARDOUR::MidiSource::_capture_length
protected

The total duration of the current capture.

Definition at line 233 of file midi_source.h.

◆ _interpolation_style

InterpolationStyleMap ARDOUR::MidiSource::_interpolation_style
protected

Definition at line 239 of file midi_source.h.

◆ _model

std::shared_ptr<MidiModel> ARDOUR::MidiSource::_model
protected

Definition at line 229 of file midi_source.h.

◆ _writing

bool ARDOUR::MidiSource::_writing
protected

Definition at line 230 of file midi_source.h.

◆ AutomationStateChanged

PBD::Signal<void(Evoral::Parameter, AutoState)> ARDOUR::MidiSource::AutomationStateChanged

Emitted when a parameter's automation state is changed

Definition at line 204 of file midi_source.h.

◆ InterpolationChanged

PBD::Signal<void(Evoral::Parameter, AutomationList::InterpolationStyle)> ARDOUR::MidiSource::InterpolationChanged

Emitted when a parameter's interpolation style is changed

Definition at line 202 of file midi_source.h.

◆ Invalidated

PBD::Signal<void(bool)> ARDOUR::MidiSource::Invalidated
mutable

Thou shalt not emit this directly, use invalidate() instead.

Definition at line 181 of file midi_source.h.

◆ ModelChanged

PBD::Signal<void()> ARDOUR::MidiSource::ModelChanged

Emitted when a different MidiModel is set

Definition at line 200 of file midi_source.h.


The documentation for this class was generated from the following file: