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 15 matching lines...) Expand all Loading... |
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 */ | 27 */ |
28 | 28 |
29 #ifndef PeriodicWave_h | 29 #ifndef PeriodicWave_h |
30 #define PeriodicWave_h | 30 #define PeriodicWave_h |
31 | 31 |
32 #include "bindings/core/v8/ScriptWrappable.h" | 32 #include "bindings/core/v8/ScriptWrappable.h" |
33 #include "platform/audio/AudioArray.h" | 33 #include "platform/audio/AudioArray.h" |
34 #include "wtf/Float32Array.h" | 34 #include "wtf/Float32Array.h" |
35 #include "wtf/Forward.h" | 35 #include "wtf/Forward.h" |
36 #include "wtf/RefCounted.h" | |
37 #include "wtf/Vector.h" | 36 #include "wtf/Vector.h" |
38 | 37 |
39 namespace blink { | 38 namespace blink { |
40 | 39 |
41 class PeriodicWave : public RefCountedWillBeGarbageCollectedFinalized<PeriodicWa
ve>, public ScriptWrappable { | 40 class PeriodicWave : public GarbageCollectedFinalized<PeriodicWave>, public Scri
ptWrappable { |
42 public: | 41 public: |
43 static PassRefPtrWillBeRawPtr<PeriodicWave> createSine(float sampleRate); | 42 static PeriodicWave* createSine(float sampleRate); |
44 static PassRefPtrWillBeRawPtr<PeriodicWave> createSquare(float sampleRate); | 43 static PeriodicWave* createSquare(float sampleRate); |
45 static PassRefPtrWillBeRawPtr<PeriodicWave> createSawtooth(float sampleRate)
; | 44 static PeriodicWave* createSawtooth(float sampleRate); |
46 static PassRefPtrWillBeRawPtr<PeriodicWave> createTriangle(float sampleRate)
; | 45 static PeriodicWave* createTriangle(float sampleRate); |
47 | 46 |
48 // Creates an arbitrary periodic wave given the frequency components (Fourie
r coefficients). | 47 // Creates an arbitrary periodic wave given the frequency components (Fourie
r coefficients). |
49 static PassRefPtrWillBeRawPtr<PeriodicWave> create(float sampleRate, Float32
Array* real, Float32Array* imag); | 48 static PeriodicWave* create(float sampleRate, Float32Array* real, Float32Arr
ay* imag); |
50 | 49 |
51 // Returns pointers to the lower and higher wave data for the pitch range co
ntaining | 50 // Returns pointers to the lower and higher wave data for the pitch range co
ntaining |
52 // the given fundamental frequency. These two tables are in adjacent "pitch"
ranges | 51 // the given fundamental frequency. These two tables are in adjacent "pitch"
ranges |
53 // where the higher table will have the maximum number of partials which won
't alias when played back | 52 // where the higher table will have the maximum number of partials which won
't alias when played back |
54 // at this fundamental frequency. The lower wave is the next range containin
g fewer partials than the higher wave. | 53 // at this fundamental frequency. The lower wave is the next range containin
g fewer partials than the higher wave. |
55 // Interpolation between these two tables can be made according to tableInte
rpolationFactor. | 54 // Interpolation between these two tables can be made according to tableInte
rpolationFactor. |
56 // Where values from 0 -> 1 interpolate between lower -> higher. | 55 // Where values from 0 -> 1 interpolate between lower -> higher. |
57 void waveDataForFundamentalFrequency(float, float* &lowerWaveData, float* &h
igherWaveData, float& tableInterpolationFactor); | 56 void waveDataForFundamentalFrequency(float, float* &lowerWaveData, float* &h
igherWaveData, float& tableInterpolationFactor); |
58 | 57 |
59 // Returns the scalar multiplier to the oscillator frequency to calculate wa
ve buffer phase increment. | 58 // Returns the scalar multiplier to the oscillator frequency to calculate wa
ve buffer phase increment. |
(...skipping 26 matching lines...) Expand all Loading... |
86 unsigned numberOfPartialsForRange(unsigned rangeIndex) const; | 85 unsigned numberOfPartialsForRange(unsigned rangeIndex) const; |
87 | 86 |
88 // Creates tables based on numberOfComponents Fourier coefficients. | 87 // Creates tables based on numberOfComponents Fourier coefficients. |
89 void createBandLimitedTables(const float* real, const float* imag, unsigned
numberOfComponents); | 88 void createBandLimitedTables(const float* real, const float* imag, unsigned
numberOfComponents); |
90 Vector<OwnPtr<AudioFloatArray> > m_bandLimitedTables; | 89 Vector<OwnPtr<AudioFloatArray> > m_bandLimitedTables; |
91 }; | 90 }; |
92 | 91 |
93 } // namespace blink | 92 } // namespace blink |
94 | 93 |
95 #endif // PeriodicWave_h | 94 #endif // PeriodicWave_h |
OLD | NEW |