| 103 | } |
| 104 | |
| 105 | void OscillatorNode::process_oscillator(ContextRenderLock & r, int bufferSize, int offset, int count) |
| 106 | { |
| 107 | AudioBus * outputBus = output(0)->bus(r); |
| 108 | if (!r.context() || !isInitialized() || !outputBus->numberOfChannels()) |
| 109 | { |
| 110 | outputBus->zero(); |
| 111 | return; |
| 112 | } |
| 113 | |
| 114 | const float sample_rate = r.context()->sampleRate(); |
| 115 | |
| 116 | int quantumFrameOffset = offset; |
| 117 | int nonSilentFramesToProcess = count; |
| 118 | |
| 119 | if (!nonSilentFramesToProcess) |
| 120 | { |
| 121 | outputBus->zero(); |
| 122 | return; |
| 123 | } |
| 124 | |
| 125 | nonSilentFramesToProcess += quantumFrameOffset; |
| 126 | |
| 127 | if (bufferSize > m_phaseIncrements.size()) |
| 128 | m_phaseIncrements.allocate(bufferSize); |
| 129 | if (bufferSize > m_detuneValues.size()) |
| 130 | m_detuneValues.allocate(bufferSize); |
| 131 | if (bufferSize > m_amplitudeValues.size()) |
| 132 | m_amplitudeValues.allocate(bufferSize); |
| 133 | if (bufferSize > m_biasValues.size()) |
| 134 | m_biasValues.allocate(bufferSize); |
| 135 | |
| 136 | // calculate phase increments |
| 137 | float* phaseIncrements = m_phaseIncrements.data(); |
| 138 | |
| 139 | if (m_frequency->hasSampleAccurateValues()) |
| 140 | { |
| 141 | // Get the sample-accurate frequency values in preparation for conversion to phase increments. |
| 142 | // They will be converted to phase increments below. |
| 143 | m_frequency->calculateSampleAccurateValues(r, phaseIncrements, nonSilentFramesToProcess); |
| 144 | } |
| 145 | else |
| 146 | { |
| 147 | // Handle ordinary parameter smoothing/de-zippering if there are no scheduled changes. |
| 148 | m_frequency->smooth(r); |
| 149 | float frequency = m_frequency->smoothedValue(); |
| 150 | for (int i = quantumFrameOffset; i < nonSilentFramesToProcess; ++i) |
| 151 | { |
| 152 | phaseIncrements[i] = frequency; |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | if (m_detune->hasSampleAccurateValues()) |
| 157 | { |
| 158 | // Get the sample-accurate detune values. |
| 159 | float* detuneValues = m_detuneValues.data(); |
| 160 | float* offset_detunes = detuneValues + +quantumFrameOffset; |
| 161 | m_detune->calculateSampleAccurateValues(r, offset_detunes, nonSilentFramesToProcess); |
| 162 |
nothing calls this directly
no test coverage detected