use C++ for PortManager::make_port_name_relative()
[ardour.git] / libs / ardour / amp.cc
index caf00dc4964ad082d07c3d238ee6b160838376c4..c62bb7ff69574c86271825777d2a1bad85175b2c 100644 (file)
@@ -42,7 +42,7 @@ Amp::Amp (Session& s, std::string type)
        : Processor(s, "Amp")
        , _apply_gain(true)
        , _apply_gain_automation(false)
-       , _current_gain(GAIN_COEFF_UNITY)
+       , _current_gain(GAIN_COEFF_ZERO)
        , _current_automation_frame (INT64_MAX)
        , _gain_automation_buffer(0)
        , _type (type)
@@ -59,7 +59,7 @@ Amp::Amp (Session& s, std::string type)
 std::string
 Amp::display_name() const
 {
-       return _("Fader");
+       return _type == "trim" ? _("Trim") : _("Fader");
 }
 
 bool
@@ -100,14 +100,14 @@ Amp::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/,
                                                Evoral::MIDIEvent<MidiBuffer::TimeType> ev = *m;
                                                if (ev.is_note_on()) {
                                                        assert(ev.time() >= 0 && ev.time() < nframes);
-                                                       ev.scale_velocity (gab[ev.time()]);
+                                                       ev.scale_velocity (fabsf (gab[ev.time()]));
                                                }
                                        }
                                }
                        }
 
 
-                       const double a = 62.78 / _session.nominal_frame_rate(); // 10 Hz LPF; see Amp::apply_gain for details
+                       const double a = 156.825 / _session.nominal_frame_rate(); // 25 Hz LPF; see Amp::apply_gain for details
                        double lpf = _current_gain;
 
                        for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
@@ -146,7 +146,7 @@ Amp::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/,
                                                for (MidiBuffer::iterator m = mb.begin(); m != mb.end(); ++m) {
                                                        Evoral::MIDIEvent<MidiBuffer::TimeType> ev = *m;
                                                        if (ev.is_note_on()) {
-                                                               ev.scale_velocity (_current_gain);
+                                                               ev.scale_velocity (fabsf (_current_gain));
                                                        }
                                                }
                                        }
@@ -199,7 +199,7 @@ Amp::apply_gain (BufferSet& bufs, framecnt_t sample_rate, framecnt_t nframes, ga
 
                                if (ev.is_note_on()) {
                                        const gain_t scale = delta * (ev.time()/(double) nframes);
-                                       ev.scale_velocity (initial+scale);
+                                       ev.scale_velocity (fabsf (initial+scale));
                                }
                        }
                }
@@ -210,7 +210,7 @@ Amp::apply_gain (BufferSet& bufs, framecnt_t sample_rate, framecnt_t nframes, ga
        /* Low pass filter coefficient: 1.0 - e^(-2.0 * π * f / 48000) f in Hz.
         * for f << SR,  approx a ~= 6.2 * f / SR;
         */
-       const double a = 62.78 / sample_rate; // 10 Hz LPF
+       const double a = 156.825 / sample_rate; // 25 Hz LPF
 
        for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
                Sample* const buffer = i->data();
@@ -289,7 +289,7 @@ Amp::apply_gain (AudioBuffer& buf, framecnt_t sample_rate, framecnt_t nframes, g
        }
 
         Sample* const buffer = buf.data();
-       const double a = 62.78 / sample_rate; // 10 Hz LPF, see  [other] Amp::apply_gain() above,
+       const double a = 156.825 / sample_rate; // 25 Hz LPF, see [other] Amp::apply_gain() above for details
 
        double lpf = initial;
         for (pframes_t nx = 0; nx < nframes; ++nx) {
@@ -335,7 +335,7 @@ Amp::apply_simple_gain (BufferSet& bufs, framecnt_t nframes, gain_t target, bool
                                for (MidiBuffer::iterator m = mb.begin(); m != mb.end(); ++m) {
                                        Evoral::MIDIEvent<MidiBuffer::TimeType> ev = *m;
                                        if (ev.is_note_on()) {
-                                               ev.scale_velocity (target);
+                                               ev.scale_velocity (fabsf (target));
                                        }
                                }
                        }