#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2010
    Posts
    121
    Rep Power
    21

    C program about enhancing speech in wav file


    Hi
    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?
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,384
    Rep Power
    1871
    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.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2010
    Posts
    121
    Rep Power
    21
    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
  6. #4
  7. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,384
    Rep Power
    1871
    > 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.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2010
    Posts
    121
    Rep Power
    21
    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

IMN logo majestic logo threadwatch logo seochat tools logo