Gain performance improvements (don't waste time applying gain when not necessary).
authorDavid Robillard <d@drobilla.net>
Thu, 10 May 2007 00:41:04 +0000 (00:41 +0000)
committerDavid Robillard <d@drobilla.net>
Thu, 10 May 2007 00:41:04 +0000 (00:41 +0000)
git-svn-id: svn://localhost/ardour2/branches/midi@1811 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/amp.cc
libs/ardour/io.cc

index ca1aa74bb57ce8ffce99a03b6aea9b3381910ee9..c437b53243e992008d5d8f39289461f86321607f 100644 (file)
@@ -39,10 +39,15 @@ Amp::run (BufferSet& bufs, nframes_t nframes, gain_t initial, gain_t target, boo
        // assert(bufs.buffer_capacity(DataType::AUDIO) >= nframes);
 
        // if we don't need to declick, defer to apply_simple_gain
-
        if (initial == target) {
-               for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
-                       apply_gain_to_buffer (i->data (), nframes, target);
+               if (target == 0.0) {
+                       for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
+                               memset (i->data(), 0, sizeof (Sample) * nframes);
+                       }
+               } else if (target != 1.0) {
+                       for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
+                               apply_gain_to_buffer (i->data(), nframes, target);
+                       }
                }
                return;
        }
index 67f365a400ab6b61316463f15b506bb2fb08b548..b3dc2a89c9ddcbd203e87408ecf433f3d6218932 100644 (file)
@@ -249,7 +249,8 @@ IO::deliver_output (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame,
 
                }
 
-               Amp::run(bufs, nframes, _gain, dg, _phase_invert);
+               if (dg != _gain || dg != 1.0)
+                       Amp::run(bufs, nframes, _gain, dg, _phase_invert);
        }
        
        // Use the panner to distribute audio to output port buffers