ardour
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
ARDOUR::SMFSource Class Reference

#include <smf_source.h>

Inheritance diagram for ARDOUR::SMFSource:
ARDOUR::MidiSource ARDOUR::FileSource Evoral::SMF< Time > ARDOUR::Source boost::enable_shared_from_this< MidiSource > ARDOUR::Source ARDOUR::SessionObject ARDOUR::SessionObject ARDOUR::SessionHandleRef PBD::StatefulDestructible ARDOUR::SessionHandleRef PBD::StatefulDestructible PBD::ScopedConnectionList PBD::Stateful PBD::Destructible PBD::ScopedConnectionList PBD::Stateful PBD::Destructible

Public Member Functions

 SMFSource (Session &session, const std::string &path, Source::Flag flags)
 
 SMFSource (Session &session, const std::string &path)
 
 SMFSource (Session &session, const XMLNode &, bool must_exist=false)
 
virtual ~SMFSource ()
 
bool safe_file_extension (const std::string &path) const
 
void append_event_beats (const Lock &lock, const Evoral::Event< Evoral::Beats > &ev)
 
void append_event_frames (const Lock &lock, const Evoral::Event< framepos_t > &ev, framepos_t source_start)
 
void mark_streaming_midi_write_started (const Lock &lock, NoteMode mode)
 
void mark_streaming_write_completed (const Lock &lock)
 
void mark_midi_streaming_write_completed (const Lock &lock, Evoral::Sequence< Evoral::Beats >::StuckNoteOption, Evoral::Beats when=Evoral::Beats())
 
XMLNodeget_state ()
 
int set_state (const XMLNode &, int version)
 
void load_model (const Glib::Threads::Mutex::Lock &lock, bool force_reload=false)
 
void destroy_model (const Glib::Threads::Mutex::Lock &lock)
 
void prevent_deletion ()
 
- Public Member Functions inherited from ARDOUR::MidiSource
 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 bool empty () const
 
virtual framecnt_t length (framepos_t pos) const
 
virtual void update_length (framecnt_t)
 
virtual void mark_streaming_write_started (const Lock &lock)
 
void mark_write_starting_now (framecnt_t position, framecnt_t capture_length, framecnt_t loop_length)
 
virtual void session_saved ()
 
std::string captured_for () const
 
void set_captured_for (std::string str)
 
bool length_mutable () const
 
void set_length_beats (TimeType l)
 
TimeType length_beats () const
 
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 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 Member Functions inherited from ARDOUR::FileSource
virtual ~FileSource ()
 
const std::string & path () const
 
int move_to_trash (const std::string &trash_dir_name)
 
void mark_take (const std::string &id)
 
void mark_immutable ()
 
void mark_immutable_except_write ()
 
void mark_nonremovable ()
 
const std::string & take_id () const
 
bool within_session () const
 
uint16_t channel () const
 
int set_source_name (const std::string &newname, bool destructive)
 
void inc_use_count ()
 
bool removable () const
 
bool is_stub () const
 
const std::string & origin () const
 
void existence_check ()
 
int rename (const std::string &name)
 
- Public Member Functions inherited from Evoral::SMF< Time >
 SMF ()
 
virtual ~SMF ()
 
void seek_to_start () const
 
uint16_t ppqn () const
 
bool is_empty () const
 
bool eof () const
 
Time last_event_time () const
 
void begin_write ()
 
void append_event_delta (uint32_t delta_t, const Event< Time > &ev)
 
void end_write () THROW_FILE_ERROR
 
void flush ()
 
int flush_header ()
 
int flush_footer ()
 
 SMF ()
 
virtual ~SMF ()
 
int open (const std::string &path, int track=1) THROW_FILE_ERROR
 
int create (const std::string &path, int track=1, uint16_t ppqn=19200) THROW_FILE_ERROR
 
void close () THROW_FILE_ERROR
 
void seek_to_start () const
 
int seek_to_track (int track)
 
int read_event (uint32_t *delta_t, uint32_t *size, uint8_t **buf, event_id_t *note_id) const
 
uint16_t num_tracks () const
 
uint16_t ppqn () const
 
bool is_empty () const
 
void begin_write ()
 
void append_event_delta (uint32_t delta_t, uint32_t size, const uint8_t *buf, event_id_t note_id)
 
