From 6b9ee4ec76e512ab04fc8b5a6b7b66a83fbfa5eb Mon Sep 17 00:00:00 2001 From: "rob@marotori.com" Date: Tue, 3 Jul 2012 15:35:23 +0000 Subject: [PATCH] Volume Leveling so wav files and system beeps are similar in end volume! --- src/ersky9x/audio.cpp | 16 ++++++++++++++++ src/ersky9x/audio.h | 1 + 2 files changed, 17 insertions(+) diff --git a/src/ersky9x/audio.cpp b/src/ersky9x/audio.cpp index 6e4ddb135..35a664c17 100644 --- a/src/ersky9x/audio.cpp +++ b/src/ersky9x/audio.cpp @@ -189,6 +189,7 @@ void audioTask(void* pdata) bufdata[i] = 0x8000; DACC->DACC_TNCR = read/4; toneStop(); + volumeInit(0); toneWavFile[0] = '\0'; toneWavFile[1] = 0; f_close(&wavFile); @@ -206,6 +207,7 @@ void audioTask(void* pdata) dacptr->DACC_TNPR = CONVERT_PTR(wavSamplesBuffer); dacptr->DACC_TCR = WAV_BUFFER_SIZE/2; dacptr->DACC_TNCR = WAV_BUFFER_SIZE/2; + volumeInit(1); toneStart(); } } @@ -225,6 +227,7 @@ void audioTask(void* pdata) CoSetTmrCnt(audioTimer, toneTimeLeft*5, 0); toneTimeLeft = 0; } + volumeInit(0); toneStart(); CoStartTmr(audioTimer); } @@ -248,6 +251,7 @@ void audioTask(void* pdata) CoSetTmrCnt(audioTimer, tone2TimeLeft*5, 0); tone2TimeLeft = 0; setFrequency(tone2Freq * 6100 / 2); + volumeInit(0); toneStart(); CoStartTmr(audioTimer); } @@ -321,6 +325,18 @@ void play(uint8_t tFreq, uint8_t tLen, uint8_t tPause, } } + +void volumeInit(uint8_t boost){ + if(boost == 0){ + setVolume(g_eeGeneral.speakerVolume); //then raise it + } else { + setVolume(g_eeGeneral.speakerVolume + 10); + /* raise it by factor of 5 higher so wav and beep similar volume! + this value of 10 could potentially be a secondary menu config option in + system setup as may be different per user? */ + } +} + void playFile(const char *filename) { strcpy(toneWavFile, filename); diff --git a/src/ersky9x/audio.h b/src/ersky9x/audio.h index d25ce2064..59daa12b5 100644 --- a/src/ersky9x/audio.h +++ b/src/ersky9x/audio.h @@ -70,6 +70,7 @@ extern "C" void retrieveAvailableAudioFiles(); void play(uint8_t tFreq, uint8_t tLen, uint8_t tPause, uint8_t tFlags=0, int8_t tFreqIncr=0); void playFile(const char *filename); void pause(uint8_t tLen); +void volumeInit(uint8_t boost); inline bool audioBusy() {