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

Allow software based volume control #3556

Merged
merged 4 commits into from Jun 9, 2016

Conversation

sreichholf
Copy link
Contributor

  • 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)
Copy link
Member

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

Copy link
Contributor Author

@sreichholf sreichholf Jun 1, 2016

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)
Copy link
Member

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?

Copy link
Contributor Author

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!

@projectkk2glider projectkk2glider added this to the OpenTX 2.2.0 milestone Jun 9, 2016
@bsongis bsongis merged commit 0c926e5 into opentx:next Jun 9, 2016
@bsongis
Copy link
Member

bsongis commented Jun 9, 2016

Perfect!

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

Successfully merging this pull request may close these issues.

None yet

3 participants