diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-07-27 14:09:16 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-07-27 14:09:16 +0000 |
commit | ece5093234e4c185cf536d2b4e5edfeb90622409 (patch) | |
tree | de566ed8a317eaac10b13c6e06a11ab3f68c97e7 /libs | |
parent | fbc946d60dbe68016abcc386932b35c4ef4ba1af (diff) |
change Control::{set,get}_float to Control::{set,get}_double and make almost all Control-related stuff use double rather than random mixtures of float, double and some integer value ; make hans' program change stuff work quite a bit better (not finished yet) including keyboard edting of pgm change values
git-svn-id: svn://localhost/ardour2/branches/3.0@7514 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
28 files changed, 73 insertions, 107 deletions
diff --git a/libs/ardour/amp.cc b/libs/ardour/amp.cc index 36d0c6bf33..f2448c06aa 100644 --- a/libs/ardour/amp.cc +++ b/libs/ardour/amp.cc @@ -93,7 +93,7 @@ Amp::run (BufferSet& bufs, sframes_t /*start_frame*/, sframes_t /*end_frame*/, n } else { /* manual (scalar) gain */ - gain_t const dg = _gain_control->user_float(); + gain_t const dg = _gain_control->user_double(); if (_current_gain != dg) { @@ -353,7 +353,7 @@ Amp::apply_simple_gain (AudioBuffer& buf, nframes_t nframes, gain_t target) void Amp::inc_gain (gain_t factor, void *src) { - float desired_gain = _gain_control->user_float(); + float desired_gain = _gain_control->user_double(); if (desired_gain == 0.0f) { set_gain (0.000001f + (0.000001f * factor), src); @@ -379,7 +379,7 @@ Amp::set_gain (gain_t val, void *src) return; } - _gain_control->set_float(val, false); + _gain_control->set_double(val, false); _session.set_dirty(); } @@ -416,7 +416,7 @@ Amp::set_state (const XMLNode& node, int version) } void -Amp::GainControl::set_value (float val) +Amp::GainControl::set_value (double val) { // max gain at about +6dB (10.0 ^ ( 6 dB * 0.05)) if (val > 1.99526231f) @@ -427,7 +427,7 @@ Amp::GainControl::set_value (float val) AutomationControl::set_value(val); } -float +double Amp::GainControl::get_value (void) const { return AutomationControl::get_value(); diff --git a/libs/ardour/ardour/amp.h b/libs/ardour/ardour/amp.h index 1b6baaebd1..52aceaf85f 100644 --- a/libs/ardour/ardour/amp.h +++ b/libs/ardour/ardour/amp.h @@ -64,7 +64,7 @@ public: static void declick (BufferSet& bufs, nframes_t nframes, int dir); - gain_t gain () const { return _gain_control->user_float(); } + gain_t gain () const { return _gain_control->user_double(); } virtual void set_gain (gain_t g, void *src); void inc_gain (gain_t delta, void *src); @@ -81,8 +81,8 @@ public: set_flags (Controllable::Flag (flags() | Controllable::GainLike)); } - void set_value (float val); - float get_value (void) const; + void set_value (double val); + double get_value (void) const; Amp* _amp; }; diff --git a/libs/ardour/ardour/automation_control.h b/libs/ardour/ardour/automation_control.h index 3c832ae704..2d22b9e661 100644 --- a/libs/ardour/ardour/automation_control.h +++ b/libs/ardour/ardour/automation_control.h @@ -77,14 +77,14 @@ public: /** Set the value and do the right thing based on automation state * (e.g. record if necessary, etc.) */ - void set_value(float val); + void set_value(double val); /** Get the current effective value based on automation state. */ - float get_value() const; + double get_value() const; - float lower() const { return parameter().min(); } - float upper() const { return parameter().max(); } + double lower() const { return parameter().min(); } + double upper() const { return parameter().max(); } protected: ARDOUR::Session& _session; diff --git a/libs/ardour/ardour/midi_track.h b/libs/ardour/ardour/midi_track.h index df1d2e11df..6236667650 100644 --- a/libs/ardour/ardour/midi_track.h +++ b/libs/ardour/ardour/midi_track.h @@ -72,7 +72,7 @@ public: , _route (route) {} - void set_value (float val); + void set_value (double val); MidiTrack* _route; }; diff --git a/libs/ardour/ardour/monitor_processor.h b/libs/ardour/ardour/monitor_processor.h index 4bf399c16a..e453551b0b 100644 --- a/libs/ardour/ardour/monitor_processor.h +++ b/libs/ardour/ardour/monitor_processor.h @@ -48,7 +48,7 @@ template<typename T> class MPControl : public PBD::Controllable { /* Controllable API */ - void set_value (float v) { + void set_value (double v) { T newval = (T) v; if (newval != _value) { _value = newval; @@ -56,12 +56,12 @@ template<typename T> class MPControl : public PBD::Controllable { } } - float get_value () const { + double get_value () const { return (float) _value; } - float lower () const { return _lower; } - float upper () const { return _upper; } + double lower () const { return _lower; } + double upper () const { return _upper; } /* "access as T" API */ diff --git a/libs/ardour/ardour/panner.h b/libs/ardour/ardour/panner.h index 2b2801841d..abee3431ce 100644 --- a/libs/ardour/ardour/panner.h +++ b/libs/ardour/ardour/panner.h @@ -291,8 +291,8 @@ public: AutomationList* alist() { return (AutomationList*)_list.get(); } Panner& panner; - void set_value (float); - float get_value (void) const; + void set_value (double); + double get_value (void) const; }; boost::shared_ptr<AutomationControl> pan_control (int id, int chan=0) { diff --git a/libs/ardour/ardour/plugin_insert.h b/libs/ardour/ardour/plugin_insert.h index 2e24bdd707..c962832eb1 100644 --- a/libs/ardour/ardour/plugin_insert.h +++ b/libs/ardour/ardour/plugin_insert.h @@ -78,8 +78,8 @@ class PluginInsert : public Processor PluginControl (PluginInsert* p, const Evoral::Parameter ¶m, boost::shared_ptr<AutomationList> list = boost::shared_ptr<AutomationList>()); - void set_value (float val); - float get_value (void) const; + void set_value (double val); + double get_value (void) const; private: PluginInsert* _plugin; diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index 54eb41f97b..b54ef74ca6 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -319,16 +319,16 @@ class Route : public SessionObject, public Automatable, public RouteGroupMember, struct SoloControllable : public AutomationControl { SoloControllable (std::string name, Route&); - void set_value (float); - float get_value (void) const; + void set_value (double); + double get_value (void) const; Route& route; }; struct MuteControllable : public AutomationControl { MuteControllable (std::string name, Route&); - void set_value (float); - float get_value (void) const; + void set_value (double); + double get_value (void) const; Route& route; }; diff --git a/libs/ardour/ardour/track.h b/libs/ardour/ardour/track.h index b3d69e4403..e40f197436 100644 --- a/libs/ardour/ardour/track.h +++ b/libs/ardour/ardour/track.h @@ -185,8 +185,8 @@ class Track : public Route, public PublicDiskstream struct RecEnableControllable : public PBD::Controllable { RecEnableControllable (Track&); - void set_value (float); - float get_value (void) const; + void set_value (double); + double get_value (void) const; Track& track; }; diff --git a/libs/ardour/automatable.cc b/libs/ardour/automatable.cc index be3701fc93..c71fabda37 100644 --- a/libs/ardour/automatable.cc +++ b/libs/ardour/automatable.cc @@ -398,7 +398,7 @@ Automatable::automation_snapshot (nframes_t now, bool force) boost::shared_ptr<AutomationControl> c = boost::dynamic_pointer_cast<AutomationControl>(i->second); if (c->automation_write()) { - c->list()->rt_add (now, i->second->user_float()); + c->list()->rt_add (now, i->second->user_double()); } } diff --git a/libs/ardour/automation_control.cc b/libs/ardour/automation_control.cc index 1460c42c7b..a4e0a7bbc0 100644 --- a/libs/ardour/automation_control.cc +++ b/libs/ardour/automation_control.cc @@ -40,22 +40,20 @@ AutomationControl::AutomationControl( { } - -float +double AutomationControl::get_value() const { bool from_list = _list && ((AutomationList*)_list.get())->automation_playback(); - return Control::get_float(from_list, _session.transport_frame()); + return Control::get_double (from_list, _session.transport_frame()); } - void -AutomationControl::set_value(float value) +AutomationControl::set_value(double value) { bool to_list = _list && _session.transport_stopped() && ((AutomationList*)_list.get())->automation_write(); - Control::set_float(value, to_list, _session.transport_frame()); + Control::set_double(value, to_list, _session.transport_frame()); Changed(); /* EMIT SIGNAL */ } diff --git a/libs/ardour/midi_buffer.cc b/libs/ardour/midi_buffer.cc index 8299d811f6..2eb9df8c5c 100644 --- a/libs/ardour/midi_buffer.cc +++ b/libs/ardour/midi_buffer.cc @@ -170,9 +170,6 @@ MidiBuffer::push_back(TimeType time, size_t size, const uint8_t* data) DEBUG_TRACE (DEBUG::MidiIO, DEBUG_STR(a).str()); #endif - // cerr << "MidiBuffer: pushing event @ " << time - // << " size = " << size << endl; - if (_size + stamp_size + size >= _capacity) { cerr << "MidiBuffer::push_back failed (buffer is full)" << endl; return false; diff --git a/libs/ardour/midi_port.cc b/libs/ardour/midi_port.cc index 6858fd1cbd..4c57b2918e 100644 --- a/libs/ardour/midi_port.cc +++ b/libs/ardour/midi_port.cc @@ -75,12 +75,11 @@ MidiPort::get_midi_buffer (nframes_t nframes, nframes_t offset) jack_midi_event_get (&ev, jack_buffer, i); -#if 0 if (ev.buffer[0] == 0xfe) { /* throw away active sensing */ continue; } -#endif + if (ev.time > off && ev.time < off+nframes) { _buffer->push_back (ev); } diff --git a/libs/ardour/midi_source.cc b/libs/ardour/midi_source.cc index fe6c733a82..5a823d332e 100644 --- a/libs/ardour/midi_source.cc +++ b/libs/ardour/midi_source.cc @@ -206,10 +206,11 @@ MidiSource::midi_read (Evoral::EventSink<nframes_t>& dst, sframes_t source_start if (time_frames < start + cnt) { dst.write(time_frames + stamp_offset - negative_stamp_offset, i->event_type(), i->size(), i->buffer()); + if (tracker) { Evoral::MIDIEvent<Evoral::MusicalTime>& ev (*(Evoral::MIDIEvent<Evoral::MusicalTime>*) (&(*i))); if (ev.is_note_on()) { - DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("\t%1 add note on %2 @ %3\n", _name, ev.note(), time_frames)); + DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("\t%1 add note on %2 @ %3 velocity %4\n", _name, ev.note(), time_frames, (int) ev.velocity())); tracker->add (ev.note(), ev.channel()); } else if (ev.is_note_off()) { DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("\t%1 add note off %2 @ %3\n", _name, ev.note(), time_frames)); diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc index b1a8b1f210..83e42800be 100644 --- a/libs/ardour/midi_track.cc +++ b/libs/ardour/midi_track.cc @@ -527,7 +527,7 @@ MidiTrack::write_immediate_event(size_t size, const uint8_t* buf) } void -MidiTrack::MidiControl::set_value(float val) +MidiTrack::MidiControl::set_value(double val) { bool valid = false; if (isinf(val)) { diff --git a/libs/ardour/monitor_processor.cc b/libs/ardour/monitor_processor.cc index 6faf46a64d..bcdc28a4ae 100644 --- a/libs/ardour/monitor_processor.cc +++ b/libs/ardour/monitor_processor.cc @@ -18,7 +18,7 @@ using namespace std; /* specialize for bool because of set_value() semantics */ namespace ARDOUR { - template<> void MPControl<bool>::set_value (float v) { + template<> void MPControl<bool>::set_value (double v) { bool newval = fabs (v) >= 0.5; if (newval != _value) { _value = newval; diff --git a/libs/ardour/panner.cc b/libs/ardour/panner.cc index 9921936cf7..b224bf558e 100644 --- a/libs/ardour/panner.cc +++ b/libs/ardour/panner.cc @@ -100,13 +100,13 @@ StreamPanner::set_mono (bool yn) } void -Panner::PanControllable::set_value (float val) +Panner::PanControllable::set_value (double val) { panner.streampanner (parameter().id()).set_position (direct_control_to_pan (val)); AutomationControl::set_value(val); } -float +double Panner::PanControllable::get_value (void) const { return AutomationControl::get_value(); diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index f50483beaf..8322770d31 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -979,7 +979,7 @@ PluginInsert::PluginControl::PluginControl (PluginInsert* p, const Evoral::Param } void -PluginInsert::PluginControl::set_value (float val) +PluginInsert::PluginControl::set_value (double val) { /* FIXME: probably should be taking out some lock here.. */ @@ -1020,12 +1020,12 @@ PluginInsert::PluginControl::set_value (float val) AutomationControl::set_value(val); } -float +double PluginInsert::PluginControl::get_value (void) const { /* FIXME: probably should be taking out some lock here.. */ - float val = _plugin->get_parameter (_list->parameter()); + double val = _plugin->get_parameter (_list->parameter()); return val; diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 1d8f3ca18e..2dc19fbf0b 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -3018,7 +3018,7 @@ Route::SoloControllable::SoloControllable (std::string name, Route& r) } void -Route::SoloControllable::set_value (float val) +Route::SoloControllable::set_value (double val) { bool bval = ((val >= 0.5f) ? true: false); # if 0 @@ -3037,7 +3037,7 @@ Route::SoloControllable::set_value (float val) #endif } -float +double Route::SoloControllable::get_value (void) const { if (Config->get_solo_control_is_listen_control()) { @@ -3057,7 +3057,7 @@ Route::MuteControllable::MuteControllable (std::string name, Route& r) } void -Route::MuteControllable::set_value (float val) +Route::MuteControllable::set_value (double val) { bool bval = ((val >= 0.5f) ? true: false); # if 0 @@ -3071,7 +3071,7 @@ Route::MuteControllable::set_value (float val) #endif } -float +double Route::MuteControllable::get_value (void) const { return route.muted() ? 1.0f : 0.0f; diff --git a/libs/ardour/track.cc b/libs/ardour/track.cc index 145251a021..0e1248db49 100644 --- a/libs/ardour/track.cc +++ b/libs/ardour/track.cc @@ -129,17 +129,17 @@ Track::RecEnableControllable::RecEnableControllable (Track& s) } void -Track::RecEnableControllable::set_value (float val) +Track::RecEnableControllable::set_value (double val) { - bool bval = ((val >= 0.5f) ? true: false); + bool bval = ((val >= 0.5) ? true: false); track.set_record_enabled (bval, this); } -float +double Track::RecEnableControllable::get_value (void) const { - if (track.record_enabled()) { return 1.0f; } - return 0.0f; + if (track.record_enabled()) { return 1.0; } + return 0.0; } bool diff --git a/libs/evoral/evoral/Control.hpp b/libs/evoral/evoral/Control.hpp index 210ee7c322..bcb9acb78a 100644 --- a/libs/evoral/evoral/Control.hpp +++ b/libs/evoral/evoral/Control.hpp @@ -37,8 +37,8 @@ public: Control(const Parameter& parameter, boost::shared_ptr<ControlList>); virtual ~Control() {} - virtual void set_float(float val, bool to_list=false, FrameTime frame=0); - virtual float get_float(bool from_list=false, FrameTime frame=0) const; + virtual void set_double(double val, bool to_list=false, double frame=0); + virtual double get_double(bool from_list=false, double frame=0) const; /** Get the latest user-set value @@ -47,10 +47,11 @@ public: * Automation write/touch works by periodically sampling this value * and adding it to the ControlList. */ - float user_float() const { return _user_value; } + double user_double() const { return _user_value; } void set_list(boost::shared_ptr<ControlList>); + boost::shared_ptr<ControlList> list() { return _list; } boost::shared_ptr<const ControlList> list() const { return _list; } @@ -62,7 +63,7 @@ public: protected: Parameter _parameter; boost::shared_ptr<ControlList> _list; - float _user_value; + double _user_value; PBD::ScopedConnection _list_marked_dirty_connection; private: diff --git a/libs/evoral/evoral/ControlSet.hpp b/libs/evoral/evoral/ControlSet.hpp index 95de58dead..090499e838 100644 --- a/libs/evoral/evoral/ControlSet.hpp +++ b/libs/evoral/evoral/ControlSet.hpp @@ -58,7 +58,7 @@ public: virtual void add_control(boost::shared_ptr<Control>); - bool find_next_event(FrameTime start, FrameTime end, ControlEvent& ev) const; + bool find_next_event(double start, double end, ControlEvent& ev) const; virtual bool controls_empty() const { return _controls.size() == 0; } virtual void clear_controls(); diff --git a/libs/evoral/evoral/Parameter.hpp b/libs/evoral/evoral/Parameter.hpp index 35fae2dee2..95ee5daa8e 100644 --- a/libs/evoral/evoral/Parameter.hpp +++ b/libs/evoral/evoral/Parameter.hpp @@ -61,33 +61,7 @@ public: /** Strict weak ordering * See: http://www.sgi.com/tech/stl/StrictWeakOrdering.html - * Sort Parameters first according to type then to id and lastly to channel. - * - * Proof: - * <ol> - * <li>Irreflexivity: f(x, x) is false because of the irreflexivity of \c < in each branch.</li> - * <li>Antisymmetry: given x != y, f(x, y) implies !f(y, x) because of the same - * property of \c < in each branch and the symmetry of operator==. </li> - * <li>Transitivity: let f(x, y) and f(y, z) => f(x, z) be true. - * We prove by contradiction, assuming the contrary: - * f(x, y) and f(x, z) hold => !f(x, z) - * - * That implies one of the following: - * <ol> - * <li> x == z which contradicts the assumption f(x, y) and f(y, x) - * because of antisymmetry. - * </li> - * <li> f(z, x) is true. That would imply that one of the ivars (we call it i) - * of x is greater than the same ivar in z while all "previous" ivars - * are equal. That would imply that also in y all those "previous" - * ivars are equal and because if x.i > z.i it is impossible - * that there is an y that satisfies x.i < y.i < z.i at the same - * time which contradicts the assumption. - * </li> - * Therefore f(x, z) is true (transitivity) - * </ol> - * </li> - * </ol> + * Sort Parameters first according to type then to channel and lastly to ID. */ inline bool operator<(const Parameter& other) const { if (_type < other._type) { diff --git a/libs/evoral/evoral/types.hpp b/libs/evoral/evoral/types.hpp index 4df560465f..fe5217da5a 100644 --- a/libs/evoral/evoral/types.hpp +++ b/libs/evoral/evoral/types.hpp @@ -34,9 +34,6 @@ namespace Evoral { typedef int32_t event_id_t; -/** Frame count (i.e. length of time in audio frames) */ -typedef uint32_t FrameTime; - /** Musical time: beats relative to some defined origin */ typedef double MusicalTime; const MusicalTime MaxMusicalTime = DBL_MAX; @@ -53,9 +50,9 @@ typedef uint32_t EventType; /** Type to describe the movement of a time range */ template<typename T> struct RangeMove { - RangeMove (T f, FrameTime l, T t) : from (f), length (l), to (t) {} + RangeMove (T f, double l, T t) : from (f), length (l), to (t) {} T from; ///< start of the range - FrameTime length; ///< length of the range + double length; ///< length of the range T to; ///< new start of the range }; diff --git a/libs/evoral/src/Control.cpp b/libs/evoral/src/Control.cpp index 985c7b1352..e83343b714 100644 --- a/libs/evoral/src/Control.cpp +++ b/libs/evoral/src/Control.cpp @@ -34,8 +34,8 @@ Control::Control(const Parameter& parameter, boost::shared_ptr<ControlList> list /** Get the currently effective value (ie the one that corresponds to current output) */ -float -Control::get_float(bool from_list, FrameTime frame) const +double +Control::get_double (bool from_list, double frame) const { if (from_list) { return _list->eval(frame); @@ -46,12 +46,12 @@ Control::get_float(bool from_list, FrameTime frame) const void -Control::set_float(float value, bool to_list, FrameTime frame) +Control::set_double (double value, bool to_list, double frame) { _user_value = value; if (to_list) { - _list->add(frame, value); + _list->add (frame, value); } } diff --git a/libs/evoral/src/ControlSet.cpp b/libs/evoral/src/ControlSet.cpp index 6142f08870..c042b21ec2 100644 --- a/libs/evoral/src/ControlSet.cpp +++ b/libs/evoral/src/ControlSet.cpp @@ -82,11 +82,11 @@ ControlSet::control (const Parameter& parameter, bool create_if_missing) } bool -ControlSet::find_next_event (FrameTime now, FrameTime end, ControlEvent& next_event) const +ControlSet::find_next_event (double now, double end, ControlEvent& next_event) const { Controls::const_iterator li; - next_event.when = std::numeric_limits<FrameTime>::max(); + next_event.when = std::numeric_limits<double>::max(); for (li = _controls.begin(); li != _controls.end(); ++li) { ControlList::const_iterator i; @@ -107,7 +107,7 @@ ControlSet::find_next_event (FrameTime now, FrameTime end, ControlEvent& next_ev } } - return next_event.when != std::numeric_limits<FrameTime>::max(); + return next_event.when != std::numeric_limits<double>::max(); } void diff --git a/libs/evoral/src/Sequence.cpp b/libs/evoral/src/Sequence.cpp index cf0ea1ae38..81f72dd7ff 100644 --- a/libs/evoral/src/Sequence.cpp +++ b/libs/evoral/src/Sequence.cpp @@ -693,7 +693,6 @@ Sequence<Time>::append(const Event<Time>& event, event_id_t evid) return; } - if (ev.is_note_on()) { NotePtr note(new Note<Time>(ev.channel(), ev.time(), 0, ev.note(), ev.velocity())); append_note_on_unlocked (note, evid); diff --git a/libs/pbd/pbd/controllable.h b/libs/pbd/pbd/controllable.h index 9f5ed5251b..3ae27f72c2 100644 --- a/libs/pbd/pbd/controllable.h +++ b/libs/pbd/pbd/controllable.h @@ -45,8 +45,8 @@ class Controllable : public PBD::StatefulDestructible { Controllable (const std::string& name, Flag f = Flag (0)); virtual ~Controllable() { Destroyed (this); } - virtual void set_value (float) = 0; - virtual float get_value (void) const = 0; + virtual void set_value (double) = 0; + virtual double get_value (void) const = 0; PBD::Signal0<void> LearningFinished; static PBD::Signal3<void,PBD::Controllable*,int,int> CreateBinding; @@ -72,8 +72,8 @@ class Controllable : public PBD::StatefulDestructible { bool is_gain_like() const { return _flags & GainLike; } bool is_integral_only() const { return _flags & IntegerOnly; } - virtual float lower() const { return 0.0f; } - virtual float upper() const { return 1.0f; } + virtual double lower() const { return 0.0; } + virtual double upper() const { return 1.0; } Flag flags() const { return _flags; } void set_flags (Flag f); @@ -107,8 +107,8 @@ class IgnorableControllable : public Controllable IgnorableControllable () : PBD::Controllable ("ignoreMe") {} ~IgnorableControllable () {} - void set_value (float /*v*/) {} - float get_value () const { return 0.0; } + void set_value (double /*v*/) {} + double get_value () const { return 0.0; } }; } |