| 20 | |
| 21 | |
| 22 | class AudioParam : public AudioSummingJunction |
| 23 | { |
| 24 | public: |
| 25 | static const double DefaultSmoothingConstant; |
| 26 | static const double SnapThreshold; |
| 27 | |
| 28 | AudioParam(AudioParamDescriptor const * const desc) noexcept; |
| 29 | virtual ~AudioParam(); |
| 30 | |
| 31 | // Intrinsic value. |
| 32 | float value() const; |
| 33 | void setValue(float); |
| 34 | |
| 35 | // Final value for k-rate parameters, otherwise use calculateSampleAccurateValues() for a-rate. |
| 36 | float finalValue(ContextRenderLock &); |
| 37 | |
| 38 | std::string name() const { return _desc->name; } |
| 39 | std::string shortName() const { return _desc->shortName; } |
| 40 | |
| 41 | double minValue() const { return _desc->minValue; } |
| 42 | double maxValue() const { return _desc->maxValue; } |
| 43 | double defaultValue() const { return _desc->defaultValue; } |
| 44 | |
| 45 | // Value smoothing: |
| 46 | |
| 47 | // When a new value is set with setValue(), in our internal use of the parameter we don't immediately jump to it. |
| 48 | // Instead we smoothly approach this value to avoid glitching. |
| 49 | float smoothedValue(); |
| 50 | |
| 51 | // Smoothly exponentially approaches to (de-zippers) the desired value. |
| 52 | // Returns true if smoothed value has already snapped exactly to value. |
| 53 | bool smooth(ContextRenderLock &); |
| 54 | |
| 55 | void resetSmoothedValue() { m_smoothedValue = m_value; } |
| 56 | void setSmoothingConstant(double k) { m_smoothingConstant = k; } |
| 57 | |
| 58 | // Parameter automation. |
| 59 | // Time is a double representing the time (in seconds) after the AudioContext was first created that the change in value will happen |
| 60 | // Returns a reference for chaining calls. |
| 61 | AudioParam & setValueAtTime(float value, float time) { m_timeline.setValueAtTime(value, time); return *this; } |
| 62 | AudioParam & linearRampToValueAtTime(float value, float time) { m_timeline.linearRampToValueAtTime(value, time); return *this; } |
| 63 | AudioParam & exponentialRampToValueAtTime(float value, float time) { m_timeline.exponentialRampToValueAtTime(value, time); return *this; } |
| 64 | AudioParam & setTargetAtTime(float target, float time, float timeConstant) { m_timeline.setTargetAtTime(target, time, timeConstant); return *this; } |
| 65 | AudioParam & setValueCurveAtTime(std::vector<float> curve, float time, float duration) { m_timeline.setValueCurveAtTime(curve, time, duration); return *this; } |
| 66 | AudioParam & cancelScheduledValues(float startTime) { m_timeline.cancelScheduledValues(startTime); return *this; } |
| 67 | |
| 68 | bool hasSampleAccurateValues() { return m_timeline.hasValues() || numberOfConnections(); } |
| 69 | |
| 70 | // Calculates numberOfValues parameter values starting at the context's current time. |
| 71 | // Must be called in the context's render thread. |
| 72 | void calculateSampleAccurateValues(ContextRenderLock &, float * values, int numberOfValues); |
| 73 | |
| 74 | AudioBus const* const bus() const; |
| 75 | |
| 76 | // Connect an audio-rate signal to control this parameter. |
| 77 | static void connect(ContextGraphLock & g, std::shared_ptr<AudioParam>, std::shared_ptr<AudioNodeOutput>); |
| 78 | static void disconnect(ContextGraphLock & g, std::shared_ptr<AudioParam>, std::shared_ptr<AudioNodeOutput>); |
| 79 | static void disconnectAll(ContextGraphLock & g, std::shared_ptr<AudioParam>); |
nothing calls this directly
no test coverage detected