// Copyright 2020-2021 Beken // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include #include #include #include #include "modules/g711.h" #include "ff.h" #include "diskio.h" #include "cli.h" static void cli_audio_g711_help(void) { os_printf("g711_encoder_test {xxx.pcm xxx.pcm} \r\n"); os_printf("g711_decoder_test {xxx.pcm xxx.pcm} \r\n"); } void cli_g711_encoder_test_cmd(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv) { char mic_file_name[50]; char out_encoder_file_name[50]; FIL file_mic; FIL file_encoder_out; int16_t mic_addr = 0; int8_t encoder_temp = 0; FRESULT fr; uint32 uiTemp = 0; uint32_t encoder_size = 0; uint32_t i = 0; if (argc != 3) { cli_audio_g711_help(); return; } sprintf(mic_file_name, "1:/%s", argv[1]); fr = f_open(&file_mic, mic_file_name, FA_READ); if (fr != FR_OK) { os_printf("open %s fail.\r\n", mic_file_name); return; } sprintf(out_encoder_file_name, "1:/%s", argv[2]); fr = f_open(&file_encoder_out, out_encoder_file_name, FA_CREATE_ALWAYS | FA_WRITE); if (fr != FR_OK) { os_printf("open %s fail.\r\n", out_encoder_file_name); return; } encoder_size = f_size(&file_mic); os_printf("encoder_size = %d \r\n", encoder_size); for (i=0; i