Skip to content

Commit

Permalink
Rename HC-3 as Favorites, #24
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Dempsey committed Dec 5, 2023
1 parent f542b74 commit 72842f7
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 59 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ SOURCES += src/HC-2/HC-2.cpp
SOURCES += src/HC-2/HC-2-ui.cpp
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/Favorites/Favorites.cpp
SOURCES += src/Favorites/Favorites-ui.cpp

#SOURCES += src/HC-4/HC-4.cpp
#SOURCES += src/HC-4/HC-4-ui.cpp
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ Pachde and HC One are not affiliated with or sponsored by Haken Audio (but we're

- **[HC-1](./doc/HC-1.md)** Fast access to favorite presets, with knobs and CV inputs for the essential controls: Macros and the Recirculator.

- **[Pedal 1 & Pedal 2](./doc/Pedals.md)** Pedal control, virtual pedals, and pedal CV in/out.

- **[Round](./doc/Round.md)** Control of rounding and the tuning scale, with CV and trigger.

- **[Compress](./doc/Compress.md)** EaganMatrix compressor controls, with CV.

- **[HC-2](./doc/HC-2.md)** TiltEQ, and CC maps (to be retired).
- **[Favorites](./doc/Favorites.md)** Pushbuttons to access up to 16 Favorite files.

- **[HC-3](./doc/HC-3.md)** Pushbuttons to access up to 16 Favorite files.

- **[Pedal 1 & Pedal 2](./doc/Pedals.md)** Pedal control, virtual pedals, and pedal CV in/out.
- **[HC-2](./doc/HC-2.md)** TiltEQ, and CC maps. This module will be going away.

## Installing

Expand Down
14 changes: 8 additions & 6 deletions doc/HC-3.md → doc/Favorites.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Module HC-3
# Module Favorites

HC-3 is a companion for HC-1, offering easy access for up to 16 HC-1 favorites files.
If you want access to more than 16, just add another instance of HC-3.
**Favorites** is a companion for HC-1, offering easy access for up to 16 HC-1 favorites files.
If you want access to more than 16, just add another instance of **Favorites**.

![HC-3 module](HC-3.png)
![Favorites module](Favorites.png)

HC-3 is initially blank when added to a ptach. Right click a button to choose an existing favorites file for that button, or drag and drop a favorites file onto the button.
Favorites is initially blank when added to a ptach. Right click a button to choose an existing favorites file for that button, or drag and drop a favorites file onto the button.
If a Favorites file is currently open in HC-1, you can choose **Use _file_** to attach it to the button.
If you don't have any favorites files yet, you can create one by saving from the HC-1 **Favorite** tab menu.

Expand All @@ -14,10 +14,12 @@ Click again and the file is forgotton in HC-1 and the light goes off. The favori

Any favorites file open in HC-1 is automatically updated as you change the favorites in the **Favorite** tab (Add, Remove, Sort, Clear, ...). There is no undo.

Once you've configured HC-3, I recommend saving your work as a Preset using the module Preset menu (just like loading and saving configuration of any Rack module).
Once you've configured Favorites, I recommend saving your work as a Preset using the module Preset menu (just like loading and saving configuration of any Rack module).
This allows you to use the same set of favorites files in other Rack patches by selecting that preset.

If you use a favorites file from one EM device on another EM device, you'll only get the favorites that have the same name on both devices, and the file will be changed to reflect the common set.
Similarly, if the favorites file contains user presets that are no longer on the device, they are silently removed.

---

![pachde (#d) logo](Logo.svg)
Binary file added doc/Favorites.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed doc/HC-3.png
Binary file not shown.
Binary file modified doc/HC-One-modules.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ The HC-One modules shown here from left to right are:

- **[Compress](Compress.md)** EaganMatrix compressor controls, with CV.

- **[Favorites](Favorites.md)** Pushbuttons to access up to 16 Favorite files.

- **[HC-2](HC-2.md)** TiltEQ, and CC maps (To Be Retired).

- **[HC-3](HC-3.md)** Pushbuttons to access up to 16 Favorite files.

![pachde (#d) logo](Logo.svg)
22 changes: 11 additions & 11 deletions src/HC-3/HC-3-ui.cpp → src/Favorites/Favorites-ui.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "HC-3.hpp"
#include "Favorites.hpp"
#include "../misc.hpp"
#include "../module_broker.hpp"
#include "../widgets/small_push.hpp"
Expand All @@ -10,12 +10,12 @@ constexpr const float START_ROW = 47.5f;
constexpr const float ITEM_INTERVAL = 20.f;
constexpr const float DIVIDER_OFFSET = 5.f;

std::string hc3_sample_data[] = {
std::string favorites_sample_data[] = {
"Experimental", "Strings", "Winds", "Guitars", "Pads", "Leads", "Album 4", "Album 5",
"Mon practice", "", "Th Jam", "Blues setlist", "Recital 6/15", "Community Concert 8/21", "" ,"empty"
};

Hc3ModuleWidget::Hc3ModuleWidget(Hc3Module* module)
FavoritesModuleWidget::FavoritesModuleWidget(FavoritesModule* module)
: my_module(module)
{
setModule(module);
Expand All @@ -30,30 +30,30 @@ Hc3ModuleWidget::Hc3ModuleWidget(Hc3Module* module)
float x = 15.f;
for (auto i = 0; i < 16; ++i) {
addChild(createPFWidget<PresetFileWidget>(Vec(x - 7.5, y - 7.5), module, i, &drawButton));
addChild(createLightCentered<SmallLight<BlueLight>>(Vec(x,y), module, Hc3Module::Lights::SETLIST + i));
addChild(createLightCentered<SmallLight<BlueLight>>(Vec(x,y), module, FavoritesModule::Lights::SETLIST + i));
y += ITEM_INTERVAL;
if (i == 7) {
y += DIVIDER_OFFSET;
}
}
}

void Hc3ModuleWidget::onDeviceChanged(const DeviceChangedEvent& e)
void FavoritesModuleWidget::onDeviceChanged(const DeviceChangedEvent& e)
{
partner_picker->onDeviceChanged(e);
}

void Hc3ModuleWidget::onDisconnect(const DisconnectEvent& e)
void FavoritesModuleWidget::onDisconnect(const DisconnectEvent& e)
{
partner_picker->onDisconnect(e);
}

void Hc3ModuleWidget::onFavoritesFileChanged(const FavoritesFileChangedEvent& e)
void FavoritesModuleWidget::onFavoritesFileChanged(const FavoritesFileChangedEvent& e)
{
refreshDescriptions();
}

void Hc3ModuleWidget::step()
void FavoritesModuleWidget::step()
{
ModuleWidget::step();
if (!module && !hacked_lights) {
Expand All @@ -64,7 +64,7 @@ void Hc3ModuleWidget::step()
auto light = dynamic_cast<BlueLight*>(child);
if (light) {
NVGcolor co = *light->baseColors.begin();
co.a = n == CHOSEN_SAMPLE ? 1.f : hc3_sample_data[n].empty() ? 0.f : .3f;
co.a = n == CHOSEN_SAMPLE ? 1.f : favorites_sample_data[n].empty() ? 0.f : .3f;
light->color = co;
++n;
}
Expand All @@ -73,7 +73,7 @@ void Hc3ModuleWidget::step()
}
}

void Hc3ModuleWidget::refreshDescriptions()
void FavoritesModuleWidget::refreshDescriptions()
{
for (auto child: children) {
auto w = dynamic_cast<PresetFileWidget*>(child);
Expand All @@ -87,7 +87,7 @@ void Hc3ModuleWidget::refreshDescriptions()
}
}

void Hc3ModuleWidget::appendContextMenu(Menu *menu)
void FavoritesModuleWidget::appendContextMenu(Menu *menu)
{
if (!module) return;
///pick companion hc1
Expand Down
41 changes: 24 additions & 17 deletions src/HC-3/HC-3.cpp → src/Favorites/Favorites.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "HC-3.hpp"
#include "Favorites.hpp"

namespace pachde
{

Hc3Module::Hc3Module()
FavoritesModule::FavoritesModule()
: loaded_id(-1)
{
clearFiles();
Expand All @@ -16,33 +16,33 @@ Hc3Module::Hc3Module()
partner_binding.setClient(this);
}

Hc3Module::~Hc3Module()
FavoritesModule::~FavoritesModule()
{
partner_binding.unsubscribe();
}

Hc1Module* Hc3Module::getPartner()
Hc1Module* FavoritesModule::getPartner()
{
return partner_binding.getPartner();
}

void Hc3Module::onDeviceChanged(const DeviceChangedEvent& e)
void FavoritesModule::onDeviceChanged(const DeviceChangedEvent& e)
{
partner_binding.onDeviceChanged(e);
if (ui_event_sink) {
ui_event_sink->onDeviceChanged(e);
}
}

void Hc3Module::onDisconnect(const DisconnectEvent& e)
void FavoritesModule::onDisconnect(const DisconnectEvent& e)
{
partner_binding.onDisconnect(e);
if (ui_event_sink) {
ui_event_sink->onDisconnect(e);
}
}

void Hc3Module::onFavoritesFileChanged(const FavoritesFileChangedEvent& e)
void FavoritesModule::onFavoritesFileChanged(const FavoritesFileChangedEvent& e)
{
if (e.path.empty()) {
setSynchronizedLoadedId(-1);
Expand All @@ -58,7 +58,7 @@ void Hc3Module::onFavoritesFileChanged(const FavoritesFileChangedEvent& e)
}
}

void Hc3Module::clearFiles()
void FavoritesModule::clearFiles()
{
loaded_id = -1;
files.clear();
Expand All @@ -67,15 +67,15 @@ void Hc3Module::clearFiles()
}
}

void Hc3Module::onReset()
void FavoritesModule::onReset()
{
clearFiles();
if (ui_event_sink) {
ui_event_sink->onFavoritesFileChanged(FavoritesFileChangedEvent{""});
}
}

void Hc3Module::onRandomize()
void FavoritesModule::onRandomize()
{
auto partner = getPartner();
if (!partner) return;
Expand All @@ -93,7 +93,7 @@ void Hc3Module::onRandomize()
partner->openFavoritesFile(files[loaded_id]);
}

void Hc3Module::useCurrentFavoriteFile(int id)
void FavoritesModule::useCurrentFavoriteFile(int id)
{
const Hc1Module* partner = getPartner();
if (!partner) return;
Expand All @@ -103,10 +103,13 @@ void Hc3Module::useCurrentFavoriteFile(int id)
}
}

json_t * Hc3Module::dataToJson()
json_t * FavoritesModule::dataToJson()
{
auto root = json_object();
json_object_set_new(root, "device-claim", json_string(partner_binding.claim.c_str()));
if (!favorites_folder.empty()) {
json_object_set_new(root, "favorites-folder", json_string(favorites_folder.c_str()));
}
if (!files.empty()) {
auto jar = json_array();
for (auto f: files) {
Expand All @@ -117,12 +120,16 @@ json_t * Hc3Module::dataToJson()
return root;
}

void Hc3Module::dataFromJson(json_t *root)
void FavoritesModule::dataFromJson(json_t *root)
{
auto j = json_object_get(root, "device-claim");
if (j) {
partner_binding.setClaim(json_string_value(j));
}
j = json_object_get(root, "favorites-folder");
if (j) {
favorites_folder = json_string_value(j);
}
auto jar = json_object_get(root, "fav_files");
if (jar) {
files.clear();
Expand All @@ -135,7 +142,7 @@ void Hc3Module::dataFromJson(json_t *root)
getPartner();
}

void Hc3Module::openFile(int id) {
void FavoritesModule::openFile(int id) {
if (id == loaded_id) return;
setSynchronizedLoadedId(id);
auto partner = getPartner();
Expand All @@ -152,12 +159,12 @@ void Hc3Module::openFile(int id) {
}

// no side effect on HC-1
void Hc3Module::setSynchronizedLoadedId(int id) {
void FavoritesModule::setSynchronizedLoadedId(int id) {
loaded_id = id;
getParamQuantity(Params::SELECTED_PARAM)->setValue(id);
}

void Hc3Module::process(const ProcessArgs& args)
void FavoritesModule::process(const ProcessArgs& args)
{
float time = poll_timer.process(args.sampleTime);
if (time > POLL_RATE) {
Expand Down Expand Up @@ -210,4 +217,4 @@ void Hc3Module::process(const ProcessArgs& args)
}

}
Model *modelHc3 = createModel<pachde::Hc3Module, pachde::Hc3ModuleWidget>("pachde-hc-favorites");
Model *modelFavorites = createModel<pachde::FavoritesModule, pachde::FavoritesModuleWidget>("pachde-hc-favorites");
19 changes: 10 additions & 9 deletions src/HC-3/HC-3.hpp → src/Favorites/Favorites.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#ifndef HC3_HPP_INCLUDED
#define HC3_HPP_INCLUDED
#ifndef Favorites_HPP_INCLUDED
#define Favorites_HPP_INCLUDED
#include <stdint.h>
#include "../HC-1/HC-1.hpp"
#include "../hc_events.hpp"
Expand All @@ -13,10 +13,10 @@

namespace pachde {

extern std::string hc3_sample_data[];
extern std::string favorites_sample_data[];
constexpr const int CHOSEN_SAMPLE = 11;

struct Hc3Module : Module, IHandleHcEvents
struct FavoritesModule : Module, IHandleHcEvents
{
enum Params {
SELECTED_PARAM,
Expand All @@ -34,12 +34,13 @@ struct Hc3Module : Module, IHandleHcEvents
std::vector<std::string> files;
PartnerBinding partner_binding;
IHandleHcEvents * ui_event_sink = nullptr;
std::string favorites_folder;

const float POLL_RATE = 1.5f;
rack::dsp::Timer poll_timer;

Hc3Module();
virtual ~Hc3Module();
FavoritesModule();
virtual ~FavoritesModule();
void clearFiles();

Hc1Module* getPartner();
Expand All @@ -62,15 +63,15 @@ struct Hc3Module : Module, IHandleHcEvents
void process(const ProcessArgs& args) override;
};

struct Hc3ModuleWidget : ModuleWidget, IHandleHcEvents
struct FavoritesModuleWidget : ModuleWidget, IHandleHcEvents
{
Hc3Module* my_module;
FavoritesModule* my_module;
DrawSquareButton drawButton;
// StaticTextLabel* device_label = nullptr;
PartnerPicker* partner_picker = nullptr;
bool hacked_lights = false;

explicit Hc3ModuleWidget(Hc3Module* module);
explicit FavoritesModuleWidget(FavoritesModule* module);

void refreshDescriptions();

Expand Down
Loading

0 comments on commit 72842f7

Please sign in to comment.