-
Notifications
You must be signed in to change notification settings - Fork 249
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
feat: Allow logarithmic amplification #715
base: master
Are you sure you want to change the base?
Conversation
This is my first contribution on this crate. Just checking in with you about the general approach for this. Is it ok? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the choices you made however I think we can do better. Let me know what you think of the feedback.
Further more did you look at the resource Roderick linked in the issue? It features a slightly more involved calculation that leads to a nicer volume curve. We could use that instead or have both the current log and that nicer one.
Yeah I wanted to keep myself in the same page with you. I just skimmed through the article I will check it out. Thanks for review |
You can look at the code I linked to, which compresses that article into 10 lines of code. You can copy and/or modify those lines from me under public domain. |
@roderickvd Do I add this to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a look at source/mod.rs
. Do we want a amplify_decibel()
in there?
I would also add it to amplify. But you are right, there are many places we deal with volume atm, we will probably want it there too. |
This is why I liked @PetrGlad's suggestion here: #714 (comment) If we just add such public helper methods, then the user can plug it where-ever they want. |
So maybe we keep |
The main issue I'm having here is that I don't understand how I fit the mapping that @roderickvd suggested into the |
Maybe we need to sketch out & agree on the API first. To me, // Direct linear gain
sink.set_volume(1.5); // amplify by 150%
source.amplify(0.5); // attenuate to 50%
// Using decibels
sink.set_volume(db_to_gain(6.0)); // +6 dB
source.amplify(db_to_gain(-3.0)); // -3 dB
// Using normalized with logarithmic scaling
sink.set_volume(norm_to_log_gain(0.5)); // 50% perceived volume
source.amplify(norm_to_log_gain(0.75)); // 75% perceived volume |
The thing I like about the |
Terms
Funny, to me setting volume and amplifying are different :) Lets see what kind of terms we got:
The name of
Yes I get that. That makes sense from a programming standpoint. On the other hand human hearing is logarithmic so linear amplification is generally not the best from a UI perspective and thus should not be the default. Helper vs UI
That would make it clear that decibels is just another way of expressing that amplification factor. On the other hand its not super discoverable and using a factor would still be the default. this: some_source
.pausable()
.fade_in(Duration::from_secs(60))
.amplify(to_linear(10));
other_source
.pausable()
.fade_in(Duration::from_secs(60))
.amplify(1.1); is to me less clear then: some_source
.pausable()
.fade_in(Duration::from_secs(60))
.amplify_by_db(10);
some_source
.pausable()
.fade_in(Duration::from_secs(60))
.amplify_by_factor(1.1); Its a difficult UI to get right.... |
I like the use of perceived there, |
I agree with @roderickvd btw and I think we should keep going back and forth till we all agree we have the best possible API. |
Adds volume control in decibels discussed in #714