c - 如何将 portaudio 录制的样本写入不同的文件?
问题描述
我正在使用peax_record.c示例从麦克风录制音频。一切都很好,但我想将录制的原始音频写入单独的文件。每一个都应该是 1 秒。1.raw 0-1 秒 2.raw 1-2 秒 ...
所以我对 WRITE_TO_FILE 做了一些修改
#if WRITE_TO_FILE
{
FILE *fid;
SAMPLE *tempRecord = (SAMPLE *) malloc( totalFrames/NUM_SECONDS );
fid = fopen("test.raw", "wb");
if( fid == NULL )
{
printf("Could not open file.");
}
for(int i=0; i <totalFrames/NUM_SECONDS ; i++) {
tempRecord[i] = data.recordedSamples[i];
}
int x = fwrite( tempRecord, NUM_CHANNELS * sizeof(SAMPLE), totalFrames/NUM_SECONDS, fid );
}
#endif
实际上,我知道,这不是我想要的,但作为第一步,我想写第一秒,如果成功,我可以写其他秒。但是使用这段代码,我遇到了分段错误。
如何解析 data.recordedSamples ?
解决方案
推荐阅读
- react-native - React Native:错误:捆绑失败:index.js:“”不是有效的标识符名称
- angularjs - 从Angularjs中的数组中获取特定元素
- c# - 外键关系没有出现在 edmx 与 mysql 数据库与 asp mvc 与数据库第一
- angularjs - 在ajax formdata中获取415(不支持的媒体类型)发布到spring
- flutter - 如何在颤动中从 SelectableText 小部件中获取选定的文本
- json - 使用 Spark 2.4 识别空 JSON 文件
- c# - 在 Unity 中捕获 360 度屏幕截图会忽略 UI 层
- sql - 如何将一个 SQL 列转换为同一行的多个列?
- java - 在 Android 中,我如何实现一个全局触摸跟踪服务,即使屏幕上正在运行其他应用程序也能正常工作
- java - Spring Boot 配置问题中的 JWT 令牌