Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.9KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2016 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of the ISC license
  6. http://www.isc.org/downloads/software-support-policy/isc-license/
  7. Permission to use, copy, modify, and/or distribute this software for any
  8. purpose with or without fee is hereby granted, provided that the above
  9. copyright notice and this permission notice appear in all copies.
  10. THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
  11. TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  12. FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
  13. OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  14. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  16. OF THIS SOFTWARE.
  17. -----------------------------------------------------------------------------
  18. To release a closed-source product which uses other parts of JUCE not
  19. licensed under the ISC terms, commercial licenses are available: visit
  20. www.juce.com for more information.
  21. ==============================================================================
  22. */
  23. #ifndef JUCE_TONEGENERATORAUDIOSOURCE_H_INCLUDED
  24. #define JUCE_TONEGENERATORAUDIOSOURCE_H_INCLUDED
  25. //==============================================================================
  26. /**
  27. A simple AudioSource that generates a sine wave.
  28. */
  29. class JUCE_API ToneGeneratorAudioSource : public AudioSource
  30. {
  31. public:
  32. //==============================================================================
  33. /** Creates a ToneGeneratorAudioSource. */
  34. ToneGeneratorAudioSource();
  35. /** Destructor. */
  36. ~ToneGeneratorAudioSource();
  37. //==============================================================================
  38. /** Sets the signal's amplitude. */
  39. void setAmplitude (float newAmplitude);
  40. /** Sets the signal's frequency. */
  41. void setFrequency (double newFrequencyHz);
  42. //==============================================================================
  43. /** Implementation of the AudioSource method. */
  44. void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override;
  45. /** Implementation of the AudioSource method. */
  46. void releaseResources() override;
  47. /** Implementation of the AudioSource method. */
  48. void getNextAudioBlock (const AudioSourceChannelInfo&) override;
  49. private:
  50. //==============================================================================
  51. double frequency, sampleRate;
  52. double currentPhase, phasePerSample;
  53. float amplitude;
  54. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToneGeneratorAudioSource)
  55. };
  56. #endif // JUCE_TONEGENERATORAUDIOSOURCE_H_INCLUDED