资源简介
用QT写的简单的录音例子,简单易学,可以作为参考.

代码片段和文件信息
#include “audiorecorder.h“
#include
struct HEADER
{
char RIFFNAME[4];
unsigned long nRIFFLength;
char WAVNAME[4];
char FMTNAME[4];
unsigned long nFMTLength;
unsigned short nAudioFormat;
unsigned short nChannleNumber;
//unsigned short nSampleRate;
unsigned long nSampleRate;
unsigned long nBytesPerSecond;
unsigned short nBytesPerSample;
unsigned short nBitsPerSample;
char DATANAME[4];
unsigned long nDataLength;
};
AudioRecorder::AudioRecorder(QWidget *parent)
: QWidget(parent)
{
start = new QPushButton(tr(“start“));
stop = new QPushButton(tr(“stop“));
play = new QPushButton(tr(“play“));
save = new QPushButton(tr(“save“));
stop->setDisabled(true);
play->setDisabled(true);
save->setDisabled(true);
debugInfo = new QTextEdit();
QHBoxLayout *hlayout = new QHBoxLayout();
hlayout->addWidget(start);
hlayout->addWidget(stop);
hlayout->addWidget(play);
hlayout->addWidget(save);
// QHBoxLayout *hlayout1 = new QHBoxLayout();
QVBoxLayout *layout = new QVBoxLayout();
layout->addLayout(hlayout);
layout->addWidget(debugInfo);
this->setLayout(layout);
outputFile = new QFile();
outputFile->setFileName(tr(“record.raw“));
format.setFrequency(8000);
format.setChannels(1);
format.setSampleSize(16);
format.setSampleType(QAudioFormat::SignedInt);
format.setByteOrder(QAudioFormat::LittleEndian);
format.setCodec(“audio/pcm“);
QAudioDeviceInfo info(QAudioDeviceInfo::defaultInputDevice());
if (!info.isFormatSupported(format)) {
qWarning(“input default format not supported try to use nearest“);
format = info.nearestFormat(format);
}
QAudioDeviceInfo info1(QAudioDeviceInfo::defaultOutputDevice());
if (!info1.isFormatSupported(format)) {
qWarning() << “output default format not supported - trying to use nearest“;
// format = info.nearestFormat(m_format);
qWarning() << “output no support input format.“;
return;
}
if(format.sampleSize() != 16) {
qWarning(“audio device doesn‘t support 16 bit support %d bit samples example cannot run“ format.sampleSize());
audioInput = 0;
return;
}
audioInput = NULL;
audioOutput = NULL;
connect(start SIGNAL(clicked()) thisSLOT(recordStart()));
connect(stop SIGNAL(clicked()) thisSLOT(recordStop()));
connect(play SIGNAL(clicked()) thisSLOT(recordPlay()));
connect(save SIGNAL(clicked()) thisSLOT(recordSave()));
}
AudioRecorder::~AudioRecorder()
{
}
void AudioRecorder::recordStart()
{
outputFile->open(QIODevice::WriteOnly | QIODevice::Truncate);
audioInput = new QAudioInput(format this);
audioInput->start(outputFile);
debugInfo->append(tr(“start record!“));
start->setDisabled(true);
stop->setDisabled(false);
play-
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6998 2010-08-26 11:49 audioRecorder\audiorecorder.cpp
文件 818 2010-08-26 11:30 audioRecorder\audiorecorder.h
文件 578 2010-08-26 17:08 audioRecorder\audioRecorder.pro
文件 14336 2014-07-05 09:51 audioRecorder\audioRecorder.pro.user
文件 255 2010-08-24 15:41 audioRecorder\main.cpp
目录 0 2014-07-05 09:52 audioRecorder
----------- --------- ---------- ----- ----
22985 6
- 上一篇:易语言源码易语言小说在线提取源码.rar
- 下一篇:老男孩运维58期视频.txt
相关资源
- 酒店管理系统基于Qt Creator5)
- VisualStudioUninstaller vs卸载工具
- 组态王驱动开发包3.0.0.7(中文)
- 多窗口后台鼠标连点器
- 使用选择性重传协议实现UDP可靠通信
- VC 获得文件属性 获取文件的创建时
- 读者写者问题(读者优先,写者优先
- vtk QT做的三维地质可视化系统2of2
- 用VC 编写的仿QQ聊天室程序源代码
- Qt局域网聊天软件
- 外点法程序
- 外罚函数程序
- Qt Creator opengl实现四元数鼠标控制轨迹
- QT局域网聊天系统(基于QT5.修改过)
- qt-电子点菜系统
- 推箱子及人工智能寻路C 源代码
- 自己写的航空订票系统c 版--数据结构
- 数据结构实验魔王语言
- MUSIC算法c 实现
- C 餐厅叫号系统(QT平)
- 国际象棋c 完整版
-
ob
jectARX给Auto CAD加工具条 - QT 实现文件下载
- qt图像处理
- 画图程序MFC/VC/VC CRectTracker 串行化
- MFC网络编程实例
- c 课程设计 职工信息管理系统
- VC 游戏编程—附源代码
- IpHlpApi.h&IpHlpApi.lib
- 清华大学 c 郑莉 ppt课件
评论
共有 条评论