Skip to content

Commit

Permalink
HC3/exp-less/status widgets/dupe-detect/em picker
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Dempsey committed Sep 25, 2023
1 parent b648abe commit 2a9b218
Show file tree
Hide file tree
Showing 29 changed files with 857 additions and 416 deletions.
2 changes: 1 addition & 1 deletion design/tuning_hamburger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct TuningMenu : Hamburger
void appendContextMenu(Menu * menu) override
{
if (!my_module) return;
menu->addChild(createMenuItem(describeTuning(tuning), "", [](){}, true));
menu->addChild(createMenuLabel(describeTuning(tuning));
menu->addChild(new MenuSeparator);
menu->addChild(createTuningMenuItem(Tuning::EqualTuning));
menu->addChild(createSubmenuItem("n-Tone Equal", "", [=](Menu * menu) {
Expand Down
14 changes: 7 additions & 7 deletions doc/HC-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,33 +123,33 @@ next to the knob, indicating which pedal is assigned to that knob.

- The bottom row shows the following, from left to right:

- Midi device input and output selectors. If you have only one Eagan Matrix device, you should never need to use these, becuase HC-1 generally finds the connected Eagan Matrix device automatically.
- EM Midi device selector. If you have only one Eagan Matrix device, you should never need to use this. HC-1 finds a connected EM device automatically.

- Test note button. Click to send a Middle C (Note 60) *Note on* MIDI message, and Ctrl+Click (Cmd on Mac) to send the corresponding *Note off*.
- Test note button. Click to send a Middle C *Note on* MIDI message (Note 60, velocity 64), and Ctrl+Click (Cmd on Mac) to send the corresponding *Note off*.
You'll see the little circle next to the button light up when a note is on, either through the Test note button, or when playing the device.
This indicator is not completely reliable, but can be useful to get a sense of MIDI activity.

- The row of indicators show different parts of the state of the module/device connection and initialization process.
When everything is conencted and working properly, you should see a row of blue indicators.
When an indicator is orange, it means the corresponding item is in-progress.

If the module gets stuck, an indicator may remain orange, and you may see the MIDI communication lights stop moving.
If you see this happen you may need to reboot the module from the menu, or unplug/power cycle your device.
If the module gets stuck, an indicator may remain orange and you may see the MIDI communication lights stop moving.
If you see this happen you may need to reset MIDI I/O, reboot the module from the menu, or unplug the Midi or USB or even power cycle your EM device.

These indicators are:

1. Note (a note is currently playing). This indicator is not completely reliable when there is a high level of MIDI traffic, but can be useful to get a sense of activity.
1. MIDI output device connection
1. MIDI input device connection
1. Connected device is a recognized Eagan Matrix, based on the device name
1. System presets initialized
1. User presets initialized
1. Current preset initialized
1. Saved preset from previous session
1. Saved preset from previous session is set
1. HC-1 has requested the device for updates when presets change
1. Device heartbeat status (heartbeat can be disabled int he menu).

- In the middle is the pachde (#d) logo
- The name of the currently connected EM device
- The name of the currently connected EM device, if any
- The device firmware version.

## Module Menu
Expand Down
4 changes: 2 additions & 2 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
{
"slug": "pachde-hc-2",
"name": "HC-2",
"description": "More Eagan Matrix controls (HC-1 expander)",
"description": "More Eagan Matrix controls (HC-1 companion)",
"tags": [ "Expander" ]
},
{
"slug": "pachde-hc-3",
"name": "HC-3",
"description": "Eagan Matrix Set lists (favorites groups)",
"description": "Eagan Matrix set lists (HC-1 companion)",
"tags": [ "Expander" ]
}
]
Expand Down
26 changes: 4 additions & 22 deletions res/HC-3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 17 additions & 72 deletions src/HC-1/HC-1-draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,54 +68,11 @@ void Hc1ModuleWidget::drawStatusDots(NVGcontext* vg)
float spacing = 6.25f;
float y = box.size.y - 7.5f;

if (my_module) {
if (!my_module) {
// note
Dot(vg, left, y, my_module->notesOn ? purple_light : gray_light, my_module->notesOn);
left += spacing;
//device_output_state
Dot(vg, left, y, InitStateColor(my_module->device_output_state));
left += spacing;
// device_input_state
Dot(vg, left, y, InitStateColor(my_module->device_input_state));
left += spacing;
//eagan matrix
Dot(vg, left, y, my_module->is_eagan_matrix ? blue_light : yellow_light);
left += spacing;
// //device_state
// Dot(vg, left, y, InitStateColor(my_module->device_hello_state));
// left += spacing;
//system_preset_state
Dot(vg, left, y, InitStateColor(my_module->system_preset_state));
left += spacing;
//user_preset_state
Dot(vg, left, y, InitStateColor(my_module->user_preset_state));
left += spacing;
//apply_favorite_state
Dot(vg, left, y, InitStateColor(my_module->apply_favorite_state));
left += spacing;
//config_state
Dot(vg, left, y, InitStateColor(my_module->config_state));
left += spacing;
//saved_preset_state
if (my_module->restore_saved_preset){
Dot(vg, left, y, InitStateColor(my_module->saved_preset_state));
}
left += spacing;
//request_updates_state
Dot(vg, left, y, InitStateColor(my_module->request_updates_state));
left += spacing;
//handshake
if (my_module->heart_beating) {
Dot(vg, left, y, InitStateColor(my_module->handshake));
}
left += spacing;
// note (debugging)
// auto n = format_string("%d", my_module->note);
// nvgText(vg, left + 5.f, box.size.y - 1.5f, n.c_str(), nullptr);
} else {
Dot(vg, 41.f, y, gray_light, false);

auto co = InitStateColor(InitState::Complete);
Dot(vg, left, y, gray_light, false);
left += spacing;
//device_output_state
Dot(vg, left, y, co);
left += spacing;
Expand All @@ -125,9 +82,6 @@ void Hc1ModuleWidget::drawStatusDots(NVGcontext* vg)
//eagan matrix
Dot(vg, left, y, blue_light);
left += spacing;
// //device_state
// Dot(vg, left, y, InitStateColor(my_module->device_hello_state));
// left += spacing;
//system_preset_state
Dot(vg, left, y, co);
left += spacing;
Expand Down Expand Up @@ -161,6 +115,10 @@ void Hc1ModuleWidget::drawLayer(const DrawArgs& args, int layer)
std::string text;
SetTextStyle(vg, font_normal, RampGray(G_85), 12.f);
if (my_module) {
if (my_module->dupe) {
SetTextStyle(vg, bold_font, GetStockColor(StockColor::Fuchsia), 16.f);
text = "[Only one HC-1 per EM]";
} else
if (my_module->broken) {
SetTextStyle(vg, bold_font, GetStockColor(StockColor::Fuchsia), 16.f);
text = "[MIDI error - please wait]";
Expand All @@ -171,6 +129,9 @@ void Hc1ModuleWidget::drawLayer(const DrawArgs& args, int layer)
if (InitState::Uninitialized == my_module->device_input_state) {
text = ".. looking for EM input ...";
} else
if (InitState::Uninitialized == my_module->duplicate_instance) {
text = ".. checking for duplicate HC-1 ...";
} else
if (my_module->is_gathering_presets()) {
text = format_string("... gathering %s preset %d ...", my_module->in_user_names ? "User" : "System", my_module->in_user_names ? my_module->user_presets.size() : my_module->system_presets.size());
} else
Expand Down Expand Up @@ -257,38 +218,18 @@ void Hc1ModuleWidget::drawPedals(NVGcontext* vg, std::shared_ptr<rack::window::F
}
}

void Hc1ModuleWidget::drawExpanderConnector(NVGcontext* vg)
{
if (my_module && my_module->expanders.any()) {
bool right_expander = my_module->expanders.right();
float left, right;
if (right_expander) {
left = box.size.x - 5.5f;
right = box.size.x;
} else {
left = 0.f;
right = 5.5f;
}
float y = 80.f;
Line(vg, left, y, right, y, COLOR_BRAND, 1.75f);
Circle(vg, left, y, 2.5f, COLOR_BRAND);
}
}

void Hc1ModuleWidget::draw(const DrawArgs& args)
{
ModuleWidget::draw(args);
auto vg = args.vg;

bool stock = !my_module || !my_module->ready();
bool stock = !module || !my_module->ready();
auto rt = stock ? EM_Recirculator::Reverb : my_module->recirculatorType();

drawExpanderConnector(vg);

auto font = GetPluginFontRegular();
if (FontOk(font)) {
#if defined SHOW_PRESET0
if (my_module)
if (module)
{
SetTextStyle(vg, font, orange_light, 9.f);
auto text = my_module->preset0.describe_short();
Expand All @@ -310,8 +251,12 @@ void Hc1ModuleWidget::draw(const DrawArgs& args)
drawPedals(vg, font, stock);
}

if (module && my_module->dupe) {
BoxRect(vg, 1.f, 1.f, box.size.x-2, box.size.y-2, GetStockColor(StockColor::Orange_red), 1.5f);
}

drawStatusDots(vg);
if (!my_module) {
if (!module) {
DrawLogo(args.vg, box.size.x*.5f - 120, 30.f, Overlay(COLOR_BRAND), 14.0);
}
DrawLogo(vg, box.size.x /2.f - 12.f, RACK_GRID_HEIGHT - ONE_HP, RampGray(G_90));
Expand Down
51 changes: 51 additions & 0 deletions src/HC-1/HC-1-midi.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,72 @@
#include "HC-1.hpp"
#include "../cc_param.hpp"
#include "../HcOne.hpp"

namespace pachde {

void Hc1Module::setMidiDevice(int id)
{
if (-1 == id) {
resetMidiIO();
device_name = "(no Eagan Matrix device)";
return;
}
output_device_id = id;
midi_output.setDeviceId(id);
device_name = midi_output.getDeviceName(id);
int id_in = findMatchingInputDevice(device_name);
midi::Input::setDeviceId(id_in);
input_device_id = id_in;
device_output_state = id == -1 ? InitState::Uninitialized : InitState::Complete;
device_input_state = id_in == -1 ? InitState::Uninitialized : InitState::Complete;
notifyDeviceChanged();
checkDuplicate();
}

void Hc1Module::resetMidiIO()
{
device_name.clear();

midi_dispatch.clear();

midi::Input::reset();
input_device_id = -1;
device_input_state = InitState::Uninitialized;

midi_output.reset();
output_device_id = -1;
device_output_state = InitState::Uninitialized;

dupe = false;
duplicate_instance = InitState::Uninitialized;

notifyDeviceChanged();
}

void Hc1Module::checkDuplicate()
{
dupe = false;
auto one = HcOne::get();
if (one->Hc1count() > 1) {
one->scan([=](Hc1Module* const& m) {
if (m != this
&& this->output_device_id >= 0
&& (this->output_device_id == m->output_device_id)) {
dupe = true;
return false;
}
return true;
});
}
duplicate_instance = InitState::Complete;
}

void Hc1Module::queueMidiMessage(uMidiMessage msg)
{
if (dupe) {
DebugLog("MIDI Output disabled when duplicate");
return;
}
if (midi_dispatch.full()) {
DebugLog("MIDI Output queue full: resetting MIDI IO");
resetMidiIO();
Expand Down
26 changes: 26 additions & 0 deletions src/HC-1/HC-1-presets.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
#include "HC-1.hpp"
namespace pachde {

void Hc1Module::tryCachedPresets() {
if (cache_presets) {
loadSystemPresets();
if (system_presets.empty()) {
system_preset_state = InitState::Uninitialized;
}
loadUserPresets();
if (user_presets.empty()) {
user_preset_state = InitState::Uninitialized;
}
if (favoritesFile.empty()) {
favoritesFromPresets();
}
}
if (!favoritesFile.empty()) {
if (system_presets.empty() || user_presets.empty()) {
apply_favorite_state = InitState::Uninitialized;
} else {
if (readFavoritesFile(favoritesFile, true)) {
apply_favorite_state = InitState::Complete;
} else {
apply_favorite_state = InitState::Broken;
}
}
}
}

void Hc1Module::setPresetOrder(PresetOrder order)
{
Expand Down
Loading

0 comments on commit 2a9b218

Please sign in to comment.