硬件部分,其实很简单,就用到了芯片的7脚,作为固定的mic输入
程序部分如下:
extern void norfs_init_api(void) ;
int app_ms(void *param ){
int msg[2];
norfs_init_api() ;
if(ms_start() == -1){
return 0;
}
log_info("---------------APP_MS------------");
///用录音的按键表 客户可以自己去加一个按键表的文件
key_table_sel((void *)ms_msg_filter);
while(1){
get_msg(2, &msg[0]);
bsp_loop();
if (common_msg_deal(msg) != (-1)) {
continue;
}
switch (msg[0]) {
case MSG_500MS:
if(ms_recing_time > 200){
//ms_record_status = 0 ;
//ms_recing_time = 0 ;
//break ;
if(ms_record_status == 1){
ms_recing_time = 0 ;
post_msg(1, MSG_MS_PLAY);//MSG_GOTO_MS_MODE
}
}
//log_info("ms_recing_time :%d \n", ms_recing_time);
break ;
case MSG_MS_RECORD:
log_info("---MSG_MS_RECORD \n");
record_start();
ms_recing_time = 0 ;
break;
case MSG_MS_RECORD_RESTART:
log_info("---MSG_MS_RECORD_RESTART \n");
ms_restart = 1;
//encode_stop();
//delay_10ms(1);
//ms_start();
ms_restart = 0 ;
break;
case MSG_MS_RECORD_STOP:
log_info("---MSG_MS_RECORD_STOP \n");
encode_stop();
ms_start() ;
break ;
case MSG_MS_PLAY:
log_info("----MSG_MS_PLAY \n");
log_info("ms_recing_time :%d \n", ms_recing_time);
//if(ms_recing_time < 3){
// ms_record_status = 0 ;
// ms_recing_time = 0 ;
// break ;
//}
encode_stop() ;
record_play();
break;
case MSG_WAV_FILE_END:
case MSG_MP3_FILE_END:
case MSG_F1A1_FILE_END:
case MSG_F1A2_FILE_END:
case MSG_MIDI_FILE_END:
log_info("decode end :%d \n", music_play_get_decoder_type(music_obj));
music_play_end_operation(music_obj);
break;
case MSG_A_FILE_END:
log_info("decode end :%d \n", music_play_get_decoder_type(music_obj));
music_play_end_operation(music_obj);
break;
case MSG_WAV_FILE_ERR:
case MSG_F1A1_FILE_ERR:
case MSG_F1A2_FILE_ERR:
case MSG_MP3_FILE_ERR:
case MSG_MIDI_FILE_ERR:
music_play_destroy(&music_obj);
break;
case MSG_A_FILE_ERR:
music_play_destroy(&music_obj);
break;
case MSG_NEXT_MODE:
app_switch_next();
break;
case MSG_APP_SWITCH_ACTIVE:
if (app_switch_en()) {
goto _app_switch;
}
break;
}
}
_app_switch:
music_play_destroy(&music_obj);
encode_stop() ;
return 0;
}
借用的也都是芯片录音的资源
变音部分如下: