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

#include <audiosource.h>

Inheritance diagram for ARDOUR::AudioSource:
ARDOUR::Source ARDOUR::Readable boost::enable_shared_from_this< ARDOUR::AudioSource > ARDOUR::SessionObject ARDOUR::SessionHandleRef PBD::StatefulDestructible PBD::ScopedConnectionList PBD::Stateful PBD::Destructible ARDOUR::AudioFileSource ARDOUR::AudioPlaylistSource ARDOUR::CoreAudioSource ARDOUR::SilentFileSource ARDOUR::SndFileSource ARDOUR::SrcFileSource

Public Member Functions

 AudioSource (Session &, std::string name)
 
 AudioSource (Session &, const XMLNode &)
 
virtual ~AudioSource ()
 
framecnt_t readable_length () const
 
virtual uint32_t n_channels () const
 
virtual bool empty () const
 
framecnt_t length (framepos_t pos) const
 
void update_length (framecnt_t cnt)
 
virtual framecnt_t available_peaks (double zoom) const
 
virtual framecnt_t read (Sample *dst, framepos_t start, framecnt_t cnt, int channel=0) const
 
virtual framecnt_t write (Sample *src, framecnt_t cnt)
 
virtual float sample_rate () const =0
 
virtual void mark_streaming_write_completed (const Lock &lock)
 
virtual bool can_truncate_peaks () const
 
void set_captured_for (std::string str)
 
std::string captured_for () const
 
int read_peaks (PeakData *peaks, framecnt_t npeaks, framepos_t start, framecnt_t cnt, double samples_per_visual_peak) const
 
int build_peaks ()
 
bool peaks_ready (boost::function< void()> callWhenReady, PBD::ScopedConnection **connection_created_if_not_ready, PBD::EventLoop *event_loop) const
 
XMLNodeget_state ()
 
int set_state (const XMLNode &, int version)
 
int rename_peakfile (std::string newpath)
 
void touch_peakfile ()
 
virtual int setup_peakfile ()
 
int prepare_for_peakfile_writes ()
 
void done_with_peakfile_writes (bool done=true)
 
virtual bool clamped_at_unity () const =0
 
- 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 ()
 
virtual void mark_streaming_write_started (const Lock &lock)
 
virtual void session_saved ()
 
XMLNodeget_state ()
 
int set_state (const XMLNode &, int version)
 
bool destructive () const
 
bool writable () const
 
virtual bool set_destructive (bool)
 
virtual bool length_mutable () 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 &)
 
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 Member Functions inherited from ARDOUR::Readable
 Readable ()
 
virtual ~Readable ()
 

Static Public Member Functions

static void set_build_missing_peakfiles (bool yn)
 
static void set_build_peakfiles (bool yn)
 
static bool get_build_peakfiles ()
 
static void allocate_working_buffers (framecnt_t framerate)
 
- Static Public Member Functions inherited from ARDOUR::SessionObject
static void make_property_quarks ()
 

Public Attributes

PBD::Signal0< void > PeaksReady
 
PBD::Signal2< void, framepos_t,
framepos_t
PeakRangeReady
 
- 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
 

Protected Member Functions

int initialize_peakfile (std::string path)
 
int build_peaks_from_scratch ()
 
int compute_and_write_peaks (Sample *buf, framecnt_t first_frame, framecnt_t cnt, bool force, bool intermediate_peaks_ready_signal)
 
void truncate_peakfile ()
 
virtual framecnt_t read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) const =0
 
virtual framecnt_t write_unlocked (Sample *dst, framecnt_t cnt)=0
 
virtual std::string peak_path (std::string audio_path)=0
 
virtual std::string find_broken_peakfile (std::string, std::string audio_path)
 
virtual int read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t start, framecnt_t cnt, double samples_per_visual_peak, framecnt_t fpp) const
 
int compute_and_write_peaks (Sample *buf, framecnt_t first_frame, framecnt_t cnt, bool force, bool intermediate_peaks_ready_signal, framecnt_t frames_per_peak)
 
- 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 &)
 

Static Protected Member Functions

static void ensure_buffers_for_level (uint32_t, framecnt_t)
 
static void ensure_buffers_for_level_locked (uint32_t, framecnt_t)
 

Protected Attributes

framecnt_t _length
 
std::string peakpath
 
std::string _captured_for
 
off_t _peak_byte_max
 
- 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
 

Static Protected Attributes

static bool _build_missing_peakfiles = false
 
static bool _build_peakfiles = false
 
static size_t _working_buffers_size = 0
 
static std::vector
< boost::shared_array< Sample > > 
_mixdown_buffers
 
static std::vector
< boost::shared_array< gain_t > > 
_gain_buffers
 
static Glib::Threads::Mutex _level_buffer_lock
 

Private Attributes

bool _peaks_built
 
Glib::Threads::Mutex _peaks_ready_lock
 
int _peakfile_fd
 
framecnt_t peak_leftover_cnt
 
framecnt_t peak_leftover_size
 
Samplepeak_leftovers
 
framepos_t peak_leftover_frame
 
bool _first_run
 
double _last_scale
 
off_t _last_map_off
 
size_t _last_raw_map_length
 
boost::scoped_array< PeakDatapeak_cache
 

Additional Inherited Members

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

Detailed Description

Definition at line 41 of file audiosource.h.

Constructor & Destructor Documentation

ARDOUR::AudioSource::AudioSource ( Session ,
std::string  name 
)
AudioSource::AudioSource ( Session s,
const XMLNode node 
)

Definition at line 95 of file audiosource.cc.

AudioSource::~AudioSource ( )
virtual

Definition at line 114 of file audiosource.cc.

Member Function Documentation

void AudioSource::allocate_working_buffers ( framecnt_t  framerate)
static

Definition at line 1009 of file audiosource.cc.

framecnt_t AudioSource::available_peaks ( double  zoom) const
virtual

Definition at line 981 of file audiosource.cc.

int ARDOUR::AudioSource::build_peaks ( )
int AudioSource::build_peaks_from_scratch ( )
protected

Definition at line 675 of file audiosource.cc.

virtual bool ARDOUR::AudioSource::can_truncate_peaks ( ) const
inlinevirtual

Reimplemented in ARDOUR::AudioFileSource, and ARDOUR::AudioPlaylistSource.

Definition at line 66 of file audiosource.h.

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

Definition at line 69 of file audiosource.h.

virtual bool ARDOUR::AudioSource::clamped_at_unity ( ) const
pure virtual
Returns
true if the each source sample s must be clamped to -1 < s < 1

Implemented in ARDOUR::SndFileSource, ARDOUR::SrcFileSource, ARDOUR::CoreAudioSource, ARDOUR::AudioPlaylistSource, and ARDOUR::SilentFileSource.

int AudioSource::compute_and_write_peaks ( Sample buf,
framecnt_t  first_frame,
framecnt_t  cnt,
bool  force,
bool  intermediate_peaks_ready 
)
protected
Parameters
first_frameOffset from the source start of the first frame to process

Definition at line 766 of file audiosource.cc.

int AudioSource::compute_and_write_peaks ( Sample buf,
framecnt_t  first_frame,
framecnt_t  cnt,
bool  force,
bool  intermediate_peaks_ready_signal,
framecnt_t  frames_per_peak 
)
protected

Definition at line 773 of file audiosource.cc.

void AudioSource::done_with_peakfile_writes ( bool  done = true)

Definition at line 748 of file audiosource.cc.

bool AudioSource::empty ( ) const
virtual

Implements ARDOUR::Source.

Reimplemented in ARDOUR::AudioPlaylistSource.

Definition at line 155 of file audiosource.cc.

void AudioSource::ensure_buffers_for_level ( uint32_t  level,
framecnt_t  frame_rate 
)
staticprotected

Definition at line 1026 of file audiosource.cc.

void AudioSource::ensure_buffers_for_level_locked ( uint32_t  level,
framecnt_t  frame_rate 
)
staticprotected

Definition at line 1033 of file audiosource.cc.

virtual std::string ARDOUR::AudioSource::find_broken_peakfile ( std::string  ,
std::string  audio_path 
)
inlineprotectedvirtual

