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

Method distanceConeGain

src/core/PannerNode.cpp:487–522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

485}
486
487float 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
524void PannerNode::notifyAudioSourcesConnectedToNode(ContextRenderLock & r, AudioNode * node)
525{

Callers

nothing calls this directly

Calls 9

magnitudeFunction · 0.85
listenerMethod · 0.80
setValueMethod · 0.80
contextMethod · 0.45
valueMethod · 0.45
positionXMethod · 0.45
positionYMethod · 0.45
positionZMethod · 0.45
gainMethod · 0.45

Tested by

no test coverage detected