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

faust2daisy generated code does not compile for -pod or -patch option #1089

Open
ghoppla opened this issue Nov 26, 2024 · 6 comments
Open

faust2daisy generated code does not compile for -pod or -patch option #1089

ghoppla opened this issue Nov 26, 2024 · 6 comments

Comments

@ghoppla
Copy link
Contributor

ghoppla commented Nov 26, 2024

faust2daisy generated code does not compile for -pod or -patch option

When compiling code using faust2daisy with option -pod or -patch the code does not compile.
Only -patchsm is working.

The problem is that somehow ValueConverter.h is not included in the generated cpp file.

Steps for reproduction

Versions Used:

  • Faust master-dev, 2.76.0, Commit: 5ed7170
  • 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]";

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 -patch -midi -sr 48000 -bs 32 -uim -source minimal_example.dsp

when running make within the generated folder

$ cd minimal_example
$ make

a lot of the compilation errors appear, since ValueConverter.h is not included:

ex_faust.cpp:1220:1: error: expected class-name before '{' token
 1220 | {
      | ^
ex_faust.cpp:1265:29: error: 'ValueConverter' was not declared in this scope
 1265 |             std::unique_ptr<ValueConverter> fConverter;
      |                             ^~~~~~~~~~~~~~
ex_faust.cpp:1265:43: error: template argument 1 is invalid
 1265 |             std::unique_ptr<ValueConverter> fConverter;
      |                                           ^
ex_faust.cpp:1265:43: error: template argument 2 is invalid
ex_faust.cpp:1267:76: error: 'ValueConverter' was not declared in this scope; did you mean 'fConverter'?
 1267 |             AnalogKnob(uint16_t* adcptr, FAUSTFLOAT* zone, std::unique_ptr<ValueConverter>& converter, int rate)
      |                                                                            ^~~~~~~~~~~~~~
      |                                                                            fConverter
ex_faust.cpp:1267:90: error: template argument 1 is invalid
 1267 |             AnalogKnob(uint16_t* adcptr, FAUSTFLOAT* zone, std::unique_ptr<ValueConverter>& converter, int rate)
      |                                                                                          ^
ex_faust.cpp:1267:90: error: template argument 2 is invalid
ex_faust.cpp: In member function 'virtual void DaisyControlUI::AnalogKnob::update()':
ex_faust.cpp:1275:36: error: base operand of '->' is not a pointer
 1275 |                 *fZone = fConverter->ui2faust(Process());
      |                                    ^~
ex_faust.cpp: In member function 'void DaisyControlUI::InitKnobs()':
ex_faust.cpp:1320:33: error: 'ValueConverter' was not declared in this scope
 1320 |                 std::unique_ptr<ValueConverter> converter;
      |                                 ^~~~~~~~~~~~~~
ex_faust.cpp:1320:47: error: template argument 1 is invalid
 1320 |                 std::unique_ptr<ValueConverter> converter;
      |                                               ^
ex_faust.cpp:1320:47: error: template argument 2 is invalid
ex_faust.cpp:1322:50: error: 'LogValueConverter' was not declared in this scope
 1322 |                     converter = std::make_unique<LogValueConverter>(0., 1., fKnobs[i].fMin, fKnobs[i].fMax);
      |                                                  ^~~~~~~~~~~~~~~~~
ex_faust.cpp:1322:107: error: no matching function for call to 'make_unique<<expression error> >(double, double, float&, float&)'
 1322 |                     converter = std::make_unique<LogValueConverter>(0., 1., fKnobs[i].fMin, fKnobs[i].fMax);

.
.
.
@ghoppla
Copy link
Contributor Author

ghoppla commented Nov 26, 2024

In this part of the daisy architecture (ex_faust.cpp) the corresponding gui source files are included.

#include "faust/gui/meta.h"
#include "faust/gui/UI.h"
#if defined PATCHSM
#include "faust/gui/DaisyPatchInitControlUI.h"
#else
#include "faust/gui/DaisyControlUI.h"
#endif
#include "faust/dsp/dsp.h"

ValueConverter.h is included in DaisyControlUI.h and DaisyPatchInitControlUI.h
I don't understand why the ValueConverter.h gets included for DaisyPatchInitControlUI.h only.

@sletz
Copy link
Member

sletz commented Nov 26, 2024

Well DaisyPatchInitControlUI was developed after DaisyControlUI with an external contribution, and looking at the file, a lot of code is actually duplicated. So I guess the proper way would be to rework all of that, and put the new code of DaisyPatchInitControlUI in DaisyControlUI to finally keep a unique DaisyControlUI file, and possibly use #if defined PATCHSM ....some code... #endif inside it.

But this means a bit of work ((-;

@ghoppla
Copy link
Contributor Author

ghoppla commented Nov 26, 2024

hmmm... unfortunately I don't have this hardware to verify that stuff finally, since I've built my own hw interface for the raw daisy seed board. I could do it in blind mode without testing on the patch / pod only but thats not that good idea I think.

@ghoppla
Copy link
Contributor Author

ghoppla commented Nov 26, 2024

Despite the fact that the code is duplicated, from the preprocessor logic the the weird thing is that ValueConverter.h is not included for the -pod and -patch Option. Don't get it why...

@sletz
Copy link
Member

sletz commented Nov 27, 2024

. I could do it in blind mode without testing on the patch / pod only but thats not that good idea I think.

But you could at least test if the restructured code would compile right ?

@ghoppla
Copy link
Contributor Author

ghoppla commented Nov 27, 2024

. I could do it in blind mode without testing on the patch / pod only but thats not that good idea I think.

But you could at least test if the restructured code would compile right ?

lol... you owned me. Okay, I do my best, but it may need some days till I find the time. I hope someone can then test the code on hardware.

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

2 participants