enzienaudio / heavy

heavy public issue tracker and static dsp code releases
https://enzienaudio.com
ISC License
71 stars 4 forks source link

Unity 3D pan not working #112

Open JackVerde opened 8 years ago

JackVerde commented 8 years ago

Maybe I'm doing something wrong but I don't seem to be getting any 3D panning in Unity. Distance rolloff works just fine. Am I supposed to do something inside the patch? (spatial blend is set to 3D) Thanks

diplojocus commented 8 years ago

@JackVerde yeah this is a strange one, I couldn't quite figure it out a while ago. Thanks for reminding me I'll ping the Unity team and again and see if I get some more info on what might be the cause :/

diplojocus commented 8 years ago

@JackVerde turns out this is a bug in Unity, they've filed it but it's undetermined when it might get fixed :/

AaronMeyers commented 8 years ago

@diplojocus can you post a link to the Unity issue tracker page so we can vote for it?

diplojocus commented 8 years ago

https://fogbugz.unity3d.com/default.asp?819377_4tr2tfssru4ae9hr

Is this the right thing?

AaronMeyers commented 8 years ago

i don't think so... over on this site https://issuetracker.unity3d.com/ you can vote on bugs, which presumably could help impact the priorities...

AaronMeyers commented 8 years ago

@diplojocus i found this one but it says its a duplicate, but i couldn't find the one its a duplicate of :/

https://issuetracker.unity3d.com/issues/onaudiofilterread-doesnt-do-panning-when-used-as-a-generator

AaronMeyers commented 8 years ago

I just discovered that panning works fine if I set the project to use the Oculus spatializer (now included with Unity) and tick the 'spatialize' box on the audio source. So until the bug is addressed, this might be a workable fallback solution.

diplojocus commented 8 years ago

Thanks for the tip @AaronMeyers !

phembree commented 7 years ago

Just came by to say that this problem is still happening (I haven't tried the Oculus spatializer yet). FYI I met you Enzien folks at Sight Glass (GDC 2017).

phembree commented 7 years ago

Ok I've figured this out with vanilla Unity spatialization. Basically I followed the instructions in this thread: https://forum.unity3d.com/threads/onaudiofilterread-sound-spatialisation.362782/ or alternatively in this thread: https://forum.unity3d.com/threads/onaudiofilterread-oafr-function-can-only-run-one-instance-in-unity.285041/

To do this with Pure Data / Heavy, basically just include an [adc~ 1 2] in your patch, and multiply those signals by whatever you are generating, before sending them out [dac~ 1 2] (this is literally just using the signals from adc~ as panning attenuation for the rest of your patch). From the Unity side, you need to make sure that the audioClip on the audioSource accompanying your Heavy audio lib is filled with an audio file that is all 1f, and loop and PlayOnAwake that audioSource.

wimachtendink commented 7 years ago

Hello, all.

I was having a lot of trouble getting spatialization to work with a project I'm working on.

I had no trouble with a simple heavy script which was added to a prefab then instantiated, but if I tried to add the heavy script as a component, I just got a mono signal.

Perhaps this is just standard Unity procedure, but I found that if I add the heavy script component on Awake() rather than Start() it worked just fine.

I'm guessing that Oculus Spatializer is only checking for spatialized audio sources once, and in getting the sequence wrong heavy is clobbering Oculus.

Hope this helps someone.

diplojocus commented 7 years ago

thanks @phembree and @wimachtendink your input!

@phembree that's an interesting solution, but still seems to be a hack around the fact that this is a bug in Unity :/ But if it works right now go for it!