#include <glibmm.h>
#include <glibmm/thread.h>
-#include <midi++/mmc.h>
-#include <midi++/port.h>
-
-#include <pbd/error.h>
-#include <pbd/pathscanner.h>
-#include <pbd/pthread_utils.h>
-#include <pbd/search_path.h>
-#include <pbd/stacktrace.h>
-
-#include <ardour/audioengine.h>
-#include <ardour/configuration.h>
-#include <ardour/session.h>
-#include <ardour/session_directory.h>
-#include <ardour/session_utils.h>
-#include <ardour/session_state_utils.h>
-#include <ardour/session_metadata.h>
-#include <ardour/buffer.h>
-#include <ardour/audio_diskstream.h>
-#include <ardour/midi_diskstream.h>
-#include <ardour/utils.h>
-#include <ardour/audioplaylist.h>
-#include <ardour/midi_playlist.h>
-#include <ardour/smf_source.h>
-#include <ardour/audiofilesource.h>
-#include <ardour/silentfilesource.h>
-#include <ardour/sndfilesource.h>
-#include <ardour/midi_source.h>
-#include <ardour/sndfile_helpers.h>
-#include <ardour/auditioner.h>
-#include <ardour/io_processor.h>
-#include <ardour/send.h>
-#include <ardour/processor.h>
-#include <ardour/bundle.h>
-#include <ardour/slave.h>
-#include <ardour/tempo.h>
-#include <ardour/audio_track.h>
-#include <ardour/midi_track.h>
-#include <ardour/cycle_timer.h>
-#include <ardour/utils.h>
-#include <ardour/named_selection.h>
-#include <ardour/version.h>
-#include <ardour/location.h>
-#include <ardour/audioregion.h>
-#include <ardour/midi_region.h>
-#include <ardour/crossfade.h>
-#include <ardour/control_protocol_manager.h>
-#include <ardour/region_factory.h>
-#include <ardour/source_factory.h>
-#include <ardour/playlist_factory.h>
-#include <ardour/filename_extensions.h>
-#include <ardour/directory_names.h>
-#include <ardour/template_utils.h>
-
-#include <control_protocol/control_protocol.h>
+#include "midi++/mmc.h"
+#include "midi++/port.h"
+
+#include "pbd/error.h"
+#include "pbd/pathscanner.h"
+#include "pbd/pthread_utils.h"
+#include "pbd/search_path.h"
+#include "pbd/stacktrace.h"
+
+#include "ardour/audioengine.h"
+#include "ardour/configuration.h"
+#include "ardour/session.h"
+#include "ardour/session_directory.h"
+#include "ardour/session_utils.h"
+#include "ardour/session_state_utils.h"
+#include "ardour/session_metadata.h"
+#include "ardour/buffer.h"
+#include "ardour/audio_diskstream.h"
+#include "ardour/midi_diskstream.h"
+#include "ardour/utils.h"
+#include "ardour/audioplaylist.h"
+#include "ardour/midi_playlist.h"
+#include "ardour/smf_source.h"
+#include "ardour/audiofilesource.h"
+#include "ardour/silentfilesource.h"
+#include "ardour/sndfilesource.h"
+#include "ardour/midi_source.h"
+#include "ardour/sndfile_helpers.h"
+#include "ardour/auditioner.h"
+#include "ardour/io_processor.h"
+#include "ardour/send.h"
+#include "ardour/processor.h"
+#include "ardour/user_bundle.h"
+#include "ardour/slave.h"
+#include "ardour/tempo.h"
+#include "ardour/audio_track.h"
+#include "ardour/midi_track.h"
+#include "ardour/midi_patch_manager.h"
+#include "ardour/cycle_timer.h"
+#include "ardour/utils.h"
+#include "ardour/named_selection.h"
+#include "ardour/version.h"
+#include "ardour/location.h"
+#include "ardour/audioregion.h"
+#include "ardour/midi_region.h"
+#include "ardour/crossfade.h"
+#include "ardour/control_protocol_manager.h"
+#include "ardour/region_factory.h"
+#include "ardour/source_factory.h"
+#include "ardour/playlist_factory.h"
+#include "ardour/filename_extensions.h"
+#include "ardour/directory_names.h"
+#include "ardour/template_utils.h"
+#include "ardour/ticker.h"
+#include "ardour/route_group.h"
+
+#include "control_protocol/control_protocol.h"
#include "i18n.h"
#include <locale.h>
insert_cnt = 0;
_transport_speed = 0;
_last_transport_speed = 0;
+ phi = (uint64_t) (0x1000000);
+ target_phi = phi;
auto_play_legal = false;
transport_sub_state = 0;
_transport_frame = 0;
- last_stop_frame = 0;
end_location = new Location (0, 0, _("end"), Location::Flags ((Location::IsMark|Location::IsEnd)));
start_location = new Location (0, 0, _("start"), Location::Flags ((Location::IsMark|Location::IsStart)));
- _end_location_is_free = true;
g_atomic_int_set (&_record_status, Disabled);
loop_changing = false;
play_loop = false;
+ have_looped = false;
_last_roll_location = 0;
_last_record_location = 0;
pending_locate_frame = 0;
pending_locate_flush = false;
audio_dstream_buffer_size = 0;
midi_dstream_buffer_size = 0;
- state_tree = 0;
state_was_pending = false;
set_next_event ();
outbound_mtc_smpte_frame = 0;
_state_of_the_state = StateOfTheState(CannotSave|InitialConnecting|Loading);
_slave = 0;
- butler_mixdown_buffer = 0;
- butler_gain_buffer = 0;
- mmc = 0;
session_send_mmc = false;
session_send_mtc = false;
post_transport_work = PostTransportWork (0);
g_atomic_int_set (&butler_should_do_transport_work, 0);
- g_atomic_int_set (&butler_active, 0);
g_atomic_int_set (&_playback_load, 100);
g_atomic_int_set (&_capture_load, 100);
g_atomic_int_set (&_playback_load_min, 100);
g_atomic_int_set (&_capture_load_min, 100);
_play_range = false;
- waiting_to_start = false;
_exporting = false;
_exporting_realtime = false;
_gain_automation_buffer = 0;
_npan_buffers = 0;
pending_abort = false;
destructive_index = 0;
- current_trans = 0;
first_file_data_format_reset = true;
first_file_header_format_reset = true;
butler_thread = (pthread_t) 0;
/* default short fade = 15ms */
- Crossfade::set_short_xfade_length ((nframes_t) floor (Config->get_short_xfade_seconds() * frame_rate()));
- SndFileSource::setup_standard_crossfades (frame_rate());
+ Crossfade::set_short_xfade_length ((nframes_t) floor (config.get_short_xfade_seconds() * frame_rate()));
+ SndFileSource::setup_standard_crossfades (*this, frame_rate());
last_mmc_step.tv_sec = 0;
last_mmc_step.tv_usec = 0;
waveforms for clicks.
*/
- click_data = 0;
- click_emphasis_data = 0;
click_length = 0;
click_emphasis_length = 0;
_clicking = false;
/* slave stuff */
- average_slave_delta = 1800;
+ average_slave_delta = 1800; // !!! why 1800 ????
have_first_delta_accumulator = false;
delta_accumulator_cnt = 0;
slave_state = Stopped;
/* handle this one in a different way than all others, so that its clear what happened */
catch (AudioEngine::PortRegistrationFailure& err) {
- error << _("Unable to create all required ports")
- << endmsg;
+ error << err.what() << endmsg;
return -1;
}
_engine.transport_locate (0);
deliver_mmc (MIDI::MachineControl::cmdMmcReset, 0);
deliver_mmc (MIDI::MachineControl::cmdLocate, 0);
+
+ MidiClockTicker::instance().set_session(*this);
+ MIDI::Name::MidiPatchManager::instance().set_session(*this);
+
+ /* initial program change will be delivered later; see ::config_changed() */
BootMessage (_("Reset Control Protocols"));
ControlProtocolManager::instance().set_session (*this);
- if (new_session) {
- _end_location_is_free = true;
- } else {
- _end_location_is_free = false;
- }
+ config.set_end_marker_is_free (new_session);
_state_of_the_state = Clean;
SearchPath sound_search_path;
SearchPath midi_search_path;
- for (
- SearchPath::const_iterator i = search_path.begin();
- i != search_path.end();
- ++i
- )
- {
+ for (SearchPath::const_iterator i = search_path.begin(); i != search_path.end(); ++i) {
sp.path = (*i).to_string ();
sp.blocks = 0; // not needed
session_dirs.push_back (sp);
midi_search_path += sdir.midi_path ();
}
- // set the AudioFileSource and SMFSource search path
-
- AudioFileSource::set_search_path (sound_search_path.to_string ());
- SMFSource::set_search_path (midi_search_path.to_string ());
-
+ // set the search path for each data type
+ FileSource::set_search_path (DataType::AUDIO, sound_search_path.to_string ());
+ SMFSource::set_search_path (DataType::MIDI, midi_search_path.to_string ());
// reset the round-robin soundfile path thingie
-
last_rr_session_dir = session_dirs.begin();
}
int
Session::load_state (string snapshot_name)
{
- if (state_tree) {
- delete state_tree;
- state_tree = 0;
- }
+ delete state_tree;
+ state_tree = 0;
state_was_pending = false;
}
const XMLProperty* prop;
- bool is_old = false;
+ bool is_old = false; // session is _very_ old (pre-2.0)
if ((prop = root.property ("version")) == 0) {
/* no version implies very old version of Ardour */
XMLProperty* prop;
LocaleGuard lg (X_("POSIX"));
- Config->set_variables (node, ConfigVariableBase::Session);
-
- if ((child = find_named_node (node, "end-marker-is-free")) != 0) {
- if ((prop = child->property ("val")) != 0) {
- _end_location_is_free = (prop->value() == "yes");
- }
- }
+ config.set_variables (node);
- return 0;
-}
-
-bool
-Session::save_config_options_predicate (ConfigVariableBase::Owner owner) const
-{
- const ConfigVariableBase::Owner modified_by_session_or_user = (ConfigVariableBase::Owner)
- (ConfigVariableBase::Session|ConfigVariableBase::Interface);
-
- return owner & modified_by_session_or_user;
-}
-
-XMLNode&
-Session::get_options () const
-{
- XMLNode* child;
- LocaleGuard lg (X_("POSIX"));
-
- XMLNode& option_root = Config->get_variables (mem_fun (*this, &Session::save_config_options_predicate));
+ /* now reset MIDI ports because the session can have its own
+ MIDI configuration.
+ */
- child = option_root.add_child ("end-marker-is-free");
- child->add_property ("val", _end_location_is_free ? "yes" : "no");
+ setup_midi ();
- return option_root;
+ return 0;
}
XMLNode&
/* various options */
- node->add_child_nocopy (get_options());
+ node->add_child_nocopy (config.get_variables ());
node->add_child_nocopy (_metadata->get_state());
for (SourceMap::iterator siter = sources.begin(); siter != sources.end(); ++siter) {
- /* Don't save information about AudioFileSources that are empty */
+ /* Don't save information about non-destructive file sources that are empty */
+ /* FIXME: MIDI breaks if this is made FileSource like it should be... */
boost::shared_ptr<AudioFileSource> fs;
-
if ((fs = boost::dynamic_pointer_cast<AudioFileSource> (siter->second)) != 0) {
-
- /* Don't save sources that are empty, unless they're destructive (which are OK
- if they are empty, because we will re-use them every time.)
- */
-
if (!fs->destructive()) {
- if (fs->length() == 0) {
+ if (fs->length(fs->timeline_position()) == 0) {
continue;
}
}
child = node->add_child ("Bundles");
{
- Glib::Mutex::Lock lm (bundle_lock);
- for (BundleList::iterator i = _bundles.begin(); i != _bundles.end(); ++i) {
+ boost::shared_ptr<BundleList> bundles = _bundles.reader ();
+ for (BundleList::iterator i = bundles->begin(); i != bundles->end(); ++i) {
boost::shared_ptr<UserBundle> b = boost::dynamic_pointer_cast<UserBundle> (*i);
if (b) {
child->add_child_nocopy (b->get_state());
/* Object loading order:
- MIDI Control
Path
- extra
+ Extra
Options/Config
+ MIDI Control // relies on data from Options/Config
Metadata
Locations
Sources
ControlProtocols
*/
- if (use_config_midi_ports ()) {
- }
-
- if ((child = find_named_node (node, "extra")) != 0) {
+ if ((child = find_named_node (node, "Extra")) != 0) {
_extra_xml = new XMLNode (*child);
}
error << _("Session: XML state has no options section") << endmsg;
}
+ if (use_config_midi_ports ()) {
+ }
+
if ((child = find_named_node (node, "Metadata")) == 0) {
warning << _("Session: XML state has no metadata section (2.0 session?)") << endmsg;
} else if (_metadata->set_state (*child)) {
boost::shared_ptr<Route> route (XMLRouteFactory (**niter));
if (route == 0) {
- error << _("Session: cannot create Route from XML description.") << endmsg;
+ error << _("Session: cannot create Route from XML description.") << endmsg;
return -1;
}
DataType type = DataType::AUDIO;
const XMLProperty* prop = node.property("default-type");
- if (prop)
+
+ if (prop) {
type = DataType(prop->value());
+ }
assert(type != DataType::NIL);
set_dirty();
for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
-
try {
if ((source = XMLSourceFactory (**niter)) == 0) {
error << _("Session: cannot create Source from XML description.") << endmsg;
}
- }
-
- catch (non_existent_source& err) {
+ } catch (MissingSource& err) {
warning << _("A sound file is missing. It will be replaced by silence.") << endmsg;
source = SourceFactory::createSilent (*this, **niter, max_frames, _current_frame_rate);
}
}
void
-Session::begin_reversible_command (const string& name)
+Session::begin_reversible_command(const string& name)
{
- current_trans = new UndoTransaction;
- current_trans->set_name (name);
+ UndoTransaction* trans = new UndoTransaction();
+ trans->set_name(name);
+ if (!_current_trans.empty()) {
+ _current_trans.top()->add_command(trans);
+ }
+ _current_trans.push(trans);
}
void
-Session::commit_reversible_command (Command *cmd)
+Session::commit_reversible_command(Command *cmd)
{
+ assert(!_current_trans.empty());
struct timeval now;
if (cmd) {
- current_trans->add_command (cmd);
+ _current_trans.top()->add_command(cmd);
}
- if (current_trans->empty()) {
+ if (_current_trans.top()->empty()) {
+ _current_trans.pop();
return;
}
- gettimeofday (&now, 0);
- current_trans->set_timestamp (now);
+ gettimeofday(&now, 0);
+ _current_trans.top()->set_timestamp(now);
- _history.add (current_trans);
+ _history.add(_current_trans.top());
+ _current_trans.pop();
}
Session::GlobalRouteBooleanState
set_global_route_boolean (s, &Route::set_record_enable, src);
}
-#if 0
-UndoAction
-Session::global_mute_memento (void* src)
-{
- return sigc::bind (mem_fun (*this, &Session::set_global_mute), get_global_route_boolean (&Route::muted), src);
-}
-
-UndoAction
-Session::global_metering_memento (void* src)
-{
- return sigc::bind (mem_fun (*this, &Session::set_global_route_metering), get_global_route_metering (), src);
-}
-
-UndoAction
-Session::global_solo_memento (void* src)
-{
- return sigc::bind (mem_fun (*this, &Session::set_global_solo), get_global_route_boolean (&Route::soloed), src);
-}
-
-UndoAction
-Session::global_record_enable_memento (void* src)
-{
- return sigc::bind (mem_fun (*this, &Session::set_global_record_enable), get_global_route_boolean (&Route::record_enabled), src);
-}
-#endif
-
static bool
accept_all_non_peak_files (const string& path, void *arg)
{
capture files.
*/
- if (!i->second->used() && i->second->length() > 0) {
+ if (!i->second->used() && i->second->length(i->second->timeline_position()) > 0) {
dead_sources.push_back (i->second);
i->second->GoingAway();
}
*/
for (SourceMap::iterator i = sources.begin(); i != sources.end(); ++i) {
- boost::shared_ptr<AudioFileSource> fs;
+ boost::shared_ptr<FileSource> fs;
- if ((fs = boost::dynamic_pointer_cast<AudioFileSource> (i->second)) != 0) {
+ if ((fs = boost::dynamic_pointer_cast<FileSource> (i->second)) != 0) {
all_sources.insert (fs->path());
}
}
Session::set_deletion_in_progress ()
{
_state_of_the_state = StateOfTheState (_state_of_the_state | Deletion);
+}
+void
+Session::clear_deletion_in_progress ()
+{
+ _state_of_the_state = StateOfTheState (_state_of_the_state & (~Deletion));
}
void
struct timeval tv;
ut->set_name(t->property("name")->value());
- stringstream ss(t->property("tv_sec")->value());
+ stringstream ss(t->property("tv-sec")->value());
ss >> tv.tv_sec;
- ss.str(t->property("tv_usec")->value());
+ ss.str(t->property("tv-usec")->value());
ss >> tv.tv_usec;
ut->set_timestamp(tv);
for (XMLNodeConstIterator child_it = t->children().begin();
- child_it != t->children().end();
- child_it++)
+ child_it != t->children().end(); child_it++)
{
XMLNode *n = *child_it;
Command *c;
if (n->name() == "MementoCommand" ||
- n->name() == "MementoUndoCommand" ||
- n->name() == "MementoRedoCommand") {
+ n->name() == "MementoUndoCommand" ||
+ n->name() == "MementoRedoCommand") {
if ((c = memento_command_factory(n))) {
ut->add_command(c);
}
} else if (n->name() == "DeltaCommand") {
- PBD::ID id(n->property("midi_source")->value());
+ PBD::ID id(n->property("midi-source")->value());
boost::shared_ptr<MidiSource> midi_source =
boost::dynamic_pointer_cast<MidiSource, Source>(source_by_id(id));
if(midi_source) {
for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) {
if ((*i)->record_enabled ()) {
- (*i)->monitor_input (!Config->get_auto_input());
+ (*i)->monitor_input (!config.get_auto_input());
}
}
}
if ((location = _locations.auto_punch_location()) != 0) {
- if (Config->get_punch_in ()) {
+ if (config.get_punch_in ()) {
replace_event (Event::PunchIn, location->start());
} else {
remove_event (location->start(), Event::PunchIn);
if ((location = _locations.auto_punch_location()) != 0) {
- if (Config->get_punch_out()) {
+ if (config.get_punch_out()) {
replace_event (Event::PunchOut, location->end());
} else {
clear_events (Event::PunchOut);
} else if (PARAM_IS ("raid-path")) {
- setup_raid_path (Config->get_raid_path());
+ setup_raid_path (config.get_raid_path());
} else if (PARAM_IS ("smpte-format")) {
} else if (PARAM_IS ("history-depth")) {
set_history_depth (Config->get_history_depth());
} else if (PARAM_IS ("sync-all-route-ordering")) {
- sync_order_keys ();
+ sync_order_keys ("session");
+ } else if (PARAM_IS ("initial-program-change")) {
+
+ if (_mmc_port && Config->get_initial_program_change() >= 0) {
+ MIDI::byte buf[2];
+
+ buf[0] = MIDI::program; // channel zero by default
+ buf[1] = (Config->get_initial_program_change() & 0x7f);
+
+ _mmc_port->midimsg (buf, sizeof (buf), 0);
+ }
+ } else if (PARAM_IS ("initial-program-change")) {
+
+ if (_mmc_port && Config->get_initial_program_change() >= 0) {
+ MIDI::byte* buf = new MIDI::byte[2];
+
+ buf[0] = MIDI::program; // channel zero by default
+ buf[1] = (Config->get_initial_program_change() & 0x7f);
+ // deliver_midi (_mmc_port, buf, 2);
+ }
+ } else if (PARAM_IS ("solo-mute-override")) {
+ catch_up_on_solo_mute_override ();
}
set_dirty ();