当前位置:   article > 正文

保存音频到文件_c++微软录制声音保存成文件

c++微软录制声音保存成文件
  1. static int save_audio(int seq, char *audio_buff, int len)
  2. {
  3. char file_name[64] = {0};
  4. int ret = 0;
  5. snprintf(file_name, sizeof(file_name), "/tmp/audio_file_%d", seq);
  6. FILE *fp = fopen(file_name, "w+");
  7. if (!fp) {
  8. return -1;
  9. }
  10. ret = fwrite((void*)audio_buff, sizeof(char), len, fp);
  11. if(ret != len) {
  12. printf("write audio_buff len=%d,ret=%d failed\n",len,ret);
  13. fclose(fp);
  14. return -1;
  15. }
  16. fclose(fp);
  17. return 0;
  18. }

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/158601
推荐阅读
相关标签
  

闽ICP备14008679号