/*
- Copyright (C) 2000-2007 Paul Davis
+ Copyright (C) 2000-2007 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include "pbd/statefuldestructible.h"
+using std::min;
+using std::max;
+
class XMLNode;
namespace PBD {
* 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, fraction of knob travel) */
+ virtual float get_interface() const { return (internal_to_interface(get_value())); }
+ virtual void set_interface (float fraction) { fraction = min( max(0.0f, fraction), 1.0f); set_value(interface_to_internal(fraction)); }
+
+ /** 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;
static PBD::Signal1<void,PBD::Controllable*> StopLearning;
static PBD::Signal1<void,Controllable*> Destroyed;
-
+
PBD::Signal0<void> Changed;
int set_state (const XMLNode&, int version);
virtual double lower() const { return 0.0; }
virtual double upper() const { return 1.0; }
+ virtual double normal() const { return 0.0; } //the default value
Flag flags() const { return _flags; }
void set_flags (Flag f);
private:
std::string _name;
+ std::string _units;
+
Flag _flags;
bool _touching;
a Controllable
*/
-class LIBPBD_API IgnorableControllable : public Controllable
+class LIBPBD_API IgnorableControllable : public Controllable
{
- public:
+ public:
IgnorableControllable () : PBD::Controllable ("ignoreMe") {}
~IgnorableControllable () {}
-
+
void set_value (double /*v*/) {}
double get_value () const { return 0.0; }
};