PluginEditor.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. ==============================================================================
  3. This file contains the basic framework code for a JUCE plugin editor.
  4. ==============================================================================
  5. */
  6. #include "PluginProcessor.h"
  7. #include "PluginEditor.h"
  8. //==============================================================================
  9. CMLSProjectAudioProcessorEditor::CMLSProjectAudioProcessorEditor (CMLSProjectAudioProcessor& p)
  10. : AudioProcessorEditor (&p), audioProcessor (p)
  11. {
  12. // Make sure that before the constructor has finished, you've set the
  13. // editor's size to whatever you need it to be.
  14. setSize (400, 300);
  15. // equalizer
  16. this->equalizerLowGainSlider.setRange(0.0, 1.0);
  17. this->equalizerLowGainSlider.setTextBoxStyle(juce::Slider::TextBoxRight, false, 100, 20);
  18. this->equalizerLowGainSlider.addListener(this);
  19. this->equalizerLowGainLabel.setText("Equalizer Low Gain", juce::dontSendNotification);
  20. addAndMakeVisible(this->equalizerLowGainSlider);
  21. addAndMakeVisible(this->equalizerLowGainLabel);
  22. this->equalizerHighGainSlider.setRange(0.0, 1.0);
  23. this->equalizerHighGainSlider.setTextBoxStyle(juce::Slider::TextBoxRight, false, 100, 20);
  24. this->equalizerHighGainSlider.addListener(this);
  25. this->equalizerHighGainLabel.setText("Equalizer High Gain", juce::dontSendNotification);
  26. addAndMakeVisible(this->equalizerHighGainSlider);
  27. addAndMakeVisible(this->equalizerHighGainLabel);
  28. // distortion
  29. this->distortionDriveSlider.setRange(0.0, 1.0);
  30. this->distortionDriveSlider.setTextBoxStyle(juce::Slider::TextBoxRight, false, 100, 20);
  31. this->distortionDriveSlider.addListener(this);
  32. this->distortionDriveLabel.setText("Distortion Drive", juce::dontSendNotification);
  33. addAndMakeVisible(this->distortionDriveSlider);
  34. addAndMakeVisible(this->distortionDriveLabel);
  35. this->distortionMixSlider.setRange(0.0, 1.0);
  36. this->distortionMixSlider.setTextBoxStyle(juce::Slider::TextBoxRight, false, 100, 20);
  37. this->distortionMixSlider.addListener(this);
  38. this->distortionMixLabel.setText("Distortion Mix", juce::dontSendNotification);
  39. addAndMakeVisible(this->distortionMixSlider);
  40. addAndMakeVisible(this->distortionMixLabel);
  41. }
  42. CMLSProjectAudioProcessorEditor::~CMLSProjectAudioProcessorEditor()
  43. {
  44. }
  45. //==============================================================================
  46. void CMLSProjectAudioProcessorEditor::paint (juce::Graphics& g)
  47. {
  48. // (Our component is opaque, so we must completely fill the background with a solid colour)
  49. g.fillAll (getLookAndFeel().findColour (juce::ResizableWindow::backgroundColourId));
  50. }
  51. void CMLSProjectAudioProcessorEditor::resized()
  52. {
  53. // This is generally where you'll want to lay out the positions of any
  54. // subcomponents in your editor..
  55. equalizerLowGainSlider.setBounds(130, 10, getWidth() - 130, 20);
  56. equalizerLowGainLabel.setBounds(10, 10, 100, 20);
  57. equalizerHighGainSlider.setBounds(130, 30, getWidth() - 130, 20);
  58. equalizerHighGainLabel.setBounds(10, 30, 100, 20);
  59. distortionDriveSlider.setBounds(130, 70, getWidth() - 130, 20);
  60. distortionDriveLabel.setBounds(10, 70, 100, 20);
  61. distortionMixSlider.setBounds(130, 90, getWidth() - 130, 20);
  62. distortionMixLabel.setBounds(10, 90, 100, 20);
  63. }
  64. void CMLSProjectAudioProcessorEditor::sliderValueChanged(juce::Slider* slider) {
  65. if (slider == &this->equalizerLowGainSlider)
  66. {
  67. this->audioProcessor.setEqLowGain(slider->getValue());
  68. }
  69. else if (slider == &this->equalizerHighGainSlider)
  70. {
  71. this->audioProcessor.setEqHighGain(slider->getValue());
  72. }
  73. else if (slider == &this->distortionDriveSlider)
  74. {
  75. this->audioProcessor.setDistortionDrive(slider->getValue());
  76. }
  77. else if (slider == &this->distortionMixSlider)
  78. {
  79. this->audioProcessor.setDistortionMix(slider->getValue());
  80. }
  81. }