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

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: Created 6 years, 5 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 HRTFPanner::~HRTFPanner() 73 HRTFPanner::~HRTFPanner()
74 { 74 {
75 } 75 }
76 76
77 size_t HRTFPanner::fftSizeForSampleRate(float sampleRate) 77 size_t HRTFPanner::fftSizeForSampleRate(float sampleRate)
78 { 78 {
79 // The HRTF impulse responses (loaded as audio resources) are 512 sample-fra mes @44.1KHz. 79 // 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). 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).
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. 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.
82 ASSERT(sampleRate >= 44100 && sampleRate <= 96000.0); 82 ASSERT(sampleRate >= 22050 && sampleRate <= 96000.0);
83 return (sampleRate < 88200.0) ? 512 : 1024; 83
84 size_t fftSize = 256;
85
86 if (sampleRate < 44100)
87 fftSize = 256;
88 else if (sampleRate >= 44100 && sampleRate < 88200.0)
89 fftSize = 512;
90 else if (sampleRate < 88200.0)
Inactive 2014/07/15 15:49:40 I am guessing you want '>', not '>'. We could simp
91 fftSize = 1024;
92
93 return fftSize;
84 } 94 }
85 95
86 void HRTFPanner::reset() 96 void HRTFPanner::reset()
87 { 97 {
88 m_convolverL1.reset(); 98 m_convolverL1.reset();
89 m_convolverR1.reset(); 99 m_convolverR1.reset();
90 m_convolverL2.reset(); 100 m_convolverL2.reset();
91 m_convolverR2.reset(); 101 m_convolverR2.reset();
92 m_delayLineL.reset(); 102 m_delayLineL.reset();
93 m_delayLineR.reset(); 103 m_delayLineR.reset();
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 double HRTFPanner::latencyTime() const 314 double HRTFPanner::latencyTime() const
305 { 315 {
306 // The latency of a FFTConvolver is also fftSize() / 2, and is in addition t o its tailTime of the 316 // The latency of a FFTConvolver is also fftSize() / 2, and is in addition t o its tailTime of the
307 // same value. 317 // same value.
308 return (fftSize() / 2) / static_cast<double>(sampleRate()); 318 return (fftSize() / 2) / static_cast<double>(sampleRate());
309 } 319 }
310 320
311 } // namespace WebCore 321 } // namespace WebCore
312 322
313 #endif // ENABLE(WEB_AUDIO) 323 #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