Hey everyone,
trying to work out FaustDSP intergration. I have successfully run and compiled this Faust example on the daisy seed: https://github.com/electro-smith/DaisySP/tree/master/examples/faustnoise
When substituting the FaustDSP code for a slightly tweaked standard example, I ran into problems with the sketch sounding at the wrong pitch.
Here’s what I did including the fix -
this code plays an saw at 440 on the left and at 660 on the right output -
declare filename "FaustSawtooth.dsp"; declare name "FaustSawtooth"; import("stdfaust.lib");
freq = nentry("freq",440,20,20000,0.01) : si.smoo;
gain = nentry("gain",1,0,1,0.01) : si.smoo;
process = os.sawtooth(freq)*gain,os.sawtooth(freq*1.5)*gain;
Here’s that code in the Faust IDE
I exported from the IDE with these settings - Platform: source Architecture: cplusplus
Then I took the .cpp file from FaustNoise example and replaced the user section in the architecture - between
/**************************BEGIN USER SECTION **************************/
and
/***************************END USER SECTION ***************************/
with the generated code from the IDE.
This ends up pretty distorted (alised) and playing one Octave too high.
To get the correct pitch, I had to change this
sample_rate = seed.AudioSampleRate();
to this
sample_rate = 96000;
To get rid of the aliasing, I had to set this
#define MY_BUFFER_SIZE 1
The preset size was 8; the higher the number the worse the distortion, the lower the better (tried 1, 2, 4, 8 , 16). 1 yields a good sounding result.
So I think there might be something of with the default sample rate and / or block size but I’m not sure … this should probably be looked at when making the Architecture Files for Faust-Daisy.