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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // The waveform type. | 45 // The waveform type. |
46 // These must be defined as in the .idl file. | 46 // These must be defined as in the .idl file. |
47 enum { | 47 enum { |
48 SINE = 0, | 48 SINE = 0, |
49 SQUARE = 1, | 49 SQUARE = 1, |
50 SAWTOOTH = 2, | 50 SAWTOOTH = 2, |
51 TRIANGLE = 3, | 51 TRIANGLE = 3, |
52 CUSTOM = 4 | 52 CUSTOM = 4 |
53 }; | 53 }; |
54 | 54 |
55 static PassRefPtr<OscillatorNode> create(AudioContext*, float sampleRate); | 55 static PassRefPtrWillBeRawPtr<OscillatorNode> create(AudioContext*, float sa
mpleRate); |
56 | 56 |
57 virtual ~OscillatorNode(); | 57 virtual ~OscillatorNode(); |
58 | 58 |
59 // AudioNode | 59 // AudioNode |
60 virtual void process(size_t framesToProcess) OVERRIDE; | 60 virtual void process(size_t framesToProcess) OVERRIDE; |
61 | 61 |
62 String type() const; | 62 String type() const; |
63 | 63 |
64 bool setType(unsigned); // Returns true on success. | 64 bool setType(unsigned); // Returns true on success. |
65 void setType(const String&); | 65 void setType(const String&); |
66 | 66 |
67 AudioParam* frequency() { return m_frequency.get(); } | 67 AudioParam* frequency() { return m_frequency.get(); } |
68 AudioParam* detune() { return m_detune.get(); } | 68 AudioParam* detune() { return m_detune.get(); } |
69 | 69 |
70 void setPeriodicWave(PeriodicWave*); | 70 void setPeriodicWave(PeriodicWave*); |
71 | 71 |
| 72 virtual void trace(Visitor*) OVERRIDE; |
| 73 |
72 private: | 74 private: |
73 OscillatorNode(AudioContext*, float sampleRate); | 75 OscillatorNode(AudioContext*, float sampleRate); |
74 | 76 |
75 // Returns true if there are sample-accurate timeline parameter changes. | 77 // Returns true if there are sample-accurate timeline parameter changes. |
76 bool calculateSampleAccuratePhaseIncrements(size_t framesToProcess); | 78 bool calculateSampleAccuratePhaseIncrements(size_t framesToProcess); |
77 | 79 |
78 virtual bool propagatesSilence() const OVERRIDE; | 80 virtual bool propagatesSilence() const OVERRIDE; |
79 | 81 |
80 // One of the waveform types defined in the enum. | 82 // One of the waveform types defined in the enum. |
81 unsigned short m_type; | 83 unsigned short m_type; |
82 | 84 |
83 // Frequency value in Hertz. | 85 // Frequency value in Hertz. |
84 RefPtr<AudioParam> m_frequency; | 86 RefPtrWillBeMember<AudioParam> m_frequency; |
85 | 87 |
86 // Detune value (deviating from the frequency) in Cents. | 88 // Detune value (deviating from the frequency) in Cents. |
87 RefPtr<AudioParam> m_detune; | 89 RefPtrWillBeMember<AudioParam> m_detune; |
88 | 90 |
89 bool m_firstRender; | 91 bool m_firstRender; |
90 | 92 |
91 // m_virtualReadIndex is a sample-frame index into our buffer representing t
he current playback position. | 93 // m_virtualReadIndex is a sample-frame index into our buffer representing t
he current playback position. |
92 // Since it's floating-point, it has sub-sample accuracy. | 94 // Since it's floating-point, it has sub-sample accuracy. |
93 double m_virtualReadIndex; | 95 double m_virtualReadIndex; |
94 | 96 |
95 // This synchronizes process(). | 97 // This synchronizes process(). |
96 mutable Mutex m_processLock; | 98 mutable Mutex m_processLock; |
97 | 99 |
98 // Stores sample-accurate values calculated according to frequency and detun
e. | 100 // Stores sample-accurate values calculated according to frequency and detun
e. |
99 AudioFloatArray m_phaseIncrements; | 101 AudioFloatArray m_phaseIncrements; |
100 AudioFloatArray m_detuneValues; | 102 AudioFloatArray m_detuneValues; |
101 | 103 |
102 RefPtr<PeriodicWave> m_periodicWave; | 104 RefPtrWillBeMember<PeriodicWave> m_periodicWave; |
103 }; | 105 }; |
104 | 106 |
105 } // namespace WebCore | 107 } // namespace WebCore |
106 | 108 |
107 #endif // OscillatorNode_h | 109 #endif // OscillatorNode_h |
OLD | NEW |