音频调试时录制pcm数据

一 场景

在音频调试时需要录制pcm数据定位问题,所以每次都找写pcm文件的代码, 这次记录一下

二 代码
cpp 复制代码
#include <iostream>
#include <fstream>

bool WriteBinaryFile1(const std::string& filename, const void* data, size_t size) {
	if (!data || size == 0) {
		return false;
	}
	static  std::ofstream file1(filename, std::ios::binary);
	if (!file1.is_open()) {
		return false;
	}
	file1.write(static_cast<const char*>(data), size);
	bool success = file1.good();
	return success;
}

bool WriteBinaryFile2(const std::string& filename, const void* data, size_t size) {
	if (!data || size == 0) {
		return false;
	}
	static  std::ofstream file2(filename, std::ios::binary);
	if (!file2.is_open()) {
		return false;
	}
	file2.write(static_cast<const char*>(data), size);
	bool success = file2.good();
	return success;
}
相关推荐
八月的雨季 最後的冰吻1 天前
音视频会议梳理
音视频
合尘猫2 天前
用 6GB 显卡搭短视频产线:MiniMax H3 + ffmpeg 全流程实录(55 秒片 / 40 分钟)
人工智能·音视频
the3clipse4 天前
Windows 11 26H2 声音与音频问题排查指南:没声音、麦克风不收音与蓝牙音频优化
音视频·le audio·windows 11 26h2·win11没声音·麦克风没声音·蓝牙耳机音质·音频服务修复
开开心心就好4 天前
PDF水印怎么去掉?勾选对象再点匹配
java·前端·mysql·支持向量机·pdf·音视频·模拟退火算法
RobinDevNotes5 天前
Claude Code 剪视频,不上传、不要 API Key
人工智能·python·音视频·开发工具·ipython
伯奥克客服5 天前
2026年视频综合一体机架构选型:从接口协议到流媒体底层的深度技术解析
架构·音视频
开开心心就好5 天前
两张表格数据对比工具,不用写函数也能查
算法·spring·智能手机·pdf·电脑·intellij-idea·音视频
FansAI_art5 天前
多角色 AIGC 短片的双模型分工:静态生图与图生视频怎么接
aigc·音视频
山顶夕景6 天前
【ECCV2026】流式视频理解Thinking in Streaming Video
音视频·vlm·视频理解·多模态理解·流式视频
zhanlang02177 天前
HTML 零基础入门到企业实战【第五章 5.4】内嵌网页 iframe 标签:嵌入网页、视频、地图实战
前端·html·音视频