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 30 matching lines...) Expand all Loading... | |
41 DEFINE_WRAPPERTYPEINFO(); | 41 DEFINE_WRAPPERTYPEINFO(); |
42 public: | 42 public: |
43 static PeriodicWave* createSine(float sampleRate); | 43 static PeriodicWave* createSine(float sampleRate); |
44 static PeriodicWave* createSquare(float sampleRate); | 44 static PeriodicWave* createSquare(float sampleRate); |
45 static PeriodicWave* createSawtooth(float sampleRate); | 45 static PeriodicWave* createSawtooth(float sampleRate); |
46 static PeriodicWave* createTriangle(float sampleRate); | 46 static PeriodicWave* createTriangle(float sampleRate); |
47 | 47 |
48 // Creates an arbitrary periodic wave given the frequency components (Fourie r coefficients). | 48 // Creates an arbitrary periodic wave given the frequency components (Fourie r coefficients). |
49 static PeriodicWave* create(float sampleRate, DOMFloat32Array* real, DOMFloa t32Array* imag, bool normalize); | 49 static PeriodicWave* create(float sampleRate, DOMFloat32Array* real, DOMFloa t32Array* imag, bool normalize); |
50 | 50 |
51 ~PeriodicWave(); | |
jochen (gone - plz use gerrit)
2016/01/26 15:33:55
needs to be virtual
Daniel Bratell
2016/01/26 16:19:13
Done.
| |
52 | |
51 // Returns pointers to the lower and higher wave data for the pitch range co ntaining | 53 // 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 | 54 // 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 | 55 // 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. | 56 // 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. | 57 // Interpolation between these two tables can be made according to tableInte rpolationFactor. |
56 // Where values from 0 -> 1 interpolate between lower -> higher. | 58 // Where values from 0 -> 1 interpolate between lower -> higher. |
57 void waveDataForFundamentalFrequency(float, float*& lowerWaveData, float*& h igherWaveData, float& tableInterpolationFactor); | 59 void waveDataForFundamentalFrequency(float, float*& lowerWaveData, float*& h igherWaveData, float& tableInterpolationFactor); |
58 | 60 |
59 // Returns the scalar multiplier to the oscillator frequency to calculate wa ve buffer phase increment. | 61 // Returns the scalar multiplier to the oscillator frequency to calculate wa ve buffer phase increment. |
60 float rateScale() const { return m_rateScale; } | 62 float rateScale() const { return m_rateScale; } |
61 | 63 |
62 // The size of the FFT to use based on the sampling rate. | 64 // The size of the FFT to use based on the sampling rate. |
63 unsigned periodicWaveSize() const; | 65 unsigned periodicWaveSize() const; |
64 | 66 |
65 // The number of ranges needed for the given sampling rate and FFT size. | 67 // The number of ranges needed for the given sampling rate and FFT size. |
66 unsigned numberOfRanges() const { return m_numberOfRanges; } | 68 unsigned numberOfRanges() const { return m_numberOfRanges; } |
67 | 69 |
68 DEFINE_INLINE_TRACE() { } | 70 DEFINE_INLINE_TRACE() { } |
69 | 71 |
70 private: | 72 private: |
71 explicit PeriodicWave(float sampleRate); | 73 explicit PeriodicWave(float sampleRate); |
72 | 74 |
73 void generateBasicWaveform(int); | 75 void generateBasicWaveform(int); |
74 | 76 |
77 size_t m_v8ExternalMemory; | |
78 | |
75 float m_sampleRate; | 79 float m_sampleRate; |
76 unsigned m_numberOfRanges; | 80 unsigned m_numberOfRanges; |
77 float m_centsPerRange; | 81 float m_centsPerRange; |
78 | 82 |
79 // The lowest frequency (in Hertz) where playback will include all of the pa rtials. | 83 // The lowest frequency (in Hertz) where playback will include all of the pa rtials. |
80 // Playing back lower than this frequency will gradually lose more high-freq uency information. | 84 // Playing back lower than this frequency will gradually lose more high-freq uency information. |
81 // This frequency is quite low (~10Hz @ 44.1KHz) | 85 // This frequency is quite low (~10Hz @ 44.1KHz) |
82 float m_lowestFundamentalFrequency; | 86 float m_lowestFundamentalFrequency; |
83 | 87 |
84 float m_rateScale; | 88 float m_rateScale; |
85 | 89 |
86 // Maximum possible number of partials (before culling). | 90 // Maximum possible number of partials (before culling). |
87 unsigned maxNumberOfPartials() const; | 91 unsigned maxNumberOfPartials() const; |
88 | 92 |
89 unsigned numberOfPartialsForRange(unsigned rangeIndex) const; | 93 unsigned numberOfPartialsForRange(unsigned rangeIndex) const; |
90 | 94 |
95 void adjustV8ExternalMemory(int delta); | |
96 | |
91 // Creates tables based on numberOfComponents Fourier coefficients. | 97 // Creates tables based on numberOfComponents Fourier coefficients. |
92 void createBandLimitedTables(const float* real, const float* imag, unsigned numberOfComponents, bool disableNormalization); | 98 void createBandLimitedTables(const float* real, const float* imag, unsigned numberOfComponents, bool disableNormalization); |
93 Vector<OwnPtr<AudioFloatArray>> m_bandLimitedTables; | 99 Vector<OwnPtr<AudioFloatArray>> m_bandLimitedTables; |
94 }; | 100 }; |
95 | 101 |
96 } // namespace blink | 102 } // namespace blink |
97 | 103 |
98 #endif // PeriodicWave_h | 104 #endif // PeriodicWave_h |
OLD | NEW |