Click here to Skip to main content
15,918,041 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 4-Apr-13 22:30pm
v3

Quote:
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


You need to know all the fields ond what they represent:
https://ccrma.stanford.edu/courses/422/projects/WaveFormat/[^]

Some examples:
http://www.codeproject.com/search.aspx?q=wave+file&x=0&y=0&sbo=kw[^]
 
Share this answer
 
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:
C++
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 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/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900