Reimplemented in ARDOUR::AudioFileSource.

Definition at line 142 of file audiosource.h.

static bool ARDOUR::AudioSource::get_build_peakfiles ( )
inlinestatic

Definition at line 94 of file audiosource.h.

XMLNode & AudioSource::get_state ( void  )
virtual

Implements PBD::Stateful.

Definition at line 131 of file audiosource.cc.

int AudioSource::initialize_peakfile ( std::string  path)
protected

Definition at line 239 of file audiosource.cc.

framecnt_t AudioSource::length ( framepos_t  pos) const
virtual

Implements ARDOUR::Source.

Reimplemented in ARDOUR::SrcFileSource.

Definition at line 161 of file audiosource.cc.

void AudioSource::mark_streaming_write_completed ( const Lock lock)
virtual

Implements ARDOUR::Source.

Reimplemented in ARDOUR::AudioFileSource.

Definition at line 999 of file audiosource.cc.

virtual uint32_t ARDOUR::AudioSource::n_channels ( ) const
inlinevirtual

Implements ARDOUR::Readable.

Reimplemented in ARDOUR::AudioPlaylistSource.

Definition at line 51 of file audiosource.h.

virtual std::string ARDOUR::AudioSource::peak_path ( std::string  audio_path)
protectedpure virtual
bool AudioSource::peaks_ready ( boost::function< void()>  doThisWhenReady,
PBD::ScopedConnection **  connection_created_if_not_ready,
PBD::EventLoop event_loop 
) const

Checks to see if peaks are ready. If so, we return true. If not, we return false, and things are set up so that doThisWhenReady is called when the peaks are ready. A new PBD::ScopedConnection is created for the associated connection and written to *connect_here_if_not.

Parameters
doThisWhenReadyFunction to call when peaks are ready (if they are not already).
connect_here_if_notAddress to write new ScopedConnection to.
event_loopEvent loop for doThisWhenReady to be called in.

Definition at line 189 of file audiosource.cc.

int AudioSource::prepare_for_peakfile_writes ( )

Definition at line 738 of file audiosource.cc.

framecnt_t AudioSource::read ( Sample dst,
framepos_t  start,
framecnt_t  cnt,
int  channel = 0 
) const
virtual

Implements ARDOUR::Readable.

Definition at line 312 of file audiosource.cc.

int AudioSource::read_peaks ( PeakData peaks,
framecnt_t  npeaks,
framepos_t  start,
framecnt_t  cnt,
double  samples_per_visual_peak 
) const

Definition at line 330 of file audiosource.cc.

int AudioSource::read_peaks_with_fpp ( PeakData peaks,
framecnt_t  npeaks,
framepos_t  start,
framecnt_t  cnt,
double  samples_per_visual_peak,
framecnt_t  samples_per_file_peak 
) const
protectedvirtual
Parameters
peaksBuffer to write peak data.
npeaksNumber of peaks to write.

Reimplemented in ARDOUR::SilentFileSource, and ARDOUR::SrcFileSource.

Definition at line 340 of file audiosource.cc.

virtual framecnt_t ARDOUR::AudioSource::read_unlocked ( Sample dst,
framepos_t  start,
framecnt_t  cnt 
) const
protectedpure virtual
framecnt_t ARDOUR::AudioSource::readable_length ( ) const
inlinevirtual

Implements ARDOUR::Readable.

Reimplemented in ARDOUR::SrcFileSource.

Definition at line 50 of file audiosource.h.

int AudioSource::rename_peakfile ( std::string  newpath)

Definition at line 220 of file audiosource.cc.

virtual float ARDOUR::AudioSource::sample_rate ( ) const
pure virtual
static void ARDOUR::AudioSource::set_build_missing_peakfiles ( bool  yn)
inlinestatic

Definition at line 86 of file audiosource.h.

static void ARDOUR::AudioSource::set_build_peakfiles ( bool  yn)
inlinestatic

Definition at line 90 of file audiosource.h.

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

Definition at line 68 of file audiosource.h.

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

Implements PBD::Stateful.

Definition at line 143 of file audiosource.cc.

virtual int ARDOUR::AudioSource::setup_peakfile ( )
inlinevirtual

Reimplemented in ARDOUR::AudioFileSource, and ARDOUR::AudioPlaylistSource.

Definition at line 98 of file audiosource.h.

void AudioSource::touch_peakfile ( )

Definition at line 203 of file audiosource.cc.

void AudioSource::truncate_peakfile ( )
protected

Definition at line 959 of file audiosource.cc.

void AudioSource::update_length ( framecnt_t  cnt)
virtual

Implements ARDOUR::Source.

Definition at line 167 of file audiosource.cc.

framecnt_t AudioSource::write ( Sample src,
framecnt_t  cnt 
)
virtual

Definition at line 321 of file audiosource.cc.

virtual framecnt_t ARDOUR::AudioSource::write_unlocked ( Sample dst,
framecnt_t  cnt 
)
protectedpure virtual

Member Data Documentation

bool AudioSource::_build_missing_peakfiles = false
staticprotected

Definition at line 109 of file audiosource.h.

bool AudioSource::_build_peakfiles = false
staticprotected

true if we want peakfiles (e.g. if we are displaying a GUI)

Definition at line 110 of file audiosource.h.

std::string ARDOUR::AudioSource::_captured_for
protected

Definition at line 129 of file audiosource.h.

bool ARDOUR::AudioSource::_first_run
mutableprivate

Definition at line 169 of file audiosource.h.

vector< boost::shared_array< gain_t > > AudioSource::_gain_buffers
staticprotected

Definition at line 121 of file audiosource.h.

off_t ARDOUR::AudioSource::_last_map_off
mutableprivate

Definition at line 171 of file audiosource.h.

size_t ARDOUR::AudioSource::_last_raw_map_length
mutableprivate

Definition at line 172 of file audiosource.h.

double ARDOUR::AudioSource::_last_scale
mutableprivate

Definition at line 170 of file audiosource.h.

framecnt_t ARDOUR::AudioSource::_length
protected

Definition at line 127 of file audiosource.h.

Glib::Threads::Mutex AudioSource::_level_buffer_lock
staticprotected

Definition at line 122 of file audiosource.h.

vector< boost::shared_array< Sample > > AudioSource::_mixdown_buffers
staticprotected

Definition at line 120 of file audiosource.h.

off_t ARDOUR::AudioSource::_peak_byte_max
mutableprotected

Definition at line 137 of file audiosource.h.

int ARDOUR::AudioSource::_peakfile_fd
private

Definition at line 163 of file audiosource.h.

bool ARDOUR::AudioSource::_peaks_built
private

Definition at line 154 of file audiosource.h.

Glib::Threads::Mutex ARDOUR::AudioSource::_peaks_ready_lock
mutableprivate

This mutex is used to protect both the _peaks_built variable and also the emission (and handling) of the PeaksReady signal. Holding the lock when emitting PeaksReady means that _peaks_built cannot be changed during the handling of the signal.

Definition at line 161 of file audiosource.h.

size_t AudioSource::_working_buffers_size = 0
staticprotected

Definition at line 112 of file audiosource.h.

boost::scoped_array<PeakData> ARDOUR::AudioSource::peak_cache
mutableprivate

Definition at line 173 of file audiosource.h.

framecnt_t ARDOUR::AudioSource::peak_leftover_cnt
private

Definition at line 164 of file audiosource.h.

framepos_t ARDOUR::AudioSource::peak_leftover_frame
private

Definition at line 167 of file audiosource.h.

framecnt_t ARDOUR::AudioSource::peak_leftover_size
private

Definition at line 165 of file audiosource.h.

Sample* ARDOUR::AudioSource::peak_leftovers
private

Definition at line 166 of file audiosource.h.

std::string ARDOUR::AudioSource::peakpath
protected

Definition at line 128 of file audiosource.h.

PBD::Signal2<void,framepos_t,framepos_t> ARDOUR::AudioSource::PeakRangeReady
mutable

Definition at line 78 of file audiosource.h.

PBD::Signal0<void> ARDOUR::AudioSource::PeaksReady
mutable

Definition at line 77 of file audiosource.h.


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