OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 ScriptWrappable::init(this); | 70 ScriptWrappable::init(this); |
71 addInput(adoptPtr(new AudioNodeInput(this))); | 71 addInput(adoptPtr(new AudioNodeInput(this))); |
72 addOutput(adoptPtr(new AudioNodeOutput(this, 2))); | 72 addOutput(adoptPtr(new AudioNodeOutput(this, 2))); |
73 | 73 |
74 // Node-specific default mixing rules. | 74 // Node-specific default mixing rules. |
75 m_channelCount = 2; | 75 m_channelCount = 2; |
76 m_channelCountMode = ClampedMax; | 76 m_channelCountMode = ClampedMax; |
77 m_channelInterpretation = AudioBus::Speakers; | 77 m_channelInterpretation = AudioBus::Speakers; |
78 | 78 |
79 m_distanceGain = AudioParam::create(context, "distanceGain", 1.0, 0.0, 1.0); | |
80 m_coneGain = AudioParam::create(context, "coneGain", 1.0, 0.0, 1.0); | |
81 | |
82 m_cachedListener = AudioListener::create(); | 79 m_cachedListener = AudioListener::create(); |
83 | 80 |
84 setNodeType(NodeTypePanner); | 81 setNodeType(NodeTypePanner); |
85 | 82 |
86 initialize(); | 83 initialize(); |
87 } | 84 } |
88 | 85 |
89 PannerNode::~PannerNode() | 86 PannerNode::~PannerNode() |
90 { | 87 { |
91 uninitialize(); | 88 uninitialize(); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 | 419 |
423 return dopplerShift; | 420 return dopplerShift; |
424 } | 421 } |
425 | 422 |
426 float PannerNode::calculateDistanceConeGain() | 423 float PannerNode::calculateDistanceConeGain() |
427 { | 424 { |
428 FloatPoint3D listenerPosition = listener()->position(); | 425 FloatPoint3D listenerPosition = listener()->position(); |
429 | 426 |
430 double listenerDistance = m_position.distanceTo(listenerPosition); | 427 double listenerDistance = m_position.distanceTo(listenerPosition); |
431 double distanceGain = m_distanceEffect.gain(listenerDistance); | 428 double distanceGain = m_distanceEffect.gain(listenerDistance); |
432 | |
433 m_distanceGain->setValue(static_cast<float>(distanceGain)); | |
434 | |
435 double coneGain = m_coneEffect.gain(m_position, m_orientation, listenerPosit
ion); | 429 double coneGain = m_coneEffect.gain(m_position, m_orientation, listenerPosit
ion); |
436 | 430 |
437 m_coneGain->setValue(static_cast<float>(coneGain)); | |
438 | |
439 return float(distanceGain * coneGain); | 431 return float(distanceGain * coneGain); |
440 } | 432 } |
441 | 433 |
442 void PannerNode::azimuthElevation(double* outAzimuth, double* outElevation) | 434 void PannerNode::azimuthElevation(double* outAzimuth, double* outElevation) |
443 { | 435 { |
444 ASSERT(context()->isAudioThread()); | 436 ASSERT(context()->isAudioThread()); |
445 | 437 |
446 if (isAzimuthElevationDirty()) | 438 if (isAzimuthElevationDirty()) |
447 calculateAzimuthElevation(&m_cachedAzimuth, &m_cachedElevation); | 439 calculateAzimuthElevation(&m_cachedAzimuth, &m_cachedElevation); |
448 | 440 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 ASSERT(context()->isAudioThread()); | 552 ASSERT(context()->isAudioThread()); |
561 | 553 |
562 m_cachedPosition = m_position; | 554 m_cachedPosition = m_position; |
563 m_cachedOrientation = m_orientation; | 555 m_cachedOrientation = m_orientation; |
564 m_cachedVelocity = m_velocity; | 556 m_cachedVelocity = m_velocity; |
565 } | 557 } |
566 | 558 |
567 } // namespace WebCore | 559 } // namespace WebCore |
568 | 560 |
569 #endif // ENABLE(WEB_AUDIO) | 561 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |