grame-cncm / faust

Functional programming language for signal processing and sound synthesis
http://faust.grame.fr
Other
2.54k stars 319 forks source link

FaustSawtooth example compilation error: narrowing convertion #791

Closed fausto78 closed 2 years ago

fausto78 commented 2 years ago

Hi, I'm quite new to cpp programming, so it probably should be my mistake... In a freshly installed Espressif-IDE I can't get to recompile the FaustSawtooth example after having introduced the cpp compiled DSP and Codec files. I followed step-by-step the tutorial on https://faustdoc.grame.fr/tutorials/esp32/#using-the-esp32-c-development-environment.

The console returns the following warning threated as an error: C:/Espressif/frameworks/esp-idf-v4.4.2/workspace/hellofaust/main/FaustSawtooth.cpp:1389:32: error: narrowing conversion of '((esp32audio*)this)->esp32audio::fSampleRate' from 'int' to 'uint32_t' {aka 'unsigned int'} inside { } [-Werror=narrowing] .sample_rate = fSampleRate

In /main/CMakeLists.txt I registered only the 3 .cpp files. I hope it's correct.

I also found a command to suppress this error, but, sorry, I don't know where to use it.

Many thanks in advance. Fausto (it's my name.. When I heard of the Faust compiler I realized I couldn't miss it :)

sletz commented 2 years ago

You can probably solve it by adding an explicit cast at C:/Espressif/frameworks/esp-idf-v4.4.2/workspace/hellofaust/main/FaustSawtooth.cpp:1389. With is the exact line ?

Interaction on Faust Slack of Discord might help also: https://faust.grame.fr/community/help/

sletz commented 2 years ago

BTW: are you using Faust in this context https://www.denerg.polito.it/en/the_department/internal_structures/laboratories/laboratori_area_elettrica/maglab ?

fausto78 commented 2 years ago

BTW: are you using Faust in this context https://www.denerg.polito.it/en/the_department/internal_structures/laboratories/laboratori_area_elettrica/maglab ?

It would be great using it in my Lab, but also to build audio effect processors and synths. Thanks for the suggestion, I'll try ASAP!

fausto78 commented 2 years ago

You can probably solve it by adding an explicit cast at C:/Espressif/frameworks/esp-idf-v4.4.2/workspace/hellofaust/main/FaustSawtooth.cpp:1389. With is the exact line ?

Interaction on Faust Slack of Discord might help also: https://faust.grame.fr/community/help/

Many thanks!! It worked and I learned a lot. Ciao Fausto

sletz commented 2 years ago

Many thanks!! It worked and I learned a lot. Ciao Fausto

If your cast edit is in a Faust architecture file, part of the Faust distribution, I would be happy to fix that. Or you can possibly prepare a Pull Request.

fausto78 commented 2 years ago

If your cast edit is in a Faust architecture file, part of the Faust distribution, I would be happy to fix that. Or you can possibly prepare a Pull Request.

It is in the cpp compiled with Faust under Ubuntu (I needed to specify -AC101, since I'm testing the Audio Dev Kit) and put in the Espressif-IDE under Win11.

Please tell me if and how could I help best.

sletz commented 2 years ago

Can you send me the file?

fausto78 commented 2 years ago

Here you can find the cpp file and the console rows with the warnings. I hope It's enough. I started again from a WM8978 example, since it's precisely the same. Many thanks again!

FaustSawtooth.zip BuildConsole_LastRows.txt

sletz commented 2 years ago

Thanks is this .sample_rate = uint32_t(fSampleRate), fix correct? If yes then I can fix it here https://github.com/grame-cncm/faust/blob/master-dev/architecture/faust/audio/esp32-dsp.h

fausto78 commented 2 years ago

Yes, it is correct!

sletz commented 2 years ago

Thanks, fixed in https://github.com/grame-cncm/faust/commit/ba61c20530e555cc78922a97a09f27726203856d