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

channel default volume is unusual #33

Open
belm0 opened this issue Jul 17, 2022 · 5 comments
Open

channel default volume is unusual #33

belm0 opened this issue Jul 17, 2022 · 5 comments

Comments

@belm0
Copy link

belm0 commented Jul 17, 2022

I was surprised that the channel default volume is 64. In audio designs, usually channel volume is attenuation only. So I'd expect the default to be the maximum (255).

Otherwise, the master volume doesn't really mean the "maximum volume", and some channels may have a volume equivalent to a master volume of 1024...

volatile uint8_t volume = 64; // channel volume (not master volume)

@lovyan03
Copy link
Collaborator

@belm0
Thank you for your important input.
I apologize for any inconvenience caused by my ignorance of standard audio designs thinking.
I will review the volume settings in the next version and set the default channel volume to 255.

By the way, the volume value is calculated internally as a square ( volume ^ 2 ) . In other words, the output varies quadratically.
Both master volume and channel volume.
Do you have any opinions or generalizations about this process?

@belm0
Copy link
Author

belm0 commented Jul 17, 2022

By the way, the volume value is calculated internally as a square ( volume ^ 2 )

I was going to say something about this requiring a 64-bit intermediate value for each sample unless some optimizations are done, but then I realized that the code is using a float buffer. I'm a little surprised because float is not very fast on ESP32, so I guess this is a luxury sound library 😉

@lovyan03
Copy link
Collaborator

@belm0
Oh.. yes, I was reluctant to use floats, but I couldn't think of a better way.
In fact, I've been racking my brains because I later realized that the float operation is even slower in ESP32C3…😨

@belm0
Copy link
Author

belm0 commented Jul 18, 2022

I have no doubt that multi-channel, 16-bit sound can be handled well within fixed-point, 32-bit operations. (The PlayStation or early consoles and sound cards had no floating point hardware, etc.)

To start, 32-bit dynamic range is really not needed for volume.

lovyan03 added a commit that referenced this issue Aug 27, 2022
Change I2S port, I2S0 is used when DAC and ADC are used, I2S1 is used otherwise
@mdxs
Copy link

mdxs commented Apr 17, 2024

This ticket can be closed as resolved. Suggesting to create a new ticket if there is a reason to keep track of looking into the use of integers instead of floats (as discussed a bit in comments to this ticket).

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

No branches or pull requests

3 participants