Skip to content

Commit

Permalink
Create Round Module, UI consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Dempsey committed Nov 27, 2023
1 parent 9b2891b commit c324a37
Show file tree
Hide file tree
Showing 19 changed files with 581 additions and 288 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ SOURCES += src/HC-2/cc_map_widget.cpp
SOURCES += src/HC-3/HC-3.cpp
SOURCES += src/HC-3/HC-3-ui.cpp

SOURCES += src/HC-4/HC-4.cpp
SOURCES += src/HC-4/HC-4-ui.cpp
#SOURCES += src/HC-4/HC-4.cpp
#SOURCES += src/HC-4/HC-4-ui.cpp

SOURCES += src/Pedals/Pedals.cpp
SOURCES += src/Pedals/Pedals-ui.cpp

SOURCES += src/Round/Round.cpp
SOURCES += src/Round/Round-ui.cpp

DISTRIBUTABLES += res
# DISTRIBUTABLES += presets
# DISTRIBUTABLES += selections
Expand Down
8 changes: 4 additions & 4 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
"tags": [ "Expander" ]
},
{
"slug": "pachde-hc-4",
"name": "HC-4",
"description": "Next HC One module",
"tags": [ "Expander" ]
"slug": "pachde-hc-round",
"name": "Round",
"description": "Rounding (HC-1 companion)",
"tags": [ "Controller", "MIDI", "Expander" ]
},
{
"slug": "pachde-hc-pedal-1",
Expand Down
19 changes: 5 additions & 14 deletions res/Pedal1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 10 additions & 20 deletions res/Pedal2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions res/Round.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/HC-1/HC-1-draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ void Hc1ModuleWidget::drawPedalAssignment(

void Hc1ModuleWidget::drawPedals(NVGcontext* vg, std::shared_ptr<rack::window::Font> font, bool stockPedals)
{
SetTextStyle(vg, font, RampGray(G_85), 10.f);
SetTextStyle(vg, font, GetStockColor(StockColor::Gold), 10.f);
if (stockPedals) {
drawPedalAssignment(vg, PRESET_RIGHT + 1.f, PRESET_BOTTOM - 19.f, '1', 64, 0);
drawPedalAssignment(vg, PRESET_RIGHT + 1.f, PRESET_BOTTOM - 4.5f, '2', 66, 0);
Expand Down
6 changes: 3 additions & 3 deletions src/HC-1/HC-1-ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void Hc1ModuleWidget::createPresetPrevNext()
});
}
addChild(w);
addChild(createStaticTextLabel<StaticTextLabel>(Vec(Vec(RIGHT_COLUMN_BUTTONS - 7.f, y + 5.f)), 25.f, "-", TextAlignment::Center, 9.f, false));
addChild(createStaticTextLabel<StaticTextLabel>(Vec(Vec(RIGHT_COLUMN_BUTTONS - 7.f, y + 5.f)), 25.f, "-", TextAlignment::Center, 10.f, true));

w = createWidgetCentered<SmallSquareButton>(Vec(RIGHT_COLUMN_BUTTONS + 7.f, y));
w->describe("Next preset\n Shift+Click by 10\n Ctrl+Click for device order");
Expand All @@ -111,10 +111,10 @@ void Hc1ModuleWidget::createPresetPrevNext()
});
}
addChild(w);
addChild(createStaticTextLabel<StaticTextLabel>(Vec(Vec(RIGHT_COLUMN_BUTTONS + 7.f, y + 5.f)), 25.f, "+", TextAlignment::Center, 9.f, false));
addChild(createStaticTextLabel<StaticTextLabel>(Vec(Vec(RIGHT_COLUMN_BUTTONS + 7.f, y + 5.f)), 25.f, "+", TextAlignment::Center, 10.f, true));
y += 12.f;

addChild(createStaticTextLabel<StaticTextLabel>(Vec(Vec(RIGHT_COLUMN_BUTTONS, y)), 25.f, "Preset", TextAlignment::Center, 9.f, false));
addChild(createStaticTextLabel<StaticTextLabel>(Vec(Vec(RIGHT_COLUMN_BUTTONS, y)), 25.f, "Preset", TextAlignment::Center, 10.f, true));
}

void Hc1ModuleWidget::createPresetPaging()
Expand Down
16 changes: 4 additions & 12 deletions src/HC-2/HC-2-layout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,18 @@ constexpr const float KNOB_SPREAD = 54.25f;
constexpr const float KNOB_COL1 = 35.f;
constexpr const float KNOB_ROW = 44.f;

constexpr const float ROUND_BOX_TOP = 35.f;
constexpr const float ROUND_BOX_LEFT = 7.5f;
constexpr const float ROUND_BOX_WIDTH = 105.f;
constexpr const float ROUND_BOX_HALF = 110.f * .5f;
constexpr const float REL_OFFSET = 20.f;
constexpr const float REL_VOFFSET = 10.f;
constexpr const float CV_COLUMN_OFFSET = 24.f;
constexpr const float CV_ROW_OFFSET = 6.f;
constexpr const float STATIC_LABEL_OFFSET = 29.5f;
constexpr const float ROUND_KNOB_ROW = 34.f;
constexpr const float ROUND_COL1 = ROUND_BOX_HALF - KNOB_RADIUS - 3.f * PAD;
constexpr const float ROUND_COL2 = ROUND_BOX_HALF + KNOB_RADIUS + 2.f * PAD;
constexpr const float ROUND_COL3 = ROUND_BOX_WIDTH - KNOB_RADIUS + PAD;

constexpr const float COMP_BOX_LEFT = ROUND_BOX_LEFT + ROUND_BOX_WIDTH + 7.5;
constexpr const float COMP_BOX_TOP = ROUND_BOX_TOP;
constexpr const float COMP_BOX_LEFT = 7.5;
constexpr const float COMP_BOX_TOP = 35.f;
constexpr const float COMP_BOX_WIDTH = KNOB_SPREAD * 4.f;

constexpr const float TEQ_BOX_LEFT = ROUND_BOX_LEFT;
constexpr const float TEQ_BOX_TOP = ROUND_BOX_TOP + KNOB_BOX_HEIGHT + 7.5f;
constexpr const float TEQ_BOX_LEFT = 7.5f;
constexpr const float TEQ_BOX_TOP = COMP_BOX_TOP + KNOB_BOX_HEIGHT + 7.5f;
constexpr const float TEQ_BOX_WIDTH = KNOB_SPREAD * 3.f;

}
61 changes: 0 additions & 61 deletions src/HC-2/HC-2-ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "../widgets/port.hpp"
#include "../widgets/small_push.hpp"
#include "../widgets/switch_4.hpp"
#include "tuning_ui.hpp"

