Polyphony for the Daisy Seed
Polyphony for the Daisy Seed
Compiling faust generated cpp using faust2daisy with -nvoices > 1 fails because of dynamic_casts in poly-dsp.h
ex_faust.cpp: In member function 'void dsp_voice_group::buildUserInterface(UI*)':
ex_faust.cpp:10312:35: error: 'dynamic_cast' not permitted with '-fno-rtti'
10312 | if (!fGroupControl || dynamic_cast<SoundUIInterface*>(ui_interface)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ex_faust.cpp: In member function 'virtual void mydsp_poly::buildUserInterface(UI*)':
ex_faust.cpp:10669:17: error: 'dynamic_cast' not permitted with '-fno-rtti'
10669 | if (dynamic_cast<midi_interface*>(ui_interface)) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ex_faust.cpp:10670:32: error: 'dynamic_cast' not permitted with '-fno-rtti'
10670 | fMidiHandler = dynamic_cast<midi_interface*>(ui_interface);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [/home/georg/Programmierung/daisy/libDaisy/core/Makefile:271: build/ex_faust.o] Fehler 1
Removing the -fno-rtti Option in libDaisy shouldn't be considered: https://github.com/electro-smith/libDaisy/issues/503
Steps for reproduction
Versions Used:
- Faust v2.76.0
- libDaisy v7.1.0
Daisy Toolchain Setup on Linux:
-
Create a folder, e.g.
$ mkdir ~/daisy -
Get arm-none-eabi:
- See DaisyWiki
-
Get libDaisy:
$ git clone --recurse-submodules https://github.com/electro-smith/libDaisy -
Create
environment.rcfile with the following content:export LIBDAISY_DIR=~/daisy/libDaisy GCC_PATH=~/daisy/gcc-arm-none-eabi-10-2020-q4-major/bin export PATH=$GCC_PATH:$PATH -
Compile libDaisy:
$ source environment.rc $ cd libDaisy $ make
** Compilation: **
- dsp file minimal_example.dsp
import("stdfaust.lib");
declare name "Daisy Seed Bug";
declare options "[midi:on]";
declare options "[nvoices:4]";
gate = button("gate");
vel = hslider("gain", 0, 0, 1, .01);
freq = hslider("freq", 440, 0, 20000, 0.01);
process = os.triangle(freq) * vel : _*en.adsr(.1,.1,.7,.2, gate) <: _,_;
- Generated cpp code with:
$ faust2daisy -nvoices 4 -midi -sr 48000 -bs 32 -uim -source minimal_example.dsp
I got it to compile with some changes
struct FAUST_API UI : public UIReal<FAUSTFLOAT> {
UI() {}
virtual ~UI() {}
// add both below
virtual bool isSoundUI() const { return false; }
virtual bool isMidiInterface() const { return false; }
class FAUST_API GenericUI : public UI
{
public:
GenericUI() {}
virtual ~GenericUI() {}
// add this:
virtual bool isSoundUI() const override { return true; }
}
Inside class MidiUI public methods add
virtual bool isMidiInterface() const override { return true; }
Inside dsp_voice_group::buildUserInterface(UI* ui_interface), change
if (!fGroupControl || dynamic_cast<SoundUIInterface*>(ui_interface)) {
to
if (!fGroupControl || ui_interface->isSoundUI()) {
Inside mydsp_poly::buildUserInterface(UI* ui_interface), change
if (dynamic_cast<midi_interface*>(ui_interface)) {
fMidiHandler = dynamic_cast<midi_interface*>(ui_interface);
to
if (ui_interface->isMidiInterface()) {
fMidiHandler = reinterpret_cast<midi_interface*>(ui_interface);
OK, but I don't want to change the UI interface in general. So an acceptable solution would be to use conditional compassion line #ifdef DAISY {....} #endif everywhere needed.
Hi David Braun, thank you very much for your work about the daisy support. I tried your code and fixed two little bugs (see PR #1106 ).
Currently, I don't get any sound out of my daisy seed board. I will debug the code using the st-link debugger...
Thanks for those fixes! Maybe it's silent because the device is expecting MIDI from one of the 3.5 mm input, using https://electro-smith.com/products/trs-3-5mm-midi-adapter not micro-USB?
Hi David, unfortunately it doesn't seem to be that easy.
I checked that by generating the following faust dsp with faust2daisy -midi -nvoices 2 -sr 48000 -bs 32 -source poly.dsp
import("stdfaust.lib");
freq = hslider("freq",440,50,2000,0.01);
gain = hslider("gain",1,0,1,0.01);
gate = button("gate");
envelope = en.adsr(0.1,0.2,0.9,0.3,gate)*gain;
process = os.sawtooth(freq)*envelope <: _,_;
effect = _+os.sawtooth(440), _+os.sawtooth(440);
So using effect you should get a tone without any midi messages (normally I use usb midi and was too lazy to add my crappy midi breakout board).
Then I updated libDaisy to be sure that this is not the issue. Doing that I got stuck with an annoying little bug we created (see PR #1107).
After fixing this I added
# Debug Symbols
DEBUG = 1
# Optimization Level (default: -Os for size optimization)
OPT ?= -Og
to the makefile.
Then I've used the st-link v2 debugger to check the code execution. It ends up in the hard fault handler when calling a ui function:
Call Stack: ex_faust.cpp main() MidiMeta::analyse mono_dsp->buildUserInterface(&jsonui); ui_interface->openVerticalBox("poly"); or (the weird thing is... if I do not try to jump into the functions I get one step further oO) ui_interface->addHorizontalSlider("freq", &fHslider0, FAUSTFLOAT(4.4e+02f), FAUSTFLOAT(5e+01f), FAUSTFLOAT(2e+03f), FAUSTFLOAT(0.01f));
It stops at the following breakpoint in the Hardfault Handler: if(SCB->CFSR & SCB_CFSR_IMPRECISERR_Msk)
So for today I'm out -_- Maybe you guys have an idea!