Open marvpaul opened 3 years ago
I have done some further investigations. What I found out so far: Faust is using Unity's OnAudioFilterRead
method to change / add the audio data which is generated by the faust plugin.
In the Unity documentation (https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnAudioFilterRead.html) it says that each entry in the audio data array should be in the range from -1 to 1. When I log an entry of this audio data after the faust plugin has filled it, it turns out that the values are way higher than 1 (up to 1.062668E+10).
private void OnAudioFilterRead(float[] buffer, int numchannels) {
ctx.process(buffer, buffer.Length / numchannels, numchannels);
Debug.Log(buffer[10]);
}
This just seems to be unexpected. Perhaps thats part of the problem?
It seems like the FMSynth2.dsp run in monophonic mode (in the Faust IDE) does not go outside the [-1,1] range. So can you first test the FMSynth2.dsp code in monophonic mode?
@sletz I tried to compile the faust code using the command ./faust2unity -ios -osx -nvoices 1 synth3.dsp
but the problem still persists. I can't hear any sound when using the plugin in Unity.
no -nvoices
for now
@sletz I now used the command ./faust2unity -ios -osx synth3.dsp
for conversion. I imported the .unitypackage, assigned the generated FaustPlugin_synth3.cs
to a GameObject, clicked "Initialization" button of the script, clicked "Play" and then clicked the "Gate" button of the script. unfortunately there's still no sound.
I suggest trying simpler DSP examples, even one generating constant signals, and debugging with Debug.Log(buffer[10]);
kind of code.
I tried to include a Faust example into Unity (2020.3.0f1). I used this example: https://github.com/grame-cncm/faust/blob/master/examples/bela/FMSynth2.dsp
First I used the command
./faust2unity -ios -osx -nvoices 6 synth3.dsp
I imported the resultingFaustPlugin_synth3.unitypackage
into my Unity project, attached theFaustPlugin_synth3.cs
to a GameObject, clicked on the "Initialization" button in the Unity Inspector and have written a simple script to trigger the plugin. The script I used is the following:I was not able to hear any sound. Is this a bug in faust2unity or did I missed something here?