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
Allow software based volume control #3556
Conversation
sreichholf
commented
May 31, 2016
- enable it for AR9X (it doesn't have HW Volume Control)
- rename "HARDWARE_VOLUME" defines to "MASTER_VOLUME" to mirror it's actual meaning
- adjust build-firmware.py and fwoptions.py
- enable it for AR9X - rename "HARDWARE_VOLUME" defines to "MASTER_VOLUME" - adjust build-firmware.py and fwoptions.py
*result = limit(AUDIO_DATA_MIN, *result + ((sample >> fade) >> (16-AUDIO_BITS_PER_SAMPLE)), AUDIO_DATA_MAX); | ||
*result = limit(AUDIO_DATA_MIN, *result + ((sample >> fade) >> (16 - AUDIO_BITS_PER_SAMPLE)), AUDIO_DATA_MAX); | ||
|
||
#if defined(SOFTWARE_VOLUME) |
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.
Why do you do this here? I would see the SOFTWARE_VOLUME after all mixing is done
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.
The reason are the (Sine based) Tones.
My initial attempt was to loop over the fully mixed buffer and apply volume on that but that caused tones to become cracks if volume is < 100%.
At least that's true with the Speaker delivered with the AR9X (2W 8Ohm).
As this is primarily for AR9X I considered it the "most important target for a good result" and adjusted it to work better.
I haven't debugged this to it's full extent but from looking at the code I do think that tone waves are kind of becoming to steep/irregular due to the interger-related fuzzyness and/or the actual mixing when mixxing before volume control.
The solution for that was to apply tone volume before mixing which in return meant this had to be done for for each wav sample, too.
But: It's well possible I simply did something wrong and therefore am completely wrong here, I'd be glad to fix that up once I know what it is :)
@@ -511,9 +515,9 @@ void audioTask(void * pdata) | |||
} | |||
#endif | |||
|
|||
void mixSample(audio_data_t * result, int sample, unsigned int fade) | |||
void mixSample(audio_data_t * result, int sample, unsigned int fade, bool swVolumeAdjust = true) |
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.
Is the new parameter still needed?
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.
No I missed that one. Sorry!
Perfect! |