new files added
[ardour.git] / libs / ardour / route.cc
index d14f1de08739ec01d58ee02f384d7b2a4adff13c..be7dfb846973aa67c1c49016d84e8d4f3e420d0d 100644 (file)
@@ -53,7 +53,7 @@ using namespace ARDOUR;
 using namespace PBD;
 
 uint32_t Route::order_key_cnt = 0;
-
+sigc::signal<void> Route::SyncOrderKeys;
 
 Route::Route (Session& sess, string name, int input_min, int input_max, int output_min, int output_max, Flag flg, DataType default_type)
        : IO (sess, name, input_min, input_max, output_min, output_max, default_type),
@@ -161,9 +161,34 @@ void
 Route::set_order_key (const char* name, long n)
 {
        order_keys[strdup(name)] = n;
+
+       if (Config->get_sync_all_route_ordering()) {
+               for (OrderKeys::iterator x = order_keys.begin(); x != order_keys.end(); ++x) {
+                       x->second = n;
+               }
+       } 
+
        _session.set_dirty ();
 }
 
+void
+Route::sync_order_keys ()
+{
+       uint32_t key;
+       
+       if (order_keys.empty()) {
+               return;
+       }
+       
+       OrderKeys::iterator x = order_keys.begin();
+       key = x->second;
+       ++x;
+
+       for (; x != order_keys.end(); ++x) {
+               x->second = key;
+       }
+}
+
 void
 Route::inc_gain (gain_t fraction, void *src)
 {
@@ -295,17 +320,17 @@ Route::process_output_buffers (BufferSet& bufs,
           -------------------------------------------------------------------------------------------------- */
 
        if (declick > 0) {
-               Amp::run (bufs, nframes, 0.0, 1.0, false);
+               Amp::run_in_place (bufs, nframes, 0.0, 1.0, false);
                _pending_declick = 0;
        } else if (declick < 0) {
-               Amp::run (bufs, nframes, 1.0, 0.0, false);
+               Amp::run_in_place (bufs, nframes, 1.0, 0.0, false);
                _pending_declick = 0;
        } else {
 
                /* no global declick */
 
                if (solo_gain != dsg) {
-                       Amp::run (bufs, nframes, solo_gain, dsg, false);
+                       Amp::run_in_place (bufs, nframes, solo_gain, dsg, false);
                        solo_gain = dsg;
                }
        }
@@ -320,7 +345,7 @@ Route::process_output_buffers (BufferSet& bufs,
        }
 
        if (!_soloed && _mute_affects_pre_fader && (mute_gain != dmg)) {
-               Amp::run (bufs, nframes, mute_gain, dmg, false);
+               Amp::run_in_place (bufs, nframes, mute_gain, dmg, false);
                mute_gain = dmg;
                mute_declick_applied = true;
        }
@@ -381,7 +406,7 @@ Route::process_output_buffers (BufferSet& bufs,
                                for (i = _processors.begin(); i != _processors.end(); ++i) {
                                        switch ((*i)->placement()) {
                                        case PreFader:
-                                               (*i)->run (bufs, start_frame, end_frame, nframes, offset);
+                                               (*i)->run_in_place (bufs, start_frame, end_frame, nframes, offset);
                                                break;
                                        case PostFader:
                                                post_fader_work = true;
@@ -407,7 +432,7 @@ Route::process_output_buffers (BufferSet& bufs,
        bufs.set_count(pre_fader_streams());
        
        if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_post_fader) {
-               Amp::run (bufs, nframes, mute_gain, dmg, false);
+               Amp::run_in_place (bufs, nframes, mute_gain, dmg, false);
                mute_gain = dmg;
                mute_declick_applied = true;
        }
@@ -417,7 +442,7 @@ Route::process_output_buffers (BufferSet& bufs,
           -------------------------------------------------------------------------------------------------- */
 
        if (meter && (_meter_point == MeterPreFader)) {
-               _meter->run(bufs, start_frame, end_frame, nframes, offset);
+               _meter->run_in_place(bufs, start_frame, end_frame, nframes, offset);
        }
 
        
@@ -460,13 +485,9 @@ Route::process_output_buffers (BufferSet& bufs,
                
            // OR recording 
                
-               // h/w monitoring not in use 
-               
-               (!Config->get_monitoring_model() == HardwareMonitoring && 
-
                 // AND software monitoring required
 
-                Config->get_monitoring_model() == SoftwareMonitoring)) { 
+               Config->get_monitoring_model() == SoftwareMonitoring) { 
                
                if (apply_gain_automation) {
                        
@@ -498,7 +519,7 @@ Route::process_output_buffers (BufferSet& bufs,
                        
                        if (_gain != dg) {
                                
-                               Amp::run (bufs, nframes, _gain, dg, _phase_invert);
+                               Amp::run_in_place (bufs, nframes, _gain, dg, _phase_invert);
                                _gain = dg;
                                
                        } else if (_gain != 0 && (_phase_invert || _gain != 1.0)) {
@@ -551,7 +572,7 @@ Route::process_output_buffers (BufferSet& bufs,
                                        case PreFader:
                                                break;
                                        case PostFader:
-                                               (*i)->run (bufs, start_frame, end_frame, nframes, offset);
+                                               (*i)->run_in_place (bufs, start_frame, end_frame, nframes, offset);
                                                break;
                                        }
                                }
@@ -570,7 +591,7 @@ Route::process_output_buffers (BufferSet& bufs,
        }
 
        if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_control_outs) {
-               Amp::run (bufs, nframes, mute_gain, dmg, false);
+               Amp::run_in_place (bufs, nframes, mute_gain, dmg, false);
                mute_gain = dmg;
                mute_declick_applied = true;
        }
@@ -615,7 +636,7 @@ Route::process_output_buffers (BufferSet& bufs,
           ----------------------------------------------------------------------*/
 
        if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_main_outs) {
-               Amp::run (bufs, nframes, mute_gain, dmg, false);
+               Amp::run_in_place (bufs, nframes, mute_gain, dmg, false);
                mute_gain = dmg;
                mute_declick_applied = true;
        }
@@ -677,7 +698,7 @@ Route::process_output_buffers (BufferSet& bufs,
                if ((_gain == 0 && !apply_gain_automation) || dmg == 0) {
                        _meter->reset();
                } else {
-                       _meter->run(output_buffers(), start_frame, end_frame, nframes, offset);
+                       _meter->run_in_place(output_buffers(), start_frame, end_frame, nframes, offset);
                }
        }
 }
@@ -698,7 +719,7 @@ Route::passthru (nframes_t start_frame, nframes_t end_frame, nframes_t nframes,
        collect_input (bufs, nframes, offset);
 
        if (meter_first) {
-               _meter->run(bufs, start_frame, end_frame, nframes, offset);
+               _meter->run_in_place(bufs, start_frame, end_frame, nframes, offset);
                meter_first = false;
        }
                
@@ -1221,6 +1242,8 @@ Route::apply_some_plugin_counts (list<ProcessorCount>& iclist)
 
        for (i = iclist.begin(); i != iclist.end(); ++i) {
                
+               cerr << "now applying for " << (*i).processor->name() << " in = " << (*i).in.n_audio() << " out = " << (*i).out.n_audio() << endl;
+
                if ((*i).processor->configure_io ((*i).in, (*i).out)) {
                        return -1;
                }
@@ -1249,6 +1272,9 @@ Route::check_some_plugin_counts (list<ProcessorCount>& iclist, ChanCount require
 
        for (i = iclist.begin(); i != iclist.end(); ++i) {
 
+
+               cerr << "Checking whether " << (*i).processor->name() << " can support " << required_inputs.n_audio() << " inputs\n";
+
                if ((*i).processor->can_support_input_configuration (required_inputs) < 0) {
                        if (err) {
                                err->index = index;
@@ -1260,6 +1286,8 @@ Route::check_some_plugin_counts (list<ProcessorCount>& iclist, ChanCount require
                (*i).in = required_inputs;
                (*i).out = (*i).processor->output_for_input_configuration (required_inputs);
 
+               cerr << "config looks like " << (*i).processor->name() << " in = " << (*i).in.n_audio() << " out = " << (*i).out.n_audio() << endl;
+
                required_inputs = (*i).out;
                
                ++index;
@@ -1445,7 +1473,7 @@ XMLNode&
 Route::state(bool full_state)
 {
        XMLNode *node = new XMLNode("Route");
-       ProcessorList:: iterator i;
+       ProcessorList::iterator i;
        char buf[32];
 
        if (_flags) {
@@ -2067,7 +2095,7 @@ Route::set_control_outs (const vector<string>& ports)
        /* now connect to the named ports */
        
        for (size_t n = 0; n < limit; ++n) {
-               if (_control_outs->connect_output (_control_outs->output (n), ports[n], this)) {
+               if (_control_outs->connect_output (_control_outs->output (n), ports[n % ports.size()], this)) {
                        error << string_compose (_("could not connect %1 to %2"), _control_outs->output(n)->name(), ports[n]) << endmsg;
                        return -1;
                }