Skip to content

Instantly share code, notes, and snippets.

@dsheeler
Created May 7, 2019 11:18
Show Gist options
  • Save dsheeler/d5b8020a8073df32dcde31be8d4a4732 to your computer and use it in GitHub Desktop.
Save dsheeler/d5b8020a8073df32dcde31be8d4a4732 to your computer and use it in GitHub Desktop.
diff --git a/app/src/naveg.c b/app/src/naveg.c
index 0fc24c2..a9039b0 100644
--- a/app/src/naveg.c
+++ b/app/src/naveg.c
@@ -22,7 +22,7 @@
#include <strings.h>
#include <math.h>
#include <float.h>
-
+#include <stdio.h>
/*
************************************************************************************************************************
@@ -83,6 +83,8 @@ struct TOOL_T {
************************************************************************************************************************
*/
+//static FILE *fp;
+//static int count = 0;
static control_t *g_controls[SLOTS_COUNT], *g_foots[SLOTS_COUNT];
static bp_list_t *g_banks, *g_naveg_pedalboards, *g_selected_pedalboards;
static uint8_t g_bp_state, g_current_bank, g_current_pedalboard, g_bp_first;
@@ -105,6 +107,7 @@ static void display_control_add(control_t *control);
static void display_control_rm(int32_t effect_instance, const char *symbol);
static void foot_control_add(control_t *control);
+static void foot_control_update(control_t *control);
static void foot_control_rm(int32_t effect_instance, const char *symbol);
static uint8_t bank_config_check(uint8_t foot);
@@ -330,6 +333,35 @@ static void display_control_rm(int32_t effect_instance, const char *symbol)
}
}
+// control assigned to foot
+static void foot_control_add(control_t *control)
+{
+ // checks the actuator id
+ if (control->actuator_id >= FOOTSWITCHES_COUNT) return;
+
+ // checks if the actuator is used like bank function
+ if (bank_config_check(control->actuator_id))
+ {
+ data_free_control(control);
+ return;
+ }
+
+ // checks if the foot is already used by other control and not is state updating
+ if (g_foots[control->actuator_id] && g_foots[control->actuator_id] != control)
+ {
+ data_free_control(control);
+ return;
+ }
+
+ // stores the foot
+ g_foots[control->actuator_id] = control;
+
+ // default state of led blink (no blink)
+ led_blink(hardware_leds(control->actuator_id), 0, 0);
+
+ foot_control_update(control);
+}
+
static void foot_control_update(control_t *control)
{
uint8_t i;
@@ -442,6 +474,9 @@ static void foot_control_update(control_t *control)
case CONTROL_PROP_ENUMERATION:
case CONTROL_PROP_SCALE_POINTS:
+ /*fp = fopen("/tmp/blahdablahda.txt", "ra");
+ fprintf(fp, "%f\n", control->value);
+ fclose(fp);*/
// updates the led
led_set_color(hardware_leds(control->actuator_id), ENUMERATED_COLOR);
@@ -451,11 +486,30 @@ static void foot_control_update(control_t *control)
{
if (control->value == control->scale_points[i]->value)
{
- control->step = i;
+ if (i == 0) {
+ led_set_color(hardware_leds(control->actuator_id), (const color_t){255, 0, 0});//ENUMERATED_COLOR);
+ } else if (i == 1) {
+ led_set_color(hardware_leds(control->actuator_id), (const color_t){0, 255, 0});//ENUMERATED_COLOR);
+ } else if (i == 2) {
+ led_set_color(hardware_leds(control->actuator_id), (const color_t){0, 0, 255});//ENUMERATED_COLOR);
+ } else if (i == 3) {
+ led_set_color(hardware_leds(control->actuator_id), (const color_t){255, 255, 0});//ENUMERATED_COLOR);
+ }
+
+ control->step = i;
break;
}
}
- control->steps = control->scale_points_count;
+ /*control->steps = control->scale_points_count;
+ if (i == control->scale_points_count) {
+ led_set_color(hardware_leds(control->actuator_id), (const color_t){255, 0, 0});//ENUMERATED_COLOR);
+ } else {
+ led_set_color(hardware_leds(control->actuator_id), (const color_t){255, 255, 0});//ENUMERATED_COLOR);
+ char tmp[32];
+ sprintf(tmp, "%.02f %.02f", control->scale_points[count]->value, control->value);
+ count = (count + 1) % control->scale_points_count;
+ screen_footer(control->actuator_id, control->label, tmp);//control->scale_points[i]->label);
+ }*/
// if is in tool mode break
if (display_has_tool_enabled(control->actuator_id)) break;
@@ -466,35 +520,6 @@ static void foot_control_update(control_t *control)
}
}
-// control assigned to foot
-static void foot_control_add(control_t *control)
-{
- // checks the actuator id
- if (control->actuator_id >= FOOTSWITCHES_COUNT) return;
-
- // checks if the actuator is used like bank function
- if (bank_config_check(control->actuator_id))
- {
- data_free_control(control);
- return;
- }
-
- // checks if the foot is already used by other control and not is state updating
- if (g_foots[control->actuator_id] && g_foots[control->actuator_id] != control)
- {
- data_free_control(control);
- return;
- }
-
- // stores the foot
- g_foots[control->actuator_id] = control;
-
- // default state of led blink (no blink)
- led_blink(hardware_leds(control->actuator_id), 0, 0);
-
- foot_control_update(control);
-}
-
// control removed from foot
static void foot_control_rm(int32_t effect_instance, const char *symbol)
{
@@ -621,8 +646,10 @@ static void control_set(uint8_t display, control_t *control)
{
// increments the step
control->step++;
- if (control->step >= control->scale_points_count) control->step = 0;
-
+ if (control->step >= control->scale_points_count) {
+ led_set_color(hardware_leds(control->actuator_id), BLACK);
+ control->step = 0;
+ }
// updates the value and the screen
control->value = control->scale_points[control->step]->value;
if (!display_has_tool_enabled(display))
diff --git a/html/js/pedalpresetsmanage.js b/html/js/pedalpresetsmanage.js
index 326d18d8..023a62a9 100644
--- a/html/js/pedalpresetsmanage.js
+++ b/html/js/pedalpresetsmanage.js
@@ -222,7 +222,7 @@ function PedalboardPresetsManager(options) {
if (options.currentlyAddressed) {
options.pedalPresetsList.find('option:selected').removeProp('selected')
- return self.prevent(e)
+ //return self.prevent(e)
}
$.ajax({
diff --git a/mod/addressings.py b/mod/addressings.py
index 575c1154..3e8a2d0f 100644
--- a/mod/addressings.py
+++ b/mod/addressings.py
@@ -792,10 +792,12 @@ class Addressings(object):
uri = presets[i]['uri']
pluginData['mapPresets'].append(uri)
options.append((i, presets[i]['label']))
+ print(pluginData['preset'], uri, handled)
if handled:
continue
if pluginData['preset'] == uri:
value = i
+ print (i, uri)
handled = True
# check if selected preset is non-existent
@@ -811,7 +813,8 @@ class Addressings(object):
maximum += 1
pluginData['mapPresets'].append(presets[i]['uri'])
options.append((i, presets[i]['label']))
-
+ print(value, maximum, options, pluginData['preset'])
+
return (value, maximum, options, pluginData['preset'])
# -----------------------------------------------------------------------------------------------------------------
diff --git a/mod/host.py b/mod/host.py
index bf8e6c93..73e4c6cf 100644
--- a/mod/host.py
+++ b/mod/host.py
@@ -984,6 +984,7 @@ class Host(object):
def process_write_queue(self):
try:
msg, callback, datatype = self._queue.pop(0)
+ print('process_write_queue: ', msg)
logging.info("[host] popped from queue: %s" % msg)
except IndexError:
self._idle = True
@@ -1275,9 +1276,12 @@ class Host(object):
def paramhmi_set(self, instance, portsymbol, value, callback):
if (instance == 'pedalboard'):
test = '/' + instance
+ elif (instance.startswith('/graph')):
+ test = instance
else:
test = '/graph/' + instance
instance_id = self.mapper.get_id_without_creating(test)
+ print(instance, portsymbol, value)
self.hmi.control_set(instance_id, portsymbol, value, callback)
def add_plugin(self, instance, uri, x, y, callback):
@@ -1762,6 +1766,7 @@ class Host(object):
self.msg_callback("param_set %s :bypass 0.0" % (instance,))
self.bypass(instance, False, None)
+ self.paramhmi_set('pedalboard', ':presets', idx, None)
self.addressings.load_current(used_actuators, (PEDALBOARD_INSTANCE_ID, ":presets"))
callback(True)
diff --git a/mod/webserver.py b/mod/webserver.py
index a5edd037..c4a1da28 100644
--- a/mod/webserver.py
+++ b/mod/webserver.py
@@ -22,6 +22,7 @@ import shutil
import subprocess
import sys
import time
+
from base64 import b64decode, b64encode
from signal import signal, SIGUSR1, SIGUSR2
from tornado import gen, iostream, web, websocket
@@ -860,6 +861,29 @@ class EffectPresetLoad(JsonRequestHandler):
@gen.engine
def get(self, instance):
uri = self.get_argument('uri')
+ begin = "file://"
+ beginpath = os.path.expanduser("~/.lv2/")
+ begin = begin + beginpath
+ myregex = begin + r"([A-Za-z0-9_]+)-([A-Za-z0-9_]+)\.lv2\/[A-Za-z0-9_]+(\.ttl)?"
+ m = re.match(myregex, uri)
+ if m:
+ instancename = m.group(1)
+ symbolname = m.group(2)
+ print(instance, symbolname)
+ matched = True
+ else:
+ print("didn't match")
+
+ if matched:
+ instance_id = SESSION.host.mapper.get_id_without_creating('/graph/' + instancename)
+ data = SESSION.host.addressings.get_presets_as_options(instance_id)
+ value, maximum, options, spreset = data
+ for pair in (options):
+ if pair[1] == symbolname:
+ value = pair[0]
+
+ #self.paramhmi_set(instance, ':presets', value, None)
+ ok = yield gen.Task(SESSION.host.paramhmi_set, instance, ":presets", value)
ok = yield gen.Task(SESSION.host.preset_load, instance, uri)
self.write(ok)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment