steep-balloon-41261
11/25/2022, 7:53 AMdry-elephant-14928
11/25/2022, 8:21 AMstocky-sandwich-45001
11/25/2022, 12:25 PMcreamy-notebook-61404
11/25/2022, 1:08 PMcreamy-notebook-61404
11/25/2022, 1:08 PM// setup an audio analyzer
this.audioContext = new window.AudioContext;
this.analyser = this.audioContext.createAnalyser();
this.analyser.fftSize = 32; // minimum
this.analyser.maxDecibels = 60;
this.analyser.maxDecibels = 20;creamy-notebook-61404
11/25/2022, 1:11 PMonLocalTrackPublished(pub: LocalTrackPublication, participant: LocalParticipant) {
if (pub.kind === 'audio') {
// connect the stream to an analyzer
let stream = pub.track?.mediaStream;
if (stream && this.audioContext) {
let source = this.audioContext?.createMediaStreamSource(stream);
source?.connect(analyser);
}
}creamy-notebook-61404
11/25/2022, 1:13 PMthis.timer = window.setInterval(() => {
if (this.analyser && this.analyser.numberOfInputs > 0) {
let frequencyData = new Uint8Array(1);
this.analyser.getByteFrequencyData(frequencyData);
let volume=frequencyData[0] / 1.5;
this.onLocalAudioLevel(volume); // do some graphics stuff with this value
}stocky-sandwich-45001
11/25/2022, 9:18 PM