Replies: 1 comment 2 replies
-
I'll see about that in the next few days. It is difficult to understand without a description or background. The 22 volume steps are intended for touchpads, for which it is completely sufficient. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Right now, the hard-coded 21 volume steps allow for only a relatively coarse setting of volume.
I'd suggest a method
Audio::setVolumeSteps(uint8_t steps)
that sets the number of steps for the volume control.This allows to set this e.g. to 32 (which is the same as many hardware volume controls provide) or to 100 (which maps nicely to a percent-based volume control).
Instead of the fixed pre-computed array of logarithmic-function multiplicators for each step, the coefficients can easily be computed by just using power-of-two
(vol * vol)
and the maximum of these (in the precomputed coefficients table this was64
) can also be easily computed at runtime (actually only once if the number of steps is set).I implemented this extension in the https://github.com/seife/ESP32-audioI2S/tree/better-volume-steps branch in my fork.
This adds the following methods:
maxVolume() returns the previous set number of volume steps so that e.g. a GUI can query what was set.
In theory, maxVolume() could be omitted, because the program that set the Steps could also just remember what it requested ;-), but I found it handy to abstract this knowledge from the caller.
The implementation in my
better-volume-steps
branch also gets rid of float arithmetics inAudio::Gain()
and simplifies (IMO, that's certainly debatable) that code.Note that the code in
better-volume-steps
is 100% backwards compatible, as long assetVolumeSteps()
was not called, it will use the same steps as before.Beta Was this translation helpful? Give feedback.
All reactions