Hi Rob, sorry I might have misunderstood your question. But somehow the problem you encountered seems unavoidable.
I never actually encountered it before, because I never used panning in Unity. with Faust plugins...I always did in the way I suggested you :) Mostly -I think- comes down to how audio is generated and managed in Unity. Basically, the Faust plugin will fill an OnAudioFilterRead() which is the way you usually go for implementing custom DSP in Unity (aka filters/effects). Somehow (but I am far from an expert) when you create an OnAudioFilterRead() this will basically take over the functionalities of the Audio Source. Even if Pitch and Volume can be applied to the generated sound, this seems not to be the case for stereo panning. That's why, usually, you will need to make the panning yourself inside the OnAudioFilterRead(). I used Faust in projects for Oculus Quest, Hololens and nReal. If you use some sound spatializer plugins (such as the one from Oculus or the one from Microsoft or Steam Audio), usually they somehow fix the problem (sometimes you need to add a dummy audio file in the AudioClip of the Audio Source) I think who developed this https://github.com/LibPdIntegration/LibPdIntegration/wiki/spatialisation found an interesting way to deal with such a problem. Maybe it can be adapted in a similar way in Faust. Il giorno lun 1 nov 2021 alle ore 01:18 Rob Hamilton < robert.k.hamil...@gmail.com> ha scritto: > Thanks for the speedy and helpful reply Alberto. > > I tested this example splitting the signal in two (which still resulted in > audio in both channels regardless of Unity panners), but adding the > left/right parameterization on those outputs allows me to separately adjust > channel levels in Unity. > > As for replacing sliders with just numerical inputs, I built the example > pasted below, but Unity throws an error within the associated > FaustUtilities_ script, seemingly looking for UI elements: > > if (!FaustUI.fJSONParser(ref fJSON, out fUI)) { // Parses the JSON file > UnityEngine.Debug.LogError("Error JSON Parser"); > } > > Does violinModel by default require UI elements, even if sliders and the > like aren't specified in the FAUST declaration? Or is the manner I declared > it below confusing things... > > Again, any suggestions or guidances are extremely helpful. > > ------------- > > TEST SCRIPT (ATTEMPTING TO REMOVE UI ELEMENTS): > > import("stdfaust.lib"); > > my_violin= pm.violinModel(stringLength,bowPress,bowVel,bowPos)*outGain > with{ > stringLength = 0; > bowVel = 0; > bowPress = 0; > bowPos = 0; > outGain = 0; > }; > > left = 0; > right = 0; > > process = my_violin <: _ * left ,_ * right; > > > > On Sun, Oct 31, 2021 at 2:25 AM Alberto Boem <boem.albe...@gmail.com> > wrote: > >> Hi Rob, >> >> I think you need to specify this in your Faust code. >> >> Have you considered doing this for splitting the signal in two? >> >> process = my_violin_ui <: _,_; >> >> https://faustdoc.grame.fr/manual/syntax/#split-composition >> >> and maybe: >> >> left = hslider("[0]left",0,0,1,0.1); >> right = hslider("[0] right",0,0,1,0.1); >> >> process = my_violin_ui <: _ * left ,_ * right; >> >> in this way, you should gain control of the two channels separately. >> >> Or maybe, try to look at the example spat/panpot.dsp in the "Examples" of >> the Faust IDE. >> >> >> As a small suggestion. >> Sometimes I found that if you need to export a .dsp file as a unity >> plugin it is better to get rid of the UI elements of Faust. Replacing >> sliders with just numerical inputs seems to make everything more smooth and >> easier to process for Unity. >> >> Il giorno dom 31 ott 2021 alle ore 11:19 Rob Hamilton < >> robert.k.hamil...@gmail.com> ha scritto: >> >>> Hi all, >>> >>> Long time fan, first time caller. >>> >>> I'm playing with some Faust violins in a Unity project and am unsure as >>> to what I should expect to hear in terms of spatialization for the output >>> I'm getting. With a simple violinModel ui example such as listed below >>> (thanks 250A) loaded into a 2-dimensional unity scene, I seem to get two >>> channels of audio, which show no consideration of the Unity AudioSource >>> "Stereo Pan" parameter, either adjusted manually in the IDE or in code. For >>> a standard mono wav asset, this would pan the single channel left to right >>> (-1 to 1), and for a standard stereo wav asset this would increase/decrease >>> the volume of channels 0 or 1 respectively. >>> >>> In the online Faust ide for this example, I can see that two channels >>> are generated, so I assume stereo output. But the plugin output doesn't act >>> as a stereo asset would. Or am I missing something (I assume the latter). >>> >>> I've tested routing these through Unity Mixer groups and can see audio >>> level data in both channels too, so I'm sure it's not my home audio rig. >>> And this is for a simple 2D project, no 3D spatialization, so I have >>> Unity's "Spatial Blend" Audio Source parameter set to 2D (which then >>> ignores the roll-off settings). >>> >>> Any suggestions would be great. >>> >>> thanks! >>> >>> Rob >>> >>> ***** CODE EXAMPLE ***** >>> >>> import("stdfaust.lib"); >>> >>> my_violin_ui = >>> pm.violinModel(stringLength,bowPress,bowVel,bowPos)*outGain >>> >>> with{ >>> >>> stringLength = hslider("v:violin/v:[0]string/[0]length[midi: ctrl >>> 72]",0.75,0,2,0.01) : si.smoo; >>> >>> bowVel = hslider("v:violin/v:[1]bow/[0]velocity[midi: ctrl >>> 71]",0,0,1,0.01) : si.smoo; >>> >>> bowPress = hslider("v:violin/v:[1]bow/[1]pressure[midi: ctrl >>> 74]",0.5,0,1,0.01) : si.smoo; >>> >>> bowPos = hslider("v:violin/v:[1]bow/[2]position[midi: ctrl >>> 73]",0.7,0,1,0.01) : si.smoo; >>> >>> outGain = hslider("v:violin/outGain",0.5,0,1,0.01); >>> >>> }; >>> >>> process = my_violin_ui; >>> >>> _______________________________________________ >>> Faudiostream-users mailing list >>> Faudiostream-users@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/faudiostream-users >>> >> > > -- > Robert Hamilton > Center for Computer Research in Music and Acoustics (CCRMA) > Stanford University > http://ccrma.stanford.edu/~rob >
_______________________________________________ Faudiostream-users mailing list Faudiostream-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/faudiostream-users