This commit is contained in:
e2002
2024-12-21 11:58:32 +03:00
parent 9ad82acc80
commit 27e33a1bc8
16 changed files with 149 additions and 60 deletions

View File

@@ -1658,16 +1658,26 @@ void Audio::setVUmeter() {
*
* \warning This feature is only available with patches that support VU meter.
*/
void Audio::getVUlevel() {
const uint8_t everyn = 4;
void Audio::computeVUlevel() {
if(!VS_PATCH_ENABLE) return;
if(!_vuInitalized) return;
static uint8_t cc = 0;
cc++;
if(!_vuInitalized || !config.store.vumeter || cc!=everyn) return;
if(cc==everyn) cc=0;
int16_t reg = read_register(SCI_AICTRL3);
uint8_t rl = map((uint8_t)reg, 85, 92, 0, 255);
uint8_t rr = map((uint8_t)(reg >> 8), 85, 92, 0, 255);
//if(rl>30 || !isRunning()) vuLeft = rl;
//if(rr>30 || !isRunning()) vuRight = rr;
vuLeft = rl;
vuRight = rr;
vuLeft = map((uint8_t)(reg & 0x00FF), 85, 92, 0, 255);
vuRight = map((uint8_t)(reg >> 8), 85, 92, 0, 255);
if(vuLeft>config.vuThreshold) config.vuThreshold = vuLeft;
if(vuRight>config.vuThreshold) config.vuThreshold=vuRight;
}
uint16_t Audio::get_VUlevel(uint16_t dimension){
if(!VS_PATCH_ENABLE) return 0;
if(!_vuInitalized || !config.store.vumeter || config.vuThreshold==0) return 0;
uint8_t L = map(vuLeft, config.vuThreshold, 0, 0, dimension);
uint8_t R = map(vuRight, config.vuThreshold, 0, 0, dimension);
return (L << 8) | R;
}
//---------------------------------------------------------------------------------------------------------------------
void Audio::setConnectionTimeout(uint16_t timeout_ms, uint16_t timeout_ms_ssl){

View File

@@ -236,6 +236,7 @@ private:
const char volumetable[22]={ 0,50,60,65,70,75,80,82,84,86,
88,90,91,92,93,94,95,96,97,98,99,100}; //22 elements
uint8_t vuLeft, vuRight;
protected:
inline void DCS_HIGH() {(dcs_pin&0x20) ? GPIO.out1_w1ts.data = 1 << (dcs_pin - 32) : GPIO.out_w1ts = 1 << dcs_pin;}
inline void DCS_LOW() {(dcs_pin&0x20) ? GPIO.out1_w1tc.data = 1 << (dcs_pin - 32) : GPIO.out_w1tc = 1 << dcs_pin;}
@@ -324,8 +325,8 @@ public:
void forceMono(bool m) {} // TODO
/* VU METER */
void setVUmeter();
void getVUlevel();
uint8_t vuLeft, vuRight;
uint16_t get_VUlevel(uint16_t dimension);
void computeVUlevel();
bool eofHeader;
// implement several function with respect to the index of string
bool startsWith (const char* base, const char* str) { return (strstr(base, str) - base) == 0;}