The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

95 lines
3.5KB

  1. #pragma once
  2. %%include_juce%%
  3. //==============================================================================
  4. /*
  5. This component lives inside our window, and this is where you should put all
  6. your controls and content.
  7. */
  8. class %%content_component_class%% : public juce::AudioAppComponent
  9. {
  10. public:
  11. //==============================================================================
  12. %%content_component_class%%()
  13. {
  14. // Make sure you set the size of the component after
  15. // you add any child components.
  16. setSize (800, 600);
  17. // Some platforms require permissions to open input channels so request that here
  18. if (juce::RuntimePermissions::isRequired (juce::RuntimePermissions::recordAudio)
  19. && ! juce::RuntimePermissions::isGranted (juce::RuntimePermissions::recordAudio))
  20. {
  21. juce::RuntimePermissions::request (juce::RuntimePermissions::recordAudio,
  22. [&] (bool granted) { setAudioChannels (granted ? 2 : 0, 2); });
  23. }
  24. else
  25. {
  26. // Specify the number of input and output channels that we want to open
  27. setAudioChannels (2, 2);
  28. }
  29. }
  30. ~%%content_component_class%%() override
  31. {
  32. // This shuts down the audio device and clears the audio source.
  33. shutdownAudio();
  34. }
  35. //==============================================================================
  36. void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override
  37. {
  38. // This function will be called when the audio device is started, or when
  39. // its settings (i.e. sample rate, block size, etc) are changed.
  40. // You can use this function to initialise any resources you might need,
  41. // but be careful - it will be called on the audio thread, not the GUI thread.
  42. // For more details, see the help for AudioProcessor::prepareToPlay()
  43. }
  44. void getNextAudioBlock (const juce::AudioSourceChannelInfo& bufferToFill) override
  45. {
  46. // Your audio-processing code goes here!
  47. // For more details, see the help for AudioProcessor::getNextAudioBlock()
  48. // Right now we are not producing any data, in which case we need to clear the buffer
  49. // (to prevent the output of random noise)
  50. bufferToFill.clearActiveBufferRegion();
  51. }
  52. void releaseResources() override
  53. {
  54. // This will be called when the audio device stops, or when it is being
  55. // restarted due to a setting change.
  56. // For more details, see the help for AudioProcessor::releaseResources()
  57. }
  58. //==============================================================================
  59. void paint (juce::Graphics& g) override
  60. {
  61. // (Our component is opaque, so we must completely fill the background with a solid colour)
  62. g.fillAll (getLookAndFeel().findColour (juce::ResizableWindow::backgroundColourId));
  63. // You can add your drawing code here!
  64. }
  65. void resized() override
  66. {
  67. // This is called when the MainContentComponent is resized.
  68. // If you add any child components, this is where you should
  69. // update their positions.
  70. }
  71. private:
  72. //==============================================================================
  73. // Your private member variables go here...
  74. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (%%content_component_class%%)
  75. };