| 212 | } |
| 213 | |
| 214 | void PannerNode::process(ContextRenderLock & r, int bufferSize) |
| 215 | { |
| 216 | AudioBus * destination = output(0)->bus(r); |
| 217 | |
| 218 | if (!isInitialized() || !input(0)->isConnected()) |
| 219 | { |
| 220 | destination->zero(); |
| 221 | return; |
| 222 | } |
| 223 | |
| 224 | AudioBus * source = input(0)->bus(r); |
| 225 | |
| 226 | if (!source) |
| 227 | { |
| 228 | destination->zero(); |
| 229 | return; |
| 230 | } |
| 231 | |
| 232 | PanningModel curr = static_cast<PanningModel>(m_panningModel->valueUint32()); |
| 233 | auto db = r.context()->hrtfDatabaseLoader(); |
| 234 | if (curr == PanningModel::HRTF) { |
| 235 | if (!db) { |
| 236 | destination->zero(); |
| 237 | return; |
| 238 | } |
| 239 | if (!db->isLoaded()) { |
| 240 | if (r.context()->isOfflineContext()) { |
| 241 | // HRTFDatabase should be loaded before proceeding for offline audio context |
| 242 | if (db) |
| 243 | db->waitForLoaderThreadCompletion(); |
| 244 | } |
| 245 | else { |
| 246 | destination->zero(); |
| 247 | return; |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | if (!m_panner) { |
| 252 | //uint32_t fftSize = HRTFPanner::fftSizeForSampleLength(db->database()->sampleSize()); |
| 253 | m_panner = std::unique_ptr<Panner>(new HRTFPanner(m_sampleRate)); //, fftSize)); |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | if (!m_panner) |
| 258 | { |
| 259 | destination->zero(); |
| 260 | return; |
| 261 | } |
| 262 | |
| 263 | |
| 264 | // Apply the panning effect. |
| 265 | double azimuth; |
| 266 | double elevation; |
| 267 | getAzimuthElevation(r, &azimuth, &elevation); |
| 268 | |
| 269 | m_panner->pan(r, azimuth, elevation, |
| 270 | *source, *destination, |
| 271 | _scheduler._renderOffset, _scheduler._renderLength); |
nothing calls this directly
no test coverage detected