mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 01:05:10 +03:00
Allow software based volume control (#3556)
* Allow software based volume control - enable it for AR9X - rename "HARDWARE_VOLUME" defines to "MASTER_VOLUME" - adjust build-firmware.py and fwoptions.py * Software based volume control: Do it right * whitespace cleanup * software volume: cleanup/revert some leftovers of undone changes
This commit is contained in:
parent
beb21ab7db
commit
0c926e5d19
9 changed files with 16 additions and 8 deletions
|
@ -229,7 +229,7 @@ elseif(PCB STREQUAL SKY9X OR PCB STREQUAL 9XRPRO OR PCB STREQUAL AR9X)
|
|||
set(TARGET_SRC ${TARGET_SRC} rtc_driver.cpp)
|
||||
set(BOOTLOADER bootflash8.lbm)
|
||||
elseif(PCB STREQUAL AR9X)
|
||||
add_definitions(-Dat91sam3s8 -DAR9X)
|
||||
add_definitions(-Dat91sam3s8 -DAR9X -DSOFTWARE_VOLUME)
|
||||
set(FLAVOUR ar9x)
|
||||
include_directories(${THIRDPARTY_DIR}/xdk-asf-3.31.0/sam/drivers/twi)
|
||||
set(SRC ${SRC} ${THIRDPARTY_DIR}/xdk-asf-3.31.0/sam/drivers/twi/twi.c)
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
|
||||
extern OS_MutexID audioMutex;
|
||||
|
||||
#if defined(SOFTWARE_VOLUME)
|
||||
extern uint8_t currentSpeakerVolume;
|
||||
#endif
|
||||
|
||||
const int16_t sineValues[] =
|
||||
{
|
||||
0, 196, 392, 588, 784, 980, 1175, 1370, 1564, 1758,
|
||||
|
@ -784,6 +788,12 @@ void AudioQueue::wakeup()
|
|||
// TRACE("pushing buffer %d\n", bufferWIdx);
|
||||
bufferWIdx = nextBufferIdx(bufferWIdx);
|
||||
buffer->size = size;
|
||||
#if defined(SOFTWARE_VOLUME)
|
||||
for(uint32_t i=0; i<buffer->size; ++i) {
|
||||
int32_t tmpSample = (int32_t) ((uint32_t) (buffer->data[i]) - AUDIO_DATA_SILENCE); // conversion from uint16_t
|
||||
buffer->data[i] = (int16_t) (((tmpSample * currentSpeakerVolume) / VOLUME_LEVEL_MAX) + AUDIO_DATA_SILENCE);
|
||||
}
|
||||
#endif
|
||||
audioPushBuffer(buffer);
|
||||
__enable_irq();
|
||||
}
|
||||
|
|
|
@ -447,7 +447,7 @@ void evalFunctions()
|
|||
break;
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_VOLUME)
|
||||
#if defined(MASTER_VOLUME)
|
||||
case FUNC_VOLUME:
|
||||
{
|
||||
getvalue_t raw = getValue(CFN_PARAM(cfn));
|
||||
|
|
|
@ -1088,7 +1088,7 @@ void evalMixes(uint8_t tick10ms)
|
|||
// must be done after mixing because some functions use the inputs/channels values
|
||||
// must be done before limits because of the applyLimit function: it checks for safety switches which would be not initialized otherwise
|
||||
if (tick10ms) {
|
||||
#if defined(HARDWARE_VOLUME)
|
||||
#if defined(MASTER_VOLUME)
|
||||
requiredSpeakerVolume = g_eeGeneral.speakerVolume + VOLUME_LEVEL_DEF;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@
|
|||
#define IS_FAI_FORBIDDEN(idx) (IS_FAI_ENABLED() && idx >= MIXSRC_FIRST_TELEM)
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define HARDWARE_VOLUME
|
||||
#define MASTER_VOLUME
|
||||
#endif
|
||||
|
||||
#if defined(SIMU)
|
||||
|
|
|
@ -430,7 +430,7 @@ void audioConsumeCurrentBuffer()
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(HARDWARE_VOLUME)
|
||||
#if defined(MASTER_VOLUME)
|
||||
void setScaledVolume(uint8_t volume)
|
||||
{
|
||||
simuAudio.currentVolume = 127 * volume * simuAudio.volumeGain / VOLUME_LEVEL_MAX / 10;
|
||||
|
|
|
@ -163,7 +163,7 @@ void audioEnd()
|
|||
|
||||
void setScaledVolume(uint8_t volume)
|
||||
{
|
||||
#if !defined(NO_HARDWARE_VOLUME)
|
||||
#if !defined(SOFTWARE_VOLUME)
|
||||
volumeRequired = volumeScale[min<uint8_t>(volume, VOLUME_LEVEL_MAX)];
|
||||
#ifndef AR9X
|
||||
__disable_irq() ;
|
||||
|
|
|
@ -94,7 +94,6 @@ elif options[optcount] == "9xrpro":
|
|||
elif options[optcount] == "ar9x":
|
||||
command_options["PCB"] = "AR9X"
|
||||
command_options["SDCARD"] = "YES"
|
||||
command_options["HARDWARE_VOLUME"] = "NO"
|
||||
firmware_options = options_ar9x
|
||||
maxsize = 65536 * 4
|
||||
board = BOARD_SKY9X
|
||||
|
|
|
@ -235,7 +235,6 @@ options_ar9x = {
|
|||
"faichoice": ("FAI", "CHOICE", None),
|
||||
"nooverridech": ("OVERRIDE_CHANNEL_FUNCTION", "NO", "YES"),
|
||||
# "rtc": ("RTCLOCK", "YES", "NO"),
|
||||
# "volume": ("HARDWARE_VOLUME", "YES", "NO") # Renove HARDWARE_VOLUME=NO in the commandline below when activating!
|
||||
}
|
||||
|
||||
options_taranis = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue