grame-cncm / faust

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

faust2api openframeworks+jack setup #468

Closed ciarandg closed 3 years ago

ciarandg commented 4 years ago

Hi, I'm trying to get started with Faust and OpenFrameworks, and am struggling to get any audio output from my program. I have a .dsp file named sin.dsp that contains the following: import("stdfaust.lib"); process = os.osc(440);

I ran faust2api -nozip -of sin.dsp, put #include "DspFaust.h" in my ofApp.h file, and added DspFaust faust = DspFaust(44100, 512); to the public section. In my ofApp.cpp file I put faust.start(); in the ofApp::setup() method. These are the only changes I've made to the default OF project template. It compiles and runs just fine, without any errors, but I'm not getting any audio output. Am I missing something? I know that it's successfully connecting to my JACK server, because in Carla I can see that it is creating a node called RtApiJack. Additionally, faust.isRunning() returns true and faust.getCPULoad() returns 0.

Apologies if I'm overlooking something obvious -- I'm fairly new to C++ and totally new to OF. Thanks in advance!

tomoyanonymous commented 4 years ago

Hi. This issue seems to be fixed between v2.20 to v2.27.2 (I tried to fix it and found that already solved...)

https://github.com/grame-cncm/faust/commit/65cdddcfc00e4b7f41f21f2e930af78459175798#diff-d39778773b599142413a4cee8fb0480f

Please make sure that your DspFaust.cpp contains a class ofaudio which has a callback function with audioInput(ofSoundBuffer& input) as an argument, not a audioInput(float* input, int bufsize, int channels). This class comes from ${faust_installed_directory}/include/faust/audio/of-audio.h. Of course, it can be solved by replacing this file to the latest version manually.

Also, as ofaudio class does not allow you to select an audio device other than a system-default device, you can manually set up ofSoundStream with raw dsp class code without any architecture file.

btw, I have tried to make an architecture file to generate ofxGui components from faust's UI definitions. It may be outdated but may be helpful to use faust and oF together.

https://github.com/tomoyanonymous/ofxFaust