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.

201 lines
7.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), 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. //==============================================================================
  95. setSize (600, 400);
  96. }
  97. DspModulePluginDemoAudioProcessorEditor::~DspModulePluginDemoAudioProcessorEditor()
  98. {
  99. }
  100. //==============================================================================
  101. void DspModulePluginDemoAudioProcessorEditor::paint (Graphics& g)
  102. {
  103. g.setColour (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
  104. g.fillAll();
  105. }
  106. void DspModulePluginDemoAudioProcessorEditor::resized()
  107. {
  108. auto bounds = getLocalBounds().reduced (10);
  109. bounds.removeFromTop (10);
  110. bounds.removeFromLeft (125);
  111. //==============================================================================
  112. inputVolumeSlider->setBounds (bounds.removeFromTop (30));
  113. bounds.removeFromTop (5);
  114. outputVolumeSlider->setBounds (bounds.removeFromTop (30));
  115. bounds.removeFromTop (15);
  116. highPassFilterFreqSlider->setBounds (bounds.removeFromTop (30));
  117. bounds.removeFromTop (5);
  118. lowPassFilterFreqSlider->setBounds (bounds.removeFromTop (30));
  119. bounds.removeFromTop (15);
  120. //==============================================================================
  121. stereoBox.setBounds (bounds.removeFromTop(30));
  122. bounds.removeFromTop (5);
  123. slopeBox.setBounds (bounds.removeFromTop (30));
  124. bounds.removeFromTop (5);
  125. waveshaperBox.setBounds (bounds.removeFromTop (30));
  126. bounds.removeFromTop (5);
  127. cabinetTypeBox.setBounds (bounds.removeFromTop (30));
  128. bounds.removeFromTop (15);
  129. //==============================================================================
  130. auto buttonSlice = bounds.removeFromTop (30);
  131. cabinetSimButton.setSize (200, bounds.getHeight());
  132. cabinetSimButton.setCentrePosition (buttonSlice.getCentre());
  133. bounds.removeFromTop (15);
  134. }
  135. //==============================================================================
  136. void DspModulePluginDemoAudioProcessorEditor::comboBoxChanged (ComboBox* box)
  137. {
  138. auto index = box->getSelectedItemIndex();
  139. if (box == &stereoBox)
  140. {
  141. processor.stereoParam->operator= (index);
  142. }
  143. else if (box == &slopeBox)
  144. {
  145. processor.slopeParam->operator= (index);
  146. }
  147. else if (box == &waveshaperBox)
  148. {
  149. processor.waveshaperParam->operator= (index);
  150. }
  151. else if (box == &cabinetTypeBox)
  152. {
  153. processor.cabinetTypeParam->operator= (index);
  154. }
  155. }