grame-cncm / faust

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

soundfile primitive broken in C++ architectures #546

Closed jmckernon closed 3 years ago

jmckernon commented 3 years ago

For faust code which uses the soundfile primitive, trying to compile it to a C++ architecture leads to an error compiling the generated C++ code. For instance, consider the following file:

process = 0,_~+(1) : soundfile("test:[url:test.wav]", 2) : !,!,_,_;

Trying to compile it with faust2csvplot yields the following errors:

faust2csvplot test.dsp
test.dsp.cpp: In member function ‘virtual void mydsp::instanceResetUserInterface()’:
test.dsp.cpp:5017:18: error: ‘defaultsound’ was not declared in this scope
 5017 |    fSoundfile0 = defaultsound;
      |                  ^~~~~~~~~~~~
test.dsp.cpp: In member function ‘virtual void mydsp::compute(int, float**, float**)’:
test.dsp.cpp:5055:41: error: invalid use of incomplete type ‘struct Soundfile’
 5055 |   int* fSoundfile0ca_le0 = fSoundfile0ca->fLength;
      |                                         ^~
test.dsp.cpp:514:8: note: forward declaration of ‘struct Soundfile’
  514 | struct Soundfile;
      |        ^~~~~~~~~
test.dsp.cpp:5057:41: error: invalid use of incomplete type ‘struct Soundfile’
 5057 |   int* fSoundfile0ca_of0 = fSoundfile0ca->fOffset;
      |                                         ^~
test.dsp.cpp:514:8: note: forward declaration of ‘struct Soundfile’
  514 | struct Soundfile;
      |        ^~~~~~~~~
test.dsp.cpp:5058:49: error: invalid use of incomplete type ‘struct Soundfile’
 5058 |   FAUSTFLOAT** fSoundfile0ca_bu0 = fSoundfile0ca->fBuffers;
      |                                                 ^~
test.dsp.cpp:514:8: note: forward declaration of ‘struct Soundfile’
  514 | struct Soundfile;
      |        ^~~~~~~~~
test.dsp.cpp:5060:41: error: invalid use of incomplete type ‘struct Soundfile’
 5060 |   int* fSoundfile0ca_of1 = fSoundfile0ca->fOffset;
      |                                         ^~
test.dsp.cpp:514:8: note: forward declaration of ‘struct Soundfile’
  514 | struct Soundfile;
      |        ^~~~~~~~~
test.dsp.cpp:5061:49: error: invalid use of incomplete type ‘struct Soundfile’
 5061 |   FAUSTFLOAT** fSoundfile0ca_bu1 = fSoundfile0ca->fBuffers;
      |                                                 ^~
test.dsp.cpp:514:8: note: forward declaration of ‘struct Soundfile’
  514 | struct Soundfile;
      |        ^~~~~~~~~

I tested this with a number of C++-based architectures, faust2csvplot, faust2jack, faust2faustvst, with the same results for all of them. The same code works correctly in FaustLive.

sletz commented 3 years ago

The soundfile primitive is not supposed by all faust2xx script for now. For faust2jack, you'll have to add the -soundfile option to make it work.

jmckernon commented 3 years ago

Ah, thanks Stéphane, I hadn't realised. I'll try with faust2jack -soundfile. I might also try to hack the soundfile code from the jack-gtk architecture into the faustvst architecture file, as this is my eventual intended destination.

I'll close this.