September 12th, 2012, 04:47 AM
C program about enhancing speech in wav file
I am trying to analyze a program that enhances speech in a noisy wav file sample
The final result has the correct wav file header and is exactly like the original one
However the final file is a few hundred bytes shorter than the original which I think should be equal in length
However, when I try to play the wav file Windows Media Player says it cannot play this file
What could be the reason?
I can plot both the wav files in Matlab and there is definitely sound in the created file
And since the header is exactly the same as the original shouldn't it be playable?
September 12th, 2012, 05:34 AM
You could try other media players, such as VLC
> And since the header is exactly the same as the original shouldn't it be playable?
Maybe WMP also checks that the size stated in the header is consistent with the overall file length.
> However the final file is a few hundred bytes shorter than the original which I think should be equal in length
Well then, check your code.
One thing to check would be whether you opened the files in binary mode.
For example, if you read a wav file in text mode on windows, then all the 0x0D bytes will be silently dropped.
September 12th, 2012, 07:33 AM
I meant only the header is exactly similar, the final file has to be different than the original one
However header being exactly similar would imply it contains the same information about the length of the file and the processed file is definitely a few 100 bytes shorter
I had assumed I would probably hear some garbage value noise because of them, but Windows Media Player just didn't play it
September 12th, 2012, 08:32 AM
> I am trying to analyze a program that enhances speech in a noisy wav file sample
So does this process remove samples from the file or not?
If it's just processing the file and adjusting all the samples, then the header will be the same, and the file will be the same length.
If (by design), the enhancement deletes samples, then the header file CANNOT be "exactly similar" (which is an oxymoron), and the file will be shorter.
If the header of the file says that there are 1000 samples in the file, and it only contains 990 (because the file isn't large enough to hold 1000), then WMP is perfectly entitled to believe the file is corrupt and not do anything.
You need to figure out which part of your overall process is screwing up. A stronger check on the validity of your WAV header would be a start.
Like for example, if you've made the file shorter, that subchunk2size has been updated.
September 12th, 2012, 09:02 AM
I am not sure whether it deletes samples or not
like I mentioned I am still analysing it
However from what I have understood till now it just takes the sound file data, passes it through some fft routines and filters, then performs iffts and writes it to a new wav file
It copies the exact header from the old file into the new file that's how I know the header will show the same length for both files
However I know from windows explorer and file properties that the new file is coming out to be a few hundred bytes shorter than the old one
This could be the reason why Media Player crashes but I am still not sure
I thought the player would just play the garbage values as sound since the file isn't actually longer than that specified in the header