#include "ui.hpp" #include "chassis.hpp" START_NAMESPACE_DISTRHO namespace Art = Artwork; void prepSlider(ImageSlider* s, uint id, int x, int y) { s->setId(id); s->setStartPos(x, y); s->setEndPos(x, y + 79); // 80px high s->setInverted(true); s->setRange(0, 127.0f); } DistrhoUIchassis::DistrhoUIchassis() : UI(Art::backgroundWidth, Art::backgroundHeight, true), fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, kImageFormatRGB), fImgLedOn(Art::ledOnData, Art::ledWidth, Art::ledHeight, kImageFormatRGBA) { Image orangeSlider(Art::orangeData, Art::sliderWidth, Art::sliderHeight, kImageFormatRGBA); Image greenSlider(Art::greenData, Art::sliderWidth, Art::sliderHeight, kImageFormatRGBA); Image blueSlider(Art::blueData, Art::sliderWidth, Art::sliderHeight, kImageFormatRGBA); Image whiteSlider(Art::whiteData, Art::sliderWidth, Art::sliderHeight, kImageFormatRGBA); xSliderLFORate = new ImageSlider(this, orangeSlider); prepSlider(xSliderLFORate, Chassis::pLFORate, 50, 72); xSliderLFORate->setCallback(this); xSliderLFODelay = new ImageSlider(this, orangeSlider); prepSlider(xSliderLFODelay, Chassis::pLFODelay, 90, 72); xSliderLFODelay->setCallback(this); xSliderLFODepth = new ImageSlider(this, greenSlider); prepSlider(xSliderLFODepth, Chassis::pLFODepth, 292, 72); xSliderLFODepth->setCallback(this); xSliderPWMDepth = new ImageSlider(this, greenSlider); prepSlider(xSliderPWMDepth, Chassis::pPWMDepth, 331, 72); xSliderPWMDepth->setCallback(this); xSliderSubLevel = new ImageSlider(this, greenSlider); prepSlider(xSliderSubLevel, Chassis::pSubLevel, 517, 72); xSliderSubLevel->setCallback(this); xSliderNoiseLevel = new ImageSlider(this, greenSlider); prepSlider(xSliderNoiseLevel, Chassis::pNoiseLevel, 558, 72); xSliderNoiseLevel->setCallback(this); // FIXME - put the stops back in xSliderHPF = new ImageSlider(this, blueSlider); prepSlider(xSliderHPF, Chassis::pHPF, 618, 72); xSliderHPF->setCallback(this); xSliderCutoff = new ImageSlider(this, blueSlider); prepSlider(xSliderCutoff, Chassis::pCutoff, 21, 261); xSliderCutoff->setCallback(this); xSliderRes = new ImageSlider(this, blueSlider); prepSlider(xSliderRes, Chassis::pRes, 60, 261); xSliderRes->setCallback(this); xSliderEnv = new ImageSlider(this, blueSlider); prepSlider(xSliderEnv, Chassis::pEnv, 144, 261); xSliderEnv->setCallback(this); xSliderLfo = new ImageSlider(this, blueSlider); prepSlider(xSliderLfo, Chassis::pLfo, 183, 261); xSliderLfo->setCallback(this); xSliderKyb = new ImageSlider(this, blueSlider); prepSlider(xSliderKyb, Chassis::pKyb, 222, 261); xSliderKyb->setCallback(this); xSliderVCALevel = new ImageSlider(this, whiteSlider); prepSlider(xSliderVCALevel, Chassis::pVCALevel, 314, 261); xSliderVCALevel->setCallback(this); xSliderAtk = new ImageSlider(this, whiteSlider); prepSlider(xSliderAtk, Chassis::pVCALevel, 375, 261); xSliderAtk->setCallback(this); xSliderDcy = new ImageSlider(this, whiteSlider); prepSlider(xSliderDcy, Chassis::pDcy, 414, 261); xSliderDcy->setCallback(this); xSliderStn = new ImageSlider(this, whiteSlider); prepSlider(xSliderStn, Chassis::pStn, 454, 261); xSliderStn->setCallback(this); xSliderRls = new ImageSlider(this, whiteSlider); prepSlider(xSliderRls, Chassis::pRls, 493, 261); xSliderRls->setCallback(this); xBtn16ft = new ImageButton(this, Image(Art::orngBtnUp, Art::orngBtnWidth, Art::orngBtnHeight, kImageFormatRGB), Image(Art::orngBtnDn, Art::orngBtnWidth, Art::orngBtnHeight, kImageFormatRGB)); xBtn16ft->setAbsolutePos(149, 103); xBtn16ft->setId(Chassis::btn16); xBtn16ft->setCallback(this); xBtn8ft = new ImageButton(this, Image(Art::orngBtnUp, Art::orngBtnWidth, Art::orngBtnHeight, kImageFormatRGB), Image(Art::orngBtnDn, Art::orngBtnWidth, Art::orngBtnHeight, kImageFormatRGB)); xBtn8ft->setAbsolutePos(190, 103); xBtn8ft->setId(Chassis::btn8); xBtn8ft->setCallback(this); xBtn4ft = new ImageButton(this, Image(Art::orngBtnUp, Art::orngBtnWidth, Art::orngBtnHeight, kImageFormatRGB), Image(Art::orngBtnDn, Art::orngBtnWidth, Art::orngBtnHeight, kImageFormatRGB)); xBtn4ft->setAbsolutePos(231, 103); xBtn4ft->setId(Chassis::btn4); xBtn4ft->setCallback(this); programLoaded(0); } DistrhoUIchassis::~DistrhoUIchassis() { printf("Called destructor for UI\n"); } void DistrhoUIchassis::programLoaded(uint32_t index) { switch (index) { case Chassis::pLFORate: xSliderLFORate->setValue(0.5); break; case Chassis::pLFODelay: xSliderLFODelay->setValue(0.5); break; } } void DistrhoUIchassis::parameterChanged(uint32_t index, float value) { switch (index) { case Chassis::pLFORate: xSliderLFORate->setValue(value); break; case Chassis::pLFODelay: xSliderLFODelay->setValue(value); break; case Chassis::pLFODepth: xSliderLFODepth->setValue(value); break; case Chassis::pPWMDepth: xSliderPWMDepth->setValue(value); break; case Chassis::pSubLevel: xSliderSubLevel->setValue(value); break; case Chassis::pNoiseLevel: xSliderNoiseLevel->setValue(value); break; case Chassis::pHPF: xSliderHPF->setValue(value); break; case Chassis::pCutoff: xSliderCutoff->setValue(value); break; case Chassis::pRes: xSliderRes->setValue(value); break; case Chassis::pEnv: xSliderEnv->setValue(value); break; case Chassis::pLfo: xSliderLfo->setValue(value); break; case Chassis::pKyb: xSliderKyb->setValue(value); break; case Chassis::pAtk: xSliderAtk->setValue(value); break; case Chassis::pDcy: xSliderDcy->setValue(value); break; case Chassis::pStn: xSliderStn->setValue(value); break; case Chassis::pRls: xSliderRls->setValue(value); break; // now the switches case Chassis::pVCORange: sw1 &= 0xf8; // mask if (value > 2) value = 2; sw1 |= (1 << (int)value); break; case Chassis::pSqr: sw1 &= 0xf7; sw1 |= ((value >= 0.5)) << 3; break; case Chassis::pSaw: sw1 &= 0xef; sw1 |= (value > 0.5) << 4; break; case Chassis::pChorus: sw1 &= 0x9f; // 60, 40, 00 switch ((int)value) { case 0: sw1 |= 0x60; break; case 1: sw1 |= 0x40; break; case 2: sw1 |= 0x00; break; } } } void DistrhoUIchassis::imageSliderDragStarted(ImageSlider* slider) { editParameter(slider->getId(), true); } void DistrhoUIchassis::imageSliderDragFinished(ImageSlider* slider) { editParameter(slider->getId(), false); } void DistrhoUIchassis::imageSliderValueChanged(ImageSlider* slider, float value) { setParameterValue(slider->getId(), value); } void DistrhoUIchassis::imageButtonClicked(ImageButton* imgBtn, int) { int id = imgBtn->getId(); // printf("imagebutton %d\n", id); switch (id) { case Chassis::btn16: sw1 &= 0xf8; sw1 |= 0x01; break; case Chassis::btn8: sw1 &= 0xf8; sw1 |= 0x02; break; case Chassis::btn4: sw1 &= 0xf8; sw1 |= 0x04; break; default: break; } } void DistrhoUIchassis::onDisplay() { const GraphicsContext& context(getGraphicsContext()); fImgBackground.draw(context); // switch 1 LEDs if (sw1 & 0x01) fImgLedOn.drawAt(context, 160, 77); // 16' if (sw1 & 0x02) fImgLedOn.drawAt(context, 198, 77); // 8' if (sw1 & 0x04) fImgLedOn.drawAt(context, 238, 77); // 4' if (sw1 & 0x08) fImgLedOn.drawAt(context, 427, 77); // pulse if (sw1 & 0x10) fImgLedOn.drawAt(context, 465, 77); // saw if ((sw1 & 0x60) == 0x40) fImgLedOn.drawAt(context, 604, 269); // chorus 1 if ((sw1 & 0x60) == 0x00) fImgLedOn.drawAt(context, 644, 269); // chorus 2 }; UI* createUI() { return new DistrhoUIchassis(); } END_NAMESPACE_DISTRHO