Skip to content

Commit

Permalink
Improve hc-1 pedal feedback, fix tip, cc29,30 stub
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Dempsey committed Oct 17, 2023
1 parent 673674c commit 5bc88a0
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 13 deletions.
20 changes: 12 additions & 8 deletions src/HC-1/HC-1-draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,20 +210,24 @@ void drawPedalKnobAssignment(NVGcontext * vg, uint8_t ped, const char * text)
}
}

void drawPedalAssignment(NVGcontext* vg, float x, float y, char ped_char, uint8_t ped, uint8_t ped_value)
void Hc1ModuleWidget::drawPedalAssignment(
NVGcontext* vg, float x, float y,
char ped_char, uint8_t ped, uint8_t ped_value)
{
auto text = format_string("p%c %s", ped_char, ShortPedalAssignment(ped).c_str());
nvgTextAlign(vg, NVGalign::NVG_ALIGN_LEFT);
nvgText(vg, PRESET_RIGHT + 1.f, y, text.c_str(), nullptr);
Line(vg, x, y+1, x, y+1 - (ped_value * 10.f / 255.f), GetStockColor(StockColor::Sea_green_Dark), 1.5f);
auto text = format_string("p%c %s", ped_char, ShortPedalAssignment(ped).c_str());
nvgText(vg, x, y, text.c_str(), nullptr);
y += 3.f;
Line(vg, x, y, x + ((ped_value * (box.size.x - x - 3.f)) / 127.f), y,
GetStockColor(StockColor::Sea_green_Dark), 2.25f);
}

void Hc1ModuleWidget::drawPedals(NVGcontext* vg, std::shared_ptr<rack::window::Font> font, bool stockPedals)
{
SetTextStyle(vg, font, RampGray(G_85), 10.f);
if (stockPedals) {
drawPedalAssignment(vg, box.size.x - 3.f, PRESET_BOTTOM - 18.f, '1', 64, 0);
drawPedalAssignment(vg, box.size.x - 3.f, PRESET_BOTTOM - 4.5f, '2', 66, 0);
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);
} else {
auto ped1 = my_module->pedal1.cc;
auto ped2 = my_module->pedal2.cc;
Expand All @@ -233,8 +237,8 @@ void Hc1ModuleWidget::drawPedals(NVGcontext* vg, std::shared_ptr<rack::window::F
drawPedalKnobAssignment(vg, ped1, "1");
drawPedalKnobAssignment(vg, ped2, "2");
}
drawPedalAssignment(vg, box.size.x - 3.f, PRESET_BOTTOM - 18.f, '1', ped1, my_module->pedal1.value);
drawPedalAssignment(vg, box.size.x - 3.f, PRESET_BOTTOM - 4.5f, '2', ped2, my_module->pedal2.value);
drawPedalAssignment(vg, PRESET_RIGHT + 1.f, PRESET_BOTTOM - 19.f, '1', ped1, my_module->pedal1.value);
drawPedalAssignment(vg, PRESET_RIGHT + 1.f, PRESET_BOTTOM - 4.5f, '2', ped2, my_module->pedal2.value);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Pedals/Pedals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ PedalCore::PedalCore(uint8_t pedal)

configPedalParam(pedal_id, PedalAssign::Sustain, this, Params::P_PEDAL_ASSIGN);

auto p = configParam(P_PEDAL_VALUE, 0.f, 127.f, 0.f, format_string("Pedal %d value", pedal_id));
auto p = configParam(P_PEDAL_VALUE, 0.f, 127.f, 0.f, format_string("Pedal %d value", 1 + pedal_id));
p->snapEnabled = true;

configInput(Inputs::I_PEDAL_VALUE, "Pedal");
Expand Down
4 changes: 2 additions & 2 deletions src/em_midi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ constexpr const uint8_t EMCC_RoundRate = 25;
constexpr const uint8_t EMCC_PreLevel = 26;
constexpr const uint8_t EMCC_Attenuation = 27;
constexpr const uint8_t EMCC_RoundInitial = 28;
constexpr const uint8_t EMCC_Pedal1 = 29;
constexpr const uint8_t EMCC_Pedal2 = 30;
constexpr const uint8_t EMCC_Jack1 = 29;
constexpr const uint8_t EMCC_Jack2 = 30;
constexpr const uint8_t EMCC_Advance = 31; //127 next, 64=next layer
constexpr const uint8_t EMCC_Category = 32;

Expand Down
9 changes: 8 additions & 1 deletion src/em_types/em_pedal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ std::string ShortPedalAssignment(uint8_t pedalcc)
case 26: return "Pre";
case 27: return "Att"; // not in HE menu
case 28: return "RIn";

case 29: return "PJ1"; // not in HE menu
case 30: return "PJ2"; // not in HE menu
case 31: return "Adv";

case 64: return "Sus";
Expand Down Expand Up @@ -64,6 +65,8 @@ std::string LongPedalAssignment(uint8_t pedalcc)
case 26: return "Pre level";
case 27: return "Attenuation"; // not in HE menu
case 28: return "Round Initial";
case 29: return "Pedal Jack 1"; // not in HE menu
case 30: return "Pedal Jack 2"; // not in HE menu
case 31: return "Preset advance";
case 64: return "Sustain";
case 65: return "Round Equal";
Expand All @@ -85,6 +88,8 @@ PedalAssign PedalAssignFromCC(uint8_t cc)
case EMCC_PreLevel: return PedalAssign::PreLevel;
case EMCC_PostLevel: return PedalAssign::PostLevel;
case EMCC_AudioInLevel: return PedalAssign::AudioInputLevel;
//case EMCC_Jack1: return PedalAssign::Jack1;
//case EMCC_Jack2: return PedalAssign::Jack2;
//case EMCC_Attenuation: return PedalAssign::Attenuation;
case EMCC_Sustain: return PedalAssign::Sustain;
case EMCC_Sostenuto: return PedalAssign::Sostenuto;
Expand Down Expand Up @@ -119,6 +124,8 @@ uint8_t PedalCC(PedalAssign assign)
case PedalAssign::PreLevel: return EMCC_PreLevel;
case PedalAssign::PostLevel: return EMCC_PostLevel;
case PedalAssign::AudioInputLevel: return EMCC_AudioInLevel;
//case PedalAssign::Jack1: return EMCC_Jack1;
//case PedalAssign::Jack2: return EMCC_Jack2;
//case PedalAssign::Attenuation: return EMCC_Attenuation;
case PedalAssign::Sustain: return EMCC_Sustain;
case PedalAssign::Sostenuto: return EMCC_Sostenuto;
Expand Down
3 changes: 2 additions & 1 deletion src/em_types/em_pedal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ enum class PedalAssign : uint8_t
PostLevel,
AudioInputLevel,
//Attenuation, // can be set/sent, but does not behave

// Jack1,
// Jack2, // found in BeautifulPursuit, but not sent when configured
Sustain,
Sostenuto,
Sostenuto2,
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/pedal_param.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ struct PedalKnob : SmallBlackKnob
menu->addChild(createPedalMenuItem(PedalAssign::RoundEqual));
}));
menu->addChild(createPedalMenuItem(PedalAssign::FineTune));
//menu->addChild(createPedalMenuItem(PedalAssign::Jack1));
//menu->addChild(createPedalMenuItem(PedalAssign::Jack2));

menu->addChild(createSubmenuItem("Extensions", "", [=](Menu * menu) {
menu->addChild(createPedalMenuItem(PedalAssign::Expression));
Expand Down

0 comments on commit 5bc88a0

Please sign in to comment.