MCPcopy Create free account
hub / github.com/LabSound/LabSound / calculateFinalValues

Method calculateFinalValues

src/core/AudioParam.cpp:99–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99void AudioParam::calculateFinalValues(ContextRenderLock & r, float * values, int numberOfValues, bool sampleAccurate)
100{
101 bool isSafe = r.context() && values && numberOfValues;
102 if (!isSafe)
103 return;
104
105 // The calculated result will be the "intrinsic" value summed with all audio-rate connections.
106
107 if (sampleAccurate)
108 {
109 // Calculate sample-accurate (a-rate) intrinsic values.
110 calculateTimelineValues(r, values, numberOfValues);
111 }
112 else
113 {
114 // Calculate control-rate (k-rate) intrinsic value.
115 bool hasValue;
116 float timelineValue = m_timeline.valueForContextTime(r, static_cast<float>(m_value), hasValue);
117
118 if (hasValue)
119 m_value = timelineValue;
120
121 values[0] = static_cast<float>(m_value);
122 }
123
124 // if there are rendering connections, be sure they are ready
125 updateRenderingState(r);
126
127 int connectionCount = numberOfRenderingConnections(r);
128 if (!connectionCount)
129 return;
130
131 // Now sum all of the audio-rate connections together (unity-gain summing junction).
132 // Note that parameter connections would normally be mono, so mix down to mono if necessary.
133
134 // LabSound: For some reason a bus was temporarily created here and the results discarded.
135 // Bug still exists in WebKit top of tree.
136 if (m_internalSummingBus && m_internalSummingBus->length() < numberOfValues)
137 m_internalSummingBus.reset();
138
139 if (!m_internalSummingBus)
140 m_internalSummingBus.reset(new AudioBus(1, numberOfValues));
141
142 // point the summing bus at the values array
143 m_internalSummingBus->setChannelMemory(0, values, numberOfValues);
144
145 for (int i = 0; i < connectionCount; ++i)
146 {
147 auto output = renderingOutput(r, i);
148
149 ASSERT(output);
150
151 // Render audio from this output.
152 AudioBus * connectionBus = output->pull(r, nullptr, AudioNode::ProcessingSizeInFrames);
153
154 // Sum, with unity-gain.
155 /// @TODO it was surprising in practice that the inputs are summed, as opposed to simply overriding.
156 /// Summing might be useful, but pure override should be an option as well.

Callers

nothing calls this directly

Calls 7

valueForContextTimeMethod · 0.80
setChannelMemoryMethod · 0.80
contextMethod · 0.45
lengthMethod · 0.45
resetMethod · 0.45
pullMethod · 0.45
sumFromMethod · 0.45

Tested by

no test coverage detected