i need to connect an already existing
audio element to a SoundSlot, i did read trough the api but could not find anything related to it. before digging trough the source, i just wanted to ask if someone did something like that before or knows if its possible.
So i am creating a new Sound with an Auido Element. After that i do create an asset and put the sound as the resource. then i assign the stuff to my AudioSlot “Voice”. but when i try to start it an error gets thrown in some part of the soundcomponent code, “this.source.start(0, offset);”
the error says that source is null which would mean that the assigned sound is null because the function checks if source is null and then creates the source out of the assigend sound. “_createSource()” _createSource returns null if _sound is null, so i guess there is something wrong with my setup.
_createSource checks if there is an buffer object in the sound object. which in my case, is false because i passed an AudioElement. in the docs it says i can pass an HTMLAudioElement as resource. I am a bit confused. https://developer.playcanvas.com/en/api/pc.Sound.html
So, yeah, the element node is suitable if you use the HTML elements, while the stream one can be used to read data from streams API or WebRTC. Well, I guess you already figured. Regarding the position of the listener, make sure you are reading and setting the position correctly. What can help is to create a dummy primitive object and set its position to the position of the listener. If the listener is the camera, you can add another camera for debugging.
Well my Listener is the camera of the local player. the emitter is the network entity. if i change the maxDistance to a lower value and move out of the distance, the sound suddenly stops but there is no fall off of the sound.
Well, it is hard to say what is happening in your case, but I would start from looking into the values you use for the panner. You can simplify it at start, e.g. don’t use directional sound, but instead create an omni point, where the sound would be of equal value, regardless of the direction the source is facing. You can set the inner cone to 360 degrees and outer one to 0. Check your distance and rolloff ratios. You can start with rolloff value of 1.