summaryrefslogtreecommitdiffstats
path: root/src/server/PortImpl.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-01-12 02:46:46 +0000
committerDavid Robillard <d@drobilla.net>2014-01-12 02:46:46 +0000
commit06c34ee30b63d0cfd8c7ae77adc637f9da9a84dd (patch)
tree99c85b5652b24a69613100c1ddb80e3df58cb8a5 /src/server/PortImpl.hpp
parent6fdfb81645889c4a81a6fce224663393eeee3f5d (diff)
downloadingen-06c34ee30b63d0cfd8c7ae77adc637f9da9a84dd.tar.gz
ingen-06c34ee30b63d0cfd8c7ae77adc637f9da9a84dd.tar.bz2
ingen-06c34ee30b63d0cfd8c7ae77adc637f9da9a84dd.zip
Combine port buffers and set state into a single voice object.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5309 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server/PortImpl.hpp')
-rw-r--r--src/server/PortImpl.hpp92
1 files changed, 49 insertions, 43 deletions
diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp
index 8e6c8e77..4dd1afb3 100644
--- a/src/server/PortImpl.hpp
+++ b/src/server/PortImpl.hpp
@@ -43,6 +43,23 @@ class BufferFactory;
class PortImpl : public NodeImpl
{
public:
+ struct SetState {
+ enum class State { SET, HALF_SET_CYCLE_1, HALF_SET_CYCLE_2 };
+
+ SetState() : state(State::SET), value(0), time(0) {}
+
+ State state; ///< State of buffer for setting control value
+ Sample value; ///< Value currently being set
+ FrameTime time; ///< Time value was set
+ };
+
+ struct Voice {
+ Voice() : buffer(NULL) {}
+
+ SetState set_state;
+ BufferRef buffer;
+ };
+
~PortImpl();
virtual GraphType graph_type() const { return GraphType::PORT; }
@@ -55,8 +72,8 @@ public:
* Audio thread. Returned value must be freed by caller.
* \a buffers must be poly() long
*/
- Raul::Array<BufferRef>* set_buffers(ProcessContext& context,
- Raul::Array<BufferRef>* buffers);
+ Raul::Array<Voice>* set_voices(ProcessContext& context,
+ Raul::Array<Voice>* voices);
/** Prepare for a new (external) polyphony value.
*
@@ -86,10 +103,10 @@ public:
void set_maximum(const Atom& max) { _max = max; }
inline BufferRef buffer(uint32_t voice) const {
- return _buffers->at((_poly == 1) ? 0 : voice);
+ return _voices->at((_poly == 1) ? 0 : voice).buffer;
}
inline BufferRef prepared_buffer(uint32_t voice) const {
- return _prepared_buffers->at(voice);
+ return _prepared_voices->at(voice).buffer;
}
void update_set_state(Context& context, uint32_t voice);
@@ -110,13 +127,14 @@ public:
/** Empty buffer contents completely (ie silence) */
virtual void clear_buffers();
- virtual bool get_buffers(BufferFactory& bufs,
- Raul::Array<BufferRef>* buffers,
- uint32_t poly,
- bool real_time) const = 0;
+public:
+ virtual bool get_buffers(BufferFactory& bufs,
+ Raul::Array<Voice>* voices,
+ uint32_t poly,
+ bool real_time) const = 0;
void setup_buffers(BufferFactory& bufs, uint32_t poly, bool real_time) {
- get_buffers(bufs, _buffers, poly, real_time);
+ get_buffers(bufs, _voices, poly, real_time);
}
void activate(BufferFactory& bufs);
@@ -153,7 +171,7 @@ public:
return _poly;
}
uint32_t prepared_poly() const {
- return (_prepared_buffers) ? _prepared_buffers->size() : 1;
+ return (_prepared_voices) ? _prepared_voices->size() : 1;
}
void set_buffer_size(Context& context, BufferFactory& bufs, size_t size);
@@ -202,39 +220,27 @@ protected:
const Atom& value,
size_t buffer_size);
- struct SetState {
- enum class State { SET, HALF_SET_CYCLE_1, HALF_SET_CYCLE_2 };
-
- SetState() : state(State::SET), value(0), time(0) {}
-
- State state; ///< State of buffer for setting control value
- Sample value; ///< Value currently being set
- FrameTime time; ///< Time value was set
- };
-
- BufferFactory& _bufs;
- uint32_t _index;
- uint32_t _poly;
- uint32_t _buffer_size;
- uint32_t _frames_since_monitor;
- float _monitor_value;
- float _peak;
- PortType _type;
- LV2_URID _buffer_type;
- Atom _value;
- Atom _min;
- Atom _max;
- Raul::Array<SetState>* _set_states;
- Raul::Array<SetState>* _prepared_set_states;
- Raul::Array<BufferRef>* _buffers;
- Raul::Array<BufferRef>* _prepared_buffers;
- bool _monitored;
- bool _set_by_user;
- bool _is_morph;
- bool _is_auto_morph;
- bool _is_logarithmic;
- bool _is_sample_rate;
- bool _is_toggled;
+ BufferFactory& _bufs;
+ uint32_t _index;
+ uint32_t _poly;
+ uint32_t _buffer_size;
+ uint32_t _frames_since_monitor;
+ float _monitor_value;
+ float _peak;
+ PortType _type;
+ LV2_URID _buffer_type;
+ Atom _value;
+ Atom _min;
+ Atom _max;
+ Raul::Array<Voice>* _voices;
+ Raul::Array<Voice>* _prepared_voices;
+ bool _monitored;
+ bool _set_by_user;
+ bool _is_morph;
+ bool _is_auto_morph;
+ bool _is_logarithmic;
+ bool _is_sample_rate;
+ bool _is_toggled;
};
} // namespace Server