Skip to content

Commit

Permalink
lichen-community-systemsgh-22: Still broken but improved refactoring …
Browse files Browse the repository at this point in the history
…of Daisy host infrastructure.
  • Loading branch information
colinbdclark committed Mar 27, 2024
1 parent 4f07c8c commit d37f38d
Show file tree
Hide file tree
Showing 34 changed files with 1,892 additions and 2,271 deletions.
60 changes: 60 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,66 @@
"svdFile": "${workspaceRoot}/.vscode/STM32H750x.svd",
"type": "cortex-debug"
},
{
"name": "Remote Lichen Sines",
"configFiles": [
"interface/stlink.cfg",
"target/stm32h7x.cfg"
],
"cwd": "${workspaceFolder}/hosts/daisy/examples/lichen-medium/sines",
"debuggerArgs": [
"-d",
"${workspaceRoot}/hosts/daisy/examples/lichen-medium/sines"
],
"executable": "${workspaceRoot}/hosts/daisy/examples/lichen-medium/sines/build/lichen-medium-sines.elf",
"interface": "swd",
"openOCDLaunchCommands": [
"init",
"reset init"
],
"preLaunchTask": "Debug Build Lichen Medium Examples",
"preRestartCommands": [
"load",
"enable breakpoint",
"monitor reset"
],
"request": "launch",
"runToEntryPoint": "main",
"servertype": "openocd",
"showDevDebugOutput": "parsed",
"svdFile": "${workspaceRoot}/.vscode/STM32H750x.svd",
"type": "cortex-debug"
},
{
"name": "Remote Lichen Freddie Bare Board Test",
"configFiles": [
"interface/stlink.cfg",
"target/stm32h7x.cfg"
],
"cwd": "${workspaceFolder}/hosts/daisy/examples/lichen-freddie/bare-board-test",
"debuggerArgs": [
"-d",
"${workspaceRoot}/hosts/daisy/examples/lichen-freddie/bare-board-test"
],
"executable": "${workspaceRoot}/hosts/daisy/examples/lichen-freddie/bare-board-test/build/lichen-freddie-bare-board-test.elf",
"interface": "swd",
"openOCDLaunchCommands": [
"init",
"reset init"
],
"preLaunchTask": "Debug Build Lichen Freddie Examples",
"preRestartCommands": [
"load",
"enable breakpoint",
"monitor reset"
],
"request": "launch",
"runToEntryPoint": "main",
"servertype": "openocd",
"showDevDebugOutput": "parsed",
"svdFile": "${workspaceRoot}/.vscode/STM32H750x.svd",
"type": "cortex-debug"
},
{
"name": "Remote Versio Filter",
"configFiles": [
Expand Down
34 changes: 33 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,38 @@
"array": "cpp",
"initializer_list": "cpp",
"map": "cpp",
"unordered_map": "cpp"
"unordered_map": "cpp",
"signaletic-host.h": "c",
"__config": "cpp",
"__debug": "cpp",
"__errc": "cpp",
"__mutex_base": "cpp",
"__threading_support": "cpp",
"__verbose_abort": "cpp",
"cctype": "cpp",
"charconv": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"complex": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"exception": "cpp",
"iosfwd": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"typeinfo": "cpp",
"variant": "cpp",
"algorithm": "cpp"
}
}
14 changes: 14 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,20 @@
],
"type": "shell"
},
{
"label": "Debug Build Lichen Freddie Examples",
"dependsOn": [
"Build libdaisy"
],
"command": "make clean;DEBUG=1 OPT=-Og make",
"options": {
"cwd": "${workspaceFolder}/hosts/daisy/examples/lichen-freddie"
},
"problemMatcher": [
"$gcc"
],
"type": "shell"
},
{
"label": "Build Bluemchen Examples",
"dependsOn": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,18 @@ struct sig_dsp_Signal* listStorage[MAX_NUM_SIGNALS];
struct sig_List signals;
struct sig_dsp_SignalListEvaluator* evaluator;

sig::libdaisy::Seed board;
sig::libdaisy::seed::SeedBoard board;
daisy::OledDisplay<daisy::SSD130xI2c64x32Driver> display;
FixedCapStr<20> displayStr;
struct sig_daisy_Host* host;
sig::libdaisy::AnalogInput knob1;
float knob1RawValue = 0.0f;
sig::libdaisy::AnalogInput knob2;
float knob2RawValue = 0.0f;
sig::libdaisy::InvertedAnalogInput cv1;
float cv1RawValue = 0.0f;
sig::libdaisy::InvertedAnalogInput cv2;
float cv2RawValue = 0.0f;
struct sig_dsp_Value* freq;
sig::libdaisy::GateInput gateIn;
struct sig_dsp_Value* gain;
Expand All @@ -38,6 +45,7 @@ struct sig_dsp_BinaryOp* harmonizerFreqScale;
struct sig_dsp_Oscillator* harmonizer;
sig::libdaisy::Toggle button;
struct sig_dsp_Value* buttonValue;
float buttonRawValue = 0.0f;
struct sig_dsp_BinaryOp* mixer;
struct sig_dsp_BinaryOp* attenuator;

Expand Down Expand Up @@ -102,8 +110,13 @@ void buildSignalGraph(struct sig_Allocator* allocator,

void AudioCallback(daisy::AudioHandle::InputBuffer in,
daisy::AudioHandle::OutputBuffer out, size_t size) {
freq->parameters.value = 1760.0f * knob1.Value();
buttonValue->parameters.value = button.Value();
knob1RawValue = knob1.Value();
knob2RawValue = knob2.Value();
cv1RawValue = cv1.Value();
cv2RawValue = cv2.Value();
buttonRawValue = button.Value();
freq->parameters.value = 1760.0f * knob1RawValue;
buttonValue->parameters.value = buttonRawValue;

evaluator->evaluate((struct sig_dsp_SignalEvaluator*) evaluator);

Expand All @@ -119,10 +132,24 @@ void updateOLED() {

displayStr.Clear();
displayStr.Append("Button ");
displayStr.AppendFloat(button.Value(), 1);
displayStr.AppendFloat(buttonRawValue, 1);
display.SetCursor(0, 0);
display.WriteString(displayStr.Cstr(), Font_6x8, true);

displayStr.Clear();
displayStr.AppendFloat(knob1RawValue, 2);
displayStr.Append(" ");
displayStr.AppendFloat(knob2RawValue, 2);
display.SetCursor(0, 8);
display.WriteString(displayStr.Cstr(), Font_6x8, true);

displayStr.Clear();
displayStr.AppendFloat(cv1RawValue, 2);
displayStr.Append(" ");
displayStr.AppendFloat(cv2RawValue, 2);
display.SetCursor(0, 16);
display.WriteString(displayStr.Cstr(), Font_6x8, true);

display.Update();
}

Expand All @@ -144,10 +171,10 @@ int main(void) {

// TODO: Move ADC initialization out of the Init function
dsy_gpio_pin adcPins[] = {
sig::libdaisy::SEED_PIN_D16,
sig::libdaisy::SEED_PIN_D15,
sig::libdaisy::SEED_PIN_D21,
sig::libdaisy::SEED_PIN_D18
sig::libdaisy::seed::PIN_D16,
sig::libdaisy::seed::PIN_D15,
sig::libdaisy::seed::PIN_D21,
sig::libdaisy::seed::PIN_D18
};

board.InitADC(adcPins, 4);
Expand All @@ -157,9 +184,11 @@ int main(void) {
&audioSettings);
buildSignalGraph(&allocator, context, &signals, &audioSettings, &status);

knob1.Init(&board.adc, 1);
// gateIn.Init(sig::libdaisy::PATCH_SM_PIN_B10);
button.Init(sig::libdaisy::SEED_PIN_D28); // Encoder button.
knob1.Init(&board.adc, 0);
knob2.Init(&board.adc, 1);
cv1.Init(&board.adc, 2);
cv2.Init(&board.adc, 3);
button.Init(sig::libdaisy::seed::PIN_D28); // Encoder button.

board.audio.Start(AudioCallback);

Expand Down
4 changes: 2 additions & 2 deletions hosts/daisy/examples/bluemchen/oscillator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ DEBUG = 0
OPT = -O3

# Sources
C_SOURCES += ../../../../../libsignaletic/vendor/tlsf/tlsf.c ../../../../../libsignaletic/src/libsignaletic.c
C_SOURCES += ../../../../../libsignaletic/vendor/tlsf/tlsf.c ../../../../../libsignaletic/src/libsignaletic.c ../../../src/signaletic-host.c
C_INCLUDES += -I../../../../../libsignaletic/vendor/tlsf -I../../../../../libsignaletic/include

CPP_SOURCES = ../../../vendor/kxmx_bluemchen/src/kxmx_bluemchen.cpp ../../../src/signaletic-daisy-host.cpp ../../../src/daisy-bluemchen-host.cpp src/${TARGET}.cpp
CPP_SOURCES = ../../../src/signaletic-daisy-host.cpp ../../../src/sig-daisy-seed.cpp src/${TARGET}.cpp

USE_FATFS = 0

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include <string>
#include <tlsf.h>
#include <libsignaletic.h>
#include "../../../../include/daisy-bluemchen-host.h"
#include "../../../../include/signaletic-daisy-host.h"
#include "../../../../include/kxmx-bluemchen-device.hpp"

using namespace kxmx;
using namespace kxmx::bluemchen;
using namespace daisy;
using namespace sig::libdaisy;

FixedCapStr<20> displayStr;

Expand All @@ -26,64 +28,67 @@ struct sig_dsp_Signal* listStorage[MAX_NUM_SIGNALS];
struct sig_List signals;
struct sig_dsp_SignalListEvaluator* evaluator;

Bluemchen bluemchen;
struct sig_daisy_Host* host;
DaisyHost<BluemchenDevice> host;

struct sig_daisy_FilteredCVIn* coarseFreqKnob;
struct sig_daisy_FilteredCVIn* fineFreqKnob;
struct sig_daisy_CVIn* vOctCVIn;
struct sig_host_FilteredCVIn* coarseFreqKnob;
struct sig_host_FilteredCVIn* fineFreqKnob;
struct sig_host_CVIn* vOctCVIn;
struct sig_dsp_BinaryOp* coarsePlusVOct;
struct sig_dsp_BinaryOp* coarseVOctPlusFine;
struct sig_dsp_LinearToFreq* frequency;
struct sig_dsp_Oscillator* osc;
struct sig_dsp_ConstantValue* gainLevel;
struct sig_dsp_BinaryOp* gain;
struct sig_daisy_AudioOut* leftOut;
struct sig_daisy_AudioOut* rightOut;
struct sig_host_AudioOut* leftOut;
struct sig_host_AudioOut* rightOut;


void UpdateOled() {
bluemchen.display.Fill(false);
host.device.display.Fill(false);

displayStr.Clear();
displayStr.Append("Starscill");
bluemchen.display.SetCursor(0, 0);
bluemchen.display.WriteString(displayStr.Cstr(), Font_6x8, true);
host.device.display.SetCursor(0, 0);
host.device.display.WriteString(displayStr.Cstr(), Font_6x8, true);

displayStr.Clear();
displayStr.AppendFloat(frequency->outputs.main[0], 1);
bluemchen.display.SetCursor(0, 8);
bluemchen.display.WriteString(displayStr.Cstr(), Font_6x8, true);
host.device.display.SetCursor(0, 8);
host.device.display.WriteString(displayStr.Cstr(), Font_6x8, true);

displayStr.Clear();
displayStr.Append(" Hz");
bluemchen.display.SetCursor(46, 8);
bluemchen.display.WriteString(displayStr.Cstr(), Font_6x8, true);
host.device.display.SetCursor(46, 8);
host.device.display.WriteString(displayStr.Cstr(), Font_6x8, true);

bluemchen.display.Update();
host.device.display.Update();
}

void buildSignalGraph(struct sig_SignalContext* context,
struct sig_Status* status) {
/** Frequency controls **/
// Bluemchen AnalogControls are all unipolar,
// so they need to be scaled to bipolar values.
coarseFreqKnob = sig_daisy_FilteredCVIn_new(&allocator, context, host);
// FIXME: this is no longer true.
coarseFreqKnob = sig_host_FilteredCVIn_new(&allocator, context);
coarseFreqKnob->hardware = &host.device.hardware;
sig_List_append(&signals, coarseFreqKnob, status);
coarseFreqKnob->parameters.control = bluemchen.CTRL_1;
coarseFreqKnob->parameters.control = sig_host_KNOB_1;
coarseFreqKnob->parameters.scale = 10.0f;
coarseFreqKnob->parameters.offset = -5.0f;
coarseFreqKnob->parameters.time = 0.01f;

fineFreqKnob = sig_daisy_FilteredCVIn_new(&allocator, context, host);
fineFreqKnob = sig_host_FilteredCVIn_new(&allocator, context);
fineFreqKnob->hardware = &host.device.hardware;
sig_List_append(&signals, fineFreqKnob, status);
fineFreqKnob->parameters.control = bluemchen.CTRL_2;
fineFreqKnob->parameters.control = sig_host_KNOB_1;
fineFreqKnob->parameters.offset = -0.5f;
fineFreqKnob->parameters.time = 0.01f;

vOctCVIn = sig_daisy_CVIn_new(&allocator, context, host);
vOctCVIn = sig_host_CVIn_new(&allocator, context);
vOctCVIn->hardware = &host.device.hardware;
sig_List_append(&signals, vOctCVIn, status);
vOctCVIn->parameters.control = bluemchen.CTRL_4;
vOctCVIn->parameters.control = sig_host_CV_IN_1;
vOctCVIn->parameters.scale = 10.0f;
vOctCVIn->parameters.offset = -5.0f;

Expand Down Expand Up @@ -120,13 +125,15 @@ void buildSignalGraph(struct sig_SignalContext* context,
gain->inputs.right = gainLevel->outputs.main;
sig_List_append(&signals, gain, status);

leftOut = sig_daisy_AudioOut_new(&allocator, context, host);
leftOut->parameters.channel = 0;
leftOut = sig_host_AudioOut_new(&allocator, context);
leftOut->hardware = &host.device.hardware;
leftOut->parameters.channel = sig_host_AUDIO_OUT_1;
leftOut->inputs.source = gain->outputs.main;
sig_List_append(&signals, leftOut, status);

rightOut = sig_daisy_AudioOut_new(&allocator, context, host);
rightOut->parameters.channel = 1;
rightOut = sig_host_AudioOut_new(&allocator, context);
rightOut->hardware = &host.device.hardware;
rightOut->parameters.channel = sig_host_AUDIO_OUT_2;
rightOut->inputs.source = gain->outputs.main;
sig_List_append(&signals, rightOut, status);
}
Expand All @@ -145,16 +152,12 @@ int main(void) {
sig_List_init(&signals, (void**) &listStorage, MAX_NUM_SIGNALS);

evaluator = sig_dsp_SignalListEvaluator_new(&allocator, &signals);
host = sig_daisy_BluemchenHost_new(&allocator,
&audioSettings,
&bluemchen,
(struct sig_dsp_SignalEvaluator*) evaluator);
sig_daisy_Host_registerGlobalHost(host);
host.Init(&audioSettings, (struct sig_dsp_SignalEvaluator*) evaluator);

struct sig_SignalContext* context = sig_SignalContext_new(&allocator,
&audioSettings);
buildSignalGraph(context, &status);
host->impl->start(host);
host.Start();

while (1) {
UpdateOled();
Expand Down
5 changes: 5 additions & 0 deletions hosts/daisy/examples/lichen-freddie/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
all:
$(MAKE) -C bare-board-test

clean:
$(MAKE) -C bare-board-test clean
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ OPT = -O0
C_SOURCES += ../../../../../libsignaletic/vendor/tlsf/tlsf.c ../../../../../libsignaletic/src/libsignaletic.c
C_INCLUDES += -I../../../../../libsignaletic/vendor/tlsf -I../../../../../libsignaletic/include

CPP_INCLUDES += -I../vendor/lib -I../../../vendor/lib/dev -I../../../include
CPP_INCLUDES += -I../vendor/lib -I../../../vendor/lib/dev -I../../../include -I/include
CPP_SOURCES = src/${TARGET}.cpp ../../../src/sig-daisy-seed.cpp

USE_FATFS = 0
Expand Down
Loading

0 comments on commit d37f38d

Please sign in to comment.