void AudioParam::calculateFinalValues(ContextRenderLock& r, float* values, unsigned numberOfValues, bool sampleAccurate) { bool isSafe = r.context() && values && numberOfValues; if (!isSafe) return; // The calculated result will be the "intrinsic" value summed with all audio-rate connections. if (sampleAccurate) { // Calculate sample-accurate (a-rate) intrinsic values. calculateTimelineValues(r, values, numberOfValues); } else { // Calculate control-rate (k-rate) intrinsic value. bool hasValue; float timelineValue = m_timeline.valueForContextTime(r, narrowPrecisionToFloat(m_value), hasValue); if (hasValue) m_value = timelineValue; values[0] = narrowPrecisionToFloat(m_value); } // if there are rendering connections, be sure they are ready updateRenderingState(r); size_t connectionCount = numberOfRenderingConnections(r); if (!connectionCount) return; // Now sum all of the audio-rate connections together (unity-gain summing junction). // Note that parameter connections would normally be mono, so mix down to mono if necessary. // LabSound: For some reason a bus was temporarily created here and the results discarded. // Bug still exists in WebKit top of tree. // if (m_data->m_internalSummingBus && m_data->m_internalSummingBus->length() < numberOfValues) m_data->m_internalSummingBus.reset(); if (!m_data->m_internalSummingBus) m_data->m_internalSummingBus.reset(new AudioBus(1, numberOfValues)); // point the summing bus at the values array m_data->m_internalSummingBus->setChannelMemory(0, values, numberOfValues); for (size_t i = 0; i < connectionCount; ++i) { auto output = renderingOutput(r, i); if (!output) continue; // Render audio from this output. AudioBus* connectionBus = output->pull(r, 0, AudioNode::ProcessingSizeInFrames); // Sum, with unity-gain. m_data->m_internalSummingBus->sumFrom(*connectionBus); } }
void AudioParam::calculateFinalValues(float* values, unsigned numberOfValues, bool sampleAccurate) { bool isGood = context() && context()->isAudioThread() && values && numberOfValues; ASSERT(isGood); if (!isGood) return; // The calculated result will be the "intrinsic" value summed with all audio-rate connections. if (sampleAccurate) { // Calculate sample-accurate (a-rate) intrinsic values. calculateTimelineValues(values, numberOfValues); } else { // Calculate control-rate (k-rate) intrinsic value. bool hasValue; float timelineValue = m_timeline.valueForContextTime(context(), narrowPrecisionToFloat(m_value), hasValue); if (hasValue) m_value = timelineValue; values[0] = narrowPrecisionToFloat(m_value); } // Now sum all of the audio-rate connections together (unity-gain summing junction). // Note that connections would normally be mono, but we mix down to mono if necessary. RefPtr<AudioBus> summingBus = AudioBus::create(1, numberOfValues, false); summingBus->setChannelMemory(0, values, numberOfValues); for (unsigned i = 0; i < numberOfRenderingConnections(); ++i) { AudioNodeOutput* output = renderingOutput(i); ASSERT(output); // Render audio from this output. AudioBus* connectionBus = output->pull(0, AudioNode::ProcessingSizeInFrames); // Sum, with unity-gain. summingBus->sumFrom(*connectionBus); } }