esonderegger / web-audio-peak-meter

Customizable peak meters, using the web audio API.
https://esonderegger.github.io/web-audio-peak-meter/
MIT License
125 stars 33 forks source link

How to Meter Live Audio? #29

Open FGP-Radio opened 2 years ago

FGP-Radio commented 2 years ago

Is it possible to meter a live audio feed (such as internet radio)? I could not seem to get one to work.

esonderegger commented 2 years ago

Since these meters take any audio node as an input, it shouldn't matter if the source is a live audio feed as opposed to something on-demand. For example, I've used oscillator nodes in the past just because sometimes they are easier to test than MediaElementSourceNode.

That said, getting the AudioContext running and getting an audio source into a web audio API node can sometimes be challenging, and each major browser handles things slightly differently. I'm working on updating the docs because they currently don't work for Safari, which requires an event listening for a user's click in order to call resume on the context - listening for play on the audio element doesn't cut it.

There could also be CORS restrictions causing problems. What type of source is the live audio feed? Do you have an example page I can take a look at?

FGP-Radio commented 2 years ago

Thanks for your reply!!! Here are a couple of examples of audio streams that I have unsuccessfully tried using. http://67.212.165.106:8004/stream https://war.streamguys1.com:7185/live

As for browser issues, I tried the program in the latest version of Chrome. I don't think that was the problem as static audio files work fine.

Krzysztof-Grzegorz commented 2 years ago

I have the same problem. Does not play stream. It does not measure the signal level http://radiochrystusakrola.pl/meter/meter_peak.html

vinnielo1 commented 8 months ago

It seems that the meter won't analyse live streams hosted on another server when using Safari on iOS. Chromium on Android, however, is less fussy, and isn't a problem. mp3 files hosted on the same server are fine on iOS, as shown in Krzysztof's example above.