ardour
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | List of all members
ARDOUR::MidiSource Class Referenceabstract

#include <midi_source.h>

Inheritance diagram for ARDOUR::MidiSource:
ARDOUR::Source boost::enable_shared_from_this< MidiSource > ARDOUR::SessionObject ARDOUR::SessionHandleRef PBD::StatefulDestructible PBD::ScopedConnectionList PBD::Stateful PBD::Destructible ARDOUR::MidiPlaylistSource ARDOUR::SMFSource

Public Types

typedef Evoral::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
}
 
typedef Glib::Threads::Mutex::Lock Lock
 

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 Lock &lock, boost::shared_ptr< MidiSource > newsrc, Evoral::Beats begin=Evoral::MinBeats, Evoral::Beats end=Evoral::MaxBeats)
 
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
 
virtual framecnt_t midi_write (const Lock &lock, MidiRingBuffer< framepos_t > &src, framepos_t source_start, framecnt_t cnt)
 
virtual void append_event_beats (const Lock &lock, const Evoral::Event< Evoral::Beats > &ev)=0
 
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)
 
void mark_write_starting_now (framecnt_t position, framecnt_t capture_length, framecnt_t loop_length)
 
virtual void mark_midi_streaming_write_completed (const Lock &lock, Evoral::Sequence< Evoral::Beats >::StuckNoteOption stuck_option, Evoral::Beats when=Evoral::Beats())
 
virtual void session_saved ()
 
std::string captured_for () const
 
void set_captured_for (std::string str)
 
XMLNodeget_state ()
 
int set_state (const XMLNode &, int version)
 
bool length_mutable () const
 
void set_length_beats (TimeType l)
 
TimeType length_beats () const
 
virtual void load_model (const Glib::Threads::Mutex::Lock &lock, bool force_reload=false)=0
 
virtual void destroy_model (const Glib::Threads::Mutex::Lock &lock)=0
 
void invalidate (const Glib::Threads::Mutex::Lock &lock, std::set< Evoral::Sequence< Evoral::Beats >::WeakNotePtr > *notes=NULL)
 
void set_note_mode (const Glib::Threads::Mutex::Lock &lock, NoteMode mode)
 
boost::shared_ptr< MidiModelmodel ()
 
void set_model (const Glib::Threads::Mutex::Lock &lock, boost::shared_ptr< MidiModel >)
 
void drop_model (const Glib::Threads::Mutex::Lock &lock)
 
Evoral::ControlList::InterpolationStyle interpolation_of (Evoral::Parameter) const
 
void set_interpolation_of (Evoral::Parameter, Evoral::ControlList::InterpolationStyle)
 
void copy_interpolation_from (boost::shared_ptr< MidiSource >)
 
void copy_interpolation_from (MidiSource *)
 
AutoState automation_state_of (Evoral::Parameter) const
 
void set_automation_state_of (Evoral::Parameter, AutoState)
 
void copy_automation_state_from (boost::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 framepos_t natural_position () const
 
void mark_for_remove ()
 
XMLNodeget_state ()
 
int set_state (const XMLNode &, int version)
 
bool destructive () const
 
bool writable () const
 
virtual bool set_destructive (bool)
 
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 &)
 
framepos_t timeline_position () const
 
virtual void set_timeline_position (framepos_t pos)
 
void set_allow_remove_if_empty (bool yn)
 
Glib::Threads::Mutex & 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)
 
- 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 ()
 
virtual ~ScopedConnectionList ()
 
void add_connection (const UnscopedConnection &c)
 
void drop_connections ()
 
- Public Member Functions inherited from PBD::Stateful
 Stateful ()
 
virtual ~Stateful ()
 
virtual bool apply_changes (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 (Command *) const
 
virtual void rdiff (std::vector< 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
 Destructible ()
 
virtual ~Destructible ()
 
void drop_references ()
 

Public Attributes

PBD::Signal0< void > ModelChanged
 
PBD::Signal2< void,
Evoral::Parameter,
Evoral::ControlList::InterpolationStyle
InterpolationChanged
 
PBD::Signal2< void,
Evoral::Parameter, AutoState
AutomationStateChanged
 
- Public Attributes inherited from ARDOUR::Source
PBD::Signal0< void > AnalysisChanged
 
AnalysisFeatureList transients
 
- Public Attributes inherited from PBD::Stateful
PBD::Signal1< void, const
PropertyChange & > 
PropertyChanged
 
- Public Attributes inherited from PBD::Destructible
PBD::Signal0< void > Destroyed
 
PBD::Signal0< void > DropReferences
 

Static Public Attributes

static PBD::Signal1< void,
MidiSource * > 
MidiSourceCreated
 
- Static Public Attributes inherited from ARDOUR::Source
static PBD::Signal1< void,
Source * > 
SourceCreated
 
- Static Public Attributes inherited from PBD::Stateful
static int current_state_version = 0
 
static int loading_state_version = 0
 

Protected Types

typedef std::map
< Evoral::Parameter,
Evoral::ControlList::InterpolationStyle
InterpolationStyleMap
 
typedef std::map
< Evoral::Parameter, AutoState
AutomationStateMap
 

Protected Member Functions

virtual void flush_midi (const Lock &lock)=0
 
virtual framecnt_t read_unlocked (const Lock &lock, Evoral::EventSink< framepos_t > &dst, framepos_t position, framepos_t start, framecnt_t cnt, MidiStateTracker *tracker, MidiChannelFilter *filter) const =0
 
virtual framecnt_t write_unlocked (const Lock &lock, MidiRingBuffer< framepos_t > &source, framepos_t position, framecnt_t 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 &)
 
PropertyChange set_values (XMLNode const &)
 
virtual void post_set (const PropertyChange &)
 
virtual void send_change (const PropertyChange &)
 
virtual void mid_thaw (const PropertyChange &)
 

Protected Attributes

std::string _captured_for
 
boost::shared_ptr< MidiModel_model
 
bool _writing
 
Evoral::Sequence
< Evoral::Beats >
::const_iterator 
_model_iter
 
bool _model_iter_valid
 
Evoral::Beats _length_beats
 
framepos_t _last_read_end
 
framepos_t _capture_length
 
framepos_t _capture_loop_length
 
InterpolationStyleMap _interpolation_style
 
AutomationStateMap _automation_state
 
- Protected Attributes inherited from ARDOUR::Source
DataType _type
 
Flag _flags
 
time_t _timestamp
 
framepos_t _timeline_position
 
bool _analysed
 
Glib::Threads::Mutex _lock
 
Glib::Threads::Mutex _analysis_lock
 
gint _use_count
 
uint32_t _level
 
std::string _ancestor_name
 
- 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 ()
 

Detailed Description

Source for MIDI data

Definition at line 44 of file midi_source.h.

Member Typedef Documentation

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

Definition at line 236 of file midi_source.h.

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 230 of file midi_source.h.

Definition at line 47 of file midi_source.h.

Constructor & Destructor Documentation

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

Definition at line 71 of file midi_source.cc.

MidiSource::~MidiSource ( )
virtual

Definition at line 85 of file midi_source.cc.

Member Function Documentation

virtual void ARDOUR::MidiSource::append_event_beats ( const Lock lock,
const Evoral::Event< Evoral::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, and ARDOUR::MidiPlaylistSource.

virtual void ARDOUR::MidiSource::append_event_frames ( const Lock lock,
const Evoral::Event< framepos_t > &  ev,
framepos_t  source_start 
)
pure virtual

Append a single event with a timestamp in frames.

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

Implemented in ARDOUR::SMFSource, and ARDOUR::MidiPlaylistSource.

AutoState MidiSource::automation_state_of ( Evoral::Parameter  p) const

Definition at line 442 of file midi_source.cc.

std::string ARDOUR::MidiSource::captured_for ( ) const
inline

Definition at line 143 of file midi_source.h.

void MidiSource::copy_automation_state_from ( boost::shared_ptr< MidiSource s)

Definition at line 500 of file midi_source.cc.

void MidiSource::copy_automation_state_from ( MidiSource s)

Definition at line 514 of file midi_source.cc.

void MidiSource::copy_interpolation_from ( boost::shared_ptr< MidiSource s)

Definition at line 494 of file midi_source.cc.

void MidiSource::copy_interpolation_from ( MidiSource s)

Definition at line 506 of file midi_source.cc.

virtual void ARDOUR::MidiSource::destroy_model ( const Glib::Threads::Mutex::Lock &  lock)
pure virtual
void MidiSource::drop_model ( const Glib::Threads::Mutex::Lock &  lock)

Definition at line 415 of file midi_source.cc.

bool MidiSource::empty ( ) const
virtual

Implements ARDOUR::Source.

Reimplemented in ARDOUR::MidiPlaylistSource.

Definition at line 158 of file midi_source.cc.

virtual void ARDOUR::MidiSource::flush_midi ( const Lock lock)
protectedpure virtual
XMLNode & MidiSource::get_state ( void  )
virtual

Implements PBD::Stateful.

Reimplemented in ARDOUR::SMFSource.

Definition at line 90 of file midi_source.cc.

Evoral::ControlList::InterpolationStyle MidiSource::interpolation_of ( Evoral::Parameter  p) const

Definition at line 431 of file midi_source.cc.

void MidiSource::invalidate ( const Glib::Threads::Mutex::Lock &  lock,
std::set< Evoral::Sequence< Evoral::Beats >::WeakNotePtr > *  notes = NULL 
)

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

Parameters
lockSource lock, which must be held by caller.
notesIf non-NULL, currently active notes are added to this set.

Definition at line 181 of file midi_source.cc.

framecnt_t MidiSource::length ( framepos_t  pos) const
virtual

Implements ARDOUR::Source.

Reimplemented in ARDOUR::MidiPlaylistSource.

Definition at line 164 of file midi_source.cc.

TimeType ARDOUR::MidiSource::length_beats ( ) const
inline

Definition at line 154 of file midi_source.h.

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

Reimplemented from ARDOUR::Source.

Definition at line 151 of file midi_source.h.

virtual void ARDOUR::MidiSource::load_model ( const Glib::Threads::Mutex::Lock &  lock,
bool  force_reload = false 
)
pure virtual
void MidiSource::mark_midi_streaming_write_completed ( const Lock lock,
Evoral::Sequence< Evoral::Beats >::StuckNoteOption  stuck_option,
Evoral::Beats  when = Evoral::Beats() 
)
virtual

Reimplemented in ARDOUR::SMFSource.

Definition at line 314 of file midi_source.cc.

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

Reimplemented in ARDOUR::SMFSource.

Definition at line 272 of file midi_source.cc.

void MidiSource::mark_streaming_write_completed ( const Lock lock)
virtual

Implements ARDOUR::Source.

Reimplemented in ARDOUR::SMFSource.

Definition at line 335 of file midi_source.cc.

void MidiSource::mark_streaming_write_started ( const Lock lock)
virtual

Reimplemented from ARDOUR::Source.

Definition at line 307 of file midi_source.cc.

void MidiSource::mark_write_starting_now ( framecnt_t  position,
framecnt_t  capture_length,
framecnt_t  loop_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.
loop_lengthThe loop length if looping, otherwise zero.

Definition at line 283 of file midi_source.cc.

framecnt_t MidiSource::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
virtual

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

Parameters
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 frames).
trackeran optional pointer to MidiStateTracker object, for note on/off tracking.
filteredParameters whose MIDI messages will not be returned.

Definition at line 188 of file midi_source.cc.

framecnt_t MidiSource::midi_write ( const Lock lock,
MidiRingBuffer< framepos_t > &  src,
framepos_t  source_start,
framecnt_t  cnt 
)
virtual

Write data from a MidiRingBuffer to this source.

Parameters
sourceSource to read from.
source_startThis source's start position in session frames.
cntThe length of time to write.

Definition at line 254 of file midi_source.cc.

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

Definition at line 168 of file midi_source.h.

virtual framecnt_t ARDOUR::MidiSource::read_unlocked ( const Lock lock,
Evoral::EventSink< framepos_t > &  dst,
framepos_t  position,
framepos_t  start,
framecnt_t  cnt,
MidiStateTracker tracker,
MidiChannelFilter filter 
) const
protectedpure virtual
void MidiSource::session_saved ( )
virtual

Reimplemented from ARDOUR::Source.

Definition at line 378 of file midi_source.cc.

void MidiSource::set_automation_state_of ( Evoral::Parameter  p,
AutoState  s 
)

Definition at line 477 of file midi_source.cc.

void ARDOUR::MidiSource::set_captured_for ( std::string  str)
inline

Definition at line 144 of file midi_source.h.

void MidiSource::set_interpolation_of ( Evoral::Parameter  p,
Evoral::ControlList::InterpolationStyle  s 
)

Set interpolation style to be used for a given parameter. This change will be propagated to anyone who needs to know.

Definition at line 460 of file midi_source.cc.

void ARDOUR::MidiSource::set_length_beats ( TimeType  l)
inline

Definition at line 153 of file midi_source.h.

void MidiSource::set_model ( const Glib::Threads::Mutex::Lock &  lock,
boost::shared_ptr< MidiModel m 
)

Definition at line 423 of file midi_source.cc.

void MidiSource::set_note_mode ( const Glib::Threads::Mutex::Lock &  lock,
NoteMode  mode 
)

Definition at line 407 of file midi_source.cc.

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

Implements PBD::Stateful.

Reimplemented in ARDOUR::SMFSource.

Definition at line 114 of file midi_source.cc.

void MidiSource::update_length ( framecnt_t  )
virtual

Implements ARDOUR::Source.

Definition at line 175 of file midi_source.cc.

int MidiSource::write_to ( const Lock lock,
boost::shared_ptr< MidiSource newsrc,
Evoral::Beats  begin = Evoral::MinBeats,
Evoral::Beats  end = Evoral::MaxBeats 
)

Write the data in the given time range to another MidiSource

Parameters
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.

Definition at line 341 of file midi_source.cc.

virtual framecnt_t ARDOUR::MidiSource::write_unlocked ( const Lock lock,
MidiRingBuffer< framepos_t > &  source,
framepos_t  position,
framecnt_t  cnt 
)
protectedpure virtual

Write data to this source from a MidiRingBuffer.

Parameters
sourceBuffer to read from.
positionThis source's start position in session frames.
cntThe duration of this block to write for.

Implemented in ARDOUR::SMFSource, and ARDOUR::MidiPlaylistSource.

Member Data Documentation

AutomationStateMap ARDOUR::MidiSource::_automation_state
protected

Definition at line 237 of file midi_source.h.

framepos_t ARDOUR::MidiSource::_capture_length
protected

The total duration of the current capture.

Definition at line 222 of file midi_source.h.

framepos_t ARDOUR::MidiSource::_capture_loop_length
protected

Length of transport loop during current capture, or zero.

Definition at line 225 of file midi_source.h.

std::string ARDOUR::MidiSource::_captured_for
protected

Definition at line 210 of file midi_source.h.

InterpolationStyleMap ARDOUR::MidiSource::_interpolation_style
protected

Definition at line 231 of file midi_source.h.

framepos_t ARDOUR::MidiSource::_last_read_end
mutableprotected

Definition at line 219 of file midi_source.h.

Evoral::Beats ARDOUR::MidiSource::_length_beats
mutableprotected

Definition at line 218 of file midi_source.h.

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

Definition at line 212 of file midi_source.h.

Evoral::Sequence<Evoral::Beats>::const_iterator ARDOUR::MidiSource::_model_iter
mutableprotected

Definition at line 215 of file midi_source.h.

bool ARDOUR::MidiSource::_model_iter_valid
mutableprotected

Definition at line 216 of file midi_source.h.

bool ARDOUR::MidiSource::_writing
protected

Definition at line 213 of file midi_source.h.

PBD::Signal2<void, Evoral::Parameter, AutoState> ARDOUR::MidiSource::AutomationStateChanged

Emitted when a parameter's automation state is changed

Definition at line 187 of file midi_source.h.

PBD::Signal2<void, Evoral::Parameter, Evoral::ControlList::InterpolationStyle> ARDOUR::MidiSource::InterpolationChanged

Emitted when a parameter's interpolation style is changed

Definition at line 185 of file midi_source.h.

PBD::Signal1< void, MidiSource * > MidiSource::MidiSourceCreated
static

Definition at line 146 of file midi_source.h.

PBD::Signal0<void> ARDOUR::MidiSource::ModelChanged

Emitted when a different MidiModel is set

Definition at line 183 of file midi_source.h.


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