OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 periodicWave->generateBasicWaveform(OscillatorNode::TRIANGLE); | 85 periodicWave->generateBasicWaveform(OscillatorNode::TRIANGLE); |
86 return periodicWave; | 86 return periodicWave; |
87 } | 87 } |
88 | 88 |
89 PeriodicWave::PeriodicWave(float sampleRate) | 89 PeriodicWave::PeriodicWave(float sampleRate) |
90 : m_sampleRate(sampleRate) | 90 : m_sampleRate(sampleRate) |
91 , m_periodicWaveSize(PeriodicWaveSize) | 91 , m_periodicWaveSize(PeriodicWaveSize) |
92 , m_numberOfRanges(NumberOfRanges) | 92 , m_numberOfRanges(NumberOfRanges) |
93 , m_centsPerRange(CentsPerRange) | 93 , m_centsPerRange(CentsPerRange) |
94 { | 94 { |
95 ScriptWrappable::init(this); | |
96 float nyquist = 0.5 * m_sampleRate; | 95 float nyquist = 0.5 * m_sampleRate; |
97 m_lowestFundamentalFrequency = nyquist / maxNumberOfPartials(); | 96 m_lowestFundamentalFrequency = nyquist / maxNumberOfPartials(); |
98 m_rateScale = m_periodicWaveSize / m_sampleRate; | 97 m_rateScale = m_periodicWaveSize / m_sampleRate; |
99 } | 98 } |
100 | 99 |
101 void PeriodicWave::waveDataForFundamentalFrequency(float fundamentalFrequency, f
loat* &lowerWaveData, float* &higherWaveData, float& tableInterpolationFactor) | 100 void PeriodicWave::waveDataForFundamentalFrequency(float fundamentalFrequency, f
loat* &lowerWaveData, float* &higherWaveData, float& tableInterpolationFactor) |
102 { | 101 { |
103 // Negative frequencies are allowed, in which case we alias to the positive
frequency. | 102 // Negative frequencies are allowed, in which case we alias to the positive
frequency. |
104 fundamentalFrequency = fabsf(fundamentalFrequency); | 103 fundamentalFrequency = fabsf(fundamentalFrequency); |
105 | 104 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 realP[n] = 0; | 295 realP[n] = 0; |
297 imagP[n] = b; | 296 imagP[n] = b; |
298 } | 297 } |
299 | 298 |
300 createBandLimitedTables(realP, imagP, halfSize); | 299 createBandLimitedTables(realP, imagP, halfSize); |
301 } | 300 } |
302 | 301 |
303 } // namespace blink | 302 } // namespace blink |
304 | 303 |
305 #endif // ENABLE(WEB_AUDIO) | 304 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |