Ralith / oddio

Lightweight game audio
Apache License 2.0
150 stars 9 forks source link

Migration from 0.5 to 0.6 Gain can't set initial volume #93

Closed Nazariglez closed 2 years ago

Nazariglez commented 2 years ago

Hello!

I am migrating from 0.5 to 0.6 and I saw that Gain doesn't allow anymore to set the initial volume, to do that I should use FixedGain but then it seems that GainControl cannot be used in the same way. Is there a way to set the volume before it starts playing and allows to change it after by the user?

This is the code I want to migrate: https://github.com/Nazariglez/notan/blob/f/prepare0.7.0/crates/notan_oddio/src/backend.rs#L290

And this is an example of how it works now using 0.5.0. You can set the volume before clicking pause and it will start at that level.

I would appreciate any hint. Thanks

Ralith commented 2 years ago

Looks like that case isn't covered by the current API. https://github.com/Ralith/oddio/pull/94 should address that.

Ralith commented 2 years ago

Released in 0.6.1.

Nazariglez commented 2 years ago

That was fast, thanks!

Though I notice two things now, the first one is that -60.0 dbs is not "silence" anymore, my set_volume function that maps 0-1 to -60-0 has sound no matter if I pass 0.0 as volume.

Another thing is that no matter the volume I pass (could be 0.0 or 0.5 whatever) before playing the sound, the first second* (is less than a second) you hear always at maximum volume and then starts to fade fast.

Maybe something that I do wrong?

Ralith commented 2 years ago

Though I notice two things now, the first one is that -60.0 dbs is not "silence" anymore

Pure silence is unrepresentable in decibels, but somewhere between -60 and -90 is inaudible in most listening environments. Zero decibels is no change, not silence.

maximum volume and then starts to fade fast.

Whoops, that's an API limitation. Will fix.

Ralith commented 2 years ago

0.6.2 adds dedicated setters on Gain that aren't subject to smoothing.

Nazariglez commented 2 years ago

Works like a charm!

Thank you so much for the help, the time, and the work.