2 ==============================================================================
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
7 JUCE is an open source library subject to commercial or open-source
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
20 ==============================================================================
26 //==============================================================================
28 A simple AudioSource that generates a sine wave.
33 class JUCE_API ToneGeneratorAudioSource
: public AudioSource
36 //==============================================================================
37 /** Creates a ToneGeneratorAudioSource. */
38 ToneGeneratorAudioSource();
41 ~ToneGeneratorAudioSource() override
;
43 //==============================================================================
44 /** Sets the signal's amplitude. */
45 void setAmplitude (float newAmplitude
);
47 /** Sets the signal's frequency. */
48 void setFrequency (double newFrequencyHz
);
51 //==============================================================================
52 /** Implementation of the AudioSource method. */
53 void prepareToPlay (int samplesPerBlockExpected
, double sampleRate
) override
;
55 /** Implementation of the AudioSource method. */
56 void releaseResources() override
;
58 /** Implementation of the AudioSource method. */
59 void getNextAudioBlock (const AudioSourceChannelInfo
&) override
;
63 //==============================================================================
64 double frequency
, sampleRate
;
65 double currentPhase
, phasePerSample
;
68 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToneGeneratorAudioSource
)