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.

221 lines
8.4KB

  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), processor (p),
  24. inputVolumeLabel ({ }, processor.inputVolumeParam->name),
  25. outputVolumeLabel ({ }, processor.outputVolumeParam->name),
  26. lowPassFilterFreqLabel ({ }, processor.lowPassFilterFreqParam->name),
  27. highPassFilterFreqLabel ({ }, processor.highPassFilterFreqParam->name),
  28. stereoLabel({}, processor.stereoParam->name),
  29. slopeLabel ({ }, processor.slopeParam->name),
  30. waveshaperLabel({ }, processor.waveshaperParam->name),
  31. cabinetTypeLabel({ }, processor.cabinetTypeParam->name)
  32. {
  33. //==============================================================================
  34. addAndMakeVisible (inputVolumeSlider = new ParameterSlider (*processor.inputVolumeParam));
  35. addAndMakeVisible (outputVolumeSlider = new ParameterSlider (*processor.outputVolumeParam));
  36. addAndMakeVisible (lowPassFilterFreqSlider = new ParameterSlider (*processor.lowPassFilterFreqParam));
  37. addAndMakeVisible (highPassFilterFreqSlider = new ParameterSlider (*processor.highPassFilterFreqParam));
  38. addAndMakeVisible (inputVolumeLabel);
  39. inputVolumeLabel.setJustificationType (Justification::centredLeft);
  40. inputVolumeLabel.attachToComponent (inputVolumeSlider, true);
  41. addAndMakeVisible (outputVolumeLabel);
  42. outputVolumeLabel.setJustificationType (Justification::centredLeft);
  43. outputVolumeLabel.attachToComponent (outputVolumeSlider, true);
  44. addAndMakeVisible (lowPassFilterFreqLabel);
  45. lowPassFilterFreqLabel.setJustificationType (Justification::centredLeft);
  46. lowPassFilterFreqLabel.attachToComponent (lowPassFilterFreqSlider, true);
  47. addAndMakeVisible (highPassFilterFreqLabel);
  48. highPassFilterFreqLabel.setJustificationType (Justification::centredLeft);
  49. highPassFilterFreqLabel.attachToComponent (highPassFilterFreqSlider, true);
  50. //==============================================================================
  51. addAndMakeVisible (stereoBox);
  52. auto i = 1;
  53. for (auto choice : processor.stereoParam->choices)
  54. stereoBox.addItem (choice, i++);
  55. stereoBox.addListener (this);
  56. stereoBox.setSelectedId (processor.stereoParam->getIndex() + 1);
  57. addAndMakeVisible (stereoLabel);
  58. stereoLabel.setJustificationType (Justification::centredLeft);
  59. stereoLabel.attachToComponent (&stereoBox, true);
  60. //==============================================================================
  61. addAndMakeVisible(slopeBox);
  62. i = 1;
  63. for (auto choice : processor.slopeParam->choices)
  64. slopeBox.addItem(choice, i++);
  65. slopeBox.addListener(this);
  66. slopeBox.setSelectedId(processor.slopeParam->getIndex() + 1);
  67. addAndMakeVisible(slopeLabel);
  68. slopeLabel.setJustificationType(Justification::centredLeft);
  69. slopeLabel.attachToComponent(&slopeBox, true);
  70. //==============================================================================
  71. addAndMakeVisible (waveshaperBox);
  72. i = 1;
  73. for (auto choice : processor.waveshaperParam->choices)
  74. waveshaperBox.addItem (choice, i++);
  75. waveshaperBox.addListener (this);
  76. waveshaperBox.setSelectedId (processor.waveshaperParam->getIndex() + 1);
  77. addAndMakeVisible (waveshaperLabel);
  78. waveshaperLabel.setJustificationType (Justification::centredLeft);
  79. waveshaperLabel.attachToComponent (&waveshaperBox, true);
  80. //==============================================================================
  81. addAndMakeVisible (cabinetTypeBox);
  82. i = 1;
  83. for (auto choice : processor.cabinetTypeParam->choices)
  84. cabinetTypeBox.addItem (choice, i++);
  85. cabinetTypeBox.addListener (this);
  86. cabinetTypeBox.setSelectedId (processor.cabinetTypeParam->getIndex() + 1);
  87. addAndMakeVisible (cabinetTypeLabel);
  88. cabinetTypeLabel.setJustificationType (Justification::centredLeft);
  89. cabinetTypeLabel.attachToComponent (&cabinetTypeBox, true);
  90. //==============================================================================
  91. addAndMakeVisible (cabinetSimButton);
  92. cabinetSimButton.addListener (this);
  93. cabinetSimButton.setButtonText (processor.cabinetSimParam->name);
  94. addAndMakeVisible (oversamplingButton);
  95. oversamplingButton.addListener (this);
  96. oversamplingButton.setButtonText (processor.oversamplingParam->name);
  97. //==============================================================================
  98. setSize (600, 400);
  99. }
  100. DspModulePluginDemoAudioProcessorEditor::~DspModulePluginDemoAudioProcessorEditor()
  101. {
  102. }
  103. //==============================================================================
  104. void DspModulePluginDemoAudioProcessorEditor::paint (Graphics& g)
  105. {
  106. g.setColour (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
  107. g.fillAll();
  108. }
  109. void DspModulePluginDemoAudioProcessorEditor::resized()
  110. {
  111. auto bounds = getLocalBounds().reduced (10);
  112. bounds.removeFromTop (10);
  113. bounds.removeFromLeft (125);
  114. //==============================================================================
  115. inputVolumeSlider->setBounds (bounds.removeFromTop (30));
  116. bounds.removeFromTop (5);
  117. outputVolumeSlider->setBounds (bounds.removeFromTop (30));
  118. bounds.removeFromTop (15);
  119. highPassFilterFreqSlider->setBounds (bounds.removeFromTop (30));
  120. bounds.removeFromTop (5);
  121. lowPassFilterFreqSlider->setBounds (bounds.removeFromTop (30));
  122. bounds.removeFromTop (15);
  123. //==============================================================================
  124. stereoBox.setBounds (bounds.removeFromTop(30));
  125. bounds.removeFromTop (5);
  126. slopeBox.setBounds (bounds.removeFromTop (30));
  127. bounds.removeFromTop (5);
  128. waveshaperBox.setBounds (bounds.removeFromTop (30));
  129. bounds.removeFromTop (5);
  130. cabinetTypeBox.setBounds (bounds.removeFromTop (30));
  131. bounds.removeFromTop (15);
  132. //==============================================================================
  133. auto buttonSlice = bounds.removeFromTop (30);
  134. cabinetSimButton.setSize (200, buttonSlice.getHeight());
  135. cabinetSimButton.setCentrePosition (buttonSlice.getCentre());
  136. bounds.removeFromTop(5);
  137. buttonSlice = bounds.removeFromTop (30);
  138. oversamplingButton.setSize(200, buttonSlice.getHeight());
  139. oversamplingButton.setCentrePosition(buttonSlice.getCentre());
  140. }
  141. //==============================================================================
  142. void DspModulePluginDemoAudioProcessorEditor::comboBoxChanged (ComboBox* box)
  143. {
  144. auto index = box->getSelectedItemIndex();
  145. if (box == &stereoBox)
  146. {
  147. processor.stereoParam->operator= (index);
  148. }
  149. else if (box == &slopeBox)
  150. {
  151. processor.slopeParam->operator= (index);
  152. }
  153. else if (box == &waveshaperBox)
  154. {
  155. processor.waveshaperParam->operator= (index);
  156. }
  157. else if (box == &cabinetTypeBox)
  158. {
  159. processor.cabinetTypeParam->operator= (index);
  160. }
  161. }
  162. void DspModulePluginDemoAudioProcessorEditor::buttonClicked (Button* button)
  163. {
  164. if (button == &cabinetSimButton)
  165. {
  166. processor.cabinetSimParam->operator= (cabinetSimButton.getToggleState());
  167. }
  168. else if (button == &oversamplingButton)
  169. {
  170. processor.oversamplingParam->operator= (oversamplingButton.getToggleState());
  171. }
  172. }