void end_write (std::string const &) THROW_FILE_ERROR
 
void flush ()
 
double round_to_file_precision (double val) const
 

Static Public Member Functions

static bool safe_midi_file_extension (const std::string &path)
 
static bool valid_midi_file (const std::string &path)
 
- Static Public Member Functions inherited from ARDOUR::SessionObject
static void make_property_quarks ()
 
- Static Public Member Functions inherited from ARDOUR::FileSource
static bool find (Session &, DataType type, const std::string &path, bool must_exist, bool &is_new, uint16_t &chan, std::string &found_path)
 
static bool find_2X (Session &, DataType type, const std::string &path, bool must_exist, bool &is_new, uint16_t &chan, std::string &found_path)
 
- Static Public Member Functions inherited from Evoral::SMF< Time >
static bool test (const std::string &path)
 

Protected Member Functions

void close ()
 
void set_path (const std::string &newpath)
 
void flush_midi (const Lock &lock)
 
- 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 Member Functions inherited from ARDOUR::FileSource
 FileSource (Session &session, DataType type, const std::string &path, const std::string &origin, Source::Flag flags=Source::Flag(0))
 
 FileSource (Session &session, const XMLNode &node, bool must_exist)
 
virtual int init (const std::string &idstr, bool must_exist)
 
virtual int move_dependents_to_trash ()
 
void set_within_session_from_path (const std::string &)
 
- Protected Member Functions inherited from Evoral::SMF< Time >
int open (const std::string &path) THROW_FILE_ERROR
 
void close () THROW_FILE_ERROR
 
int read_event (uint32_t *delta_t, uint32_t *size, uint8_t **buf) const
 

Private Member Functions

int open_for_write ()
 
void ensure_disk_file (const Lock &lock)
 
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
 
framecnt_t write_unlocked (const Lock &lock, MidiRingBuffer< framepos_t > &src, framepos_t position, framecnt_t cnt)
 

Private Attributes

bool _open
 
Evoral::Beats _last_ev_time_beats
 
framepos_t _last_ev_time_frames
 
framepos_t _smf_last_read_end
 
framepos_t _smf_last_read_time
 

Additional Inherited Members

- Public Types inherited from ARDOUR::MidiSource
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 Attributes inherited from ARDOUR::MidiSource
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 inherited from ARDOUR::MidiSource
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
 
- Static Public Attributes inherited from ARDOUR::FileSource
static PBD::Signal2< int,
std::string, std::vector
< std::string > > 
AmbiguousFileName
 
- Protected Types inherited from ARDOUR::MidiSource
typedef std::map
< Evoral::Parameter,
Evoral::ControlList::InterpolationStyle
InterpolationStyleMap
 
typedef std::map
< Evoral::Parameter, AutoState
AutomationStateMap
 
- Protected Attributes inherited from ARDOUR::MidiSource
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
 
- Protected Attributes inherited from ARDOUR::FileSource
std::string _path
 
std::string _take_id
 
bool _file_is_new
 
uint16_t _channel
 
bool _within_session
 
std::string _origin
 

Detailed Description

Standard Midi File (Type 0) Source

Definition at line 37 of file smf_source.h.

Constructor & Destructor Documentation

ARDOUR::SMFSource::SMFSource ( Session session,
const std::string &  path,
Source::Flag  flags 
)

Constructor for new internal-to-session files

ARDOUR::SMFSource::SMFSource ( Session session,
const std::string &  path 
)

Constructor for existing external-to-session files

SMFSource::SMFSource ( Session s,
const XMLNode node,
bool  must_exist = false 
)

Constructor for existing in-session files

Constructor used for existing internal-to-session files.

Definition at line 127 of file smf_source.cc.

SMFSource::~SMFSource ( )
virtual

Definition at line 188 of file smf_source.cc.

Member Function Documentation

void SMFSource::append_event_beats ( const Lock lock,
const Evoral::Event< Evoral::Beats > &  ev 
)
virtual

Append an event with a timestamp in beats

Implements ARDOUR::MidiSource.

Definition at line 393 of file smf_source.cc.

void SMFSource::append_event_frames ( const Lock lock,
const Evoral::Event< framepos_t > &  ev,
framepos_t  position 
)
virtual

