This message was deleted.
# helpdesk
s
This message was deleted.
p
Copy code
track.setWebAudioPlugins();
I think you will want to set the actual panner node here? you should remove • track.pannerNode = pannerNode • sourceNode.connect(pannerNode).connect(audioContext.destination) you need to • supply your own audio context in
{ expWebAudioMix: {audioContext: this.audioContext}}
• call
track.setWebAudioPlugins([pannerNode]);
s
Hey Lukas, Thanks for you answer, did that but still nothing happen. No errors nothing, track is subscribed but nothing appears in my DOM,meaning no audio track.
I got the audio working (input problem), spatialization seems to work but the attenuation does not work)
Copy code
var AC = new AudioContext();
const room = new LivekitClient.Room({options : {expWebAudioMix:  AC}});

function handleTrackSubscribed(track, publication, participant) {


    if (track.kind === LivekitClient.Track.Kind.Audio) {
   var  audioContext  = this.audioContext;
      const sourceNode = audioContext.createMediaStreamSource(track.mediaStream)

        // Create and set PannerNode
        var  pannerNode = new PannerNode(audioContext, {
          distanceModel: "exponential",
          coneInnerAngle: 360, 
          coneOuterAngle: 360,
          refDistance:12,
          maxDistance: 15,
          rolloffFactor:2,
          coneOuterGain: 0,
        });
        //Define Start Position
        pannerNode.positionX.setValueAtTime(10000, 0); 
        pannerNode.positionY.setValueAtTime(10000, 0);
        pannerNode.positionZ.setValueAtTime(0, 0);
        //Connect to destination
       track.setWebAudioPlugins([pannerNode]);

       track.attach();
}
p
have you tried lowering the refDistance setting or setting maxDistance higher? that seems rather close right now. you would only get slight attenuation between 12-15 right now edit: ah, maxDistance is only used for
linear
distance model anyways… but if panning is working already the attenuation should work too as long as your rollof and refdistance settings make sense.
s
I have tried every combinations, the sound always remains at the same level
Linear could work for me having no attenuation between 0-12 and small attetnuation betwween 12-16. But I need the sound to phase out 🙂
is setWebAudioPlugins and expWebAudioMix doing anything special ? Or creating and managing my audio elements is the same?
p
try with
Copy code
distanceModel: "linear",
refDistance: 1,
maxDistance: 10000,
rolloffFactor: 10,
s
const sourceNode = audioContext.createMediaStreamSource(track.mediaStream) Should I keep this? I don't think so right?
Copy code
var AC = new AudioContext();
const room = new LivekitClient.Room({options : {expWebAudioMix:  AC}});

function handleTrackSubscribed(track, publication, participant) {

      if (track.kind === LivekitClient.Track.Kind.Audio) {
        var  audioContext  = this.audioContext;     
             // Create and set PannerNode
             var  pannerNode = new PannerNode(audioContext, {
               distanceModel: "linear",
               refDistance:1,
               maxDistance: 1000,
               rolloffFactor:10,
             });
            
            track.setWebAudioPlugins([pannerNode]);
            track.attach();
  
        // Create and set Listener
        SpeakerPositions.set(participant.identity, new Map());
        SpeakerPositions.get(participant.identity).set("panner", pannerNode);
        SpeakerPositions.get(participant.identity).set("position", {x:0, y: 0, z:0});
    }
  }
I think panner is not working at all
p
I think you would have an easier time if you enabled type checking in your IDE. this seems wrong
expWebAudioMix: AC
. it should say
expWebAudioMix: {audioContext: AC}
s
oh right
is webaudiomix doing anything special?
I reused my old way
and it's working