Closed flojawi closed 4 years ago
I added a -teensy
option in faust2api
in https://github.com/grame-cncm/faust/commit/65f6b357190424c74bd390adb86b1e09b1ca18d0
But "blind commit", can you test and report ? Thanks.
Haven't tested it on the Teensy so far, but it compiles now, great :)
OK thanks. I would be interesting to now how it works on the Teensy (including possibly MIDI and polyphonic options...).
Well, i was too optimistic. I have tried to follow the examples in the article above under section "3.2 Polyphonic DSP Engine". I've created following .dsp file named "MyFaustSynth":
import("stdfaust.lib");
freq = nentry("freq",300,50,2000,0.01); gain = nentry("gain",0.5,0,1,0.01); gate = button("gate"); envelope = en.asr(0.01,gain,0.01,gate); process = os.sawtooth(freq)envelope; effect = +@(ma.SR0.15)*0.3; //echo
The faust code compiles (using faust2api -teensy -nvoices 4 -effect auto MyFaustSynthPoly.dsp
), however, the resulting .cpp and .h files are always named DspFaust, regardless of the Name of the .dsp file (contrary to the article). So i tried to compile to following teensy code in the Arduino IDE (with settings for the Teensy 3.6 as well as the Teensy 4.0):
DspFaust faustsynth(44100, 128); void setup() { } void loop() { }
which gave loads of error messages. It seems to me, that either the above article was referencing functions of the faust compiler, which didn't get implemented in the current master-dev branch, or those functions got removed somehow. That would be strange, since you are listed as an author of the article.
What error messages ?
/tmp/arduino_build_118388/sketch/DspFaust.cpp: In function 'void deleteClist(clist)': /tmp/arduino_build_118388/sketch/DspFaust.cpp:7795:59: error: 'dynamic_cast' not permitted with -fno-rtti uiOwnedItem owned = dynamic_cast<uiOwnedItem>(it); ^ /tmp/arduino_build_118388/sketch/DspFaust.cpp: In member function 'void teensyaudio::updateImp()': /tmp/arduino_build_118388/sketch/DspFaust.cpp:17236:13: error: 'fDSP' was not declared in this scope fDSP->compute(AUDIO_BLOCK_SAMPLES, fInChannel, fOutChannel); ^ /tmp/arduino_build_118388/sketch/DspFaust.cpp: In member function 'virtual void teensyaudio::update()': /tmp/arduino_build_118388/sketch/DspFaust.cpp:17253:53: error: 'FAUST_INPUTS' was not declared in this scope void update(void) { if (fRunning) updateImp<FAUST_INPUTS, FAUST_OUTPUTS>(); } ^ /tmp/arduino_build_118388/sketch/DspFaust.cpp:17253:67: error: 'FAUST_OUTPUTS' was not declared in this scope void update(void) { if (fRunning) updateImp<FAUST_INPUTS, FAUST_OUTPUTS>(); } ^ /tmp/arduino_build_118388/sketch/DspFaust.cpp:17253:82: error: no matching function for call to 'teensyaudio::updateImp()' void update(void) { if (fRunning) updateImp<FAUST_INPUTS, FAUST_OUTPUTS>(); } ^ /tmp/arduino_build_118388/sketch/DspFaust.cpp:17222:14: note: candidate: template<int INPUTS, int OUTPUTS> void teensyaudio::updateImp() void updateImp() ^ /tmp/arduino_build_118388/sketch/DspFaust.cpp:17222:14: note: template argument deduction/substitution failed: /tmp/arduino_build_118388/sketch/DspFaust.cpp:17253:82: error: template argument 1 is invalid void update(void) { if (fRunning) updateImp<FAUST_INPUTS, FAUST_OUTPUTS>(); } ^ /tmp/arduino_build_118388/sketch/DspFaust.cpp:17253:82: error: template argument 2 is invalid /tmp/arduino_build_118388/sketch/DspFaust.cpp: In constructor 'teensyaudio::teensyaudio()': /tmp/arduino_build_118388/sketch/DspFaust.cpp:17257:35: error: 'FAUST_INPUTS' was not declared in this scope teensyaudio():AudioStream(FAUST_INPUTS, new audio_block_t[FAUST_INPUTS]), fRunning(false) ^ /tmp/arduino_build_118388/sketch/DspFaust.cpp: In destructor 'virtual teensyaudio::~teensyaudio()': /tmp/arduino_build_118388/sketch/DspFaust.cpp:17262:33: error: 'fDSP' was not declared in this scope for (int i = 0; i < fDSP->getNumInputs(); i++) { ^ /tmp/arduino_build_118388/sketch/DspFaust.cpp:17266:33: error: 'fDSP' was not declared in this scope for (int i = 0; i < fDSP->getNumOutputs(); i++) { ^ /tmp/arduino_build_118388/sketch/DspFaust.cpp: In member function 'virtual bool teensyaudio::init(const char, dsp)': /tmp/arduino_build_118388/sketch/DspFaust.cpp:17274:13: error: 'fDSP' was not declared in this scope fDSP->init(AUDIO_SAMPLE_RATE_EXACT); ^ /tmp/arduino_build_118388/sketch/DspFaust.cpp:17293:9: warning: no return statement in function returning non-void [-Wreturn-type] } ^ /tmp/arduino_build_118388/sketch/DspFaust.cpp: In constructor 'DspFaust::DspFaust(bool)': /tmp/arduino_build_118388/sketch/DspFaust.cpp:24039:26: error: exception handling disabled, use -fexceptions to enable throw std::bad_alloc(); ^
-fno-rtti
and add -fexceptions
in the compilation flagsso I did as you said, removed -fno-rtti
and added -fexceptions
to the compiler flags.
I'm still getting these error messages:
/tmp/arduino_build_595100/sketch/DspFaust.cpp: In member function 'virtual void teensyaudio::update()': DspFaust.cpp:16717: error: 'FAUST_INPUTS' was not declared in this scope void update(void) { if (fRunning) updateImp<FAUST_INPUTS, FAUST_OUTPUTS>(); } ^ DspFaust.cpp:16717: error: 'FAUST_OUTPUTS' was not declared in this scope void update(void) { if (fRunning) updateImp<FAUST_INPUTS, FAUST_OUTPUTS>(); } ^ DspFaust.cpp:16717: error: no matching function for call to 'teensyaudio::updateImp()' void update(void) { if (fRunning) updateImp<FAUST_INPUTS, FAUST_OUTPUTS>(); } ^ /tmp/arduino_build_595100/sketch/DspFaust.cpp:16686:14: note: candidate: template<int INPUTS, int OUTPUTS> void teensyaudio::updateImp() void updateImp() ^ /tmp/arduino_build_595100/sketch/DspFaust.cpp:16686:14: note: template argument deduction/substitution failed: DspFaust.cpp:16717: error: template argument 1 is invalid void update(void) { if (fRunning) updateImp<FAUST_INPUTS, FAUST_OUTPUTS>(); } ^ DspFaust.cpp:16717: error: template argument 2 is invalid /tmp/arduino_build_595100/sketch/DspFaust.cpp: In constructor 'teensyaudio::teensyaudio()': DspFaust.cpp:16721: error: 'FAUST_INPUTS' was not declared in this scope teensyaudio():AudioStream(FAUST_INPUTS, new audio_block_t[FAUST_INPUTS]), fRunning(false), fDSP(NULL) ^ /tmp/arduino_build_595100/sketch/DspFaust.cpp: In member function 'virtual bool teensyaudio::init(const char, dsp*)': DspFaust.cpp:16758: warning: control reaches end of non-void function } ^
Maybe it has to do with rtti and exceptions turned off for Teensy, like stated in this forum post: https://forum.pjrc.com/threads/41364-fno-rtti-amp-dynamic_cast
Another try here: https://github.com/grame-cncm/faust/commit/2b0d008f7f9c9680972d65c8cd7eaad7530b83ab
(sorry for those blind commits.... I cannot test here...)
"RTTI and exceptions are C++ features that add a lot of bloat to compiled programs. They're turned off for Teensy and most other microcontrollers." ==> this may be an issue yes, but the problem you have is still a compilation error. First we have to fix it.
With your new commit, I can compile the code in the Arduino IDE ( so this has worked (: ), but uploading to teensy fails with this error message:
No Teensy boards were found on any USB ports of your computer.
Please press the PROGRAM MODE BUTTON on your Teensy to upload your sketch.
when I do so, press the program mode button, and upload again, it sais:
Unable to open /dev/bus/usb/001/018 for reboot request
Often this error is caused by ModemManager mistaking Teensy for a modem.
Make sure you have the latest 49-teensy.rules, or uninstall ModemManager!
Maybe, i have broken something else in the boards.txt file, as other teensy programs get linking errors now, even when undoing the changes with -fno-rtti
and -fexceptions
. So i will try to recover my previous system state.
Actually, i'm not that dependent on faust2api -teensy, faust2teensy -lib is better suited for me, cause I can integrate it easier in my project. (also considering the bigger memory footprint of faust2api) En plus, I don't have the resources at the time for extensive testing, I just wanted to report that issue. But thank you for your fast help! :)
OK, so stay with faust2teensy -lib for now.
Contrary to this paper http://smc2019.uma.es/articles/S1/S1_03_SMC2019_paper.pdf , i'm not able to compile faust code with the command faust2api -teensy. Only faust2teensy -lib does produce code for the teensy.