* radically cleaned up / refactored midi_clock_slave.cc
[ardour.git] / libs / ardour / session_state.cc
index a1b4f34a250e0cbae9b13031f7f4b02a9d020db5..560143db97293689cf5cac524ced4abad6f4f220 100644 (file)
@@ -86,6 +86,7 @@
 #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>
@@ -164,6 +165,7 @@ Session::first_stage_init (string fullpath, string snapshot_name)
        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;
@@ -171,7 +173,6 @@ Session::first_stage_init (string fullpath, string snapshot_name)
        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;
@@ -186,9 +187,6 @@ Session::first_stage_init (string fullpath, string snapshot_name)
        _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);
@@ -226,8 +224,6 @@ Session::first_stage_init (string fullpath, string snapshot_name)
           waveforms for clicks.
        */
        
-       click_data = 0;
-       click_emphasis_data = 0;
        click_length = 0;
        click_emphasis_length = 0;
        _clicking = false;
@@ -359,6 +355,9 @@ Session::second_stage_init (bool new_session)
        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"));
 
@@ -769,10 +768,8 @@ Session::restore_state (string snapshot_name)
 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;
 
@@ -3270,6 +3267,17 @@ Session::config_changed (const char* parameter_name)
 
                        _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 ();