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

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 fftSizeForSampleRate logic. 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
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.
Raymond Toy 2014/09/08 20:01:49 Nit: Remove the sentence beginning with "We double
KhNo 2014/09/10 12:59:06 Done.
80 ASSERT(sampleRate >= 44100 && sampleRate <= 96000.0); 80 ASSERT(sampleRate >= 3000 && sampleRate <= 192000);
81 return (sampleRate < 88200.0) ? 512 : 1024; 81
82 int impulseLength = 256;
Raymond Toy 2014/09/08 20:01:49 Nit: I think I'd call this truncatedImpulseLength,
KhNo 2014/09/10 12:59:05 Done.
83 double ratio = sampleRate / 44100;
Raymond Toy 2014/09/08 20:01:49 Nit: Rename ratio to sampleRateRatio (to kind of m
KhNo 2014/09/10 12:59:05 Done.
84 double resampledLength = impulseLength * ratio;
85
86 return 2 * (1 << static_cast<unsigned>(log2(resampledLength)));
82 } 87 }
83 88
84 void HRTFPanner::reset() 89 void HRTFPanner::reset()
85 { 90 {
86 m_convolverL1.reset(); 91 m_convolverL1.reset();
87 m_convolverR1.reset(); 92 m_convolverR1.reset();
88 m_convolverL2.reset(); 93 m_convolverL2.reset();
89 m_convolverR2.reset(); 94 m_convolverR2.reset();
90 m_delayLineL.reset(); 95 m_delayLineL.reset();
91 m_delayLineR.reset(); 96 m_delayLineR.reset();
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 313
309 void HRTFPanner::trace(Visitor* visitor) 314 void HRTFPanner::trace(Visitor* visitor)
310 { 315 {
311 visitor->trace(m_databaseLoader); 316 visitor->trace(m_databaseLoader);
312 Panner::trace(visitor); 317 Panner::trace(visitor);
313 } 318 }
314 319
315 } // namespace blink 320 } // namespace blink
316 321
317 #endif // ENABLE(WEB_AUDIO) 322 #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