daisy seed fx should be good, implemented for bw_wah
This commit is contained in:
parent
e199678912
commit
0a56d74388
@ -1,9 +1,9 @@
|
|||||||
LIBDAISY_DIR := ${ROOT_DIR}/../../../../libDaisy
|
LIBDAISY_DIR := ${ROOT_DIR}/../../../../libDaisy
|
||||||
|
|
||||||
ifdef SYNTH
|
ifdef SYNTH
|
||||||
CPP_SOURCES = ${ROOT_DIR}/../../common/daisy-seed/synth.cpp
|
CPP_SOURCES = ${ROOT_DIR}/../../common/daisy-seed/synth.cpp ${CPP_SOURCES_EXTRA}
|
||||||
else
|
else
|
||||||
CPP_SOURCES = ${ROOT_DIR}/../../common/daisy-seed/fx.cpp
|
CPP_SOURCES = ${ROOT_DIR}/../../common/daisy-seed/fx.cpp ${CPP_SOURCES_EXTRA}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LDFLAGS += -u _printf_float
|
LDFLAGS += -u _printf_float
|
||||||
@ -12,5 +12,11 @@ SYSTEM_FILES_DIR = ${LIBDAISY_DIR}/core
|
|||||||
include ${SYSTEM_FILES_DIR}/Makefile
|
include ${SYSTEM_FILES_DIR}/Makefile
|
||||||
|
|
||||||
CPPFLAGS += \
|
CPPFLAGS += \
|
||||||
|
-I${ROOT_DIR} \
|
||||||
|
-I${ROOT_DIR}/../src \
|
||||||
|
-I${ROOT_DIR}/../../../include
|
||||||
|
|
||||||
|
CFLAGS += \
|
||||||
|
-I${ROOT_DIR} \
|
||||||
-I${ROOT_DIR}/../src \
|
-I${ROOT_DIR}/../src \
|
||||||
-I${ROOT_DIR}/../../../include
|
-I${ROOT_DIR}/../../../include
|
||||||
|
@ -1,52 +1,96 @@
|
|||||||
#include "daisy_seed.h"
|
#include "daisy_seed.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "config_daisy_seed.h"
|
||||||
|
|
||||||
|
#define BLOCK_SIZE 32
|
||||||
|
|
||||||
using namespace daisy;
|
using namespace daisy;
|
||||||
|
|
||||||
DaisySeed hardware;
|
DaisySeed hardware;
|
||||||
|
CpuLoadMeter loadMeter;
|
||||||
|
|
||||||
P_TYPE instance;
|
P_TYPE instance;
|
||||||
|
|
||||||
|
float buf[2][BLOCK_SIZE];
|
||||||
|
float *bufs[2] = { buf[0], buf[1] };
|
||||||
|
|
||||||
|
static void setParams() {
|
||||||
|
for (int i = 0; i < NUM_PINS; i++)
|
||||||
|
P_SET_PARAMETER(&instance, config_pins[i].param_index, hardware.adc.GetFloat(i));
|
||||||
|
}
|
||||||
|
|
||||||
static void AudioCallback(
|
static void AudioCallback(
|
||||||
AudioHandle::InterleavingInputBuffer in,
|
AudioHandle::InterleavingInputBuffer in,
|
||||||
AudioHandle::InterleavingOutputBuffer out,
|
AudioHandle::InterleavingOutputBuffer out,
|
||||||
size_t size) {
|
size_t size) {
|
||||||
// set params
|
loadMeter.OnBlockStart();
|
||||||
// update coeffs ctrl
|
setParams();
|
||||||
for (size_t i = 0; i < size; i++)
|
const size_t n = size >> 1;
|
||||||
// update coeffs audio
|
#if NUM_CHANNELS_IN != 0
|
||||||
out[i] = in[i];
|
for (size_t i = 0; i < n; i++) {
|
||||||
|
const size_t j = i << 1;
|
||||||
|
buf[0][i] = in[j];
|
||||||
|
# if NUM_CHANNELS_IN > 1
|
||||||
|
buf[1][i] = in[j + 1];
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
P_PROCESS(&instance, (const float **)bufs, bufs, n);
|
||||||
|
for (size_t i = 0; i < n; i++) {
|
||||||
|
const size_t j = i << 1;
|
||||||
|
#if NUM_CHANNELS_OUT > 0
|
||||||
|
out[j] = buf[0][i];
|
||||||
|
#else
|
||||||
|
out[j] = 0.f;
|
||||||
|
#endif
|
||||||
|
#if NUM_CHANNELS_OUT > 1
|
||||||
|
out[j + 1] = buf[1][i];
|
||||||
|
#else
|
||||||
|
out[j + 1] = 0.f;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
loadMeter.OnBlockEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
hardware.Configure();
|
hardware.Configure();
|
||||||
hardware.Init();
|
hardware.Init();
|
||||||
|
|
||||||
// ...
|
AdcChannelConfig adcConfig[NUM_PINS];
|
||||||
AdcChannelConfig adcConfig;
|
for (int i = 0; i < NUM_PINS; i++)
|
||||||
adcConfig.InitSingle(hardware.GetPin(21));
|
adcConfig[i].InitSingle(hardware.GetPin(config_pins[i].pin));
|
||||||
|
|
||||||
hardware.adc.Init(&adcConfig, 1);
|
hardware.adc.Init(adcConfig, NUM_PINS);
|
||||||
hardware.adc.Start();
|
hardware.adc.Start();
|
||||||
// ...
|
|
||||||
|
|
||||||
hardware.SetAudioBlockSize(32);
|
hardware.SetAudioBlockSize(BLOCK_SIZE);
|
||||||
float sample_rate = hardware.AudioSampleRate();
|
float sample_rate = hardware.AudioSampleRate();
|
||||||
|
|
||||||
// init
|
P_INIT(&instance);
|
||||||
// set sample rate
|
P_SET_SAMPLE_RATE(&instance, sample_rate);
|
||||||
|
|
||||||
hardware.StartLog();
|
hardware.StartLog();
|
||||||
|
|
||||||
// set params
|
loadMeter.Init(sample_rate, BLOCK_SIZE);
|
||||||
// reset coeffs
|
|
||||||
// reset state
|
setParams();
|
||||||
|
P_RESET(&instance);
|
||||||
|
|
||||||
hardware.StartAudio(AudioCallback);
|
hardware.StartAudio(AudioCallback);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
//hardware.adc.GetFloat(0);
|
const float avgLoad = loadMeter.GetAvgCpuLoad();
|
||||||
//hardware.PrintLine("%f",x);
|
const float maxLoad = loadMeter.GetMaxCpuLoad();
|
||||||
//System::Delay(x);
|
const float minLoad = loadMeter.GetMinCpuLoad();
|
||||||
|
hardware.PrintLine("---");
|
||||||
|
for (int i = 0; i < NUM_PARAMETERS; i++)
|
||||||
|
if (config_parameters[i].out)
|
||||||
|
hardware.PrintLine("%s: %f", config_parameters[i].name, P_GET_PARAMETER(&instance, i));
|
||||||
|
hardware.PrintLine("---");
|
||||||
|
hardware.PrintLine("Processing Load %:");
|
||||||
|
hardware.PrintLine("Max: " FLT_FMT3, FLT_VAR3(maxLoad * 100.0f));
|
||||||
|
hardware.PrintLine("Avg: " FLT_FMT3, FLT_VAR3(avgLoad * 100.0f));
|
||||||
|
hardware.PrintLine("Min: " FLT_FMT3, FLT_VAR3(minLoad * 100.0f));
|
||||||
|
System::Delay(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||||
|
|
||||||
TARGET = bw_example_fx_wah
|
TARGET = bw_example_fx_wah
|
||||||
CPP_SOURCES += ${ROOT_DIR}/../src/bw_example_fx_wah.c
|
|
||||||
|
C_SOURCES += ${ROOT_DIR}/../src/bw_example_fx_wah.c
|
||||||
|
|
||||||
include ${ROOT_DIR}/../../common/daisy-seed/daisy-seed.mk
|
include ${ROOT_DIR}/../../common/daisy-seed/daisy-seed.mk
|
||||||
|
35
examples/fx_wah/daisy-seed/config_daisy_seed.h
Normal file
35
examples/fx_wah/daisy-seed/config_daisy_seed.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Brickworks
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 Orastron Srl unipersonale
|
||||||
|
*
|
||||||
|
* Brickworks is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* Brickworks is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Brickworks. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* File authors: Stefano D'Angelo, Paolo Marrone
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CONFIG_DAISY_SEED_H
|
||||||
|
#define _CONFIG_DAISY_SEED_H
|
||||||
|
|
||||||
|
struct config_pin {
|
||||||
|
int param_index;
|
||||||
|
int pin;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define NUM_PINS 1
|
||||||
|
|
||||||
|
static struct config_pin config_pins[NUM_PINS] = {
|
||||||
|
{ 0, 15 }
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user