You need to enable JavaScript to run this app.
导航

【OC】dump 音频

最近更新时间2023.03.17 15:43:42

首次发布时间2023.03.17 15:43:42

使用步骤

〇、创建文件夹路径

会在该路径下保存dump出来的文件,只需要指定文件路径,不需要指定文件名。最后会在该路径下生成命名为"audiosdk_$fileNamePrefix_$handleAddress_input_$sampleRate_$channelNum.wav"、
"audiosdk_$fileNamePrefix_$handleAddress_output_$sampleRate_$channelNum.wav"这两个文件,分别对应输入数据和输出数据。若是为了调试回声消除(见【C】回声消除-V2 ),会在该路径下生成
"audiosdk_$fileNamePrefix_$handleAddress_mic_$sampleRate_$channelNum.wav"、
"audiosdk_$fileNamePrefix_$handleAddress_ref_$sampleRate_$channelNum.wav"、
"audiosdk_$fileNamePrefix_$handleAddress_output_$sampleRate_$channelNum.wav"
这3个文件,分别代表输入的mic数据、输入的ref数据、处理后的输出数据。

一、在创建算法句柄后初始化Debug 设置

在通过 SAMICoreCreateHandleByIdentify 创建算法句柄 handle后(见SAMI core各功能接口文档“使用步骤”中的“创建算法句柄”小节),调用SAMICoreInitDebugConfig初始化Debug设置。

SAMICore_DebugConfig* debug_config = [[SAMICore_DebugConfig alloc] init];
debug_config.dumpPath = documentFilePath;//set a directory instead of a file for dump
debug_config.fileNamePrefix = @"anything_you_want_to_mark";//fileNamePrefix will be the second "word" of the dumped file name
debug_config.sampleRate = sample_rate_;
debug_config.numberChannels = num_channel_;
int result = [handle initDebugWithConfig: debug_config];

以下情况会初始化失败:

  1. 没有正确传入handle,例如在initWithIdentify前就调用initDebugWithConfig.

二、创建 SAMICoreBlock 用于存放输入和输出

见SAMI core 各功能接口“使用步骤”中的“创建 SAMICoreBlock 用于存放输入和输出”小节示例中采用这种方法。

三、处理音频

见SAMI core 各功能接口“使用步骤”中的“处理音频”小节示例中采用这种方法。

四、释放dump Audio资源

int result = [handle releaseDebugConfig];

五、释放资源

释放 handle

handle = nil;

六、备注

下述接口需在同一条线程调用
SAMICoreInitDebugConfig
SAMICoreReleaseDebugConfig
SAMICoreProcess