Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to create a volume level meter? #35

Open
JanMisker opened this issue Oct 19, 2022 · 3 comments
Open

Possible to create a volume level meter? #35

JanMisker opened this issue Oct 19, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@JanMisker
Copy link

The package is great, works very well.

I was wondering whether it is possible to create a volume level meter.
So a single or dual (stereo) bar display?

@hvianna
Copy link
Owner

hvianna commented Dec 16, 2022

I'll probably implement this at some point, but I'm thinking it will be better as a separate module. Would love to try and replicate some vintage analog VU meters.

@hvianna hvianna added the enhancement New feature or request label Dec 16, 2022
@JanMisker
Copy link
Author

I was able to create it quite easily, drawing on a separate canvas.
I use getBars() and then getting the max value and max peak to draw a bar for the value and a little 'dash' on top for the peak. Also applying the fillStyle and strokeStyle from the regular analyzer, to get the same gradient fill. Works quite nice, see image. Probably the values are not technically correct as 'volume', but for the user it's a good enough indicator to understand how 'loud' they are.
Screenshot 2022-12-27 at 21 45 19

@hvianna
Copy link
Owner

hvianna commented Dec 29, 2022

@JanMisker That's a nice solution! You can also use getEnergy() and getEnergy('peak'), although currently it returns only a single channel - there's a demo of it in https://audiomotion.dev/demo/fluid.html (see the Energy meters button).

Maybe it would be worth expanding getEnergy() to return separate left and right channels. I'll have a look into it.

And you're correct, these are not very accurate volume measurements. Ideally it would be done by analyzing the time-domain (waveform) data, instead of the frequency-domain. That's why I said I'll probably create a separate module just for the meters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants