Ardour  9.0-pre0-582-g084a23a80d
ARDOUR::SMFSource Class Reference

#include <smf_source.h>

Inheritance diagram for ARDOUR::SMFSource:
[legend]

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 WriterLock &lock, const Evoral::Event< Temporal::Beats > &ev)
 
void append_event_samples (const WriterLock &lock, const Evoral::Event< samplepos_t > &ev, samplepos_t source_start)
 
void update_length (timepos_t const &dur)
 
void mark_streaming_midi_write_started (const WriterLock &lock, NoteMode mode)
 
void mark_streaming_write_completed (const WriterLock &lock, Temporal::timecnt_t const &duration)
 
void mark_midi_streaming_write_completed (const WriterLock &lock, Evoral::Sequence< Temporal::Beats >::StuckNoteOption, Temporal::timecnt_t const &duration)
 
XMLNodeget_state () const
 
int set_state (const XMLNode &, int version)
 
void load_model (const WriterLock &lock, bool force_reload=false)
 
void destroy_model (const WriterLock &lock)
 
void prevent_deletion ()
 
void set_path (const std::string &newpath)
 
SMF::UsedChannels used_midi_channels ()
 
void render (const ReaderLock &lock, Evoral::EventSink< Temporal::Beats > &dst)
 
Temporal::Beats duration () const
 
- 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 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 timecnt_t midi_write (const WriterLock &lock, MidiRingBuffer< samplepos_t > &source, timepos_t const &source_start, timecnt_t const &cnt)
 
virtual void mark_streaming_write_started (const WriterLock &lock)
 
void mark_write_starting_now (timepos_t const &position, samplecnt_t capture_length)
 
virtual void session_saved ()
 
bool length_mutable () const
 
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
 
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 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 ()
 
bool within_session () const
 
uint16_t channel () const
 
float gain () const
 
virtual void set_gain (float g, bool temporarily=false)
 
virtual void set_channel (uint16_t c)
 
int set_source_name (const std::string &newname)
 
bool removable () const
 
bool is_stub () const
 
const std::string & origin () const
 
void set_origin (std::string const &o)
 
void replace_file (const std::string &)
 
void existence_check ()
 
int rename (const std::string &name)
 
- Public Member Functions inherited from Evoral::SMF
 SMF ()
 
virtual ~SMF ()
 
int open (const std::string &path, int track=1, bool scan=true)
 
int create (const std::string &path, int track=1, uint16_t ppqn=19200)
 
void close ()
 
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 &)
 
void flush ()
 
void set_length (Temporal::Beats const &)
 
double round_to_file_precision (double val) const
 
int smf_format () const
 
Temporal::Beats file_duration () const
 
int num_channels () const
 
UsedChannels const & used_channels () const
 
void set_used_channels (UsedChannels used)
 
uint64_t n_note_on_events () const
 
bool has_pgm_change () const
 
void track_names (std::vector< std::string > &) const
 
void instrument_names (std::vector< std::string > &) const
 
int num_tempos () const
 
Temponth_tempo (size_t n) const
 
Markers const & markers () const
 
void load_markers ()
 
std::shared_ptr< Temporal::TempoMaptempo_map (bool &provided) 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
static bool test (const std::string &path)
 

Protected Member Functions

void close ()
 
void flush_midi (const WriterLock &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 &) 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 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 &)
 

Private Member Functions

int open_for_write ()
 
void ensure_disk_file (const WriterLock &lock)
 
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
 
timecnt_t write_unlocked (const WriterLock &lock, MidiRingBuffer< samplepos_t > &src, timepos_t const &position, timecnt_t const &cnt)
 
void load_model_unlocked (bool force_reload=false)
 

Private Attributes

bool _open
 
Temporal::Beats _last_ev_time_beats
 
samplepos_t _last_ev_time_samples
 
timepos_t _smf_last_read_end
 
timepos_t _smf_last_read_time
 

Additional Inherited Members

- Public Types inherited from ARDOUR::MidiSource
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 Types inherited from Evoral::SMF
typedef std::bitset< 16 > UsedChannels
 
typedef std::vector< MarkerAtMarkers
 
- Public Attributes inherited from ARDOUR::MidiSource
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
 
- 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
 
- Static Public Attributes inherited from ARDOUR::FileSource
static PBD::Signal< int(std::string, std::vector< std::string >)> AmbiguousFileName
 
- Protected Types inherited from ARDOUR::MidiSource
typedef std::map< Evoral::Parameter, AutomationList::InterpolationStyleInterpolationStyleMap
 
typedef std::map< Evoral::Parameter, AutoStateAutomationStateMap
 
- Protected Types inherited from ARDOUR::Source
typedef std::vector< SegmentDescriptorSegmentDescriptors
 
- Protected Attributes inherited from ARDOUR::MidiSource
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
 
- Protected Attributes inherited from ARDOUR::FileSource
std::string _path
 
bool _file_is_new
 
uint16_t _channel
 
bool _within_session
 
std::string _origin
 
float _gain
 
- Protected Attributes inherited from Evoral::SMF
uint64_t _n_note_on_events
 
bool _has_pgm_change
 
int _num_channels
 
UsedChannels _used_channels
 

Detailed Description

Standard Midi File (Type 0) Source

Definition at line 38 of file smf_source.h.

Constructor & Destructor Documentation

◆ SMFSource() [1/3]

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

Constructor for new internal-to-session files

◆ SMFSource() [2/3]

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

Constructor for existing external-to-session files

◆ SMFSource() [3/3]

ARDOUR::SMFSource::SMFSource ( Session session,
const XMLNode ,
bool  must_exist = false 
)

Constructor for existing in-session files

◆ ~SMFSource()

virtual ARDOUR::SMFSource::~SMFSource ( )
virtual

Member Function Documentation

◆ append_event_beats()

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

Append a single event with a timestamp in beats.

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

Implements ARDOUR::MidiSource.

◆ append_event_samples()

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

Append a single event with a timestamp in samples.

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

Implements ARDOUR::MidiSource.

◆ close()

void ARDOUR::SMFSource::close ( )
protectedvirtual

Implements ARDOUR::FileSource.

◆ destroy_model()

void ARDOUR::SMFSource::destroy_model ( const WriterLock lock)
virtual

Implements ARDOUR::MidiSource.

◆ duration()

Temporal::Beats ARDOUR::SMFSource::duration ( ) const
virtual

Reimplemented from Evoral::SMF.

◆ ensure_disk_file()

void ARDOUR::SMFSource::ensure_disk_file ( const WriterLock lock)
private

◆ flush_midi()

void ARDOUR::SMFSource::flush_midi ( const WriterLock lock)
protectedvirtual

Implements ARDOUR::MidiSource.

◆ get_state()

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

Reimplemented from ARDOUR::MidiSource.

◆ load_model()

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

Implements ARDOUR::MidiSource.

◆ load_model_unlocked()

void ARDOUR::SMFSource::load_model_unlocked ( bool  force_reload = false)
private

◆ mark_midi_streaming_write_completed()

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

Reimplemented from ARDOUR::MidiSource.

◆ mark_streaming_midi_write_started()

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

Reimplemented from ARDOUR::MidiSource.

◆ mark_streaming_write_completed()

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

Reimplemented from ARDOUR::MidiSource.

◆ open_for_write()

int ARDOUR::SMFSource::open_for_write ( )
private

◆ prevent_deletion()

void ARDOUR::SMFSource::prevent_deletion ( )
virtual

Reimplemented from ARDOUR::FileSource.

◆ read_unlocked()

timecnt_t ARDOUR::SMFSource::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
privatevirtual

Implements ARDOUR::MidiSource.

◆ render()

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

Implements ARDOUR::MidiSource.

◆ safe_file_extension()

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

Implements ARDOUR::FileSource.

Definition at line 51 of file smf_source.h.

◆ safe_midi_file_extension()

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

◆ set_path()

void ARDOUR::SMFSource::set_path ( const std::string &  newpath)
virtual

Reimplemented from ARDOUR::FileSource.

◆ set_state()

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

Reimplemented from ARDOUR::FileSource.

◆ update_length()

void ARDOUR::SMFSource::update_length ( timepos_t const &  dur)
virtual

Reimplemented from ARDOUR::Source.

◆ used_midi_channels()

SMF::UsedChannels ARDOUR::SMFSource::used_midi_channels ( )

Query the smf file for its channel info

◆ valid_midi_file()

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

◆ write_unlocked()

timecnt_t ARDOUR::SMFSource::write_unlocked ( const WriterLock lock,
MidiRingBuffer< samplepos_t > &  source,
timepos_t const &  position,
timecnt_t const &  cnt 
)
privatevirtual

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.

Implements ARDOUR::MidiSource.

Member Data Documentation

◆ _last_ev_time_beats

Temporal::Beats ARDOUR::SMFSource::_last_ev_time_beats
private

Definition at line 92 of file smf_source.h.

◆ _last_ev_time_samples

samplepos_t ARDOUR::SMFSource::_last_ev_time_samples
private

Definition at line 93 of file smf_source.h.

◆ _open

bool ARDOUR::SMFSource::_open
private

Definition at line 91 of file smf_source.h.

◆ _smf_last_read_end

timepos_t ARDOUR::SMFSource::_smf_last_read_end
mutableprivate

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

Definition at line 95 of file smf_source.h.

◆ _smf_last_read_time

timepos_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 97 of file smf_source.h.


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