Reorder audio.c
This commit is contained in:
528
audio.c
528
audio.c
@@ -31,50 +31,11 @@
|
|||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
|
||||||
|
|
||||||
static const uint8_t VoiceClipLengthChinese[58] =
|
|
||||||
{
|
|
||||||
0x32, 0x32, 0x32, 0x37, 0x37, 0x32, 0x32, 0x32,
|
|
||||||
0x32, 0x37, 0x37, 0x32, 0x64, 0x64, 0x64, 0x64,
|
|
||||||
0x64, 0x69, 0x64, 0x69, 0x5A, 0x5F, 0x5F, 0x64,
|
|
||||||
0x64, 0x69, 0x64, 0x64, 0x69, 0x69, 0x69, 0x64,
|
|
||||||
0x64, 0x6E, 0x69, 0x5F, 0x64, 0x64, 0x64, 0x69,
|
|
||||||
0x69, 0x69, 0x64, 0x69, 0x64, 0x64, 0x55, 0x5F,
|
|
||||||
0x5A, 0x4B, 0x4B, 0x46, 0x46, 0x69, 0x64, 0x6E,
|
|
||||||
0x5A, 0x64,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t VoiceClipLengthEnglish[76] =
|
|
||||||
{
|
|
||||||
0x50, 0x32, 0x2D, 0x2D, 0x2D, 0x37, 0x37, 0x37,
|
|
||||||
0x32, 0x32, 0x3C, 0x37, 0x46, 0x46, 0x4B, 0x82,
|
|
||||||
0x82, 0x6E, 0x82, 0x46, 0x96, 0x64, 0x46, 0x6E,
|
|
||||||
0x78, 0x6E, 0x87, 0x64, 0x96, 0x96, 0x46, 0x9B,
|
|
||||||
0x91, 0x82, 0x82, 0x73, 0x78, 0x64, 0x82, 0x6E,
|
|
||||||
0x78, 0x82, 0x87, 0x6E, 0x55, 0x78, 0x64, 0x69,
|
|
||||||
0x9B, 0x5A, 0x50, 0x3C, 0x32, 0x55, 0x64, 0x64,
|
|
||||||
0x50, 0x46, 0x46, 0x46, 0x4B, 0x4B, 0x50, 0x50,
|
|
||||||
0x55, 0x4B, 0x4B, 0x32, 0x32, 0x32, 0x32, 0x37,
|
|
||||||
0x41, 0x32, 0x3C, 0x37,
|
|
||||||
};
|
|
||||||
|
|
||||||
VOICE_ID_t gVoiceID[8];
|
|
||||||
uint8_t gVoiceReadIndex;
|
|
||||||
uint8_t gVoiceWriteIndex;
|
|
||||||
volatile uint16_t gCountdownToPlayNextVoice_10ms;
|
|
||||||
volatile bool gFlagPlayQueuedVoice;
|
|
||||||
VOICE_ID_t gAnotherVoiceID = VOICE_ID_INVALID;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BEEP_Type_t gBeepToPlay = BEEP_NONE;
|
BEEP_Type_t gBeepToPlay = BEEP_NONE;
|
||||||
|
|
||||||
void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
||||||
{
|
{
|
||||||
uint16_t ToneConfig;
|
|
||||||
uint16_t ToneFrequency;
|
|
||||||
uint16_t Duration;
|
|
||||||
|
|
||||||
if (Beep != BEEP_880HZ_60MS_TRIPLE_BEEP &&
|
if (Beep != BEEP_880HZ_60MS_TRIPLE_BEEP &&
|
||||||
Beep != BEEP_500HZ_60MS_DOUBLE_BEEP &&
|
Beep != BEEP_500HZ_60MS_DOUBLE_BEEP &&
|
||||||
@@ -84,10 +45,10 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
|||||||
!gEeprom.BEEP_CONTROL)
|
!gEeprom.BEEP_CONTROL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef ENABLE_AIRCOPY
|
#ifdef ENABLE_AIRCOPY
|
||||||
if (gScreenToDisplay == DISPLAY_AIRCOPY)
|
if (gScreenToDisplay == DISPLAY_AIRCOPY)
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (gCurrentFunction == FUNCTION_RECEIVE)
|
if (gCurrentFunction == FUNCTION_RECEIVE)
|
||||||
return;
|
return;
|
||||||
@@ -95,20 +56,21 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
|||||||
if (gCurrentFunction == FUNCTION_MONITOR)
|
if (gCurrentFunction == FUNCTION_MONITOR)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ToneConfig = BK4819_ReadRegister(BK4819_REG_71);
|
#ifdef ENABLE_FMRADIO
|
||||||
|
if (gFmRadioMode)
|
||||||
|
BK1080_Mute(true);
|
||||||
|
#endif
|
||||||
|
|
||||||
AUDIO_AudioPathOff();
|
AUDIO_AudioPathOff();
|
||||||
|
|
||||||
if (gCurrentFunction == FUNCTION_POWER_SAVE && gRxIdleMode)
|
if (gCurrentFunction == FUNCTION_POWER_SAVE && gRxIdleMode)
|
||||||
BK4819_RX_TurnOn();
|
BK4819_RX_TurnOn();
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
|
||||||
if (gFmRadioMode)
|
|
||||||
BK1080_Mute(true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SYSTEM_DelayMs(20);
|
SYSTEM_DelayMs(20);
|
||||||
|
|
||||||
|
uint16_t ToneConfig = BK4819_ReadRegister(BK4819_REG_71);
|
||||||
|
|
||||||
|
uint16_t ToneFrequency;
|
||||||
switch (Beep)
|
switch (Beep)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
@@ -142,6 +104,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
|||||||
|
|
||||||
SYSTEM_DelayMs(60);
|
SYSTEM_DelayMs(60);
|
||||||
|
|
||||||
|
uint16_t Duration;
|
||||||
switch (Beep)
|
switch (Beep)
|
||||||
{
|
{
|
||||||
case BEEP_880HZ_60MS_TRIPLE_BEEP:
|
case BEEP_880HZ_60MS_TRIPLE_BEEP:
|
||||||
@@ -161,18 +124,15 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
|||||||
BK4819_ExitTxMute();
|
BK4819_ExitTxMute();
|
||||||
Duration = 60;
|
Duration = 60;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BEEP_880HZ_40MS_OPTIONAL:
|
case BEEP_880HZ_40MS_OPTIONAL:
|
||||||
case BEEP_440HZ_40MS_OPTIONAL:
|
case BEEP_440HZ_40MS_OPTIONAL:
|
||||||
BK4819_ExitTxMute();
|
BK4819_ExitTxMute();
|
||||||
Duration = 40;
|
Duration = 40;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BEEP_880HZ_200MS:
|
case BEEP_880HZ_200MS:
|
||||||
BK4819_ExitTxMute();
|
BK4819_ExitTxMute();
|
||||||
Duration = 200;
|
Duration = 200;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BEEP_440HZ_500MS:
|
case BEEP_440HZ_500MS:
|
||||||
case BEEP_880HZ_500MS:
|
case BEEP_880HZ_500MS:
|
||||||
default:
|
default:
|
||||||
@@ -187,10 +147,6 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
|||||||
|
|
||||||
AUDIO_AudioPathOff();
|
AUDIO_AudioPathOff();
|
||||||
|
|
||||||
#ifdef ENABLE_VOX
|
|
||||||
gVoxResumeCountdown = 80;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SYSTEM_DelayMs(5);
|
SYSTEM_DelayMs(5);
|
||||||
BK4819_TurnsOffTones_TurnsOnRX();
|
BK4819_TurnsOffTones_TurnsOnRX();
|
||||||
SYSTEM_DelayMs(5);
|
SYSTEM_DelayMs(5);
|
||||||
@@ -199,254 +155,294 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
|
|||||||
if (gEnableSpeaker)
|
if (gEnableSpeaker)
|
||||||
AUDIO_AudioPathOn();
|
AUDIO_AudioPathOn();
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
if (gFmRadioMode)
|
if (gFmRadioMode)
|
||||||
BK1080_Mute(false);
|
BK1080_Mute(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (gCurrentFunction == FUNCTION_POWER_SAVE && gRxIdleMode)
|
if (gCurrentFunction == FUNCTION_POWER_SAVE && gRxIdleMode)
|
||||||
BK4819_Sleep();
|
BK4819_Sleep();
|
||||||
|
|
||||||
|
#ifdef ENABLE_VOX
|
||||||
|
gVoxResumeCountdown = 80;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
|
|
||||||
void AUDIO_PlayVoice(uint8_t VoiceID)
|
static const uint8_t VoiceClipLengthChinese[58] =
|
||||||
{
|
{
|
||||||
unsigned int i;
|
0x32, 0x32, 0x32, 0x37, 0x37, 0x32, 0x32, 0x32,
|
||||||
|
0x32, 0x37, 0x37, 0x32, 0x64, 0x64, 0x64, 0x64,
|
||||||
|
0x64, 0x69, 0x64, 0x69, 0x5A, 0x5F, 0x5F, 0x64,
|
||||||
|
0x64, 0x69, 0x64, 0x64, 0x69, 0x69, 0x69, 0x64,
|
||||||
|
0x64, 0x6E, 0x69, 0x5F, 0x64, 0x64, 0x64, 0x69,
|
||||||
|
0x69, 0x69, 0x64, 0x69, 0x64, 0x64, 0x55, 0x5F,
|
||||||
|
0x5A, 0x4B, 0x4B, 0x46, 0x46, 0x69, 0x64, 0x6E,
|
||||||
|
0x5A, 0x64,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const uint8_t VoiceClipLengthEnglish[76] =
|
||||||
|
{
|
||||||
|
0x50, 0x32, 0x2D, 0x2D, 0x2D, 0x37, 0x37, 0x37,
|
||||||
|
0x32, 0x32, 0x3C, 0x37, 0x46, 0x46, 0x4B, 0x82,
|
||||||
|
0x82, 0x6E, 0x82, 0x46, 0x96, 0x64, 0x46, 0x6E,
|
||||||
|
0x78, 0x6E, 0x87, 0x64, 0x96, 0x96, 0x46, 0x9B,
|
||||||
|
0x91, 0x82, 0x82, 0x73, 0x78, 0x64, 0x82, 0x6E,
|
||||||
|
0x78, 0x82, 0x87, 0x6E, 0x55, 0x78, 0x64, 0x69,
|
||||||
|
0x9B, 0x5A, 0x50, 0x3C, 0x32, 0x55, 0x64, 0x64,
|
||||||
|
0x50, 0x46, 0x46, 0x46, 0x4B, 0x4B, 0x50, 0x50,
|
||||||
|
0x55, 0x4B, 0x4B, 0x32, 0x32, 0x32, 0x32, 0x37,
|
||||||
|
0x41, 0x32, 0x3C, 0x37,
|
||||||
|
};
|
||||||
|
|
||||||
|
VOICE_ID_t gVoiceID[8];
|
||||||
|
uint8_t gVoiceReadIndex;
|
||||||
|
uint8_t gVoiceWriteIndex;
|
||||||
|
volatile uint16_t gCountdownToPlayNextVoice_10ms;
|
||||||
|
volatile bool gFlagPlayQueuedVoice;
|
||||||
|
VOICE_ID_t gAnotherVoiceID = VOICE_ID_INVALID;
|
||||||
|
|
||||||
|
|
||||||
|
void AUDIO_PlayVoice(uint8_t VoiceID)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
|
||||||
|
SYSTEM_DelayMs(20);
|
||||||
|
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
|
||||||
|
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
if ((VoiceID & 0x80U) == 0)
|
||||||
|
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_VOICE_1);
|
||||||
|
else
|
||||||
|
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_VOICE_1);
|
||||||
|
|
||||||
|
SYSTICK_DelayUs(1000);
|
||||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
|
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
|
||||||
SYSTEM_DelayMs(20);
|
SYSTICK_DelayUs(1200);
|
||||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
|
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
|
||||||
|
VoiceID <<= 1;
|
||||||
for (i = 0; i < 8; i++)
|
SYSTICK_DelayUs(200);
|
||||||
{
|
|
||||||
if ((VoiceID & 0x80U) == 0)
|
|
||||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_VOICE_1);
|
|
||||||
else
|
|
||||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_VOICE_1);
|
|
||||||
|
|
||||||
SYSTICK_DelayUs(1000);
|
|
||||||
GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
|
|
||||||
SYSTICK_DelayUs(1200);
|
|
||||||
GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_VOICE_0);
|
|
||||||
VoiceID <<= 1;
|
|
||||||
SYSTICK_DelayUs(200);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AUDIO_PlaySingleVoice(bool bFlag)
|
void AUDIO_PlaySingleVoice(bool bFlag)
|
||||||
|
{
|
||||||
|
uint8_t VoiceID;
|
||||||
|
uint8_t Delay;
|
||||||
|
|
||||||
|
VoiceID = gVoiceID[0];
|
||||||
|
|
||||||
|
if (gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF && gVoiceWriteIndex > 0)
|
||||||
{
|
{
|
||||||
uint8_t VoiceID;
|
if (gEeprom.VOICE_PROMPT == VOICE_PROMPT_CHINESE)
|
||||||
uint8_t Delay;
|
{ // Chinese
|
||||||
|
if (VoiceID >= ARRAY_SIZE(VoiceClipLengthChinese))
|
||||||
|
goto Bailout;
|
||||||
|
|
||||||
VoiceID = gVoiceID[0];
|
Delay = VoiceClipLengthChinese[VoiceID];
|
||||||
|
VoiceID += VOICE_ID_CHI_BASE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // English
|
||||||
|
if (VoiceID >= ARRAY_SIZE(VoiceClipLengthEnglish))
|
||||||
|
goto Bailout;
|
||||||
|
|
||||||
if (gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF && gVoiceWriteIndex > 0)
|
Delay = VoiceClipLengthEnglish[VoiceID];
|
||||||
|
VoiceID += VOICE_ID_ENG_BASE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gCurrentFunction == FUNCTION_RECEIVE ||
|
||||||
|
gCurrentFunction == FUNCTION_MONITOR ||
|
||||||
|
gCurrentFunction == FUNCTION_INCOMING) // 1of11
|
||||||
|
BK4819_SetAF(BK4819_AF_MUTE);
|
||||||
|
|
||||||
|
#ifdef ENABLE_FMRADIO
|
||||||
|
if (gFmRadioMode)
|
||||||
|
BK1080_Mute(true);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
AUDIO_AudioPathOn();
|
||||||
|
|
||||||
|
#ifdef ENABLE_VOX
|
||||||
|
gVoxResumeCountdown = 2000;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SYSTEM_DelayMs(5);
|
||||||
|
AUDIO_PlayVoice(VoiceID);
|
||||||
|
|
||||||
|
if (gVoiceWriteIndex == 1)
|
||||||
|
Delay += 3;
|
||||||
|
|
||||||
|
if (bFlag)
|
||||||
{
|
{
|
||||||
if (gEeprom.VOICE_PROMPT == VOICE_PROMPT_CHINESE)
|
SYSTEM_DelayMs(Delay * 10);
|
||||||
{ // Chinese
|
|
||||||
if (VoiceID >= ARRAY_SIZE(VoiceClipLengthChinese))
|
|
||||||
goto Bailout;
|
|
||||||
|
|
||||||
Delay = VoiceClipLengthChinese[VoiceID];
|
|
||||||
VoiceID += VOICE_ID_CHI_BASE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // English
|
|
||||||
if (VoiceID >= ARRAY_SIZE(VoiceClipLengthEnglish))
|
|
||||||
goto Bailout;
|
|
||||||
|
|
||||||
Delay = VoiceClipLengthEnglish[VoiceID];
|
|
||||||
VoiceID += VOICE_ID_ENG_BASE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gCurrentFunction == FUNCTION_RECEIVE ||
|
if (gCurrentFunction == FUNCTION_RECEIVE ||
|
||||||
gCurrentFunction == FUNCTION_MONITOR ||
|
gCurrentFunction == FUNCTION_MONITOR ||
|
||||||
gCurrentFunction == FUNCTION_INCOMING) // 1of11
|
gCurrentFunction == FUNCTION_INCOMING) // 1of11
|
||||||
BK4819_SetAF(BK4819_AF_MUTE);
|
RADIO_SetModulation(gRxVfo->Modulation);
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
#ifdef ENABLE_FMRADIO
|
||||||
if (gFmRadioMode)
|
if (gFmRadioMode)
|
||||||
BK1080_Mute(true);
|
BK1080_Mute(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
AUDIO_AudioPathOn();
|
if (!gEnableSpeaker)
|
||||||
|
AUDIO_AudioPathOff();
|
||||||
|
|
||||||
|
gVoiceWriteIndex = 0;
|
||||||
|
gVoiceReadIndex = 0;
|
||||||
|
|
||||||
|
#ifdef ENABLE_VOX
|
||||||
|
gVoxResumeCountdown = 80;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gVoiceReadIndex = 1;
|
||||||
|
gCountdownToPlayNextVoice_10ms = Delay;
|
||||||
|
gFlagPlayQueuedVoice = false;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bailout:
|
||||||
|
gVoiceReadIndex = 0;
|
||||||
|
gVoiceWriteIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AUDIO_SetVoiceID(uint8_t Index, VOICE_ID_t VoiceID)
|
||||||
|
{
|
||||||
|
if (Index >= ARRAY_SIZE(gVoiceID))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (Index == 0)
|
||||||
|
{
|
||||||
|
gVoiceWriteIndex = 0;
|
||||||
|
gVoiceReadIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
gVoiceID[Index] = VoiceID;
|
||||||
|
|
||||||
|
gVoiceWriteIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint16_t Value)
|
||||||
|
{
|
||||||
|
uint16_t Remainder;
|
||||||
|
uint8_t Result;
|
||||||
|
uint8_t Count;
|
||||||
|
|
||||||
|
if (Index == 0)
|
||||||
|
{
|
||||||
|
gVoiceWriteIndex = 0;
|
||||||
|
gVoiceReadIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Count = 0;
|
||||||
|
Result = Value / 1000U;
|
||||||
|
Remainder = Value % 1000U;
|
||||||
|
if (Remainder < 100U)
|
||||||
|
{
|
||||||
|
if (Remainder < 10U)
|
||||||
|
goto Skip;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Result = Remainder / 100U;
|
||||||
|
gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Result;
|
||||||
|
Count++;
|
||||||
|
Remainder -= Result * 100U;
|
||||||
|
}
|
||||||
|
Result = Remainder / 10U;
|
||||||
|
gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Result;
|
||||||
|
Count++;
|
||||||
|
Remainder -= Result * 10U;
|
||||||
|
|
||||||
|
Skip:
|
||||||
|
gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Remainder;
|
||||||
|
|
||||||
|
return Count + 1U;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AUDIO_PlayQueuedVoice(void)
|
||||||
|
{
|
||||||
|
uint8_t VoiceID;
|
||||||
|
uint8_t Delay;
|
||||||
|
bool Skip;
|
||||||
|
|
||||||
|
Skip = false;
|
||||||
|
|
||||||
|
if (gVoiceReadIndex != gVoiceWriteIndex && gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF)
|
||||||
|
{
|
||||||
|
VoiceID = gVoiceID[gVoiceReadIndex];
|
||||||
|
if (gEeprom.VOICE_PROMPT == VOICE_PROMPT_CHINESE)
|
||||||
|
{
|
||||||
|
if (VoiceID < ARRAY_SIZE(VoiceClipLengthChinese))
|
||||||
|
{
|
||||||
|
Delay = VoiceClipLengthChinese[VoiceID];
|
||||||
|
VoiceID += VOICE_ID_CHI_BASE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Skip = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (VoiceID < ARRAY_SIZE(VoiceClipLengthEnglish))
|
||||||
|
{
|
||||||
|
Delay = VoiceClipLengthEnglish[VoiceID];
|
||||||
|
VoiceID += VOICE_ID_ENG_BASE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Skip = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
gVoiceReadIndex++;
|
||||||
|
|
||||||
|
if (!Skip)
|
||||||
|
{
|
||||||
|
if (gVoiceReadIndex == gVoiceWriteIndex)
|
||||||
|
Delay += 3;
|
||||||
|
|
||||||
|
AUDIO_PlayVoice(VoiceID);
|
||||||
|
|
||||||
|
gCountdownToPlayNextVoice_10ms = Delay;
|
||||||
|
gFlagPlayQueuedVoice = false;
|
||||||
|
|
||||||
#ifdef ENABLE_VOX
|
#ifdef ENABLE_VOX
|
||||||
gVoxResumeCountdown = 2000;
|
gVoxResumeCountdown = 2000;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SYSTEM_DelayMs(5);
|
|
||||||
AUDIO_PlayVoice(VoiceID);
|
|
||||||
|
|
||||||
if (gVoiceWriteIndex == 1)
|
|
||||||
Delay += 3;
|
|
||||||
|
|
||||||
if (bFlag)
|
|
||||||
{
|
|
||||||
SYSTEM_DelayMs(Delay * 10);
|
|
||||||
|
|
||||||
if (gCurrentFunction == FUNCTION_RECEIVE ||
|
|
||||||
gCurrentFunction == FUNCTION_MONITOR ||
|
|
||||||
gCurrentFunction == FUNCTION_INCOMING) // 1of11
|
|
||||||
RADIO_SetModulation(gRxVfo->Modulation);
|
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
|
||||||
if (gFmRadioMode)
|
|
||||||
BK1080_Mute(false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!gEnableSpeaker)
|
|
||||||
AUDIO_AudioPathOff();
|
|
||||||
|
|
||||||
gVoiceWriteIndex = 0;
|
|
||||||
gVoiceReadIndex = 0;
|
|
||||||
|
|
||||||
#ifdef ENABLE_VOX
|
|
||||||
gVoxResumeCountdown = 80;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
gVoiceReadIndex = 1;
|
|
||||||
gCountdownToPlayNextVoice_10ms = Delay;
|
|
||||||
gFlagPlayQueuedVoice = false;
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bailout:
|
|
||||||
gVoiceReadIndex = 0;
|
|
||||||
gVoiceWriteIndex = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AUDIO_SetVoiceID(uint8_t Index, VOICE_ID_t VoiceID)
|
if (gCurrentFunction == FUNCTION_RECEIVE ||
|
||||||
|
gCurrentFunction == FUNCTION_MONITOR ||
|
||||||
|
gCurrentFunction == FUNCTION_INCOMING)
|
||||||
{
|
{
|
||||||
if (Index >= ARRAY_SIZE(gVoiceID))
|
RADIO_SetModulation(gRxVfo->Modulation); // 1of11
|
||||||
return;
|
|
||||||
|
|
||||||
if (Index == 0)
|
|
||||||
{
|
|
||||||
gVoiceWriteIndex = 0;
|
|
||||||
gVoiceReadIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
gVoiceID[Index] = VoiceID;
|
|
||||||
|
|
||||||
gVoiceWriteIndex++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint16_t Value)
|
#ifdef ENABLE_FMRADIO
|
||||||
{
|
if (gFmRadioMode)
|
||||||
uint16_t Remainder;
|
BK1080_Mute(false);
|
||||||
uint8_t Result;
|
#endif
|
||||||
uint8_t Count;
|
|
||||||
|
|
||||||
if (Index == 0)
|
if (!gEnableSpeaker)
|
||||||
{
|
AUDIO_AudioPathOff();
|
||||||
gVoiceWriteIndex = 0;
|
|
||||||
gVoiceReadIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Count = 0;
|
#ifdef ENABLE_VOX
|
||||||
Result = Value / 1000U;
|
gVoxResumeCountdown = 80;
|
||||||
Remainder = Value % 1000U;
|
#endif
|
||||||
if (Remainder < 100U)
|
|
||||||
{
|
|
||||||
if (Remainder < 10U)
|
|
||||||
goto Skip;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Result = Remainder / 100U;
|
|
||||||
gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Result;
|
|
||||||
Count++;
|
|
||||||
Remainder -= Result * 100U;
|
|
||||||
}
|
|
||||||
Result = Remainder / 10U;
|
|
||||||
gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Result;
|
|
||||||
Count++;
|
|
||||||
Remainder -= Result * 10U;
|
|
||||||
|
|
||||||
Skip:
|
gVoiceWriteIndex = 0;
|
||||||
gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Remainder;
|
gVoiceReadIndex = 0;
|
||||||
|
}
|
||||||
return Count + 1U;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AUDIO_PlayQueuedVoice(void)
|
|
||||||
{
|
|
||||||
uint8_t VoiceID;
|
|
||||||
uint8_t Delay;
|
|
||||||
bool Skip;
|
|
||||||
|
|
||||||
Skip = false;
|
|
||||||
|
|
||||||
if (gVoiceReadIndex != gVoiceWriteIndex && gEeprom.VOICE_PROMPT != VOICE_PROMPT_OFF)
|
|
||||||
{
|
|
||||||
VoiceID = gVoiceID[gVoiceReadIndex];
|
|
||||||
if (gEeprom.VOICE_PROMPT == VOICE_PROMPT_CHINESE)
|
|
||||||
{
|
|
||||||
if (VoiceID < ARRAY_SIZE(VoiceClipLengthChinese))
|
|
||||||
{
|
|
||||||
Delay = VoiceClipLengthChinese[VoiceID];
|
|
||||||
VoiceID += VOICE_ID_CHI_BASE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Skip = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (VoiceID < ARRAY_SIZE(VoiceClipLengthEnglish))
|
|
||||||
{
|
|
||||||
Delay = VoiceClipLengthEnglish[VoiceID];
|
|
||||||
VoiceID += VOICE_ID_ENG_BASE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Skip = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
gVoiceReadIndex++;
|
|
||||||
|
|
||||||
if (!Skip)
|
|
||||||
{
|
|
||||||
if (gVoiceReadIndex == gVoiceWriteIndex)
|
|
||||||
Delay += 3;
|
|
||||||
|
|
||||||
AUDIO_PlayVoice(VoiceID);
|
|
||||||
|
|
||||||
gCountdownToPlayNextVoice_10ms = Delay;
|
|
||||||
gFlagPlayQueuedVoice = false;
|
|
||||||
|
|
||||||
#ifdef ENABLE_VOX
|
|
||||||
gVoxResumeCountdown = 2000;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gCurrentFunction == FUNCTION_RECEIVE ||
|
|
||||||
gCurrentFunction == FUNCTION_MONITOR ||
|
|
||||||
gCurrentFunction == FUNCTION_INCOMING) // 1of11
|
|
||||||
RADIO_SetModulation(gRxVfo->Modulation);
|
|
||||||
|
|
||||||
#ifdef ENABLE_FMRADIO
|
|
||||||
if (gFmRadioMode)
|
|
||||||
BK1080_Mute(false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!gEnableSpeaker)
|
|
||||||
AUDIO_AudioPathOff();
|
|
||||||
|
|
||||||
#ifdef ENABLE_VOX
|
|
||||||
gVoxResumeCountdown = 80;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gVoiceWriteIndex = 0;
|
|
||||||
gVoiceReadIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user