Closed pierreguillot closed 6 years ago
1) " I can try to recopy the single-precision signals into double-precision signals and then to reinterpret_cast this double-precision signals to single-precision signals for the compute method of the DSP instance but this seems pretty tricky..."
You may use the dsp_sample_adapter
class defined infaust/dsp/dsp-adapter.h
file to do that.
2) " I don't know how it works internally but if I use the option -single the two options are defined and the objects doesn't output any sound." faustgen~ on Max/MSP indeed used -double
and defines FAUSTFLOAT
as double
. This -single/-double behavior is a bug and should be detected at compilation time (done in https://github.com/grame-cncm/faust/commit/5ef1f5e325b9a7c0dec66107a7ede0531a02346f)
I just made something similar in C and it works perfectly! Thanks!
In the code, I check if the option -double
is defined and if so, I use a different matrix for the signals. I have 1 signals matrix for single precision and 1 signals matrix for double precision. Perhaps there is a better (dynamic?) approach but it works :)
PS: Perhaps it could be useful to get the floating-point precision directly from an instance? Because if you use machine code to generate the instance you can't know the floating-point precision, isn't it?
PPS: So for the moment, I check "manually" if the floating-point precision is not defined twice (or more).
"PS: Perhaps it could be useful to get the floating-point precision directly from an instance?" I think it would be better as a factory method, and in a more general way, that is getting all compilation parameters as a string (like -vec -vs 32 -double
...etc)
I think it would be better as a factory method, and in a more general way, that is getting all compilation parameters as a string (like -vec -vs 32 -double...etc)
Yes, indeed that's better. Do you want me to create a new specific issue for this feature (and I close this one)?
This -single/-double behavior is a bug and should be detected at compilation time (done in 5ef1f5e)
I tried and it works perfectly! Thanks
"Do you want me to create a new specific issue for this feature (and I close this one)?" yes please do thanks.
The FAUST quick reference says that using the options single/double/quad defines the floating-point format for internal computations (p. 43). So I thought that this floating-point format is used internally and that I can feed the compute method of the DSP instance with the floating-point format defined by FAUSTFLOAT. I guess this is the behavior that I expect but it doesn't seem to work like that.
If I use the option
-double
with the object faustgen~ for Pd (using the method compileoption), the external crashes because Pd uses a single-precision floating-point format FAUSTFLOAT is also single-precision floating-point format. I can try to recopy the single-precision signals into double-precision signals and then to reinterpret_cast this double-precision signals to single-precision signals for the compute method of the DSP instance but this seems pretty tricky...On another side, the object faustgen~ for Max uses the default option
-double
(l. 483 of faustgen~.cpp). I don't know how it works internally but if I use the option-single
the two options are defined and the objects doesn't output any sound.So can I use the options of the floating-point format with LLVM? It would be great because sometimes the internal process requires more precision than the input/output signals (or sometimes a part of the process can be optimized using smaller precision). And if not, I think that the FAUST compiler should generates a warning (as for the option
-quad
).