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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 | 70 |
71 HRTFPanner::~HRTFPanner() | 71 HRTFPanner::~HRTFPanner() |
72 { | 72 { |
73 } | 73 } |
74 | 74 |
75 size_t HRTFPanner::fftSizeForSampleRate(float sampleRate) | 75 size_t HRTFPanner::fftSizeForSampleRate(float sampleRate) |
76 { | 76 { |
77 // The HRTF impulse responses (loaded as audio resources) are 512 sample-fra mes @44.1KHz. | 77 // The HRTF impulse responses (loaded as audio resources) are 512 sample-fra mes @44.1KHz. |
78 // Currently, we truncate the impulse responses to half this size, but an FF T-size of twice impulse response size is needed (for convolution). | 78 // Currently, we truncate the impulse responses to half this size, but an FF T-size of twice impulse response size is needed (for convolution). |
79 // 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. | 79 // 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. |
80 ASSERT(sampleRate >= 44100 && sampleRate <= 96000.0); | 80 ASSERT(sampleRate >= 3000 && sampleRate <= 192000); |
81 return (sampleRate < 88200.0) ? 512 : 1024; | 81 |
82 if (sampleRate < 5512.5) | |
Raymond Toy
2014/09/05 21:01:43
Actually, I was just looking. I think we can do be
KhNo
2014/09/05 21:29:16
int impulseLength = 256;
float impulseSampleRa
| |
83 return 32; | |
84 if (sampleRate < 11025) | |
85 return 64; | |
86 if (sampleRate < 22050) | |
87 return 128; | |
88 if (sampleRate < 44100) | |
89 return 256; | |
90 if (sampleRate < 88200) | |
91 return 512; | |
92 if (sampleRate < 176400) | |
93 return 1024; | |
94 | |
95 return 2048; | |
82 } | 96 } |
83 | 97 |
84 void HRTFPanner::reset() | 98 void HRTFPanner::reset() |
85 { | 99 { |
86 m_convolverL1.reset(); | 100 m_convolverL1.reset(); |
87 m_convolverR1.reset(); | 101 m_convolverR1.reset(); |
88 m_convolverL2.reset(); | 102 m_convolverL2.reset(); |
89 m_convolverR2.reset(); | 103 m_convolverR2.reset(); |
90 m_delayLineL.reset(); | 104 m_delayLineL.reset(); |
91 m_delayLineR.reset(); | 105 m_delayLineR.reset(); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 | 322 |
309 void HRTFPanner::trace(Visitor* visitor) | 323 void HRTFPanner::trace(Visitor* visitor) |
310 { | 324 { |
311 visitor->trace(m_databaseLoader); | 325 visitor->trace(m_databaseLoader); |
312 Panner::trace(visitor); | 326 Panner::trace(visitor); |
313 } | 327 } |
314 | 328 |
315 } // namespace blink | 329 } // namespace blink |
316 | 330 |
317 #endif // ENABLE(WEB_AUDIO) | 331 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |