#include <stdio.h>
const int NUM_SAMPLES = 48000*100; // 指定样本数量
int main() {
const unsigned short LEFT_CHANNEL_DATA = 0x2211; // 左声道数据
const unsigned short RIGHT_CHANNEL_DATA = 0x4433; // 右声道数据
// 打开文件以写入PCM数据
FILE *pcm_file = fopen("output.pcm", "wb");
if (!pcm_file) {
printf("Failed to open PCM file.\n");
return 1;
}
// 生成PCM数据流
for (int i = 0; i < NUM_SAMPLES; ++i) {
// 写入左声道数据
fwrite(&LEFT_CHANNEL_DATA, sizeof(unsigned short), 1, pcm_file);
// 写入右声道数据
fwrite(&RIGHT_CHANNEL_DATA, sizeof(unsigned short), 1, pcm_file);
}
// 关闭文件
fclose(pcm_file);
printf("PCM data generated successfully.\n");
return 0;
}
6557

被折叠的 条评论
为什么被折叠?



