Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: Source/platform/audio/HRTFPanner.cpp

Issue 375383002: Extending supported sample rate from 3.0KHz to 192.0KHz for OfflineAudioContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Change some review point and logic to find fftsize. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/modules/webaudio/OfflineAudioContext.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 27 matching lines...) Expand all
38 38
39 namespace blink { 39 namespace blink {
40 40
41 // The value of 2 milliseconds is larger than the largest delay which exists in any HRTFKernel from the default HRTFDatabase (0.0136 seconds). 41 // The value of 2 milliseconds is larger than the largest delay which exists in any HRTFKernel from the default HRTFDatabase (0.0136 seconds).
42 // We ASSERT the delay values used in process() with this value. 42 // We ASSERT the delay values used in process() with this value.
43 const double MaxDelayTimeSeconds = 0.002; 43 const double MaxDelayTimeSeconds = 0.002;
44 44
45 const int UninitializedAzimuth = -1; 45 const int UninitializedAzimuth = -1;
46 const unsigned RenderingQuantum = 128; 46 const unsigned RenderingQuantum = 128;
47 47
48 const size_t fftSizes[] = { 64, 128, 256, 512, 1024, 2048, 4096 };
49
48 HRTFPanner::HRTFPanner(float sampleRate, HRTFDatabaseLoader* databaseLoader) 50 HRTFPanner::HRTFPanner(float sampleRate, HRTFDatabaseLoader* databaseLoader)
49 : Panner(PanningModelHRTF) 51 : Panner(PanningModelHRTF)
50 , m_databaseLoader(databaseLoader) 52 , m_databaseLoader(databaseLoader)
51 , m_sampleRate(sampleRate) 53 , m_sampleRate(sampleRate)
52 , m_crossfadeSelection(CrossfadeSelection1) 54 , m_crossfadeSelection(CrossfadeSelection1)
53 , m_azimuthIndex1(UninitializedAzimuth) 55 , m_azimuthIndex1(UninitializedAzimuth)
54 , m_elevation1(0) 56 , m_elevation1(0)
55 , m_azimuthIndex2(UninitializedAzimuth) 57 , m_azimuthIndex2(UninitializedAzimuth)
56 , m_elevation2(0) 58 , m_elevation2(0)
57 , m_crossfadeX(0) 59 , m_crossfadeX(0)
(...skipping 14 matching lines...) Expand all
72 74
73 HRTFPanner::~HRTFPanner() 75 HRTFPanner::~HRTFPanner()
74 { 76 {
75 } 77 }
76 78
77 size_t HRTFPanner::fftSizeForSampleRate(float sampleRate) 79 size_t HRTFPanner::fftSizeForSampleRate(float sampleRate)
78 { 80 {
79 // The HRTF impulse responses (loaded as audio resources) are 512 sample-fra mes @44.1KHz. 81 // The HRTF impulse responses (loaded as audio resources) are 512 sample-fra mes @44.1KHz.
80 // Currently, we truncate the impulse responses to half this size, but an FF T-size of twice impulse response size is needed (for convolution). 82 // Currently, we truncate the impulse responses to half this size, but an FF T-size of twice impulse response size is needed (for convolution).
81 // 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. 83 // 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.
82 ASSERT(sampleRate >= 44100 && sampleRate <= 96000.0); 84 ASSERT(sampleRate >= 3000 && sampleRate <= 192000);
Raymond Toy 2014/09/05 05:18:30 I think you should use AudioBuffer::minAllowedSamp
KhNo 2014/09/05 05:32:39 Yes, I agree with that. However, current implement
83 return (sampleRate < 88200.0) ? 512 : 1024; 85
86 int index = 6;
87
88 if (sampleRate <= 5512.5)
89 index = 0;
90 else if (sampleRate <= 11025)
91 index = 1;
92 else if (sampleRate <= 22050)
93 index = 2;
94 else if (sampleRate <= 44100)
95 index = 3;
96 else if (sampleRate <= 88200)
97 index = 4;
98 else if (sampleRate <= 176400)
99 index = 5;
100
101 return fftSizes[index];
Raymond Toy 2014/09/05 05:18:30 Since this is so simple, I think you should just d
KhNo 2014/09/05 05:32:39 Done.
84 } 102 }
85 103
86 void HRTFPanner::reset() 104 void HRTFPanner::reset()
87 { 105 {
88 m_convolverL1.reset(); 106 m_convolverL1.reset();
89 m_convolverR1.reset(); 107 m_convolverR1.reset();
90 m_convolverL2.reset(); 108 m_convolverL2.reset();
91 m_convolverR2.reset(); 109 m_convolverR2.reset();
92 m_delayLineL.reset(); 110 m_delayLineL.reset();
93 m_delayLineR.reset(); 111 m_delayLineR.reset();
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 double HRTFPanner::latencyTime() const 322 double HRTFPanner::latencyTime() const
305 { 323 {
306 // The latency of a FFTConvolver is also fftSize() / 2, and is in addition t o its tailTime of the 324 // The latency of a FFTConvolver is also fftSize() / 2, and is in addition t o its tailTime of the
307 // same value. 325 // same value.
308 return (fftSize() / 2) / static_cast<double>(sampleRate()); 326 return (fftSize() / 2) / static_cast<double>(sampleRate());
309 } 327 }
310 328
311 } // namespace blink 329 } // namespace blink
312 330
313 #endif // ENABLE(WEB_AUDIO) 331 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/modules/webaudio/OfflineAudioContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698