|
...
|
...
|
@@ -13,6 +13,7 @@ |
|
|
|
#include "JZ_widget.h"
|
|
|
|
#include "wiringPi.h"
|
|
|
|
#include "uav_widget.h"
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
int music_sum=0;//歌曲总数
|
|
|
|
int music_num=0;//当前播放的歌曲编号
|
|
...
|
...
|
@@ -733,10 +734,14 @@ int Opus_play(int8_t *cbits,int32_t len){//解码opus并播放 |
|
|
|
Deinit_opus();
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
opus_int16 TempPcm[WIDGET_SPEAKER_AUDIO_OPUS_MAX_FRAME_SIZE * WIDGET_SPEAKER_AUDIO_OPUS_CHANNELS];
|
|
|
|
for (i = 0; i < WIDGET_SPEAKER_AUDIO_OPUS_CHANNELS * frame_size; i++) { //转换
|
|
|
|
pcm_bytes[2 * i] = out[i] & 0xFF;
|
|
|
|
pcm_bytes[2 * i + 1] = (out[i] >> 8) & 0xFF;
|
|
|
|
|
|
|
|
TempPcm[i] = out[i] & 0xFF | (out[i] >> 8) << 8;
|
|
|
|
TempPcm[i] = PcmNoiseReduction(TempPcm[i]); //滤波
|
|
|
|
|
|
|
|
pcm_bytes[2 * i] = TempPcm[i] & 0xFF;
|
|
|
|
pcm_bytes[2 * i + 1] = (TempPcm[i] >> 8) & 0xFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
rawPlay(16000,pcm_bytes,frame_size*2);//播放音频
|
|
...
|
...
|
@@ -1195,3 +1200,26 @@ uint8_t GetRecordStatus(void) |
|
|
|
{
|
|
|
|
return aplay_flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************
|
|
|
|
*实时喊话降噪
|
|
|
|
*函数名:PcmNoiseReduction
|
|
|
|
*函数参数:
|
|
|
|
@data:待处理数据
|
|
|
|
*返回值:
|
|
|
|
处理好的数据
|
|
|
|
*函数作者:wzy
|
|
|
|
*************************************/
|
|
|
|
#define NOISE_THRESHOLD 0.003 // 降噪阈值
|
|
|
|
static short PcmNoiseReduction(short data)
|
|
|
|
{
|
|
|
|
// 转换为浮点数并进行降噪
|
|
|
|
short re_data;
|
|
|
|
float float_buffer = data / 32768.0f;
|
|
|
|
if (fabs(float_buffer) < NOISE_THRESHOLD)
|
|
|
|
{
|
|
|
|
float_buffer = 0.0f; // 如果样本小于阈值,则将其置为零
|
|
|
|
}
|
|
|
|
re_data = (short)(float_buffer * 32767.0f); // 溢出处理
|
|
|
|
return re_data;
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|