static void dtmf_mcu_Init(kal_uint16 uSampleRate) { kal_uint32 uIntBufSize=0, uPcmBufSize=0, uTotalBufferSize=0; kal_uint8 *pAllocBuf; DTMF_SR uSr=0; memset(&DTMF_SW, 0, sizeof(DTMF_SW)); DTMF_SW.uSampleRate = uSampleRate; switch (DTMF_SW.uSampleRate) { case 8000: uSr = DTMF_8K; break; case 11025: uSr = DTMF_11K; break; case 12000: uSr = DTMF_12K; break; case 16000: uSr = DTMF_16K; break; case 22050: uSr = DTMF_22K; break; case 24000: uSr = DTMF_24K; break; case 32000: uSr = DTMF_32K; break; case 44100: uSr = DTMF_44K; break; case 48000: uSr = DTMF_48K; break; default: ASSERT(0); break; } DTMF_GetBufferSize(&uIntBufSize, &uPcmBufSize, uSr, DTMF_MONO); uTotalBufferSize = uIntBufSize + uPcmBufSize * DTMF_BUFFERED_FRAME_NUMBER; kal_trace( TRACE_GROUP_AUD_PLAYBACK, MCU_DTMF_INIT, uSampleRate, uPcmBufSize, uTotalBufferSize); pAllocBuf = (kal_uint8 *)audio_alloc_mem(uTotalBufferSize); ASSERT(pAllocBuf); ASSERT(uIntBufSize); ASSERT(uPcmBufSize); DTMF_SW.uFrameByte = uPcmBufSize; DTMF_SW.RingBuffer.rb_base = (kal_uint8*)pAllocBuf; DTMF_SW.RingBuffer.rb_size = uPcmBufSize * DTMF_BUFFERED_FRAME_NUMBER; DTMF_SW.RingBuffer.write = uPcmBufSize * uPreSilenceLength; //fill a silence to prevent pop up noise DTMF_SW.RingBuffer.read=0; pAllocBuf += uPcmBufSize * DTMF_BUFFERED_FRAME_NUMBER; DTMF_SW.pHandle = DTMF_Init( (void *)pAllocBuf, DTMF_CONTINUOUS, uSr, DTMF_MONO); ASSERT(DTMF_SW.pHandle); DTMF_SW.uAudId = L1Audio_GetAudioID(); L1Audio_SetFlag( DTMF_SW.uAudId ); L1Audio_SetEventHandler( DTMF_SW.uAudId, dtmf_mcu_Process ); }
/***************************************************************************** * FUNCTION * gmiInit * DESCRIPTION * This function is used to initialize GMI Driver *****************************************************************************/ void gmiInit( uint16 aud_id ) { gmi.aud_id = aud_id; L1Audio_SetEventHandler( gmi.aud_id, gmiHandler ); GPTI_GetHandle( &gmi.gpt ); gmi.state = GMI_STATE_IDLE; }
void BGSND_INIT() { memset(&bgSnd, 0, sizeof(BGSND_T)); // get audio ID bgSnd.aud_id = L1Audio_GetAudioID(); L1Audio_SetEventHandler( bgSnd.aud_id, (L1Audio_EventHandler)bgsndEventHandler ); bgSnd.timer = kal_create_timer("bgSnd"); }
void toneInit( uint16 aud_id ) { tone.aud_id = aud_id; tone.handler = 0; L1Audio_SetEventHandler( aud_id, toneHandler ); tone.amp = TONE_INIT_AMP; tone.bQTMF = false; tone.state = TONE_STATE_NONE; tone.isWait = false; tone.seqNum = 0; tone.info = &toneInfo; AFE_TurnOnFIR( L1SP_TONE ); }
void ToneLoopBackRec(void(*callback)( kal_uint8 *pBuf, kal_uint16 mode ), ToneLBR_Para *pstPara ) { #ifndef __L1_STANDALONE__ // avoid link error ASSERT(ToneLBR.uState == TLBR_STATE_IDLE); ASSERT(0xFFFF == ToneLBR.aud_id); ToneLBR.aud_id = L1Audio_GetAudioID(); L1Audio_SetEventHandler( ToneLBR.aud_id, toneLoopbackRecHandler ); ToneLBR.callback = callback; ToneLBR.uState = TLBR_STATE_INIT; ToneLBR.uSize = pstPara->uSize - (pstPara->uSize%BYTES_PER_FRAME); ToneLBR.pBuf = pstPara->pBuf; ToneLBR.uMode = pstPara->uMode; AFE_EnableToneLoopBackFlag( KAL_TRUE ); AM_EnableToneLoopBackFlag( KAL_TRUE ); if(pstPara->uMode) KT_SetOutputDevice( L1SP_LOUD_SPEAKER ); // loud speaker mode else KT_SetOutputDevice( L1SP_SPEAKER1 ); // normal mode kal_trace( TRACE_FUNC, L1AUDIO_TONE_LOOPBACK_REC_MODE, pstPara->uMode); KT_SetOutputVolume( pstPara->bAnalogSpkGain, 0 ); KT_Play( pstPara->uFreq, pstPara->uFreq, 0 ); KT_SetAmplitude( pstPara->uKT_AMP ); kal_sleep_task(30); // to ensure tone is stable // Activate 2-way PCM AM_DSP_SetSpeechUplinkDigitalGain(pstPara->uUL_DigGain); // *DP_VOL_IN_PCM = pstPara->uUL_DigGain; // uplink digital gain AM_DSP_SetSpeechDigitalGain(pstPara->uDL_DigGain); // *DP_VOL_OUT_PCM = pstPara->uDL_DigGain; AFE_MuteMicrophone(KAL_FALSE); // un-mute microphone L1SP_SetMicrophoneVolume( pstPara->uAnalogMicGain ); Media_SetOutputDevice( 0 ); PCM2WAY_Start( toneLoopBackRecHisr, 1 ); // voice #endif // #ifndef __L1_STANDALONE__ }
void AVB_Open() { kal_uint32 uWorkingBuffer; kal_trace( TRACE_GROUP_SCO, L1AUDIO_AVB_OPEN, AVB.uState); ASSERT(AVB.uState == AVB_STATE_IDLE); ASSERT(AVB.uSampleRate); PcmSink_StartBT(PCMSINK_BT_SCO); mhdlHookPcmRut(); BLI_GetMemSize(AVB.uSampleRate, AVB.uChannelNumber, AVB_SAMPLE_RATE, AVB_CHANNEL_NUM, &uWorkingBuffer); uWorkingBuffer = (uWorkingBuffer+3) & ~3; AVB.pBuffer = (kal_uint16 *)audio_alloc_mem_cacheable(uWorkingBuffer + AVB_DSP_BUFFER_SIZE + AVB_SRC_BUFFER_SIZE); ASSERT(AVB.pBuffer); AVB.pBLISRC = BLI_Open(AVB.uSampleRate, AVB.uChannelNumber, AVB_SAMPLE_RATE, AVB_CHANNEL_NUM, ((kal_int8*)AVB.pBuffer)+AVB_DSP_BUFFER_SIZE, audio_alloc_ext_mem_cacheable_simplified); ASSERT(AVB.pBLISRC); AVB.PCM.rb_base = ((kal_int8*)AVB.pBuffer)+AVB_DSP_BUFFER_SIZE+uWorkingBuffer; AVB.PCM.rb_size = AVB_SRC_BUFFER_SIZE; AVB.PCM.write = 0; AVB.PCM.read = 0; AVB.uAudID = L1Audio_GetAudioID(); L1Audio_SetFlag( AVB.uAudID ); L1Audio_SetEventHandler( AVB.uAudID, AVB_Process ); AVB.uState = AVB_STATE_RUNING; L1Audio_HookHisrHandler( D2C_AUDIO_VIA_8KBT_ID, AVB_HISR, 0); }
/* ========================================================================= */ void SPE_CustomProcess_On(kal_uint16 sph_mode, SPE_Par_Struct *SPE_PAR, kal_uint8 *state) { #if defined( __VOICE_CHANGER_SUPPORT__ ) SPH_VOICE_CHANGER_MODE mode = 0; // Apply VCH only in speech if(!AM_IsSpeechOn()) { return; } if (!VCHIsDcmLoad) { DCM_Load(DYNAMIC_CODE_COMPRESS_VCH , 0, 0); VCHIsDcmLoad = KAL_TRUE; } kal_trace( TRACE_GROUP_AUD_SPE_CSUT, SPEECH_VCH_PROCESS, 1, VCHIsDcmLoad); #endif spe_custom = audio_alloc_mem_cacheable(sizeof(SPE_CUSTOM_STRUCT)); memset(spe_custom, 0, sizeof(SPE_CUSTOM_STRUCT)); /*Copy the actual parameters to control structure*/ spe_custom->aud_id = L1Audio_GetAudioID(); #if defined(__INTERNAL_SPE_ENGINE__) { kal_uint16 i; kal_uint32 aec_mem_size; for(i=0;i<16;i++) spe_custom->Sph_Enh_ctrl.enhance_pars[i] = SPE_PAR->mode_par[i]; for(i=0;i<12;i++) spe_custom->Sph_Enh_ctrl.enhance_pars[i+16] = SPE_PAR->common_par[i]; aec_mem_size = ENH_API_Get_Memory(&spe_custom->Sph_Enh_ctrl); if(aec_mem_size > 0) { spe_custom->working_buffer = audio_alloc_mem_cacheable( aec_mem_size * sizeof(kal_int8) ); memset(spe_custom->working_buffer, 0, aec_mem_size * sizeof(kal_int8)); ENH_API_Alloc(&spe_custom->Sph_Enh_ctrl, (kal_uint32 *)spe_custom->working_buffer); } else spe_custom->working_buffer = NULL; ENH_API_Init(&spe_custom->Sph_Enh_ctrl, SPE_PAR->out_fir, SPE_PAR->in_fir); } #elif defined( __VOICE_CHANGER_SUPPORT__ ) spe_custom->working_buffer = audio_alloc_mem_cacheable( PCM_BUFFER_LENGTH*2*sizeof(kal_uint8)); if(spe_custom->working_buffer != NULL) { memset(spe_custom->working_buffer, 0, PCM_BUFFER_LENGTH*2*sizeof(kal_uint8)); } #endif L1Audio_SetEventHandler(spe_custom->aud_id , spe_custom_task); L1Audio_SetFlag(spe_custom->aud_id); spe_custom->state = SPE_STATE_WORKING; #if defined( __VOICE_CHANGER_SUPPORT__ ) mode = L1SP_GetVoiceChangerMode(); VCHG_Open(8,mode); #endif #if 1 PCM4WAY_Start(spe_custom_hisr_hdlr, 0); #else /* under construction !*/ /* under construction !*/ /* under construction !*/ #endif }