- return dB_to_coefficient (lower_db + v * range_db);
- }
-}
-
-double
-GainControl::internal_to_user (double v) const
-{
- return accurate_coefficient_to_dB (v);
-}
-
-double
-GainControl::user_to_internal (double u) const
-{
- return dB_to_coefficient (u);
-}
-
-std::string
-GainControl::get_user_string () const
-{
- char theBuf[32]; sprintf( theBuf, _("%3.1f dB"), accurate_coefficient_to_dB (get_value()));
- return std::string(theBuf);
-}
-
-gain_t
-GainControl::get_master_gain () const
-{
- Glib::Threads::Mutex::Lock sm (master_lock, Glib::Threads::TRY_LOCK);
-
- if (sm.locked()) {
- return get_master_gain_locked ();
- }
-
- return 1.0;
-}
-
-gain_t
-GainControl::get_master_gain_locked () const
-{
- /* Master lock MUST be held */
-
- gain_t g = 1.0;
-
- for (Masters::const_iterator m = _masters.begin(); m != _masters.end(); ++m) {
- g *= (*m)->get_value ();
- }
-
- return g;
-}
-
-void
-GainControl::add_master (boost::shared_ptr<VCA> vca)
-{
- gain_t old_master_val;
- gain_t new_master_val;
-
- {
- Glib::Threads::Mutex::Lock lm (master_lock);
- old_master_val = get_master_gain_locked ();
- _masters.insert (vca->control());
- _masters_numbers.insert (vca->number());
- new_master_val = get_master_gain_locked ();
-
- /* note that we bind @param m as a weak_ptr<GainControl>, thus
- avoiding holding a reference to the control in the binding
- itself.
- */
-
- vca->DropReferences.connect_same_thread (masters_connections, boost::bind (&GainControl::master_going_away, this, vca));
-
- }
-
- if (old_master_val != new_master_val) {
- Changed(); /* EMIT SIGNAL */
- }
-}
-
-void
-GainControl::master_going_away (boost::weak_ptr<VCA> wv)
-{
- boost::shared_ptr<VCA> v = wv.lock();
- if (v) {
- remove_master (v);