samirkumardas / pcm-player

A minimalist javascript audio player for PCM streaming audio
Other
293 stars 83 forks source link

Possible to dynamically change sample rate? #18

Closed rhysmorgan134 closed 1 year ago

rhysmorgan134 commented 1 year ago

Hi first of all, thanks for your great repos! Jmuxer has been huge for me. I have an application that can receive audio packets in 8 different sample rates/channel counts, I currently handle this with 8 different ffplay instances that I pass those packets to. If I were to switch to this package would it be possible dynamically change the sample rate? I am guessing not, if not would you forsee any issues with running 8 instances of pcm-player?

Thanks Again!

samirkumardas commented 1 year ago

Thank you. You are right. You cannot change the sample rate dynamically at the moment. But you can add that functionality easily. Add a new method setSampleRate to the PCMPlayer and update the property sampleRate within that method whenever it is called.

Now you can invoke setSampleRate from your code logic whenever you need to change the sample rate

rhysmorgan134 commented 1 year ago

Worked flawlessly, Thankyou!