GoogleChromeLabs / web-audio-samples

Web Audio API samples by Chrome Web Audio Team
https://bit.ly/web-audio-samples
Apache License 2.0
686 stars 196 forks source link

VU-meter library design #337

Closed TenghuiZhang closed 1 year ago

TenghuiZhang commented 1 year ago

This PR inlcudes the vu-meter library design. It requires the ID of canvas element where the waveform will be rendered and min decibel of for VU-meter as initialization input. minDecibel define the range of vu-meter to consider silent. When the VU-Meter is created, it requires the analyserNode as real-time audio input data for calculating the correct vm-meter library.

The larger decibel means the louder the voice is and vice-verse. The range is from 0 to minDecibel(Is an negative number).

VU-Meter decibels design reference:

hoch commented 1 year ago

Also we can make the PR description more useful for reviewers. A list of bullet points that summarizes the nature of changes would be nice.

TenghuiZhang commented 1 year ago

This is VM-meter UI library recording VM-Meter recording.webm

TenghuiZhang commented 1 year ago

SInce there is no good RMS npm library to use, I keep my original RMS calculation formula as an individual function.

I am still using the AnalyserNode.getByteFrequencyData() because it is uint8array, instead of floart32array of getFloatFrequencyData(). Uint8array it is easy to calculate with range 0-255.

Reference: https://www.npmjs.com/search?q=keywords:rootMeanSquare https://www.npmjs.com/search?q=keywords:rms

TenghuiZhang commented 1 year ago

This is the new version UI of VU-meter: Waveform UI.webm