Results 1 to 2 of 2
  1. #1
    zellazode is offline Member
    Join Date
    Sep 2009
    Posts
    2
    Rep Power
    0

    Default handling WAV file

    Hello,
    I want to retrieve information out of a Wav file - for a Fourier transfrom.

    I am using AudioInputStream. The problem is that I would prefer it to be in float(s), because the bytes affect my analysis.

    Alterantivley, if you could provide me with a link to an FT of a wave file, that works well*, I'd be very greatful.

    *By works well, I mean - The FT I have now computes for a certain frequency, a certain amplitude. When I change the wave file to be quieter, the fourier transfrom doesn't always show a change in amplitude (sometimes increase).
    I printed the array of bytes produced by AudioInputStream, and it looks something like this:
    100
    0
    -98
    1
    6
    32
    -45

    and on the more quiet one, it looks like this:
    24
    0
    -23
    1
    1
    1
    -2

    So you see - 1,6 and 32 were all mapped to the value 1, once the sample was of lower volume. I think this is affecting my analysis, and would prefer to retrieve float information out of WAV files.

    Could you help?

    Thank you all.

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    6

    Default

    I'm no expert in math or acoustics, but the information stored in a sound file isn't floating point data to begin with.

    The degree of accuracy is determined by the sample rate, and the size of the sample (22Khz @ 8bit) for example. So, there are no magic hidden floating point values stored in the file, just lots of rounded integers.

    If you need a greater degree of accuracy in your transformations, then I suggest converting all of the bytes read (which can be read as ints or longs depending on the bit size) into floats or doubles and then performing transformations.

    However, if you then intend to play the sound again, you're going to loose any trailing decimal information since everything will have to go back to a non-floating point value.

    I suspect you're having trouble with the conversion of the bytes to something else in your transform. When I spent a very brief time playing with sound analysis, the sounds I was working with were stored in 2 byte chunks, and transformations had to be applied to the two bytes together, not each individually (16 bit) because the two bytes needed to be treated as one number i.e.
    10110101 10010011 is 46483 (unsigned), not
    181 and 147
    Not realizing this at first, I was performing transformations byte by byte which let to garbage results.

    I wasn't doing anything fancy however, just pitch shifting, playing backwards, etc...

Similar Threads

  1. Sms handling in j2ee
    By prts_mfs in forum Java Servlet
    Replies: 1
    Last Post: 04-22-2009, 08:40 AM
  2. Event handling... help?
    By kevzspeare in forum New To Java
    Replies: 2
    Last Post: 04-04-2009, 08:46 PM
  3. rmi and event handling
    By darkhorse in forum Advanced Java
    Replies: 0
    Last Post: 03-15-2009, 08:20 AM
  4. Problem in File Handling in Java
    By getbiplab in forum New To Java
    Replies: 6
    Last Post: 03-31-2008, 12:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •