| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // OscillatorNode is an audio generator of periodic waveforms. | 44 // OscillatorNode is an audio generator of periodic waveforms. |
| 45 | 45 |
| 46 class OscillatorHandler final : public AudioScheduledSourceHandler { | 46 class OscillatorHandler final : public AudioScheduledSourceHandler { |
| 47 public: | 47 public: |
| 48 // The waveform type. | 48 // The waveform type. |
| 49 // These must be defined as in the .idl file. | 49 // These must be defined as in the .idl file. |
| 50 enum { SINE = 0, SQUARE = 1, SAWTOOTH = 2, TRIANGLE = 3, CUSTOM = 4 }; | 50 enum { SINE = 0, SQUARE = 1, SAWTOOTH = 2, TRIANGLE = 3, CUSTOM = 4 }; |
| 51 | 51 |
| 52 static PassRefPtr<OscillatorHandler> Create(AudioNode&, | 52 static PassRefPtr<OscillatorHandler> Create(AudioNode&, |
| 53 float sample_rate, | 53 float sample_rate, |
| 54 const String& oscillator_type, |
| 55 PeriodicWave* wave_table, |
| 54 AudioParamHandler& frequency, | 56 AudioParamHandler& frequency, |
| 55 AudioParamHandler& detune); | 57 AudioParamHandler& detune); |
| 56 ~OscillatorHandler() override; | 58 ~OscillatorHandler() override; |
| 57 | 59 |
| 58 // AudioHandler | 60 // AudioHandler |
| 59 void Process(size_t frames_to_process) override; | 61 void Process(size_t frames_to_process) override; |
| 60 | 62 |
| 61 String GetType() const; | 63 String GetType() const; |
| 62 void SetType(const String&, ExceptionState&); | 64 void SetType(const String&, ExceptionState&); |
| 63 | 65 |
| 64 void SetPeriodicWave(PeriodicWave*); | 66 void SetPeriodicWave(PeriodicWave*); |
| 65 | 67 |
| 66 private: | 68 private: |
| 67 OscillatorHandler(AudioNode&, | 69 OscillatorHandler(AudioNode&, |
| 68 float sample_rate, | 70 float sample_rate, |
| 71 const String& oscillator_type, |
| 72 PeriodicWave* wave_table, |
| 69 AudioParamHandler& frequency, | 73 AudioParamHandler& frequency, |
| 70 AudioParamHandler& detune); | 74 AudioParamHandler& detune); |
| 71 bool SetType(unsigned); // Returns true on success. | 75 bool SetType(unsigned); // Returns true on success. |
| 72 | 76 |
| 73 // Returns true if there are sample-accurate timeline parameter changes. | 77 // Returns true if there are sample-accurate timeline parameter changes. |
| 74 bool CalculateSampleAccuratePhaseIncrements(size_t frames_to_process); | 78 bool CalculateSampleAccuratePhaseIncrements(size_t frames_to_process); |
| 75 | 79 |
| 76 bool PropagatesSilence() const override; | 80 bool PropagatesSilence() const override; |
| 77 | 81 |
| 78 // One of the waveform types defined in the enum. | 82 // One of the waveform types defined in the enum. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 98 // This Persistent doesn't make a reference cycle including the owner | 102 // This Persistent doesn't make a reference cycle including the owner |
| 99 // OscillatorNode. It is cross-thread, as it will be accessed by the audio | 103 // OscillatorNode. It is cross-thread, as it will be accessed by the audio |
| 100 // thread. | 104 // thread. |
| 101 CrossThreadPersistent<PeriodicWave> periodic_wave_; | 105 CrossThreadPersistent<PeriodicWave> periodic_wave_; |
| 102 }; | 106 }; |
| 103 | 107 |
| 104 class OscillatorNode final : public AudioScheduledSourceNode { | 108 class OscillatorNode final : public AudioScheduledSourceNode { |
| 105 DEFINE_WRAPPERTYPEINFO(); | 109 DEFINE_WRAPPERTYPEINFO(); |
| 106 | 110 |
| 107 public: | 111 public: |
| 108 static OscillatorNode* Create(BaseAudioContext&, ExceptionState&); | 112 static OscillatorNode* Create(BaseAudioContext&, |
| 113 const String& oscillator_type, |
| 114 PeriodicWave* wave_table, |
| 115 ExceptionState&); |
| 109 static OscillatorNode* Create(BaseAudioContext*, | 116 static OscillatorNode* Create(BaseAudioContext*, |
| 110 const OscillatorOptions&, | 117 const OscillatorOptions&, |
| 111 ExceptionState&); | 118 ExceptionState&); |
| 112 DECLARE_VIRTUAL_TRACE(); | 119 DECLARE_VIRTUAL_TRACE(); |
| 113 | 120 |
| 114 String type() const; | 121 String type() const; |
| 115 void setType(const String&, ExceptionState&); | 122 void setType(const String&, ExceptionState&); |
| 116 AudioParam* frequency(); | 123 AudioParam* frequency(); |
| 117 AudioParam* detune(); | 124 AudioParam* detune(); |
| 118 void setPeriodicWave(PeriodicWave*); | 125 void setPeriodicWave(PeriodicWave*); |
| 119 | 126 |
| 120 private: | 127 private: |
| 121 OscillatorNode(BaseAudioContext&); | 128 OscillatorNode(BaseAudioContext&, |
| 129 const String& oscillator_type, |
| 130 PeriodicWave* wave_table); |
| 122 OscillatorHandler& GetOscillatorHandler() const; | 131 OscillatorHandler& GetOscillatorHandler() const; |
| 123 | 132 |
| 124 Member<AudioParam> frequency_; | 133 Member<AudioParam> frequency_; |
| 125 Member<AudioParam> detune_; | 134 Member<AudioParam> detune_; |
| 126 }; | 135 }; |
| 127 | 136 |
| 128 } // namespace blink | 137 } // namespace blink |
| 129 | 138 |
| 130 #endif // OscillatorNode_h | 139 #endif // OscillatorNode_h |
| OLD | NEW |