资源简介
这里面主要是用C++读取WAV文件的信息,包括采样率,位数,数据值等信息!
代码片段和文件信息
/* rifffile.cpp
Copyright (c) 1996 1988 by Timothy J. Weber.
See rifffile.txt for documentation.
*/
#include “rifffile.h“
using namespace std;
/***************************************************************************
macros and constants
***************************************************************************/
// define REVERSE_ENDIANISM if the endianism of the host platform is not Intel
// (Intel is little-endian)
#ifdef REVERSE_ENDIANISM
#define SWAP_32(int32) ( \
((((DWORD) int32) & 0x000000FFL) << 24) + \
((((DWORD) int32) & 0x0000FF00L) << 8) + \
((((DWORD) int32) & 0x00FF0000L) >> 8) + \
((((DWORD) int32) & 0xFF000000L) >> 24))
#endif
struct TypeRecord {
char* typeName; // four-letter name
char* realName; // English name
};
const int numExtraTypes = 24;
const TypeRecord extraTypes[numExtraTypes] = {
{ “DISP“ “Display name“ }
{ “IARL“ “Archival location“ }
{ “IART“ “Artist“ }
{ “ICMS“ “Commissioned“ }
{ “ICMT“ “Comments“ }
{ “ICOP“ “Copyright“ }
{ “ICRD“ “Creation date“ }
{ “ICRP“ “Cropped“ }
{ “IDIM“ “Dimensions“ }
{ “IDPI“ “Dots Per Inch“ }
{ “IENG“ “Engineer“ }
{ “IGNR“ “Genre“ }
{ “IKEY“ “Keywords“ }
{ “ILGT“ “Lightness“ }
{ “IMED“ “Medium“ }
{ “INAM“ “Name“ }
{ “IPLT“ “Palette Setting“ }
{ “IPRD“ “Product“ }
{ “ISBJ“ “Subject“ }
{ “ISFT“ “Software“ }
{ “ISHP“ “Sharpness“ }
{ “ISRC“ “Source“ }
{ “ISRF“ “Source Form“ }
{ “ITCH“ “Technician“ }
};
/***************************************************************************
typedefs and class definitions
***************************************************************************/
/***************************************************************************
prototypes for static functions
***************************************************************************/
/***************************************************************************
static variables
***************************************************************************/
/***************************************************************************
member functions for RiffFile
***************************************************************************/
RiffFile::RiffFile(const char *name):
fp(fopen(name “rb“))
{
if (fp && !rewind()) {
fclose(fp);
fp = 0;
}
}
RiffFile::~RiffFile()
{
if (fp)
fclose(fp);
}
bool RiffFile::rewind()
{
// clear the chunk stack
while (!chunks.empty())
chunks.pop();
// rewind to the start of the file
if (fseek(fp 0 SEEK_SET))
return false;
// look for a valid RIFF header
RiffChunk topChunk(*this);
if (feof(fp) || strcmp(topChunk.name “RIFF“))
return false;
// found; push it on the stack and leave the put pointer in the same place
// as the get pointer.
formSize = topChunk.size;
chunks.push(topChunk);
return true;
}
bool RiffFile::push(const char* chu
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 9087 2012-04-02 15:28 WAVW\RIFFFile.cpp
文件 2299 2012-04-02 15:28 WAVW\rifffile.h
文件 3211 2001-08-15 10:59 WAVW\RIFFFile.txt
....... 6279 1997-03-13 19:09 WAVW\WavCat\RIFFFile.cpp
....... 1911 1997-03-13 19:08 WAVW\WavCat\RIFFFile.h
....... 2449 1997-03-13 19:08 WAVW\WavCat\RIFFFile.txt
文件 14309 2002-09-28 23:10 WAVW\WAVE.cpp
文件 4309 2002-09-28 23:11 WAVW\WAVE.h
文件 10870 2002-09-28 23:10 WAVW\WAVE.txt
文件 36804 2012-04-02 13:27 WAVW\WAVE.zip
文件 4080 2000-12-20 18:20 WAVW\WaveTest\A440.bpr
文件 810 2000-12-20 22:35 WAVW\WaveTest\A440.cpp
文件 68463 2012-04-02 13:38 WAVW\WaveTest\Debug\RIFFFile.obj
文件 0 2012-04-02 13:38 WAVW\WaveTest\Debug\RIFFFile.sbr
文件 91136 2012-04-02 13:38 WAVW\WaveTest\Debug\vc60.idb
文件 135168 2012-04-02 13:38 WAVW\WaveTest\Debug\vc60.pdb
文件 240588 2012-04-02 13:38 WAVW\WaveTest\Debug\WAVE.obj
文件 0 2012-04-02 13:38 WAVW\WaveTest\Debug\WAVE.sbr
文件 328704 2012-04-02 13:38 WAVW\WaveTest\Debug\WaveTest.bsc
文件 565328 2012-04-02 13:38 WAVW\WaveTest\Debug\WaveTest.exe
文件 835100 2012-04-02 13:38 WAVW\WaveTest\Debug\WaveTest.ilk
I.A.... 187016 2012-04-02 13:38 WAVW\WaveTest\Debug\WaveTest.pch
文件 1164288 2012-04-02 13:38 WAVW\WaveTest\Debug\WaveTest.pdb
文件 5 2012-04-02 13:35 WAVW\WaveTest\Debug\新建文本文档.bat
文件 650 2002-09-28 17:01 WAVW\WaveTest\Regress.bat
文件 4591 2000-12-20 22:54 WAVW\WaveTest\Reverb.bpr
文件 1551 2000-12-21 09:14 WAVW\WaveTest\Reverb.cpp
文件 823 2000-12-21 11:14 WAVW\WaveTest\WaveTest.bpg
文件 4412 2000-12-21 11:15 WAVW\WaveTest\WaveTest.bpr
文件 2769 2000-12-21 11:15 WAVW\WaveTest\WaveTest.cpp
............此处省略15个文件信息
评论
共有 条评论