Skip to content

Commit

Permalink
lichen-community-systemsgh-22: Updates DPT support to use new Host API.
Browse files Browse the repository at this point in the history
  • Loading branch information
colinbdclark committed Jul 4, 2024
1 parent da32804 commit 6d9a679
Show file tree
Hide file tree
Showing 13 changed files with 595 additions and 332 deletions.
30 changes: 30 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,36 @@
"svdFile": "${workspaceRoot}/.vscode/STM32H750x.svd",
"type": "cortex-debug"
},
{
"name": "Remote DPT passthrough",
"configFiles": [
"interface/stlink.cfg",
"target/stm32h7x.cfg"
],
"cwd": "${workspaceFolder}/hosts/daisy/examples/dpt/passthrough",
"debuggerArgs": [
"-d",
"${workspaceRoot}/hosts/daisy/examples/dpt/passthrough"
],
"executable": "${workspaceRoot}/hosts/daisy/examples/dpt/passthrough/build/signaletic-dpt-passthrough.elf",
"interface": "swd",
"openOCDLaunchCommands": [
"init",
"reset init"
],
"preLaunchTask": "Debug Build DPT 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 DPT lfos",
"configFiles": [
Expand Down
2 changes: 2 additions & 0 deletions hosts/daisy/examples/dpt/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
all:
$(MAKE) -C lfos
$(MAKE) -C passthrough

clean:
$(MAKE) -C lfos clean
$(MAKE) -C passthrough clean
8 changes: 4 additions & 4 deletions hosts/daisy/examples/dpt/lfos/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Project Name
TARGET ?= signaletic-dpt-lfos

DEBUG = 0
OPT = -O3
DEBUG = 1
OPT = -O0

# 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_INCLUDES += -I../vendor/lib -I../../../vendor/lib/dev -I../../../include
CPP_SOURCES = src/${TARGET}.cpp ../../../vendor/dpt/lib/daisy_dpt.cpp ../../../vendor/dpt/lib/dev/DAC7554.cpp ../../../src/signaletic-daisy-host.cpp ../../../src/daisy-dpt-host.cpp
CPP_SOURCES = ../../../vendor/dpt/lib/dev/DAC7554.cpp ../../../src/signaletic-daisy-host.cpp ../../../src/sig-daisy-patch-sm.cpp src/${TARGET}.cpp

USE_FATFS = 0

Expand Down
103 changes: 49 additions & 54 deletions hosts/daisy/examples/dpt/lfos/include/signaletic-dpt-lfos-signals.h
Original file line number Diff line number Diff line change
@@ -1,60 +1,57 @@
#include <libsignaletic.h>
#include "../../../../include/signaletic-daisy-host.hpp"
#include "../../../../include/signaletic-host.h"

struct sig_daisy_ClockedLFO_Inputs {
struct sig_host_ClockedLFO_Inputs {
float_array_ptr clockFreq;
};

struct sig_daisy_ClockedLFO_Parameters {
struct sig_host_ClockedLFO_Parameters {
int freqScaleCVInputControl;
int lfoGainCVInputControl;
int cvOutputControl;
};

// TODO: This isn't quite the correct name.
struct sig_daisy_ClockedLFO {
struct sig_host_ClockedLFO {
struct sig_dsp_Signal signal;
struct sig_daisy_ClockedLFO_Inputs inputs;
struct sig_daisy_ClockedLFO_Parameters parameters;
struct sig_host_ClockedLFO_Inputs inputs;
struct sig_host_ClockedLFO_Parameters parameters;
struct sig_dsp_Signal_SingleMonoOutput outputs;
struct sig_daisy_FilteredCVIn* freqScaleIn;
struct sig_host_FilteredCVIn* freqScaleIn;
struct sig_dsp_BinaryOp* clockFreqMultiplier;
struct sig_daisy_FilteredCVIn* lfoGainIn;
struct sig_host_FilteredCVIn* lfoGainIn;
struct sig_dsp_Oscillator* lfo;
struct sig_daisy_CVOut* cvOut;
struct sig_host_CVOut* cvOut;
struct sig_host_HardwareInterface* hardware;
};

void sig_host_ClockedLFO_generate(void* signal) {
struct sig_host_ClockedLFO* self =
(struct sig_host_ClockedLFO*) signal;
// FIXME: Need to either more formally separate construction from
// initialization, or introduce an additional lifecycle hook for
// handling this kind of initialization logic.
self->freqScaleIn->hardware = self->hardware;
self->freqScaleIn->parameters.control =
self->parameters.freqScaleCVInputControl;
self->lfoGainIn->hardware = self->hardware;
self->lfoGainIn->parameters.control =
self->parameters.lfoGainCVInputControl;
self->cvOut->hardware = self->hardware;
self->cvOut->parameters.control = self->parameters.cvOutputControl;

struct sig_daisy_ClockedLFO* sig_daisy_ClockedLFO_new(
struct sig_Allocator* allocator, struct sig_SignalContext* context,
struct sig_daisy_Host* host);
void sig_daisy_ClockedLFO_init(struct sig_daisy_ClockedLFO* self,
struct sig_SignalContext* context);
void sig_daisy_ClockedLFO_generate(void* signal);
void sig_daisy_ClockedLFO_destroy(struct sig_Allocator* allocator,
struct sig_daisy_ClockedLFO* self);


struct sig_daisy_ClockedLFO* sig_daisy_ClockedLFO_new(
struct sig_Allocator* allocator, struct sig_SignalContext* context,
struct sig_daisy_Host* host) {
struct sig_daisy_ClockedLFO* self = sig_MALLOC(allocator,
struct sig_daisy_ClockedLFO);

self->freqScaleIn = sig_daisy_FilteredCVIn_new(allocator, context, host);
self->clockFreqMultiplier = sig_dsp_Mul_new(allocator, context);
self->lfoGainIn = sig_daisy_FilteredCVIn_new(allocator, context, host);
self->lfo = sig_dsp_LFTriangle_new(allocator, context);
self->cvOut = sig_daisy_CVOut_new(allocator, context, host);

sig_daisy_ClockedLFO_init(self, context);
self->clockFreqMultiplier->inputs.left = self->inputs.clockFreq;

return self;
self->freqScaleIn->signal.generate(self->freqScaleIn);
self->clockFreqMultiplier->signal.generate(self->clockFreqMultiplier);
self->lfoGainIn->signal.generate(self->lfoGainIn);
self->lfo->signal.generate(self->lfo);
self->cvOut->signal.generate(self->cvOut);
}

void sig_daisy_ClockedLFO_init(struct sig_daisy_ClockedLFO* self,
void sig_host_ClockedLFO_init(struct sig_host_ClockedLFO* self,
struct sig_SignalContext* context) {
sig_dsp_Signal_init(self, context, *sig_daisy_ClockedLFO_generate);
sig_dsp_Signal_init(self, context, *sig_host_ClockedLFO_generate);
self->parameters.freqScaleCVInputControl = 1;
self->parameters.lfoGainCVInputControl = 2;
self->parameters.cvOutputControl = 1;
Expand All @@ -76,31 +73,29 @@ void sig_daisy_ClockedLFO_init(struct sig_daisy_ClockedLFO* self,
sig_CONNECT_TO_SILENCE(self, clockFreq, context);
}

void sig_daisy_ClockedLFO_generate(void* signal) {
struct sig_daisy_ClockedLFO* self =
(struct sig_daisy_ClockedLFO*) signal;
self->freqScaleIn->parameters.control =
self->parameters.freqScaleCVInputControl;
self->lfoGainIn->parameters.control =
self->parameters.lfoGainCVInputControl;
self->cvOut->parameters.control = self->parameters.cvOutputControl;
struct sig_host_ClockedLFO* sig_host_ClockedLFO_new(
struct sig_Allocator* allocator, struct sig_SignalContext* context) {
struct sig_host_ClockedLFO* self = sig_MALLOC(allocator,
struct sig_host_ClockedLFO);

self->clockFreqMultiplier->inputs.left = self->inputs.clockFreq;
self->freqScaleIn = sig_host_FilteredCVIn_new(allocator, context);
self->clockFreqMultiplier = sig_dsp_Mul_new(allocator, context);
self->lfoGainIn = sig_host_FilteredCVIn_new(allocator, context);
self->lfo = sig_dsp_LFTriangle_new(allocator, context);
self->cvOut = sig_host_CVOut_new(allocator, context);

self->freqScaleIn->signal.generate(self->freqScaleIn);
self->clockFreqMultiplier->signal.generate(self->clockFreqMultiplier);
self->lfoGainIn->signal.generate(self->lfoGainIn);
self->lfo->signal.generate(self->lfo);
self->cvOut->signal.generate(self->cvOut);
sig_host_ClockedLFO_init(self, context);

return self;
}

void sig_daisy_ClockedLFO_destroy(struct sig_Allocator* allocator,
struct sig_daisy_ClockedLFO* self) {
sig_daisy_FilteredCVIn_destroy(allocator, self->freqScaleIn);
void sig_host_ClockedLFO_destroy(struct sig_Allocator* allocator,
struct sig_host_ClockedLFO* self) {
sig_host_FilteredCVIn_destroy(allocator, self->freqScaleIn);
sig_dsp_Mul_destroy(allocator, self->clockFreqMultiplier);
sig_daisy_FilteredCVIn_destroy(allocator, self->lfoGainIn);
sig_host_FilteredCVIn_destroy(allocator, self->lfoGainIn);
sig_dsp_LFTriangle_destroy(allocator, self->lfo);
sig_daisy_CVOut_destroy(allocator, self->cvOut);
sig_host_CVOut_destroy(allocator, self->cvOut);

// We don't call sig_dsp_Signal_destroy
// because our output is borrowed from self->lfo,
Expand Down
Loading

0 comments on commit 6d9a679

Please sign in to comment.