| 485 | } |
| 486 | |
| 487 | float PannerNode::distanceConeGain(ContextRenderLock & r) |
| 488 | { |
| 489 | auto listener = r.context()->listener(); |
| 490 | |
| 491 | /// @fixme these values should be per sample, not per quantum |
| 492 | FloatPoint3D listenerPosition = { |
| 493 | listener->positionX()->value(), |
| 494 | listener->positionY()->value(), |
| 495 | listener->positionZ()->value()}; |
| 496 | |
| 497 | /// @fixme these values should be per sample, not per quantum |
| 498 | FloatPoint3D position = { |
| 499 | positionX()->value(), |
| 500 | positionY()->value(), |
| 501 | positionZ()->value()}; |
| 502 | |
| 503 | double listenerDistance = magnitude(position - listenerPosition); // "distanceTo" |
| 504 | |
| 505 | double distanceGain = m_distanceEffect->gain(listenerDistance); |
| 506 | |
| 507 | m_distanceGain->setValue(static_cast<float>(distanceGain)); |
| 508 | |
| 509 | // FIXME: could optimize by caching coneGain |
| 510 | |
| 511 | /// @fixme these values should be per sample, not per quantum |
| 512 | FloatPoint3D orientation = { |
| 513 | orientationX()->value(), |
| 514 | orientationY()->value(), |
| 515 | orientationZ()->value()}; |
| 516 | |
| 517 | double coneGain = m_coneEffect->gain(position, orientation, listenerPosition); |
| 518 | |
| 519 | m_coneGain->setValue(static_cast<float>(coneGain)); |
| 520 | |
| 521 | return float(distanceGain * coneGain); |
| 522 | } |
| 523 | |
| 524 | void PannerNode::notifyAudioSourcesConnectedToNode(ContextRenderLock & r, AudioNode * node) |
| 525 | { |