VST3: fetch midi mappings all at once, use it for note/sound-off
[carla.git] / source / modules / juce_audio_basics / sources / juce_ToneGeneratorAudioSource.h
blob0eb4163d2a6417011a03c39a16f0eb98dd6b9edd
1 /*
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
8 licensing.
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
18 DISCLAIMED.
20 ==============================================================================
23 namespace juce
26 //==============================================================================
27 /**
28 A simple AudioSource that generates a sine wave.
31 @tags{Audio}
33 class JUCE_API ToneGeneratorAudioSource : public AudioSource
35 public:
36 //==============================================================================
37 /** Creates a ToneGeneratorAudioSource. */
38 ToneGeneratorAudioSource();
40 /** Destructor. */
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;
62 private:
63 //==============================================================================
64 double frequency, sampleRate;
65 double currentPhase, phasePerSample;
66 float amplitude;
68 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToneGeneratorAudioSource)
71 } // namespace juce