资源简介
使用QT实现pcm和wav文件相互转换,读取wav音频格式等。其中有些数据类型属于qt特有如qint32, QString等完全可以转成int,std::string,移植的话转成相应类型即可。
代码片段和文件信息
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** “Redistribution and use in source and binary forms with or without
** modification are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** “AS IS“ AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING BUT NOT
** LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT INDIRECT INCIDENTAL
** SPECIAL EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT
** LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE
** DATA OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY WHETHER IN CONTRACT STRICT LIABILITY OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.“
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include
#include
#include
#include “wavfile.h“
struct chunk
{
char id[4];
quint32 size;
};
struct RIFFHeader
{
chunk descriptor; // “RIFF“
char type[4]; // “WAVE“
};
struct WAVEHeader
{
chunk descriptor;
quint16 audioFormat;
quint16 numChannels;
quint32 sampleRate;
quint32 byteRate;
quint16 blockAlign;
quint16 bitsPerSample;
};
struct DATAHeader
{
chunk descriptor;
};
struct CombinedHeader
{
RIFFHeader riff;
WAVEHeader wave;
};
WavFile::WavFile(Qobject *parent)
: QFile(parent)
m_headerLength(0)
{
}
//isRead == true为读方式, ==false 为写方式
bool WavFile::open(const QString &fileName bool isRead)
{
bool result;
if(this->isOpen())
QFile::close();
setFileName(fileName);
if(isRead)
result = QFile::open(QIODevice::ReadOnly) && readAudioForma
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2653 2018-09-01 19:20 wavfile.h
文件 7871 2018-09-01 19:20 wavfile.cpp
相关资源
- TCP收发json. 客户端和服务端
- Qt 下的udp socket通信
- QT文件资源管理器
- pcm-g711a-采集器-播放器
- 26个英文字母.wav .mp3 格式 读音
- Qt做的画图程序的源码
- QT如何实现后台运行即最小化到右下角
- Qt QTableWidget 基本功能及排序功能
-
Multi-focus image fusion ba
sed on wavelet t - qt-everywhere-opensource-src-5.6.0.tar.gz
- 一个DPCM的源代码
- QT之打开文件对话框选择文件
- QT是实现图片得拖拉功能
- QTP自动化测试-相关练习操作视频
- linux Qt4 软键盘
- Qt使用FontAwesome的
- 毕业设计——基于QT的GPS车载导航系统
- Qt实现拼图游戏
-
Qt st
yle Sheets Examples - 提供Qt中快速多次发射信号与耗时槽函
- 基于Qt的坦克大战游戏源码
- Qt5.5 代码实现记事本程序 MiniText
- Qt4第三方库qextserialport
- 多界面跳转切换
- Qt VideoCapture图像采集
- Qt Designer汉化包亲测可用内附说明.z
- Qt 自定义导航栏
- qt黑白棋源码简单
- Qt4.8.4和creator和mingw安装配置说明总结
- 在ARM9和ARMLinux下利用QT编写的实时数据
评论
共有 条评论