| 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 19 matching lines...) Expand all Loading... |
| 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 "core/dom/DOMTypedArray.h" | 33 #include "core/dom/DOMTypedArray.h" |
| 34 #include "platform/audio/AudioArray.h" | 34 #include "platform/audio/AudioArray.h" |
| 35 #include "wtf/Forward.h" | 35 #include "wtf/Forward.h" |
| 36 #include "wtf/Vector.h" | 36 #include "wtf/Vector.h" |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 class AbstractAudioContext; |
| 41 class ExceptionState; |
| 42 |
| 40 class PeriodicWave final : public GarbageCollectedFinalized<PeriodicWave>, publi
c ScriptWrappable { | 43 class PeriodicWave final : public GarbageCollectedFinalized<PeriodicWave>, publi
c ScriptWrappable { |
| 41 DEFINE_WRAPPERTYPEINFO(); | 44 DEFINE_WRAPPERTYPEINFO(); |
| 42 public: | 45 public: |
| 43 static PeriodicWave* createSine(float sampleRate); | 46 static PeriodicWave* createSine(float sampleRate); |
| 44 static PeriodicWave* createSquare(float sampleRate); | 47 static PeriodicWave* createSquare(float sampleRate); |
| 45 static PeriodicWave* createSawtooth(float sampleRate); | 48 static PeriodicWave* createSawtooth(float sampleRate); |
| 46 static PeriodicWave* createTriangle(float sampleRate); | 49 static PeriodicWave* createTriangle(float sampleRate); |
| 47 | 50 |
| 48 // Creates an arbitrary periodic wave given the frequency components (Fourie
r coefficients). | 51 // 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); | 52 static PeriodicWave* create( |
| 53 AbstractAudioContext&, |
| 54 DOMFloat32Array* real, |
| 55 DOMFloat32Array* imag, |
| 56 bool normalize, |
| 57 ExceptionState&); |
| 50 | 58 |
| 51 virtual ~PeriodicWave(); | 59 virtual ~PeriodicWave(); |
| 52 | 60 |
| 53 // Returns pointers to the lower and higher wave data for the pitch range co
ntaining | 61 // Returns pointers to the lower and higher wave data for the pitch range co
ntaining |
| 54 // the given fundamental frequency. These two tables are in adjacent "pitch"
ranges | 62 // the given fundamental frequency. These two tables are in adjacent "pitch"
ranges |
| 55 // where the higher table will have the maximum number of partials which won
't alias when played back | 63 // where the higher table will have the maximum number of partials which won
't alias when played back |
| 56 // at this fundamental frequency. The lower wave is the next range containin
g fewer partials than the higher wave. | 64 // at this fundamental frequency. The lower wave is the next range containin
g fewer partials than the higher wave. |
| 57 // Interpolation between these two tables can be made according to tableInte
rpolationFactor. | 65 // Interpolation between these two tables can be made according to tableInte
rpolationFactor. |
| 58 // Where values from 0 -> 1 interpolate between lower -> higher. | 66 // Where values from 0 -> 1 interpolate between lower -> higher. |
| 59 void waveDataForFundamentalFrequency(float, float*& lowerWaveData, float*& h
igherWaveData, float& tableInterpolationFactor); | 67 void waveDataForFundamentalFrequency(float, float*& lowerWaveData, float*& h
igherWaveData, float& tableInterpolationFactor); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 void adjustV8ExternalMemory(int delta); | 103 void adjustV8ExternalMemory(int delta); |
| 96 | 104 |
| 97 // Creates tables based on numberOfComponents Fourier coefficients. | 105 // Creates tables based on numberOfComponents Fourier coefficients. |
| 98 void createBandLimitedTables(const float* real, const float* imag, unsigned
numberOfComponents, bool disableNormalization); | 106 void createBandLimitedTables(const float* real, const float* imag, unsigned
numberOfComponents, bool disableNormalization); |
| 99 Vector<OwnPtr<AudioFloatArray>> m_bandLimitedTables; | 107 Vector<OwnPtr<AudioFloatArray>> m_bandLimitedTables; |
| 100 }; | 108 }; |
| 101 | 109 |
| 102 } // namespace blink | 110 } // namespace blink |
| 103 | 111 |
| 104 #endif // PeriodicWave_h | 112 #endif // PeriodicWave_h |
| OLD | NEW |