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

Side by Side Diff: Source/modules/webaudio/PeriodicWave.h

Issue 205173002: Move webaudio to oilpan (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/modules/webaudio/PannerNode.h ('k') | Source/modules/webaudio/PeriodicWave.cpp » ('j') | 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) 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 22 matching lines...) Expand all
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/OwnPtr.h" 35 #include "wtf/OwnPtr.h"
36 #include "wtf/PassRefPtr.h" 36 #include "wtf/PassRefPtr.h"
37 #include "wtf/RefCounted.h" 37 #include "wtf/RefCounted.h"
38 #include "wtf/RefPtr.h" 38 #include "wtf/RefPtr.h"
39 #include "wtf/Vector.h" 39 #include "wtf/Vector.h"
40 40
41 namespace WebCore { 41 namespace WebCore {
42 42
43 class PeriodicWave : public ScriptWrappable, public RefCounted<PeriodicWave> { 43 class PeriodicWave : public RefCountedWillBeGarbageCollectedFinalized<PeriodicWa ve>, public ScriptWrappable {
44 public: 44 public:
45 static PassRefPtr<PeriodicWave> createSine(float sampleRate); 45 static PassRefPtrWillBeRawPtr<PeriodicWave> createSine(float sampleRate);
46 static PassRefPtr<PeriodicWave> createSquare(float sampleRate); 46 static PassRefPtrWillBeRawPtr<PeriodicWave> createSquare(float sampleRate);
47 static PassRefPtr<PeriodicWave> createSawtooth(float sampleRate); 47 static PassRefPtrWillBeRawPtr<PeriodicWave> createSawtooth(float sampleRate) ;
48 static PassRefPtr<PeriodicWave> createTriangle(float sampleRate); 48 static PassRefPtrWillBeRawPtr<PeriodicWave> createTriangle(float sampleRate) ;
49 49
50 // Creates an arbitrary periodic wave given the frequency components (Fourie r coefficients). 50 // Creates an arbitrary periodic wave given the frequency components (Fourie r coefficients).
51 static PassRefPtr<PeriodicWave> create(float sampleRate, Float32Array* real, Float32Array* imag); 51 static PassRefPtrWillBeRawPtr<PeriodicWave> create(float sampleRate, Float32 Array* real, Float32Array* imag);
52 52
53 // 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
54 // 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
55 // 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
56 // 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.
57 // 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.
58 // Where values from 0 -> 1 interpolate between lower -> higher. 58 // Where values from 0 -> 1 interpolate between lower -> higher.
59 void waveDataForFundamentalFrequency(float, float* &lowerWaveData, float* &h igherWaveData, float& tableInterpolationFactor); 59 void waveDataForFundamentalFrequency(float, float* &lowerWaveData, float* &h igherWaveData, float& tableInterpolationFactor);
60 60
61 // 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.
62 float rateScale() const { return m_rateScale; } 62 float rateScale() const { return m_rateScale; }
63 63
64 unsigned periodicWaveSize() const { return m_periodicWaveSize; } 64 unsigned periodicWaveSize() const { return m_periodicWaveSize; }
65 65
66 void trace(Visitor*) { }
67
66 private: 68 private:
67 explicit PeriodicWave(float sampleRate); 69 explicit PeriodicWave(float sampleRate);
68 70
69 void generateBasicWaveform(int); 71 void generateBasicWaveform(int);
70 72
71 float m_sampleRate; 73 float m_sampleRate;
72 unsigned m_periodicWaveSize; 74 unsigned m_periodicWaveSize;
73 unsigned m_numberOfRanges; 75 unsigned m_numberOfRanges;
74 float m_centsPerRange; 76 float m_centsPerRange;
75 77
(...skipping 10 matching lines...) Expand all
86 unsigned numberOfPartialsForRange(unsigned rangeIndex) const; 88 unsigned numberOfPartialsForRange(unsigned rangeIndex) const;
87 89
88 // Creates tables based on numberOfComponents Fourier coefficients. 90 // Creates tables based on numberOfComponents Fourier coefficients.
89 void createBandLimitedTables(const float* real, const float* imag, unsigned numberOfComponents); 91 void createBandLimitedTables(const float* real, const float* imag, unsigned numberOfComponents);
90 Vector<OwnPtr<AudioFloatArray> > m_bandLimitedTables; 92 Vector<OwnPtr<AudioFloatArray> > m_bandLimitedTables;
91 }; 93 };
92 94
93 } // namespace WebCore 95 } // namespace WebCore
94 96
95 #endif // PeriodicWave_h 97 #endif // PeriodicWave_h
OLDNEW
« no previous file with comments | « Source/modules/webaudio/PannerNode.h ('k') | Source/modules/webaudio/PeriodicWave.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698