| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 | 58 |
| 59 HRTFPanner::~HRTFPanner() | 59 HRTFPanner::~HRTFPanner() |
| 60 { | 60 { |
| 61 } | 61 } |
| 62 | 62 |
| 63 size_t HRTFPanner::fftSizeForSampleRate(double sampleRate) | 63 size_t HRTFPanner::fftSizeForSampleRate(double sampleRate) |
| 64 { | 64 { |
| 65 // The HRTF impulse responses (loaded as audio resources) are 512 sample-fra
mes @44.1KHz. | 65 // The HRTF impulse responses (loaded as audio resources) are 512 sample-fra
mes @44.1KHz. |
| 66 // Currently, we truncate the impulse responses to half this size, but an FF
T-size of twice impulse response size is needed (for convolution). | 66 // Currently, we truncate the impulse responses to half this size, but an FF
T-size of twice impulse response size is needed (for convolution). |
| 67 // So for sample rates around 44.1KHz an FFT size of 512 is good. We double
that size for higher sample rates. | 67 // So for sample rates around 44.1KHz an FFT size of 512 is good. We double
the FFT-size only for sample rates at least double this. |
| 68 ASSERT(sampleRate >= 44100 && sampleRate <= 96000.0); | 68 ASSERT(sampleRate >= 44100 && sampleRate <= 96000.0); |
| 69 return (sampleRate <= 48000.0) ? 512 : 1024; | 69 return (sampleRate < 88200.0) ? 512 : 1024; |
| 70 } | 70 } |
| 71 | 71 |
| 72 void HRTFPanner::reset() | 72 void HRTFPanner::reset() |
| 73 { | 73 { |
| 74 m_isFirstRender = true; | 74 m_isFirstRender = true; |
| 75 m_convolverL.reset(); | 75 m_convolverL.reset(); |
| 76 m_convolverR.reset(); | 76 m_convolverR.reset(); |
| 77 m_delayLineL.reset(); | 77 m_delayLineL.reset(); |
| 78 m_delayLineR.reset(); | 78 m_delayLineR.reset(); |
| 79 } | 79 } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 220 |
| 221 // Now do the convolutions in-place. | 221 // Now do the convolutions in-place. |
| 222 m_convolverL.process(kernelL->fftFrame(), segmentDestinationL, segmentDe
stinationL, framesPerSegment); | 222 m_convolverL.process(kernelL->fftFrame(), segmentDestinationL, segmentDe
stinationL, framesPerSegment); |
| 223 m_convolverR.process(kernelR->fftFrame(), segmentDestinationR, segmentDe
stinationR, framesPerSegment); | 223 m_convolverR.process(kernelR->fftFrame(), segmentDestinationR, segmentDe
stinationR, framesPerSegment); |
| 224 } | 224 } |
| 225 } | 225 } |
| 226 | 226 |
| 227 } // namespace WebCore | 227 } // namespace WebCore |
| 228 | 228 |
| 229 #endif // ENABLE(WEB_AUDIO) | 229 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |