X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=libs%2Fardour%2Fardour%2Fsession.h;h=082e05a9bdf26584f1699479a64f797ef25ac430;hb=9f4c7a9e9edd260a72f040b036982d4c5da89292;hp=1a88882eb6ea4572e5bc90273e4d29e204816c16;hpb=49510ba1d7fc1c85e767c05f10f9481998ef94b0;p=ardour.git diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 1a88882eb6..082e05a9bd 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -20,42 +20,40 @@ #ifndef __ardour_session_h__ #define __ardour_session_h__ -#include #include #include -#include #include #include +#include +#include +#include +#include #include #include -#include - -#include +#include #include #include -#include -#include -#include -#include -#include - -#include -#include +#include "pbd/error.h" +#include "pbd/pool.h" +#include "pbd/rcu.h" +#include "pbd/statefuldestructible.h" +#include "pbd/undo.h" -#include -#include +#include "midi++/mmc.h" +#include "midi++/types.h" -#include -#include -#include -#include -#include +#include "pbd/destructible.h" +#include "pbd/stateful.h" -#include +#include "ardour/ardour.h" +#include "ardour/chan_count.h" +#include "ardour/configuration.h" +#include "ardour/location.h" +#include "ardour/smpte.h" class XMLTree; class XMLNode; @@ -69,58 +67,57 @@ namespace PBD { class Controllable; } +namespace Evoral { + class Curve; +} + namespace ARDOUR { -class Port; +class AudioDiskstream; class AudioEngine; -class Slave; -class Diskstream; -class Route; -class AuxInput; -class Source; +class AudioFileSource; +class AudioRegion; class AudioSource; +class AudioTrack; +class Auditioner; +class AutomationList; +class AuxInput; class BufferSet; -class IO; - +class Bundle; +class ControlProtocolInfo; class Diskstream; -class AudioDiskstream; +class ExportHandler; +class ExportStatus; +class IO; +class IOProcessor; class MidiDiskstream; -class AudioFileSource; +class MidiRegion; class MidiSource; -class Auditioner; -class Processor; -class Send; -class IOProcessor; -class PortInsert; -class PluginInsert; -class Bundle; -class TempoMap; -class AudioTrack; +class MidiTrack; class NamedSelection; -class AudioRegion; - -class Region; class Playlist; -class VSTPlugin; -class ControlProtocolInfo; - -class MidiTrack; -class MidiRegion; +class PluginInsert; +class Port; +class PortInsert; +class Processor; +class Region; +class Route; +class RouteGroup; class SMFSource; - +class Send; class SessionDirectory; class SessionMetadata; -class ExportHandler; -class ExportStatus; - -struct RouteGroup; +class Slave; +class Source; +class TempoMap; +class VSTPlugin; using std::vector; using std::string; using std::map; using std::set; -class Session : public PBD::StatefulDestructible +class Session : public PBD::StatefulDestructible, public boost::noncopyable { private: typedef std::pair,bool> RouteBooleanState; @@ -136,115 +133,114 @@ class Session : public PBD::StatefulDestructible }; struct Event { - enum Type { - SetTransportSpeed, - SetDiskstreamSpeed, - Locate, - LocateRoll, - LocateRollLocate, - SetLoop, - PunchIn, - PunchOut, - RangeStop, - RangeLocate, - Overwrite, - SetSlaveSource, - Audition, - InputConfigurationChange, - SetAudioRange, - SetPlayRange, - - /* only one of each of these events - can be queued at any one time - */ - - StopOnce, - AutoLoop - }; - - enum Action { - Add, - Remove, - Replace, - Clear - }; - - Type type; - Action action; - nframes_t action_frame; - nframes_t target_frame; - double speed; - - union { - void* ptr; - bool yes_or_no; - nframes_t target2_frame; - SlaveSource slave; - Route* route; - }; - - boost::shared_ptr region; - - list audio_range; - list music_range; - - Event(Type t, Action a, nframes_t when, nframes_t where, double spd, bool yn = false) - : type (t), - action (a), - action_frame (when), - target_frame (where), - speed (spd), - yes_or_no (yn) {} - - void set_ptr (void* p) { - ptr = p; - } - - bool before (const Event& other) const { - return action_frame < other.action_frame; - } - - bool after (const Event& other) const { - return action_frame > other.action_frame; - } - - static bool compare (const Event *e1, const Event *e2) { - return e1->before (*e2); - } - - void *operator new (size_t ignored) { - return pool.alloc (); - } - - void operator delete(void *ptr, size_t size) { - pool.release (ptr); - } - - static const nframes_t Immediate = 0; - - private: - static MultiAllocSingleReleasePool pool; + enum Type { + SetTransportSpeed, + SetDiskstreamSpeed, + Locate, + LocateRoll, + LocateRollLocate, + SetLoop, + PunchIn, + PunchOut, + RangeStop, + RangeLocate, + Overwrite, + SetSlaveSource, + Audition, + InputConfigurationChange, + SetAudioRange, + SetPlayRange, + + /* only one of each of these events can be queued at any one time */ + + StopOnce, + AutoLoop + }; + + enum Action { + Add, + Remove, + Replace, + Clear + }; + + Type type; + Action action; + nframes_t action_frame; + nframes_t target_frame; + double speed; + + union { + void* ptr; + bool yes_or_no; + nframes_t target2_frame; + SlaveSource slave; + Route* route; + }; + + list audio_range; + list music_range; + + boost::shared_ptr region; + + Event(Type t, Action a, nframes_t when, nframes_t where, double spd, bool yn = false) + : type (t) + , action (a) + , action_frame (when) + , target_frame (where) + , speed (spd) + , yes_or_no (yn) + {} + + void set_ptr (void* p) { + ptr = p; + } + + bool before (const Event& other) const { + return action_frame < other.action_frame; + } + + bool after (const Event& other) const { + return action_frame > other.action_frame; + } + + static bool compare (const Event *e1, const Event *e2) { + return e1->before (*e2); + } + + void *operator new (size_t ignored) { + return pool.alloc (); + } + + void operator delete(void *ptr, size_t size) { + pool.release (ptr); + } + + static const nframes_t Immediate = 0; + + private: + static MultiAllocSingleReleasePool pool; }; /* creating from an XML file */ Session (AudioEngine&, - const string& fullpath, - const string& snapshot_name, - string mix_template = ""); + const string& fullpath, + const string& snapshot_name, + string mix_template = ""); /* creating a new Session */ Session (AudioEngine&, - string fullpath, - string snapshot_name, - AutoConnectOption input_auto_connect, - AutoConnectOption output_auto_connect, - uint32_t control_out_channels, - uint32_t master_out_channels, - uint32_t n_physical_in, - uint32_t n_physical_out, - nframes_t initial_length); + string fullpath, + string snapshot_name, + AutoConnectOption input_auto_connect, + AutoConnectOption output_auto_connect, + uint32_t control_out_channels, + uint32_t master_out_channels, + uint32_t n_physical_in, + uint32_t n_physical_out, + nframes_t initial_length); virtual ~Session (); @@ -279,12 +275,13 @@ class Session : public PBD::StatefulDestructible Glib::ustring peak_path (Glib::ustring) const; - static string change_audio_path_by_name (string oldpath, string oldname, string newname, bool destructive); - static string change_midi_path_by_name (string oldpath, string oldname, string newname, bool destructive); + static string change_source_path_by_name (string oldpath, string oldname, string newname, bool destructive); string peak_path_from_audio_path (string) const; - string audio_path_from_name (string, uint32_t nchans, uint32_t chan, bool destructive); - string midi_path_from_name (string); + string new_audio_source_name (const string&, uint32_t nchans, uint32_t chan, bool destructive); + string new_midi_source_name (const string&); + string new_source_path_from_name (DataType type, const string&); + RouteList new_route_from_template (uint32_t how_many, const std::string& template_path); void process (nframes_t nframes); @@ -306,7 +303,6 @@ class Session : public PBD::StatefulDestructible uint32_t n_diskstreams() const; typedef std::list > DiskstreamList; - typedef std::list > RouteList; int load_routes (const XMLNode&); boost::shared_ptr get_routes() const { @@ -376,6 +372,9 @@ class Session : public PBD::StatefulDestructible sigc::signal Xrun; sigc::signal TransportLooped; + /** emitted when a locate has occurred */ + sigc::signal Located; + sigc::signal RouteAdded; void request_roll_at_and_return (nframes_t start, nframes_t return_to); @@ -402,16 +401,15 @@ class Session : public PBD::StatefulDestructible bool transport_locked () const; int wipe (); - //int wipe_diskstream (AudioDiskstream *); int remove_region_from_region_list (boost::shared_ptr); nframes_t get_maximum_extent () const; nframes_t current_end_frame() const { return end_location->start(); } nframes_t current_start_frame() const { return start_location->start(); } - // "actual" sample rate of session, set by current audioengine rate, pullup/down etc. + /// "actual" sample rate of session, set by current audioengine rate, pullup/down etc. nframes_t frame_rate() const { return _current_frame_rate; } - // "native" sample rate of session, regardless of current audioengine rate, pullup/down etc + /// "native" sample rate of session, regardless of current audioengine rate, pullup/down etc nframes_t nominal_frame_rate() const { return _nominal_frame_rate; } nframes_t frames_per_hour() const { return _frames_per_hour; } @@ -443,10 +441,10 @@ class Session : public PBD::StatefulDestructible void remove_event (nframes_t frame, Event::Type type); void clear_events (Event::Type type); - nframes_t get_block_size() const { return current_block_size; } + nframes_t get_block_size() const { return current_block_size; } nframes_t worst_output_latency () const { return _worst_output_latency; } - nframes_t worst_input_latency () const { return _worst_input_latency; } - nframes_t worst_track_latency () const { return _worst_track_latency; } + nframes_t worst_input_latency () const { return _worst_input_latency; } + nframes_t worst_track_latency () const { return _worst_track_latency; } int save_state (std::string snapshot_name, bool pending = false); int restore_state (std::string snapshot_name); @@ -472,7 +470,7 @@ class Session : public PBD::StatefulDestructible /// The instant xml file is written to the session directory void add_instant_xml (XMLNode&, bool write_to_config = true); - XMLNode * instant_xml (const std::string& str); + XMLNode* instant_xml (const std::string& str); enum StateOfTheState { Clean = 0x0, @@ -497,8 +495,8 @@ class Session : public PBD::StatefulDestructible sigc::signal edit_group_added; sigc::signal mix_group_added; - sigc::signal edit_group_removed; - sigc::signal mix_group_removed; + sigc::signal edit_group_removed; + sigc::signal mix_group_removed; void foreach_edit_group (sigc::slot sl) { for (list::iterator i = edit_groups.begin(); i != edit_groups.end(); i++) { @@ -514,11 +512,13 @@ class Session : public PBD::StatefulDestructible /* fundamental operations. duh. */ - std::list > new_audio_track (int input_channels, int output_channels, TrackMode mode = Normal, uint32_t how_many = 1); + std::list > new_audio_track ( + int input_channels, int output_channels, TrackMode mode = Normal, uint32_t how_many = 1); + RouteList new_audio_route (int input_channels, int output_channels, uint32_t how_many); - std::list > new_midi_track (TrackMode mode = Normal, uint32_t how_many = 1); - //boost::shared_ptr new_midi_route (uint32_t how_many = 1); + std::list > new_midi_track ( + TrackMode mode = Normal, uint32_t how_many = 1); void remove_route (boost::shared_ptr); void resort_routes (); @@ -554,8 +554,8 @@ class Session : public PBD::StatefulDestructible void sync_time_vars(); void bbt_time (nframes_t when, BBT_Time&); - void smpte_to_sample( SMPTE::Time& smpte, nframes_t& sample, bool use_offset, bool use_subframes ) const; - void sample_to_smpte( nframes_t sample, SMPTE::Time& smpte, bool use_offset, bool use_subframes ) const; + void smpte_to_sample(SMPTE::Time& smpte, nframes_t& sample, bool use_offset, bool use_subframes) const; + void sample_to_smpte(nframes_t sample, SMPTE::Time& smpte, bool use_offset, bool use_subframes) const; void smpte_time (SMPTE::Time &); void smpte_time (nframes_t when, SMPTE::Time&); void smpte_time_subframes (nframes_t when, SMPTE::Time&); @@ -564,7 +564,7 @@ class Session : public PBD::StatefulDestructible void smpte_duration_string (char *, nframes_t) const; void set_smpte_offset (nframes_t); - nframes_t smpte_offset () const { return _smpte_offset; } + nframes_t smpte_offset () const { return _smpte_offset; } void set_smpte_offset_negative (bool); bool smpte_offset_negative () const { return _smpte_offset_negative; } @@ -574,12 +574,12 @@ class Session : public PBD::StatefulDestructible static sigc::signal EndTimeChanged; static sigc::signal SMPTEOffsetChanged; - void request_slave_source (SlaveSource); - bool synced_to_jack() const { return Config->get_slave_source() == JACK; } + void request_slave_source (SlaveSource); + bool synced_to_jack() const { return Config->get_slave_source() == JACK; } - double transport_speed() const { return _transport_speed; } - bool transport_stopped() const { return _transport_speed == 0.0f; } - bool transport_rolling() const { return _transport_speed != 0.0f; } + double transport_speed() const { return _transport_speed; } + bool transport_stopped() const { return _transport_speed == 0.0f; } + bool transport_rolling() const { return _transport_speed != 0.0f; } void set_silent (bool yn); bool silent () { return _silent; } @@ -615,22 +615,22 @@ class Session : public PBD::StatefulDestructible /* source management */ - struct import_status : public InterThreadInfo { - string doing_what; + struct ImportStatus : public InterThreadInfo { + string doing_what; - /* control info */ - uint32_t total; - SrcQuality quality; - volatile bool freeze; - std::vector paths; - bool replace_existing_source; + /* control info */ + uint32_t total; + SrcQuality quality; + volatile bool freeze; + std::vector paths; + bool replace_existing_source; - /* result */ - SourceList sources; + /* result */ + SourceList sources; }; - void import_audiofiles (import_status&); - bool sample_rate_convert (import_status&, string infile, string& outfile); + void import_audiofiles (ImportStatus&); + bool sample_rate_convert (ImportStatus&, string infile, string& outfile); string build_tmp_convert_name (string file); boost::shared_ptr get_export_handler (); @@ -658,23 +658,19 @@ class Session : public PBD::StatefulDestructible int remove_last_capture (); - /* handlers should return -1 for "stop cleanup", 0 for - "yes, delete this playlist" and 1 for "no, don't delete - this playlist. + /** handlers should return -1 for "stop cleanup", + 0 for "yes, delete this playlist", + 1 for "no, don't delete this playlist". */ - sigc::signal > AskAboutPlaylistDeletion; - /* handlers should return 0 for "ignore the rate mismatch" - and !0 for "do not use this session" + /** handlers should return 0 for "ignore the rate mismatch", + !0 for "do not use this session" */ - static sigc::signal AskAboutSampleRateMismatch; - /* handlers should return !0 for use pending state, 0 for - ignore it. + /** handlers should return !0 for use pending state, 0 for ignore it. */ - static sigc::signal AskAboutPendingState; boost::shared_ptr create_audio_source_for_session (ARDOUR::AudioDiskstream&, uint32_t which_channel, bool destructive); @@ -708,7 +704,6 @@ class Session : public PBD::StatefulDestructible sigc::signal NamedSelectionRemoved; /* Curves and AutomationLists (TODO when they go away) */ - void add_curve(Evoral::Curve*); void add_automation_list(AutomationList*); /* fade curves */ @@ -729,8 +724,8 @@ class Session : public PBD::StatefulDestructible /* flattening stuff */ - boost::shared_ptr write_one_track (AudioTrack&, nframes_t start, nframes_t end, bool overwrite, vector >&, - InterThreadInfo& wot); + boost::shared_ptr write_one_track (AudioTrack&, nframes_t start, nframes_t end, + bool overwrite, vector >&, InterThreadInfo& wot); int freeze (InterThreadInfo&); /* session-wide solo/mute/rec-enable */ @@ -782,7 +777,7 @@ class Session : public PBD::StatefulDestructible sigc::signal > BundleAdded; sigc::signal > BundleRemoved; - /* MIDI */ + /* MIDI control */ void midi_panic(void); int set_mtc_port (string port_tag); @@ -919,7 +914,7 @@ class Session : public PBD::StatefulDestructible /* clicking */ - boost::shared_ptr click_io() { return _click_io; } + boost::shared_ptr click_io() { return _click_io; } /* disk, buffer loads */ @@ -947,21 +942,14 @@ class Session : public PBD::StatefulDestructible gain_t* gain_automation_buffer () const { return _gain_automation_buffer; } pan_t** pan_automation_buffer () const { return _pan_automation_buffer; } - /* buffers for conversion */ - enum RunContext { - ButlerContext = 0, - TransportContext, - ExportContext - }; - /* VST support */ static long vst_callback (AEffect* effect, - long opcode, - long index, - long value, - void* ptr, - float opt); + long opcode, + long index, + long value, + void* ptr, + float opt); static sigc::signal SendFeedback; @@ -972,8 +960,6 @@ class Session : public PBD::StatefulDestructible void add_controllable (boost::shared_ptr); void remove_controllable (PBD::Controllable*); - /* metadata */ - SessionMetadata & metadata () { return *_metadata; } protected: @@ -1038,7 +1024,6 @@ class Session : public PBD::StatefulDestructible bool auto_play_legal; nframes_t _last_slave_transport_frame; nframes_t maximum_output_latency; - nframes_t last_stop_frame; volatile nframes64_t _requested_return_frame; BufferSet* _scratch_buffers; BufferSet* _silent_buffers; @@ -1090,10 +1075,10 @@ class Session : public PBD::StatefulDestructible bool follow_slave (nframes_t, nframes_t); void calculate_moving_average_of_slave_delta(int dir, nframes_t this_delta); void track_slave_state( - float slave_speed, + float slave_speed, nframes_t slave_transport_frame, nframes_t this_delta, - bool starting); + bool starting); void follow_slave_silently(nframes_t nframes, nframes_t offset, float slave_speed); void set_slave_source (SlaveSource); @@ -1131,7 +1116,6 @@ class Session : public PBD::StatefulDestructible } int get_transport_declick_required () { - if (transport_sub_state & PendingDeclickIn) { transport_sub_state &= ~PendingDeclickIn; return 1; @@ -1143,7 +1127,8 @@ class Session : public PBD::StatefulDestructible } bool maybe_stop (nframes_t limit) { - if ((_transport_speed > 0.0f && _transport_frame >= limit) || (_transport_speed < 0.0f && _transport_frame == 0)) { + if ( (_transport_speed > 0.0f && _transport_frame >= limit) + || (_transport_speed < 0.0f && _transport_frame == 0) ) { stop_transport (); return true; } @@ -1206,15 +1191,17 @@ class Session : public PBD::StatefulDestructible mutable gint butler_should_do_transport_work; int butler_request_pipe[2]; - inline bool transport_work_requested() const { return g_atomic_int_get(&butler_should_do_transport_work); } + inline bool transport_work_requested() const { + return g_atomic_int_get(&butler_should_do_transport_work); + } struct ButlerRequest { - enum Type { - Wake, - Run, - Pause, - Quit - }; + enum Type { + Wake, + Run, + Pause, + Quit + }; }; enum PostTransportWork { @@ -1236,14 +1223,15 @@ class Session : public PBD::StatefulDestructible }; static const PostTransportWork ProcessCannotProceedMask = - PostTransportWork (PostTransportInputChange| - PostTransportSpeed| - PostTransportReverse| - PostTransportCurveRealloc| - PostTransportScrub| - PostTransportAudition| - PostTransportLocate| - PostTransportStop); + PostTransportWork ( + PostTransportInputChange| + PostTransportSpeed| + PostTransportReverse| + PostTransportCurveRealloc| + PostTransportScrub| + PostTransportAudition| + PostTransportLocate| + PostTransportStop); PostTransportWork post_transport_work; @@ -1398,15 +1386,11 @@ class Session : public PBD::StatefulDestructible bool process_can_proceed() const { return !(post_transport_work & ProcessCannotProceedMask); } struct MIDIRequest { - - enum Type { - PortChange, - Quit - }; - - Type type; - - MIDIRequest () {} + enum Type { + PortChange, + Quit + }; + Type type; }; Glib::Mutex midi_lock; @@ -1463,13 +1447,13 @@ class Session : public PBD::StatefulDestructible uint32_t audio_dstream_buffer_size; uint32_t midi_dstream_buffer_size; - int load_diskstreams (const XMLNode&); + int load_diskstreams (const XMLNode&); /* routes stuff */ SerializedRCUManager routes; - void add_routes (RouteList&, bool save); + void add_routes (RouteList&, bool save); uint32_t destructive_index; boost::shared_ptr XMLRouteFactory (const XMLNode&); @@ -1513,8 +1497,6 @@ class Session : public PBD::StatefulDestructible SourceMap get_sources() { return sources; } private: - - int load_sources (const XMLNode& node); XMLNode& get_sources_as_xml (); @@ -1550,7 +1532,6 @@ class Session : public PBD::StatefulDestructible NamedSelection *XMLNamedSelectionFactory (const XMLNode&); /* CURVES and AUTOMATION LISTS */ - std::map curves; std::map automation_lists; /* DEFAULT FADE CURVES */ @@ -1588,18 +1569,18 @@ class Session : public PBD::StatefulDestructible /* S/W RAID */ struct space_and_path { - uint32_t blocks; /* 4kB blocks */ - string path; + uint32_t blocks; /* 4kB blocks */ + string path; - space_and_path() { - blocks = 0; - } + space_and_path() { + blocks = 0; + } }; struct space_and_path_ascending_cmp { - bool operator() (space_and_path a, space_and_path b) { - return a.blocks > b.blocks; - } + bool operator() (space_and_path a, space_and_path b) { + return a.blocks > b.blocks; + } }; void setup_raid_path (string path); @@ -1648,36 +1629,36 @@ class Session : public PBD::StatefulDestructible /* click track */ struct Click { - nframes_t start; - nframes_t duration; - nframes_t offset; - const Sample *data; + nframes_t start; + nframes_t duration; + nframes_t offset; + const Sample *data; - Click (nframes_t s, nframes_t d, const Sample *b) - : start (s), duration (d), data (b) { offset = 0; } + Click (nframes_t s, nframes_t d, const Sample *b) + : start (s), duration (d), data (b) { offset = 0; } - void *operator new(size_t ignored) { - return pool.alloc (); - }; + void *operator new(size_t ignored) { + return pool.alloc (); + }; - void operator delete(void *ptr, size_t size) { - pool.release (ptr); - } + void operator delete(void *ptr, size_t size) { + pool.release (ptr); + } private: - static Pool pool; + static Pool pool; }; typedef list Clicks; - Clicks clicks; - bool _clicking; + Clicks clicks; + bool _clicking; boost::shared_ptr _click_io; - Sample* click_data; - Sample* click_emphasis_data; - nframes_t click_length; - nframes_t click_emphasis_length; - mutable Glib::RWLock click_lock; + Sample* click_data; + Sample* click_emphasis_data; + nframes_t click_length; + nframes_t click_emphasis_length; + mutable Glib::RWLock click_lock; static const Sample default_click[]; static const nframes_t default_click_length; @@ -1712,11 +1693,11 @@ class Session : public PBD::StatefulDestructible /* VST support */ long _vst_callback (VSTPlugin*, - long opcode, - long index, - long value, - void* ptr, - float opt); + long opcode, + long index, + long value, + void* ptr, + float opt); /* number of hardware ports we're using, based on max (requested,available) @@ -1731,7 +1712,6 @@ class Session : public PBD::StatefulDestructible uint32_t n_physical_midi_outputs; uint32_t n_physical_midi_inputs; - int find_all_sources (std::string path, std::set& result); int find_all_sources_across_snapshots (std::set& result, bool exclude_this_snapshot); @@ -1755,13 +1735,9 @@ class Session : public PBD::StatefulDestructible static bool _disable_all_loaded_plugins; - /* Metadata */ - SessionMetadata * _metadata; - /* used in ::audible_frame() */ - - mutable bool have_looped; + mutable bool have_looped; ///< Used in ::audible_frame(*) }; } // namespace ARDOUR