namespace pachde {

Expand All @@ -28,55 +27,6 @@ inline uint8_t GetSmallParamValue(rack::app::ModuleWidget* w, int id, uint8_t de
return U8(pq->getValue());
}

void Hc2ModuleWidget::createRoundingUI(float x, float y)
{
// Rounding cluster
addChild(createHeaderWidget(x, y, ROUND_BOX_WIDTH, KNOB_BOX_HEIGHT));
addChild(createStaticTextLabel<StaticTextLabel>(Vec(x + MORE_PAD, y + PAD), 40.f, "Rounding", TextAlignment::Left));

addParam(createParamCentered<SwitchHorz4>(
Vec(x + ROUND_COL2, y + PAD + PAD + HALF_KNOB),
module, Hc2P::P_ROUND_KIND));

addChild(createModKnob(
Vec( x + ROUND_COL1, y + ROUND_KNOB_ROW),
module, Hc2P::P_ROUND_RATE, Hc2I::IN_ROUND_RATE, Hc2P::P_ROUND_RATE_REL));
addParam(createLightParamCentered<PDLightLatch<TinySimpleLight<BlueLight>>>(
Vec( x + ROUND_COL1 - REL_OFFSET, y + ROUND_KNOB_ROW - REL_VOFFSET),
module, Hc2P::P_ROUND_RATE_REL, Hc2L::L_ROUND_RATE_REL));
addChild(createInputCentered<ColorPort>(
Vec( x + ROUND_COL1 - CV_COLUMN_OFFSET, y + ROUND_KNOB_ROW + HALF_KNOB),
module, Hc2I::IN_ROUND_RATE));

auto p = createParamCentered<TuningKnob>(Vec( x + ROUND_COL2, y + ROUND_KNOB_ROW), module, Hc2P::P_ROUND_TUNING);
p->setImage();
addChild(p);

addParam(createLightParamCentered<PDLightLatch<TinySimpleLight<BlueLight>>>(
Vec( x + ROUND_COL3, y + ROUND_KNOB_ROW - REL_VOFFSET),
module, Hc2P::P_ROUND_INITIAL, Hc2L::L_ROUND_INITIAL));
addChild(createInputCentered<ColorPort>(
Vec( x + ROUND_COL3, y + ROUND_KNOB_ROW + HALF_KNOB),
module, Hc2I::IN_ROUND_INITIAL));

rounding_summary = createLazyDynamicTextLabel(
Vec(x + ROUND_BOX_HALF, y + KNOB_BOX_HEIGHT - 11.f),
Vec(100.f, 12.f),
[=]() {
bool initial = GetSmallParamValue(this, Hc2P::P_ROUND_INITIAL);
auto rk = describeRoundKindShort(static_cast<RoundKind>(GetSmallParamValue(this, Hc2P::P_ROUND_KIND)));
auto rr = GetSmallParamValue(this,Hc2P::P_ROUND_RATE);
PackedTuning tuning = static_cast<PackedTuning>(GetSmallParamValue(this, Hc2P::P_ROUND_TUNING));
auto ts = describeTuning(unpackTuning(tuning));
return format_string("%s %s %d %s",
rk.c_str(), (initial ? "I" : "\u2022"), rr, ts.c_str());
},
9.f, false, TextAlignment::Center,
GetStockColor(StockColor::Gold), true)
;
addChild(rounding_summary);
}

void Hc2ModuleWidget::createCompressorUI(float x, float y)
{
addChild(createHeaderWidget(x, y, COMP_BOX_WIDTH, KNOB_BOX_HEIGHT));
Expand Down Expand Up @@ -158,7 +108,6 @@ Hc2ModuleWidget::Hc2ModuleWidget(Hc2Module * module)
setPanel(createPanel(asset::plugin(pluginInstance, "res/HC-2.svg")));
addChild(partner_picker = createPartnerPicker(7.f, 14.f, 180.f, module ? &module->partner_binding : nullptr));

createRoundingUI(ROUND_BOX_LEFT, ROUND_BOX_TOP);
createCompressorUI(COMP_BOX_LEFT, COMP_BOX_TOP);
createTiltEqUI(TEQ_BOX_LEFT, TEQ_BOX_TOP);

Expand All @@ -167,16 +116,6 @@ Hc2ModuleWidget::Hc2ModuleWidget(Hc2Module * module)
addChild(createCCMap<CCMap>(x, box.size.y - 24.f, true, CCMapChannel::Sixteen, this));
}

void Hc2ModuleWidget::onPresetChanged(const PresetChangedEvent& e)
{
rounding_summary->modified();
}

void Hc2ModuleWidget::onRoundingChanged(const RoundingChangedEvent& e)
{
rounding_summary->modified();
}

void Hc2ModuleWidget::onDeviceChanged(const DeviceChangedEvent& e)
{
partner_picker->onDeviceChanged(e);
Expand Down
141 changes: 0 additions & 141 deletions src/HC-2/HC-2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "../widgets/cc_param.hpp"
#include "../widgets/components.hpp"
#include "../widgets/pedal_param.hpp"
#include "tuning_ui.hpp"

namespace pachde {

Expand All @@ -16,21 +15,6 @@ Hc2Module::Hc2Module()

config(Params::NUM_PARAMS, Inputs::NUM_INPUTS, Outputs::NUM_OUTPUTS, Lights::NUM_LIGHTS);

configInput(Inputs::IN_ROUND_RATE, "Round rate");

auto p = configCCParam(EMCC_RoundRate, false, this, Params::P_ROUND_RATE, Inputs::IN_ROUND_RATE, Params::P_ROUND_RATE_REL, Lights::L_ROUND_RATE_REL, 0.f, 127.f, 0.f, "Round rate");
p->snapEnabled = true;
configSwitch(P_ROUND_RATE_REL, 0.f, 1.f, 0.f, "Round rate CV-relative", offon);
configSwitch(P_ROUND_INITIAL, 0.f, 1.f, 0.f, "Round initial", offon);
configInput(Inputs::IN_ROUND_INITIAL, "Round initial trigger");
configSwitch(P_ROUND_KIND, 0.f, 3.f, 0.f, "Round type", {
"Normal",
"Release",
"Y (Full to none)",
"Inverse Y (None to full)"
});
configTuningParam(this, P_ROUND_TUNING);

configCCParam(EMCC_CompressorThreshold, false, this, P_COMP_THRESHOLD, IN_COMP_THRESHOLD, P_COMP_THRESHOLD_REL, L_COMP_THRESHOLD_REL, 0.f, 127.f, 127.f, "Threshold", "%", 0.f, 100.f/127.f)->snapEnabled = true;
configCCParam(EMCC_CompressorThreshold, false, this, P_COMP_ATTACK, IN_COMP_ATTACK, P_COMP_ATTACK_REL, L_COMP_ATTACK_REL, 0.f, 127.f, 64.f, "Attack", "%", 0.f, 100.f/127.f)->snapEnabled = true;
configCCParam(EMCC_CompressorThreshold, false, this, P_COMP_RATIO, IN_COMP_RATIO, P_COMP_RATIO_REL, L_COMP_RATIO_REL, 0.f, 127.f, 64.f, "Ratio", "%", 0.f, 100.f/127.f)->snapEnabled = true;
Expand Down Expand Up @@ -93,51 +77,6 @@ Hc1Module* Hc2Module::getPartner()
return getPartnerImpl<Hc2Module>(this);
}

void Hc2Module::onPresetChanged(const PresetChangedEvent& e)
{
pullRounding();
if (ui_event_sink) {
ui_event_sink->onPresetChanged(e);
}
}

void Hc2Module::onRoundingChanged(const RoundingChangedEvent& e)
{
bool changed = false;
auto old = rounding;
rounding = e.rounding;

if (old.rate != rounding.rate) {
changed = true;
auto pq = dynamic_cast<CCParamQuantity*>(getParamQuantity(Params::P_ROUND_RATE));
pq->setValueSilent(rounding.rate);
}

if (old.initial != rounding.initial) {
changed = true;
getParamQuantity(Params::P_ROUND_INITIAL)->setValue(1.f * rounding.initial);
getLight(Lights::L_ROUND_INITIAL).setBrightness(1.0f * rounding.initial);
}

if (old.kind != rounding.kind) {
changed = true;
getParamQuantity(Params::P_ROUND_KIND)->setValue(static_cast<uint8_t>(rounding.kind));
}
if (old.tuning != rounding.tuning) {
changed = true;
getParamQuantity(Params::P_ROUND_TUNING)->setValue(packTuning(rounding.tuning));
}
if (old.equal != rounding.equal) {
changed = true;
// $BUGBUG: why is this commented out?
//getParamQuantity(Params::P_ROUND_EQUAL)->setValue(rounding.equal);
}

if (changed && ui_event_sink) {
ui_event_sink->onRoundingChanged(e);
}
}

void Hc2Module::onCompressorChanged(const CompressorChangedEvent &e)
{
bool changed = false;
Expand Down Expand Up @@ -215,31 +154,6 @@ void Hc2Module::onDisconnect(const DisconnectEvent& e)
}
}

void Hc2Module::pullRounding(Hc1Module * partner)
{
if (!partner) partner = getPartner();
if (!partner) return;
rounding = partner->em.rounding;
getParamQuantity(Params::P_ROUND_KIND)->setValue(static_cast<uint8_t>(rounding.kind));
getParamQuantity(Params::P_ROUND_INITIAL)->setValue(1.f * rounding.initial);
getLight(Lights::L_ROUND_INITIAL).setBrightness(1.0f * rounding.initial);
dynamic_cast<CCParamQuantity*>(getParamQuantity(Params::P_ROUND_RATE))->setValueSilent(rounding.rate);
getParamQuantity(Params::P_ROUND_TUNING)->setValue(packTuning(rounding.tuning));
if (ui_event_sink) {
ui_event_sink->onRoundingChanged(RoundingChangedEvent{rounding});
}
}

void Hc2Module::pushRounding(Hc1Module * partner)
{
if (!partner) partner = getPartner();
if (!partner) return;
partner->em.rounding = rounding;
if (ui_event_sink) {
ui_event_sink->onRoundingChanged(RoundingChangedEvent{rounding});
}
}

void Hc2Module::pullCompressor(Hc1Module *partner)
{
if (!partner) partner = getPartner();
Expand Down Expand Up @@ -313,50 +227,6 @@ void Hc2Module::processCV(int paramId)
}
}

void Hc2Module::processRoundingControls()
{
{
auto pq = dynamic_cast<CCParamQuantity*>(getParamQuantity(Params::P_ROUND_RATE));
assert(pq);
auto rr = pq->valueToSend();
if (pq->last_value != rr) {
rounding.rate = rr;
pushRounding();
pq->syncValue();
}
}
{
bool ri = getParamQuantity(Params::P_ROUND_INITIAL)->getValue() >= .5f;
getLight(Lights::L_ROUND_INITIAL).setBrightness(1.0f * rounding.initial);
if (rounding.initial != ri) {
rounding.initial = ri;
pushRounding();
sendControlChange(EM_MasterChannel, EMCC_RoundInitial, ri * 127);
}
}

{
RoundKind kind = static_cast<RoundKind>(static_cast<uint8_t>(getParamQuantity(P_ROUND_KIND)->getValue()));
if (kind != rounding.kind) {
rounding.kind = kind;
pushRounding();
auto partner = getPartner();
uint8_t rev = partner ? (partner->em.reverse_surface ? 1 : 0) : 0;
sendControlChange(EM_SettingsChannel, EMCC_Reverse_Rounding, (static_cast<uint8_t>(kind) << 1) | rev);
}
}

{
auto tq = dynamic_cast<TuningParamQuantity*>(getParamQuantity(P_ROUND_TUNING));
Tuning tuning = tq->getTuning();
if (tuning != rounding.tuning) {
rounding.tuning = tuning;
pushRounding();
sendControlChange(EM_SettingsChannel, EMCC_TuningGrid, tuning);
}
}
}

void Hc2Module::processCompressorControls()
{
bool changed = false;
Expand Down Expand Up @@ -426,7 +296,6 @@ void Hc2Module::processTiltEqControls()
void Hc2Module::processControls()
{
if (!control_rate.process()) { return; }
processRoundingControls();
processCompressorControls();
processTiltEqControls();
}
Expand All @@ -435,7 +304,6 @@ void Hc2Module::process(const ProcessArgs& args)
{
if (++check_cv > CV_INTERVAL) {
check_cv = 0;
processCV(Params::P_ROUND_RATE);
processCV(Params::P_COMP_THRESHOLD);
processCV(Params::P_COMP_ATTACK);
processCV(Params::P_COMP_RATIO);
Expand All @@ -445,15 +313,6 @@ void Hc2Module::process(const ProcessArgs& args)
processCV(Params::P_TEQ_MIX);
}

if (getInput(Inputs::IN_ROUND_INITIAL).isConnected()) {
auto v = getInput(Inputs::IN_ROUND_INITIAL).getVoltage();
if (round_initial_trigger.process(v, 0.1f, 5.f)) {
round_initial_trigger.reset();
auto pq = getParamQuantity(Params::P_ROUND_INITIAL);
bool ri = !(pq->getValue() >= .5f); // toggle
pq->setValue(1.0f * ri);
}
}
processControls();
getLight(Lights::L_COMPRESSOR).setBrightness(static_cast<float>(compressor.mix)/127.f);
getLight(Lights::L_TEQ).setBrightness(static_cast<float>(tilt_eq.mix)/127.f);
Expand Down
Loading

0 comments on commit c324a37

Please sign in to comment.