tweaks for the monitor section. refactoring of some buttons, using new ArdourKnob instead of VolumeController. New ArdourDisplay shows a controllables user value, and provides support for preset values (hardcoded at present). Further refactoring to come, so that ArdourWidgets are derived from a common class. Controllable now has more responsibility for scaling between internal, user, and interface (knob percent) values. This also needs more refactoring and might have some unintended consequences. tested with audio and nothing seems amiss, yet.

This commit is contained in:
Ben Loftis 2014-07-18 08:47:45 -05:00
parent ac9219a3c8
commit b2b736d596
16 changed files with 967 additions and 31 deletions

View file

@ -426,6 +426,19 @@ Amp::GainControl::internal_to_user (double v) const
return accurate_coefficient_to_dB (v);
}
double
Amp::GainControl::user_to_internal (double u) const
{
return dB_to_coefficient (u);
}
std::string
Amp::GainControl::get_user_string () const
{
char theBuf[32]; sprintf( theBuf, "%3.1f dB", accurate_coefficient_to_dB (get_value()));
return std::string(theBuf);
}
/** Write gain automation for this cycle into the buffer previously passed in to
* set_gain_automation_buffer (if we are in automation playback mode and the
* transport is rolling).

View file

@ -90,6 +90,8 @@ public:
double internal_to_interface (double) const;
double interface_to_internal (double) const;
double internal_to_user (double) const;
double user_to_internal (double) const;
std::string get_user_string () const;
Amp* _amp;
};

View file

@ -32,6 +32,8 @@
#include "ardour/types.h"
#include "ardour/processor.h"
#include "ardour/dB.h"
class XMLNode;
namespace ARDOUR {
@ -63,6 +65,15 @@ public:
return (float) _value;
}
double internal_to_user (double i) const { return accurate_coefficient_to_dB (i);}
double user_to_internal (double u) const { return dB_to_coefficient(u) ;}
std::string get_user_string () const
{
char theBuf[32]; sprintf( theBuf, "%3.1f dB", accurate_coefficient_to_dB (get_value()));
return std::string(theBuf);
}
double lower () const { return _lower; }
double upper () const { return _upper; }

View file

@ -43,6 +43,15 @@ public:
void set_value (double v) { if (_setter (v)) { Changed(); /* EMIT SIGNAL */ } }
double get_value () const { return _getter (); }
double internal_to_user (double i) const { return accurate_coefficient_to_dB (i);}
double user_to_internal (double u) const { return dB_to_coefficient(u) ;}
std::string get_user_string () const
{
char theBuf[32]; sprintf( theBuf, "%3.1f dB", accurate_coefficient_to_dB (get_value()));
return std::string(theBuf);
}
private:
boost::function1<bool,double> _setter;
boost::function0<double> _getter;

View file

@ -29,6 +29,10 @@ namespace ArdourCanvas {
extern LIBCANVAS_API Color rgba_to_color (double r, double g, double b, double a);
extern LIBCANVAS_API void set_source_rgba (Cairo::RefPtr<Cairo::Context>, Color);
extern LIBCANVAS_API void set_source_rgb_a (Cairo::RefPtr<Cairo::Context>, Color, float alpha); //override the color's alpha
extern LIBCANVAS_API void set_source_rgba (cairo_t*, Color);
extern LIBCANVAS_API void set_source_rgb_a (cairo_t*, Color, float alpha); //override the color's alpha
Distance LIBCANVAS_API distance_to_segment_squared (Duple const & p, Duple const & p1, Duple const & p2, double& t, Duple& at);

View file

@ -154,6 +154,39 @@ ArdourCanvas::set_source_rgba (Cairo::RefPtr<Cairo::Context> context, Color colo
);
}
void
ArdourCanvas::set_source_rgb_a (Cairo::RefPtr<Cairo::Context> context, Color color, float alpha)
{
context->set_source_rgba (
((color >> 24) & 0xff) / 255.0,
((color >> 16) & 0xff) / 255.0,
((color >> 8) & 0xff) / 255.0,
alpha
);
}
void
ArdourCanvas::set_source_rgba (cairo_t *cr, Color color)
{
cairo_set_source_rgba ( cr,
((color >> 24) & 0xff) / 255.0,
((color >> 16) & 0xff) / 255.0,
((color >> 8) & 0xff) / 255.0,
((color >> 0) & 0xff) / 255.0
);
}
void
ArdourCanvas::set_source_rgb_a (cairo_t *cr, Color color, float alpha)
{
cairo_set_source_rgba ( cr,
((color >> 24) & 0xff) / 255.0,
((color >> 16) & 0xff) / 255.0,
((color >> 8) & 0xff) / 255.0,
alpha
);
}
ArdourCanvas::Distance
ArdourCanvas::distance_to_segment_squared (Duple const & p, Duple const & p1, Duple const & p2, double& t, Duple& at)
{

View file

@ -60,11 +60,25 @@ class LIBPBD_API Controllable : public PBD::StatefulDestructible {
* but passed to the processor as a linear quantity.
*/
/** Set `internal' value */
/** Get and Set `internal' value */
virtual void set_value (double) = 0;
/** @return `internal' value */
virtual double get_value (void) const = 0;
/** Conversions between `internal', 'interface', and 'user' values */
virtual double internal_to_interface (double i) const {return (i-lower())/(upper() - lower());} //by default, the interface range is just a linear interpolation between lower and upper values
virtual double interface_to_internal (double i) const {return lower() + i*(upper() - lower());}
virtual double internal_to_user (double i) const {return i;} //by default the internal value is the same as the user value
virtual double user_to_internal (double i) const {return i;} //by default the internal value is the same as the user value
/** Get and Set `interface' value (typically, percent of knob travel) */
virtual float get_interface() const { return (internal_to_interface(get_value())); }
virtual void set_interface (float percent) { percent = std::min( std::max(0.0f, percent), 1.0f); set_value(interface_to_internal(percent)); }
/** Get and Set `user' value ( dB or milliseconds, etc. This MIGHT be the same as the internal value, but in a few cases it is not ) */
virtual float get_user() const { return (internal_to_user(get_value())); }
virtual void set_user (float user_v) { set_value(user_to_internal(user_v)); }
virtual std::string get_user_string() const { return std::string(); }
PBD::Signal0<void> LearningFinished;
static PBD::Signal3<void,PBD::Controllable*,int,int> CreateBinding;
static PBD::Signal1<void,PBD::Controllable*> DeleteBinding;
@ -99,6 +113,8 @@ class LIBPBD_API Controllable : public PBD::StatefulDestructible {
private:
std::string _name;
std::string _units;
Flag _flags;
bool _touching;