properly handle integer steps in plugin controls
[ardour.git] / libs / ardour / audio_track.cc
index 61b6e56bb6676d871d884607e6d3b03a99d4a1af..c056763efc57ee8fbaa4d133ce474329f6e351db 100644 (file)
@@ -187,16 +187,16 @@ AudioTrack::set_state (const XMLNode& node, int version)
 {
        const XMLProperty *prop;
 
-       if (Track::set_state (node, version)) {
-               return -1;
-       }
-
        if ((prop = node.property (X_("mode"))) != 0) {
                _mode = TrackMode (string_2_enum (prop->value(), _mode));
        } else {
                _mode = Normal;
        }
 
+       if (Track::set_state (node, version)) {
+               return -1;
+       }
+
        pending_state = const_cast<XMLNode*> (&node);
 
        if (_session.state_of_the_state() & Session::Loading) {
@@ -244,7 +244,7 @@ AudioTrack::set_state_part_two ()
 {
        XMLNode* fnode;
        XMLProperty* prop;
-       LocaleGuard lg (X_("POSIX"));
+       LocaleGuard lg (X_("C"));
 
        /* This is called after all session state has been restored but before
           have been made ports and connections are established.
@@ -350,6 +350,16 @@ AudioTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_fram
                return dret;
        }
 
+       if (_mute_control->list() && _mute_control->automation_playback()) {
+               bool        valid = false;
+               const float mute  = _mute_control->list()->rt_safe_eval(transport_frame, valid);
+               if (mute >= 0.5 && !muted()) {
+                       _mute_control->set_value(1.0);  // mute
+               } else if (mute < 0.5 && muted()) {
+                       _mute_control->set_value(0.0);  // unmute
+               }
+       }
+
        _silent = false;
        _amp->apply_gain_automation(false);
 
@@ -383,7 +393,7 @@ AudioTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_fram
 
 int
 AudioTrack::export_stuff (BufferSet& buffers, framepos_t start, framecnt_t nframes,
-                         boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export)
+                         boost::shared_ptr<Processor> endpoint, bool include_endpoint, bool for_export, bool for_freeze)
 {
        boost::scoped_array<gain_t> gain_buffer (new gain_t[nframes]);
        boost::scoped_array<Sample> mix_buffer (new Sample[nframes]);
@@ -417,7 +427,7 @@ AudioTrack::export_stuff (BufferSet& buffers, framepos_t start, framecnt_t nfram
                }
        }
 
-       bounce_process (buffers, start, nframes, endpoint, include_endpoint, for_export);
+       bounce_process (buffers, start, nframes, endpoint, include_endpoint, for_export, for_freeze);
 
        return 0;
 }
@@ -490,7 +500,7 @@ AudioTrack::bounce_range (framepos_t start, framepos_t end, InterThreadInfo& itt
                          boost::shared_ptr<Processor> endpoint, bool include_endpoint)
 {
        vector<boost::shared_ptr<Source> > srcs;
-       return _session.write_one_track (*this, start, end, false, srcs, itt, endpoint, include_endpoint, false);
+       return _session.write_one_track (*this, start, end, false, srcs, itt, endpoint, include_endpoint, false, false);
 }
 
 void
@@ -533,8 +543,8 @@ AudioTrack::freeze_me (InterThreadInfo& itt)
 
        boost::shared_ptr<Region> res;
 
-       if ((res = _session.write_one_track (*this, _session.current_start_frame(), _session.current_end_frame(), true, srcs, itt, 
-                                            main_outs(), false, false)) == 0) {
+       if ((res = _session.write_one_track (*this, _session.current_start_frame(), _session.current_end_frame(),
+                                       true, srcs, itt, main_outs(), false, false, true)) == 0) {
                return;
        }
 
@@ -545,7 +555,10 @@ AudioTrack::freeze_me (InterThreadInfo& itt)
 
                for (ProcessorList::iterator r = _processors.begin(); r != _processors.end(); ++r) {
 
-                       if (!(*r)->does_routing() && !boost::dynamic_pointer_cast<PeakMeter>(*r)) {
+                       if ((*r)->does_routing() && (*r)->active()) {
+                               break;
+                       }
+                       if (!boost::dynamic_pointer_cast<PeakMeter>(*r)) {
 
                                FreezeRecordProcessorInfo* frii  = new FreezeRecordProcessorInfo ((*r)->get_state(), (*r));
 
@@ -553,9 +566,10 @@ AudioTrack::freeze_me (InterThreadInfo& itt)
 
                                _freeze_record.processor_info.push_back (frii);
 
-                               /* now deactivate the processor */
-
-                               (*r)->deactivate ();
+                               /* now deactivate the processor, */
+                               if (!boost::dynamic_pointer_cast<Amp>(*r)) {
+                                       (*r)->deactivate ();
+                               }
                        }
                        
                        _session.set_dirty ();
@@ -589,7 +603,7 @@ AudioTrack::freeze_me (InterThreadInfo& itt)
 
        /* reset stuff that has already been accounted for in the freeze process */
 
-       set_gain (1.0, this);
+       set_gain (GAIN_COEFF_UNITY, this);
        _amp->gain_control()->set_automation_state (Off);
        /* XXX need to use _main_outs _panner->set_automation_state (Off); */