2
0
Fork 0
OB-Xd/Source/PluginEditor.cpp

555 lines
26 KiB
C++
Raw Normal View History

2017-01-23 10:15:08 +00:00
/*
==============================================================================
This file was auto-generated by the Introjucer!
It contains the basic startup code for a Juce application.
==============================================================================
*/
#include "PluginProcessor.h"
#include "PluginEditor.h"
#include <utility>
// #include "GUI/BinaryData.h"
//==============================================================================
ObxdAudioProcessorEditor::ObxdAudioProcessorEditor (ObxdAudioProcessor& ownerFilter)
: AudioProcessorEditor (&ownerFilter), processor (ownerFilter)
2017-01-23 10:15:08 +00:00
{
2020-04-20 20:57:41 +00:00
skinFolder = ownerFilter.getCurrentSkinFolder();
2020-04-21 13:08:05 +00:00
loadSkin(processor);
//rebuildComponents (processor);
//
//clean();
repaint();
}
void ObxdAudioProcessorEditor::loadSkin(ObxdAudioProcessor& ownerFilter){
ownerFilter.removeChangeListener (this);
2020-04-20 20:57:41 +00:00
//File coords("/Users/jimmy/Downloads/coords.xml");
2020-04-21 13:08:05 +00:00
skinFolder = ownerFilter.getCurrentSkinFolder();
2020-04-20 20:57:41 +00:00
File coords = skinFolder.getChildFile ("coords.xml");
bool useClassicSkin = coords.existsAsFile();
if (!useClassicSkin) {
rebuildComponents (processor);
return;
}
XmlDocument skin (coords);
XmlElement* doc = skin.getDocumentElement();
if (doc) {
2020-04-21 13:08:05 +00:00
2020-04-20 20:57:41 +00:00
if (doc->getTagName() == "PROPERTIES"){
2020-04-21 13:08:05 +00:00
2020-04-20 20:57:41 +00:00
forEachXmlChildElementWithTagName(*doc, child, "VALUE"){
if (child->hasAttribute("NAME") && child->hasAttribute("x") && child->hasAttribute("y")) {
String name = child->getStringAttribute("NAME");
int x = child->getIntAttribute("x");
int y = child->getIntAttribute("y");
int d = child->getIntAttribute("d");
2020-04-21 09:54:19 +00:00
int w = child->getIntAttribute("w");
int h = child->getIntAttribute("h");
2020-04-21 13:08:05 +00:00
if (name == "guisize"){ setSize (x, y); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "resonanceKnob"){ resonanceKnob = addKnob (x, y, d, ownerFilter, RESONANCE, "Resonance", 0); }
if (name == "cutoffKnob"){ cutoffKnob = addKnob (x, y, d, ownerFilter, CUTOFF, "Cutoff", 0.4); }
if (name == "filterEnvelopeAmtKnob"){ filterEnvelopeAmtKnob = addKnob (x, y, d, ownerFilter, ENVELOPE_AMT, "Envelope", 0); }
if (name == "multimodeKnob"){ multimodeKnob = addKnob (x, y, d, ownerFilter, MULTIMODE, "Multimode", 0.5); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "volumeKnob"){ volumeKnob = addKnob (x, y, d, ownerFilter, VOLUME, "Volume", 0.4); }
if (name == "portamentoKnob"){ portamentoKnob = addKnob (x, y, d, ownerFilter, PORTAMENTO, "Portamento", 0); }
if (name == "osc1PitchKnob"){ osc1PitchKnob = addKnob (x, y, d, ownerFilter, OSC1P, "Osc1Pitch", 0); }
if (name == "pulseWidthKnob"){ pulseWidthKnob = addKnob (x, y, d, ownerFilter, PW, "PW", 0); }
if (name == "osc2PitchKnob"){ osc2PitchKnob = addKnob (x, y, d, ownerFilter, OSC2P, "Osc2Pitch", 0); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "osc1MixKnob"){ osc1MixKnob = addKnob (x, y, d, ownerFilter, OSC1MIX, "Osc1", 1); }
if (name == "osc2MixKnob"){ osc2MixKnob = addKnob (x, y, d, ownerFilter, OSC2MIX, "Osc2", 1); }
if (name == "noiseMixKnob"){ noiseMixKnob = addKnob (x, y, d, ownerFilter, NOISEMIX, "Noise", 0); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "xmodKnob"){ xmodKnob = addKnob (x, y, d, ownerFilter, XMOD, "Xmod", 0); }
if (name == "osc2DetuneKnob"){ osc2DetuneKnob = addKnob (x, y, d, ownerFilter, OSC2_DET, "Detune", 0); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "envPitchModKnob"){ envPitchModKnob = addKnob (x, y, d, ownerFilter, ENVPITCH, "PEnv", 0); }
if (name == "brightnessKnob"){ brightnessKnob = addKnob (x, y, d, ownerFilter, BRIGHTNESS, "Bri", 1); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "attackKnob"){ attackKnob = addKnob (x, y, d, ownerFilter, LATK, "Atk", 0); }
if (name == "decayKnob"){ decayKnob = addKnob (x, y, d, ownerFilter, LDEC, "Dec", 0); }
if (name == "sustainKnob"){ sustainKnob = addKnob (x, y, d, ownerFilter, LSUS, "Sus", 1); }
if (name == "releaseKnob"){ releaseKnob = addKnob (x, y, d, ownerFilter, LREL, "Rel", 0); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "fattackKnob"){ fattackKnob = addKnob (x, y, d, ownerFilter, FATK, "Atk", 0); }
if (name == "fdecayKnob"){ fdecayKnob = addKnob (x, y, d, ownerFilter, FDEC, "Dec", 0); }
if (name == "fsustainKnob"){ fsustainKnob = addKnob (x, y, d, ownerFilter, FSUS, "Sus", 1); }
if (name == "freleaseKnob"){ freleaseKnob = addKnob (x, y, d, ownerFilter, FREL, "Rel", 0); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "lfoFrequencyKnob"){ lfoFrequencyKnob = addKnob (x, y, d, ownerFilter, LFOFREQ, "Freq", 0); }
if (name == "lfoAmt1Knob"){ lfoAmt1Knob = addKnob (x, y, d, ownerFilter, LFO1AMT, "Pitch", 0); }
if (name == "lfoAmt2Knob"){ lfoAmt2Knob = addKnob (x, y, d, ownerFilter, LFO2AMT, "PWM", 0); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "lfoSinButton"){ lfoSinButton = addButton (x, y, ownerFilter, LFOSINWAVE, "Sin"); }
if (name == "lfoSquareButton"){ lfoSquareButton = addButton (x, y, ownerFilter, LFOSQUAREWAVE, "SQ"); }
if (name == "lfoSHButton"){ lfoSHButton = addButton (x, y, ownerFilter, LFOSHWAVE, "S&H"); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "lfoOsc1Button"){ lfoOsc1Button = addButton (x, y, ownerFilter, LFOOSC1, "Osc1"); }
if (name == "lfoOsc2Button"){ lfoOsc2Button = addButton (x, y, ownerFilter, LFOOSC2, "Osc2"); }
if (name == "lfoFilterButton"){ lfoFilterButton = addButton (x, y, ownerFilter, LFOFILTER, "Filt"); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "lfoPwm1Button"){ lfoPwm1Button = addButton (x, y, ownerFilter, LFOPW1, "Osc1"); }
if (name == "lfoPwm2Button"){ lfoPwm2Button = addButton (x, y, ownerFilter, LFOPW2, "Osc2"); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "hardSyncButton"){ hardSyncButton = addButton (x, y, ownerFilter, OSC2HS, "Sync"); }
if (name == "osc1SawButton"){ osc1SawButton = addButton (x, y, ownerFilter, OSC1Saw, "S"); }
if (name == "osc2SawButton"){ osc2SawButton = addButton (x, y, ownerFilter, OSC2Saw, "S"); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "osc1PulButton"){ osc1PulButton = addButton (x, y, ownerFilter, OSC1Pul, "P"); }
if (name == "osc2PulButton"){ osc2PulButton = addButton (x, y, ownerFilter, OSC2Pul, "P"); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "pitchQuantButton"){ pitchQuantButton = addButton (x, y, ownerFilter, OSCQuantize, "Step"); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "filterBPBlendButton"){ filterBPBlendButton = addButton (x, y, ownerFilter, BANDPASS, "Bp"); }
if (name == "fourPoleButton"){ fourPoleButton = addButton (x, y, ownerFilter, FOURPOLE, "24"); }
if (name == "filterHQButton"){ filterHQButton = addButton (x, y, ownerFilter, FILTER_WARM, "HQ"); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "filterKeyFollowButton"){ filterKeyFollowButton = addButton (x, y, ownerFilter, FLT_KF, "Key"); }
if (name == "unisonButton"){ unisonButton = addButton (x, y, ownerFilter, UNISON, "Uni"); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "tuneKnob"){ tuneKnob = addKnob (x, y, d, ownerFilter, TUNE, "Tune", 0.5); }
if (name == "transposeKnob"){ transposeKnob = addKnob (x, y, d, ownerFilter, OCTAVE, "Transpose", 0.5); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "voiceDetuneKnob"){ voiceDetuneKnob =addKnob (x, y, d, ownerFilter, UDET, "VoiceDet", 0); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "bendLfoRateKnob"){ bendLfoRateKnob = addKnob (x, y, d, ownerFilter, BENDLFORATE, "ModRate", 0.4); }
if (name == "veloFltEnvKnob"){ veloFltEnvKnob = addKnob (x, y, d, ownerFilter, VFLTENV, "VFE", 0); }
if (name == "veloAmpEnvKnob"){ veloAmpEnvKnob = addKnob (x, y, d, ownerFilter, VAMPENV, "VAE", 0); }
if (name == "midiLearnButton"){ midiLearnButton = addButton (x, y, ownerFilter, MIDILEARN, "LEA"); }
if (name == "midiUnlearnButton"){ midiUnlearnButton = addButton (x, y, ownerFilter, UNLEARN, "UNL"); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "pan1Knob"){ pan1Knob = addKnob (x, y, d, ownerFilter, PAN1, "1", 0.5); }
if (name == "pan2Knob"){ pan2Knob = addKnob (x, y, d, ownerFilter, PAN2, "2", 0.5); }
if (name == "pan3Knob"){ pan3Knob = addKnob (x, y, d, ownerFilter, PAN3, "3", 0.5); }
if (name == "pan4Knob"){ pan4Knob = addKnob (x, y, d, ownerFilter, PAN4, "4", 0.5); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "pan5Knob"){ pan5Knob = addKnob (x, y, d, ownerFilter, PAN5, "5", 0.5); }
if (name == "pan6Knob"){ pan6Knob = addKnob (x, y, d, ownerFilter, PAN6, "6", 0.5); }
if (name == "pan7Knob"){ pan7Knob = addKnob (x, y, d, ownerFilter, PAN7, "7", 0.5); }
if (name == "pan8Knob"){ pan8Knob = addKnob (x, y, d, ownerFilter, PAN8, "8", 0.5); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "bendOsc2OnlyButton"){ bendOsc2OnlyButton = addButton (x, y, ownerFilter, BENDOSC2, "Osc2"); }
if (name == "bendRangeButton"){ bendRangeButton = addButton (x, y, ownerFilter, BENDRANGE, "12"); }
if (name == "asPlayedAllocButton"){ asPlayedAllocButton = addButton (x, y, ownerFilter, ASPLAYEDALLOCATION, "APA"); }
2020-04-20 20:57:41 +00:00
2020-04-21 08:53:36 +00:00
if (name == "filterDetuneKnob"){ filterDetuneKnob = addKnob (x, y, d, ownerFilter, FILTERDER, "Flt", 0.2); }
if (name == "portamentoDetuneKnob"){ portamentoDetuneKnob = addKnob (x, y, d, ownerFilter, PORTADER, "Port", 0.2); }
if (name == "envelopeDetuneKnob"){ envelopeDetuneKnob = addKnob (x, y, d, ownerFilter, ENVDER, "Env", 0.2); }
2020-04-21 13:08:05 +00:00
if (name == "voiceSwitch"){
//if (voiceSwitch) voiceSwitch->setVisible(false);
voiceSwitch = addList (x, y, w, h, ownerFilter, VOICE_COUNT, "VoiceCount", ImageCache::getFromFile(skinFolder.getChildFile("voices.png"))); }
if (name == "legatoSwitch"){
//if (legatoSwitch) legatoSwitch->setVisible(false);
legatoSwitch = addList (x, y, w, h, ownerFilter, LEGATOMODE, "Legato", ImageCache::getFromFile(skinFolder.getChildFile("legato.png"))); }
2020-04-20 20:57:41 +00:00
//DBG(" Name: " << name << " X: " <<x <<" Y: "<<y);
}
}
}
}
// Prepare data
if (voiceSwitch){
for (int i = 1; i <= 32; ++i)
{
voiceSwitch->addChoice (String (i));
2020-04-21 13:08:05 +00:00
voiceSwitch ->setValue(ownerFilter.getParameter(VOICE_COUNT),dontSendNotification);
2020-04-20 20:57:41 +00:00
}
}
if (legatoSwitch) {
legatoSwitch->addChoice ("Keep All");
legatoSwitch->addChoice ("Keep Filter Envelope");
legatoSwitch->addChoice ("Keep Amplitude Envelope");
legatoSwitch->addChoice ("Retrig");
2020-04-21 13:08:05 +00:00
legatoSwitch ->setValue(ownerFilter.getParameter(LEGATOMODE),dontSendNotification);
2020-04-20 20:57:41 +00:00
}
2020-04-21 13:08:05 +00:00
ownerFilter.addChangeListener (this);
2020-04-20 20:57:41 +00:00
repaint();
2017-01-23 10:15:08 +00:00
}
ObxdAudioProcessorEditor::~ObxdAudioProcessorEditor()
{
processor.removeChangeListener (this);
// deleteAllChildren(); // WATCH OUT!
2017-01-23 10:15:08 +00:00
}
void ObxdAudioProcessorEditor::placeLabel (int x, int y, String text)
2017-01-23 10:15:08 +00:00
{
Label* lab = new Label();
lab->setBounds (x, y, 110, 20);
lab->setJustificationType (Justification::centred);
lab->setText (text,dontSendNotification);
lab->setInterceptsMouseClicks (false, true);
addAndMakeVisible (lab);
2017-01-23 10:15:08 +00:00
}
2020-04-21 09:54:19 +00:00
ButtonList* ObxdAudioProcessorEditor::addList (int x, int y, int width, int height, ObxdAudioProcessor& filter, int parameter, String /*name*/, Image img)
2017-01-23 10:15:08 +00:00
{
2020-04-21 09:54:19 +00:00
ButtonList *bl = new ButtonList (img, height);
bl->setBounds (x, y, width, height);
2017-01-23 10:15:08 +00:00
//bl->setValue(filter->getParameter(parameter),dontSendNotification);
addAndMakeVisible (bl);
// bl->addListener (this);
2017-01-23 10:15:08 +00:00
return bl;
}
2020-04-21 08:53:36 +00:00
Knob* ObxdAudioProcessorEditor::addKnob (int x, int y, int d, ObxdAudioProcessor& filter, int parameter, String /*name*/, float defval)
2017-01-23 10:15:08 +00:00
{
2020-04-21 07:51:15 +00:00
Knob* knob = new Knob (ImageCache::getFromFile(skinFolder.getChildFile("knob.png")), 144);
2017-01-23 10:15:08 +00:00
//Label* knobl = new Label();
knob->setSliderStyle (Slider::RotaryVerticalDrag);
knob->setTextBoxStyle (knob->NoTextBox, true, 0, 0);
knob->setRange (0, 1);
addAndMakeVisible (knob);
2017-01-23 10:15:08 +00:00
//addAndMakeVisible(knobl);
2020-04-21 13:08:05 +00:00
knob->setBounds (x, y, d+(d/6), d+(d/6));
// knob->setValue (filter.getParameter (parameter), dontSendNotification);
2017-01-23 10:15:08 +00:00
//knobl->setJustificationType(Justification::centred);
//knobl->setInterceptsMouseClicks(false,true);
//knobl->setBounds(x-10,y+40,60,10);
//knobl->setText(name,dontSendNotification);
knob->setTextBoxIsEditable (false);
knob->setDoubleClickReturnValue (true, defval);
// knob->addListener (this);
knobAttachments.add (new Knob::KnobAttachment (filter.getPluginState(),
2020-04-21 08:53:36 +00:00
filter.getEngineParameterId (parameter),
*knob));
2017-01-23 10:15:08 +00:00
return knob;
}
2020-04-21 13:08:05 +00:00
void ObxdAudioProcessorEditor::clean(){
this->removeAllChildren();
/*
//knobAttachments.clearQuick(true);
//toggleAttachments.clearQuick(true);
//buttonListAttachments.clearQuick(true);
for (auto knob : {&cutoffKnob,&resonanceKnob,&osc1PitchKnob,&osc2PitchKnob,&osc2DetuneKnob,&volumeKnob, &portamentoKnob,&voiceDetuneKnob,&filterEnvelopeAmtKnob,&pulseWidthKnob,&xmodKnob,&multimodeKnob,&attackKnob,&decayKnob,&sustainKnob,&releaseKnob,
&fattackKnob,&fdecayKnob,&fsustainKnob,&freleaseKnob,&osc1MixKnob,&osc2MixKnob,&noiseMixKnob,
&filterDetuneKnob,&envelopeDetuneKnob,&portamentoDetuneKnob,
&tuneKnob,
&lfoFrequencyKnob,&lfoAmt1Knob,&lfoAmt2Knob,
&pan1Knob,&pan2Knob,&pan3Knob,&pan4Knob,&pan5Knob,&pan6Knob,&pan7Knob,&pan8Knob
}){
if (*knob){
(*knob)->deleteAllChildren();
delete *knob;
*knob = nullptr;
}
}
for (auto btn : {&osc1SawButton,&osc2SawButton,&osc1PulButton,&osc2PulButton,&filterKeyFollowButton,&unisonButton,&pitchQuantButton,
&filterHQButton,&filterBPBlendButton,
&lfoSinButton,&lfoSquareButton,&lfoSHButton,&lfoOsc1Button,&lfoOsc2Button,&lfoFilterButton,
&lfoPwm1Button,&lfoPwm2Button,
&bendRangeButton,&bendOsc2OnlyButton,
&fourPoleButton,&asPlayedAllocButton,&midiLearnButton,&midiUnlearnButton}){
if (*btn){
(*btn)->deleteAllChildren();
delete *btn;
*btn = nullptr;
}
}
for (auto list :{
&voiceSwitch,&legatoSwitch}){
if (*list){
(*list)->deleteAllChildren();
delete *list;
*list = nullptr;
}
}
*/
}
2020-04-21 08:53:36 +00:00
TooglableButton* ObxdAudioProcessorEditor::addButton (int x, int y, ObxdAudioProcessor& filter, int parameter, String name)
2017-01-23 10:15:08 +00:00
{
2020-04-20 20:57:41 +00:00
TooglableButton* button = new TooglableButton (ImageCache::getFromFile(skinFolder.getChildFile("button.png")));
2017-01-23 10:15:08 +00:00
// button->setButtonStyle(DrawableButton::ButtonStyle::ImageAboveTextLabel);
addAndMakeVisible (button);
button->setBounds (x, y, 19, 35);
button->setButtonText (name);
// button->setValue(filter.getParameter(parameter),0);
// button->addListener(this);
toggleAttachments.add (new TooglableButton::ToggleAttachment (filter.getPluginState(),
filter.getEngineParameterId (parameter),
*button));
2017-01-23 10:15:08 +00:00
return button;
}
void ObxdAudioProcessorEditor::rebuildComponents (ObxdAudioProcessor& ownerFilter)
2017-01-23 10:15:08 +00:00
{
skinFolder = ownerFilter.getCurrentSkinFolder();
//bool useClassicSkin = skinFolder.getChildFile ("legato.png").existsAsFile();
2017-01-23 10:15:08 +00:00
ownerFilter.removeChangeListener (this);
2017-01-23 10:15:08 +00:00
// deleteAllChildren(); // WATCH OUT!
2017-01-23 10:15:08 +00:00
setSize (1440, 450);
2020-04-21 08:53:36 +00:00
cutoffKnob = addKnob (893, 77, 48, ownerFilter, CUTOFF, "Cutoff", 0.4);
resonanceKnob = addKnob (990, 77, 48, ownerFilter, RESONANCE, "Resonance", 0);
filterEnvelopeAmtKnob = addKnob (1088, 77, 48, ownerFilter, ENVELOPE_AMT, "Envelope", 0);
multimodeKnob = addKnob (990, 167, 48, ownerFilter, MULTIMODE, "Multimode", 0.5);
2020-04-21 08:53:36 +00:00
volumeKnob = addKnob (56, 77, 48, ownerFilter, VOLUME, "Volume", 0.4);
portamentoKnob = addKnob (188, 77, 48, ownerFilter, PORTAMENTO, "Portamento", 0);
osc1PitchKnob = addKnob (593, 77, 48, ownerFilter, OSC1P, "Osc1Pitch", 0);
pulseWidthKnob = addKnob (691, 77, 48, ownerFilter, PW, "PW", 0);
osc2PitchKnob = addKnob (788, 77, 48, ownerFilter, OSC2P, "Osc2Pitch", 0);
2020-04-21 08:53:36 +00:00
osc1MixKnob = addKnob (597, 237, 48, ownerFilter, OSC1MIX, "Osc1", 1);
osc2MixKnob = addKnob (788, 237, 48, ownerFilter, OSC2MIX, "Osc2", 1);
noiseMixKnob = addKnob (691, 237, 48, ownerFilter, NOISEMIX, "Noise", 0);
2020-04-21 08:53:36 +00:00
xmodKnob = addKnob (656, 324, 48, ownerFilter, XMOD, "Xmod", 0);
osc2DetuneKnob = addKnob (800, 324, 48, ownerFilter, OSC2_DET, "Detune", 0);
2020-04-21 08:53:36 +00:00
envPitchModKnob = addKnob (728, 324, 48, ownerFilter, ENVPITCH, "PEnv", 0);
brightnessKnob = addKnob (586, 324, 48, ownerFilter, BRIGHTNESS, "Bri", 1);
2020-04-21 08:53:36 +00:00
attackKnob = addKnob (1182, 165, 48, ownerFilter, LATK, "Atk", 0);
decayKnob = addKnob (1246, 165, 48, ownerFilter, LDEC, "Dec", 0);
sustainKnob = addKnob (1309, 165, 48, ownerFilter, LSUS, "Sus", 1);
releaseKnob = addKnob (1373, 165, 48, ownerFilter, LREL, "Rel", 0);
2020-04-21 08:53:36 +00:00
fattackKnob = addKnob (1182, 75, 48, ownerFilter, FATK, "Atk", 0);
fdecayKnob = addKnob (1246, 75, 48, ownerFilter, FDEC, "Dec", 0);
fsustainKnob = addKnob (1309, 75, 48, ownerFilter, FSUS, "Sus", 1);
freleaseKnob = addKnob (1373, 75, 48, ownerFilter, FREL, "Rel", 0);
2020-04-21 08:53:36 +00:00
lfoFrequencyKnob = addKnob (293, 77, 48, ownerFilter, LFOFREQ, "Freq", 0);
lfoAmt1Knob = addKnob (390, 77, 48, ownerFilter, LFO1AMT, "Pitch", 0);
lfoAmt2Knob = addKnob (488, 77, 48, ownerFilter, LFO2AMT, "PWM", 0);
2020-04-21 08:53:36 +00:00
lfoSinButton = addButton (309, 162, ownerFilter, LFOSINWAVE, "Sin");
lfoSquareButton = addButton (309, 252, ownerFilter, LFOSQUAREWAVE, "SQ");
lfoSHButton = addButton (309, 335, ownerFilter, LFOSHWAVE, "S&H");
2020-04-21 08:53:36 +00:00
lfoOsc1Button = addButton (406, 162, ownerFilter, LFOOSC1, "Osc1");
lfoOsc2Button = addButton (406, 252, ownerFilter, LFOOSC2, "Osc2");
lfoFilterButton = addButton (406, 335, ownerFilter, LFOFILTER, "Filt");
2020-04-21 08:53:36 +00:00
lfoPwm1Button = addButton (504, 162, ownerFilter, LFOPW1, "Osc1");
lfoPwm2Button = addButton (504, 252, ownerFilter, LFOPW2, "Osc2");
2020-04-21 08:53:36 +00:00
hardSyncButton = addButton (730, 162, ownerFilter, OSC2HS, "Sync");
osc1SawButton = addButton (587, 162, ownerFilter, OSC1Saw, "S");
osc2SawButton = addButton (782, 162, ownerFilter, OSC2Saw, "S");
2020-04-21 08:53:36 +00:00
osc1PulButton = addButton (632, 162, ownerFilter, OSC1Pul, "P");
osc2PulButton = addButton (827, 162, ownerFilter, OSC2Pul, "P");
2020-04-21 08:53:36 +00:00
pitchQuantButton = addButton (684, 162, ownerFilter, OSCQuantize, "Step");
2020-04-21 08:53:36 +00:00
filterBPBlendButton = addButton (1082, 162, ownerFilter, BANDPASS, "Bp");
fourPoleButton = addButton (1127, 162, ownerFilter, FOURPOLE, "24");
filterHQButton = addButton (932, 162, ownerFilter, FILTER_WARM, "HQ");
2020-04-21 08:53:36 +00:00
filterKeyFollowButton = addButton (887, 162, ownerFilter, FLT_KF, "Key");
unisonButton = addButton (205, 162, ownerFilter, UNISON, "Uni");
2020-04-21 08:53:36 +00:00
tuneKnob = addKnob (30, 252, 48, ownerFilter, TUNE, "Tune", 0.5);
transposeKnob = addKnob (90, 252, 48, ownerFilter, OCTAVE, "Transpose", 0.5);
2020-04-21 08:53:36 +00:00
voiceDetuneKnob = addKnob (188, 252, 48, ownerFilter, UDET, "VoiceDet", 0);
2020-04-21 08:53:36 +00:00
bendLfoRateKnob = addKnob (928, 300, 36, ownerFilter, BENDLFORATE, "ModRate", 0.4);
veloFltEnvKnob = addKnob (1013, 300, 36, ownerFilter, VFLTENV, "VFE", 0);
veloAmpEnvKnob = addKnob (1111, 300, 36, ownerFilter, VAMPENV, "VAE", 0);
2020-04-21 08:53:36 +00:00
midiLearnButton = addButton (74, 162, ownerFilter, MIDILEARN, "LEA");
midiUnlearnButton = addButton (122, 162, ownerFilter, UNLEARN, "UNL");
2020-04-21 08:53:36 +00:00
pan1Knob = addKnob (914, 368, 36, ownerFilter, PAN1, "1", 0.5);
pan2Knob = addKnob (977, 368, 36, ownerFilter, PAN2, "2", 0.5);
pan3Knob = addKnob (1040, 368, 36, ownerFilter, PAN3, "3", 0.5);
pan4Knob = addKnob (1103, 368, 36, ownerFilter, PAN4, "4", 0.5);
2020-04-21 08:53:36 +00:00
pan5Knob = addKnob (1165, 368, 36, ownerFilter, PAN5, "5", 0.5);
pan6Knob = addKnob (1228, 368, 36, ownerFilter, PAN6, "6", 0.5);
pan7Knob = addKnob (1290, 368, 36, ownerFilter, PAN7, "7", 0.5);
pan8Knob = addKnob (1353, 368, 36, ownerFilter, PAN8, "8", 0.5);
2020-04-21 08:53:36 +00:00
bendOsc2OnlyButton = addButton (228, 335, ownerFilter, BENDOSC2, "Osc2");
bendRangeButton = addButton (183, 335, ownerFilter, BENDRANGE, "12");
asPlayedAllocButton = addButton (25, 162, ownerFilter, ASPLAYEDALLOCATION, "APA");
2020-04-21 08:53:36 +00:00
filterDetuneKnob = addKnob (1228, 300, 36, ownerFilter, FILTERDER, "Flt", 0.2);
portamentoDetuneKnob = addKnob (1291, 300, 36, ownerFilter, PORTADER, "Port", 0.2);
envelopeDetuneKnob = addKnob (1353, 300, 36, ownerFilter, ENVDER, "Env", 0.2);
2020-04-21 09:54:19 +00:00
voiceSwitch = addList (124, 338, 17, 24, ownerFilter, VOICE_COUNT, "VoiceCount", ImageCache::getFromMemory (BinaryData::voices_png, BinaryData::voices_pngSize));
for (int i = 1; i <= 32; ++i)
{
voiceSwitch->addChoice (String (i));
}
2020-04-21 09:54:19 +00:00
legatoSwitch = addList (25, 338, 65, 24, ownerFilter, LEGATOMODE, "Legato", ImageCache::getFromMemory (BinaryData::legato_png, BinaryData::legato_pngSize));
legatoSwitch->addChoice ("Keep All");
legatoSwitch->addChoice ("Keep Filter Envelope");
legatoSwitch->addChoice ("Keep Amplitude Envelope");
legatoSwitch->addChoice ("Retrig");
buttonListAttachments.add (new ButtonList::ButtonListAttachment (ownerFilter.getPluginState(),
ownerFilter.getEngineParameterId (VOICE_COUNT),
*voiceSwitch));
buttonListAttachments.add (new ButtonList::ButtonListAttachment (ownerFilter.getPluginState(),
ownerFilter.getEngineParameterId (LEGATOMODE),
*legatoSwitch));
2020-04-20 20:57:41 +00:00
ownerFilter.addChangeListener (this);
2017-01-23 10:15:08 +00:00
repaint();
}
//void ObxdAudioProcessorEditor::buttonClicked(Button * b)
//{
//}
//void ObxdAudioProcessorEditor::comboBoxChanged (ComboBox* cb)
//{
// ButtonList* bl = (ButtonList*)(cb);
// ObxdAudioProcessor* flt = getFilter();
// #define cp(T) {flt->setParameterNotifyingHost(T,bl->getValue());}
//#define handleCParam(K,T) if (bl == K) {cp(T)} else
// handleCParam(voiceSwitch,VOICE_COUNT)
// handleCParam(legatoSwitch,LEGATOMODE)
// {};
//}
//void ObxdAudioProcessorEditor::sliderValueChanged (Slider* c)
//{
//}
2017-01-23 10:15:08 +00:00
//==============================================================================
void ObxdAudioProcessorEditor::changeListenerCallback (ChangeBroadcaster* source)
{
repaint();
2017-01-23 10:15:08 +00:00
}
void ObxdAudioProcessorEditor::mouseUp(const MouseEvent& e)
{
if (e.mods.isRightButtonDown() || e.mods.isCommandDown())
{
PopupMenu menu;
PopupMenu skinMenu;
PopupMenu bankMenu;
PopupMenu progMenu;
2017-01-23 10:15:08 +00:00
Array<File> skins;
const Array<File>& banks = processor.getBankFiles();
2017-01-23 10:15:08 +00:00
int skinStart = 0;
{
DirectoryIterator it(processor.getSkinFolder(), false, "*", File::findDirectories);
2017-01-23 10:15:08 +00:00
while (it.next())
{
2019-09-01 17:02:11 +00:00
skins.addUsingDefaultSort(it.getFile());
2017-01-23 10:15:08 +00:00
}
for (int i = 0; i < skins.size(); ++i)
{
const File skin = skins.getUnchecked(i);
skinMenu.addItem(i + skinStart + 1, skin.getFileName(), true, skin.getFileName() == skinFolder.getFileName());
}
menu.addSubMenu("Skins", skinMenu);
}
int bankStart = 1000;
{
const String currentBank = processor.getCurrentBankFile().getFileName();
2017-01-23 10:15:08 +00:00
for (int i = 0; i < banks.size(); ++i)
{
const File bank = banks.getUnchecked(i);
bankMenu.addItem(i + bankStart + 1, bank.getFileNameWithoutExtension(), true, bank.getFileName() == currentBank);
2017-01-23 10:15:08 +00:00
}
menu.addSubMenu("Banks", bankMenu);
}
int progStart = 2000;
{
for (int i = 0; i < processor.getNumPrograms(); ++i)
{
progMenu.addItem(i + progStart + 1, processor.getProgramName(i), true, i == processor.getCurrentProgram());
}
menu.addSubMenu("Programs", progMenu);
}
2017-01-23 10:15:08 +00:00
const Point<int> pos = e.getMouseDownScreenPosition();
int result = menu.showAt(Rectangle<int>(pos.getX(), pos.getY(), 1, 1));
if (result >= (skinStart + 1) && result <= (skinStart + skins.size()))
{
result -= 1;
result -= skinStart;
const File newSkinFolder = skins.getUnchecked(result);
processor.setCurrentSkinFolder(newSkinFolder.getFileName());
2017-01-23 10:15:08 +00:00
2020-04-21 13:08:05 +00:00
//rebuildComponents (processor);
clean();
loadSkin(processor);
2017-01-23 10:15:08 +00:00
}
else if (result >= (bankStart + 1) && result <= (bankStart + banks.size()))
{
result -= 1;
result -= bankStart;
const File bankFile = banks.getUnchecked(result);
processor.loadFromFXBFile (bankFile);
2017-01-23 10:15:08 +00:00
}
else if (result >= (progStart + 1) && result <= (progStart + processor.getNumPrograms()))
{
result -= 1;
result -= progStart;
processor.setCurrentProgram (result);
}
2017-01-23 10:15:08 +00:00
}
}
void ObxdAudioProcessorEditor::paint(Graphics& g)
{
g.fillAll (Colours::white);
const File mainFile(skinFolder.getChildFile("main.png"));
if (skinFolder.exists() && mainFile.exists())
{
const Image image = ImageCache::getFromFile(mainFile);
g.drawImage (image,
0, 0, image.getWidth(), image.getHeight(),
0, 0, image.getWidth(), image.getHeight());
}
else
{
const Image image = ImageCache::getFromMemory(BinaryData::main_png, BinaryData::main_pngSize);
g.drawImage (image,
0, 0, image.getWidth(), image.getHeight(),
0, 0, image.getWidth(), image.getHeight());
}
}