Append an event with a timestamp in frames (framepos_t)

Implements ARDOUR::MidiSource.

Definition at line 446 of file smf_source.cc.

void SMFSource::close ( )
protectedvirtual

Implements ARDOUR::FileSource.

Definition at line 206 of file smf_source.cc.

void SMFSource::destroy_model ( const Glib::Threads::Mutex::Lock &  lock)
virtual

Implements ARDOUR::MidiSource.

Definition at line 719 of file smf_source.cc.

void SMFSource::ensure_disk_file ( const Lock lock)
private

Ensure that this source has some file on disk, even if it's just a SMF header

Definition at line 750 of file smf_source.cc.

void SMFSource::flush_midi ( const Lock lock)
protectedvirtual

Implements ARDOUR::MidiSource.

Definition at line 727 of file smf_source.cc.

XMLNode & SMFSource::get_state ( void  )
virtual

Reimplemented from ARDOUR::MidiSource.

Definition at line 495 of file smf_source.cc.

void SMFSource::load_model ( const Glib::Threads::Mutex::Lock &  lock,
bool  force_reload = false 
)
virtual

Implements ARDOUR::MidiSource.

Definition at line 606 of file smf_source.cc.

void SMFSource::mark_midi_streaming_write_completed ( const Lock lock,
Evoral::Sequence< Evoral::Beats >::StuckNoteOption  stuck_notes_option,
Evoral::Beats  when = Evoral::Beats() 
)
virtual

Reimplemented from ARDOUR::MidiSource.

Definition at line 542 of file smf_source.cc.

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

Reimplemented from ARDOUR::MidiSource.

Definition at line 521 of file smf_source.cc.

void SMFSource::mark_streaming_write_completed ( const Lock lock)
virtual

Reimplemented from ARDOUR::MidiSource.

Definition at line 536 of file smf_source.cc.

int SMFSource::open_for_write ( )
private

Definition at line 196 of file smf_source.cc.

void SMFSource::prevent_deletion ( )
virtual

Reimplemented from ARDOUR::FileSource.

Definition at line 776 of file smf_source.cc.

framecnt_t SMFSource::read_unlocked ( const Lock lock,
Evoral::EventSink< framepos_t > &  destination,
framepos_t  position,
framepos_t  start,
framecnt_t  duration,
MidiStateTracker tracker,
MidiChannelFilter filter 
) const
privatevirtual

All stamps in audio frames

Implements ARDOUR::MidiSource.

Definition at line 213 of file smf_source.cc.

bool ARDOUR::SMFSource::safe_file_extension ( const std::string &  path) const
inlinevirtual

Implements ARDOUR::FileSource.

Definition at line 50 of file smf_source.h.

bool SMFSource::safe_midi_file_extension ( const std::string &  path)
static

Definition at line 572 of file smf_source.cc.

void SMFSource::set_path ( const std::string &  newpath)
protectedvirtual

Reimplemented from ARDOUR::FileSource.

Definition at line 743 of file smf_source.cc.

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

Reimplemented from ARDOUR::FileSource.

Definition at line 503 of file smf_source.cc.

bool SMFSource::valid_midi_file ( const std::string &  path)
static

Definition at line 563 of file smf_source.cc.

framecnt_t SMFSource::write_unlocked ( const Lock lock,
MidiRingBuffer< framepos_t > &  source,
framepos_t  position,
framecnt_t  cnt 
)
privatevirtual

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.

Implements ARDOUR::MidiSource.

Definition at line 312 of file smf_source.cc.

Member Data Documentation

Evoral::Beats ARDOUR::SMFSource::_last_ev_time_beats
private

Definition at line 81 of file smf_source.h.

framepos_t ARDOUR::SMFSource::_last_ev_time_frames
private

Definition at line 82 of file smf_source.h.

bool ARDOUR::SMFSource::_open
private

Definition at line 80 of file smf_source.h.

framepos_t ARDOUR::SMFSource::_smf_last_read_end
mutableprivate

end time (start + duration) of last call to read_unlocked

Definition at line 84 of file smf_source.h.

framepos_t ARDOUR::SMFSource::_smf_last_read_time
mutableprivate

time (in SMF ticks, 1 tick per _ppqn) of the last event read by read_unlocked

Definition at line 86 of file smf_source.h.


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