Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polyphony for the Daisy Seed #1090

Open
ghoppla opened this issue Nov 29, 2024 · 5 comments
Open

Polyphony for the Daisy Seed #1090

ghoppla opened this issue Nov 29, 2024 · 5 comments

Comments

@ghoppla
Copy link
Contributor

ghoppla commented Nov 29, 2024

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:
electro-smith/libDaisy#503

Steps for reproduction

Versions Used:

  • Faust v2.76.0
  • libDaisy v7.1.0

Daisy Toolchain Setup on Linux:

  1. Create a folder, e.g.

    $ mkdir ~/daisy
  2. Get arm-none-eabi:

  3. Get libDaisy:

    $ git clone --recurse-submodules https://github.com/electro-smith/libDaisy
  4. Create environment.rc file 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
  5. Compile libDaisy:

    $ source environment.rc
    $ cd libDaisy
    $ make

** Compilation: **

  1. 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) <: _,_;
  1. Generated cpp code with:
$ faust2daisy -nvoices 4 -midi -sr 48000 -bs 32 -uim -source minimal_example.dsp
@DBraun
Copy link
Collaborator

DBraun commented Dec 29, 2024

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);

@sletz
Copy link
Member

sletz commented Jan 2, 2025

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.

DBraun added a commit to DBraun/faust that referenced this issue Jan 2, 2025
sletz pushed a commit that referenced this issue Jan 2, 2025
@ghoppla
Copy link
Contributor Author

ghoppla commented Jan 2, 2025

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...

@DBraun
Copy link
Collaborator

DBraun commented Jan 3, 2025

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?

@ghoppla
Copy link
Contributor Author

ghoppla commented Jan 3, 2025

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants