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.

224 lines
8.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #include "PluginProcessor.h"
  20. #include "PluginEditor.h"
  21. //==============================================================================
  22. DspModulePluginDemoAudioProcessorEditor::DspModulePluginDemoAudioProcessorEditor (DspModulePluginDemoAudioProcessor& p)
  23. : AudioProcessorEditor (&p),
  24. processor (p),
  25. inputVolumeLabel ({}, processor.inputVolumeParam->name),
  26. outputVolumeLabel ({}, processor.outputVolumeParam->name),
  27. lowPassFilterFreqLabel ({}, processor.lowPassFilterFreqParam->name),
  28. highPassFilterFreqLabel ({}, processor.highPassFilterFreqParam->name),
  29. stereoLabel ({}, processor.stereoParam->name),
  30. slopeLabel ({}, processor.slopeParam->name),
  31. waveshaperLabel ({}, processor.waveshaperParam->name),
  32. cabinetTypeLabel ({}, processor.cabinetTypeParam->name)
  33. {
  34. //==============================================================================
  35. addAndMakeVisible (inputVolumeSlider = new ParameterSlider (*processor.inputVolumeParam));
  36. addAndMakeVisible (outputVolumeSlider = new ParameterSlider (*processor.outputVolumeParam));
  37. addAndMakeVisible (lowPassFilterFreqSlider = new ParameterSlider (*processor.lowPassFilterFreqParam));
  38. addAndMakeVisible (highPassFilterFreqSlider = new ParameterSlider (*processor.highPassFilterFreqParam));
  39. addAndMakeVisible (inputVolumeLabel);
  40. inputVolumeLabel.setJustificationType (Justification::centredLeft);
  41. inputVolumeLabel.attachToComponent (inputVolumeSlider, true);
  42. addAndMakeVisible (outputVolumeLabel);
  43. outputVolumeLabel.setJustificationType (Justification::centredLeft);
  44. outputVolumeLabel.attachToComponent (outputVolumeSlider, true);
  45. addAndMakeVisible (lowPassFilterFreqLabel);
  46. lowPassFilterFreqLabel.setJustificationType (Justification::centredLeft);
  47. lowPassFilterFreqLabel.attachToComponent (lowPassFilterFreqSlider, true);
  48. addAndMakeVisible (highPassFilterFreqLabel);
  49. highPassFilterFreqLabel.setJustificationType (Justification::centredLeft);
  50. highPassFilterFreqLabel.attachToComponent (highPassFilterFreqSlider, true);
  51. //==============================================================================
  52. addAndMakeVisible (stereoBox);
  53. auto i = 1;
  54. for (auto choice : processor.stereoParam->choices)
  55. stereoBox.addItem (choice, i++);
  56. stereoBox.addListener (this);
  57. stereoBox.setSelectedId (processor.stereoParam->getIndex() + 1);
  58. addAndMakeVisible (stereoLabel);
  59. stereoLabel.setJustificationType (Justification::centredLeft);
  60. stereoLabel.attachToComponent (&stereoBox, true);
  61. //==============================================================================
  62. addAndMakeVisible(slopeBox);
  63. i = 1;
  64. for (auto choice : processor.slopeParam->choices)
  65. slopeBox.addItem(choice, i++);
  66. slopeBox.addListener(this);
  67. slopeBox.setSelectedId(processor.slopeParam->getIndex() + 1);
  68. addAndMakeVisible(slopeLabel);
  69. slopeLabel.setJustificationType(Justification::centredLeft);
  70. slopeLabel.attachToComponent(&slopeBox, true);
  71. //==============================================================================
  72. addAndMakeVisible (waveshaperBox);
  73. i = 1;
  74. for (auto choice : processor.waveshaperParam->choices)
  75. waveshaperBox.addItem (choice, i++);
  76. waveshaperBox.addListener (this);
  77. waveshaperBox.setSelectedId (processor.waveshaperParam->getIndex() + 1);
  78. addAndMakeVisible (waveshaperLabel);
  79. waveshaperLabel.setJustificationType (Justification::centredLeft);
  80. waveshaperLabel.attachToComponent (&waveshaperBox, true);
  81. //==============================================================================
  82. addAndMakeVisible (cabinetTypeBox);
  83. i = 1;
  84. for (auto choice : processor.cabinetTypeParam->choices)
  85. cabinetTypeBox.addItem (choice, i++);
  86. cabinetTypeBox.addListener (this);
  87. cabinetTypeBox.setSelectedId (processor.cabinetTypeParam->getIndex() + 1);
  88. addAndMakeVisible (cabinetTypeLabel);
  89. cabinetTypeLabel.setJustificationType (Justification::centredLeft);
  90. cabinetTypeLabel.attachToComponent (&cabinetTypeBox, true);
  91. //==============================================================================
  92. addAndMakeVisible (cabinetSimButton);
  93. cabinetSimButton.addListener (this);
  94. cabinetSimButton.setButtonText (processor.cabinetSimParam->name);
  95. cabinetSimButton.setToggleState (processor.cabinetSimParam->get(), NotificationType::dontSendNotification);
  96. addAndMakeVisible (oversamplingButton);
  97. oversamplingButton.addListener (this);
  98. oversamplingButton.setButtonText (processor.oversamplingParam->name);
  99. oversamplingButton.setToggleState (processor.oversamplingParam->get(), NotificationType::dontSendNotification);
  100. //==============================================================================
  101. setSize (600, 400);
  102. }
  103. DspModulePluginDemoAudioProcessorEditor::~DspModulePluginDemoAudioProcessorEditor()
  104. {
  105. }
  106. //==============================================================================
  107. void DspModulePluginDemoAudioProcessorEditor::paint (Graphics& g)
  108. {
  109. g.setColour (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
  110. g.fillAll();
  111. }
  112. void DspModulePluginDemoAudioProcessorEditor::resized()
  113. {
  114. auto bounds = getLocalBounds().reduced (10);
  115. bounds.removeFromTop (10);
  116. bounds.removeFromLeft (125);
  117. //==============================================================================
  118. inputVolumeSlider->setBounds (bounds.removeFromTop (30));
  119. bounds.removeFromTop (5);
  120. outputVolumeSlider->setBounds (bounds.removeFromTop (30));
  121. bounds.removeFromTop (15);
  122. highPassFilterFreqSlider->setBounds (bounds.removeFromTop (30));
  123. bounds.removeFromTop (5);
  124. lowPassFilterFreqSlider->setBounds (bounds.removeFromTop (30));
  125. bounds.removeFromTop (15);
  126. //==============================================================================
  127. stereoBox.setBounds (bounds.removeFromTop(30));
  128. bounds.removeFromTop (5);
  129. slopeBox.setBounds (bounds.removeFromTop (30));
  130. bounds.removeFromTop (5);
  131. waveshaperBox.setBounds (bounds.removeFromTop (30));
  132. bounds.removeFromTop (5);
  133. cabinetTypeBox.setBounds (bounds.removeFromTop (30));
  134. bounds.removeFromTop (15);
  135. //==============================================================================
  136. auto buttonSlice = bounds.removeFromTop (30);
  137. cabinetSimButton.setSize (200, buttonSlice.getHeight());
  138. cabinetSimButton.setCentrePosition (buttonSlice.getCentre());
  139. bounds.removeFromTop(5);
  140. buttonSlice = bounds.removeFromTop (30);
  141. oversamplingButton.setSize(200, buttonSlice.getHeight());
  142. oversamplingButton.setCentrePosition(buttonSlice.getCentre());
  143. }
  144. //==============================================================================
  145. void DspModulePluginDemoAudioProcessorEditor::comboBoxChanged (ComboBox* box)
  146. {
  147. auto index = box->getSelectedItemIndex();
  148. if (box == &stereoBox)
  149. {
  150. processor.stereoParam->operator= (index);
  151. }
  152. else if (box == &slopeBox)
  153. {
  154. processor.slopeParam->operator= (index);
  155. }
  156. else if (box == &waveshaperBox)
  157. {
  158. processor.waveshaperParam->operator= (index);
  159. }
  160. else if (box == &cabinetTypeBox)
  161. {
  162. processor.cabinetTypeParam->operator= (index);
  163. }
  164. }
  165. void DspModulePluginDemoAudioProcessorEditor::buttonClicked (Button* button)
  166. {
  167. if (button == &cabinetSimButton)
  168. {
  169. processor.cabinetSimParam->operator= (cabinetSimButton.getToggleState());
  170. }
  171. else if (button == &oversamplingButton)
  172. {
  173. processor.oversamplingParam->operator= (oversamplingButton.getToggleState());
  174. }
  175. }