更改WAV文件内容 [英] Change WAV file contents
问题描述
我正在尝试切断wav文件中的部分声音。
这个程序实际上切断了正面声音。但我认为声音的最后部分与原始的wav文件相比是重复的。可能我猜我没有改变格式内容。那么我该如何更改文件格式内容?如Chunksize或BlockAlign..etc?
最后是否有可能在原始文件中写入并删除一些数据?因为它不能正常工作,我复制原始的wav文件使test.wav切断
需要你的帮助
I''m trying to cut off a part of sound in a wav file.
This program actually cut off the front sound. but I think the last part of sound is repeated compared to original wav file. Probably I guess I didn''t change format contents. So then How can I change file format contents? such as Chunksize or BlockAlign..etc?
lastly Is it possible that write and remove some data in original file?? As it didn''t work well, I copied original wav file to make test.wav cut off
Need your help
推荐答案
最后是否有可能在原始文件中写入和删除一些数据?由于它不能很好地工作,我复制原始的wav文件使test.wav切断
lastly Is it possible that write and remove some data in original file?? As it didn''t work well, I copied original wav file to make test.wav cut off
你需要知道所有的字段是什么它们代表:
https://ccrma.stanford.edu/courses/422/ projects / WaveFormat / [ ^ ]
一些例子:
http://www.codeproject.com/search.aspx?q=wave+file&x=0&y=0&sbo=kw 一> [ ^ ]
您还必须调整标题(块和子块)数据以匹配新(缩短)文件的大小。假设文件使用RIFF_WAVE格式,您可以使用以下结构:
You must also adjust the headers (chunk and sub-chunks) data to match the size of the new (shortened) file. Assuming the file uses RIFF_WAVE format, you can use this structure:
typedef struct {
char chunkID[4]; // "RIFF"
DWORD chunkSize; // file size - 8
char type[4]; // "WAVE"
char fmt[4]; // "fmt "
DWORD fmtSize; // size of following format section
} RiffHdr_t;
fmtSize
指定以下fmt块的大小,该块可能是 WAVEFORMAT
, PCMWAVEFORMAT
或 WAVEFORMATEX
结构(在 mmsystem.h 中定义)。之后是包含原始声音数据的数据部分。
参见https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ [ ^ ]
fmtSize
specifies the size of the following "fmt " block which may be a WAVEFORMAT
, PCMWAVEFORMAT
, or WAVEFORMATEX
structure (defined in mmsystem.h). After this follows a "data" section containing the raw sound data.
See also https://ccrma.stanford.edu/courses/422/projects/WaveFormat/[^]
这篇关于更改WAV文件内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!