views:

642

answers:

2

Hi all,

I've got this small code that performs recording in java. I whish to add some sort of functionality to draw a visual presentation of this. How would you advise me to approach this? (I am very new to java )

I'd like the visual presentation to appear as a foreground of a current existing image.

A: 

You may be able to do this with Java Sound API (AudioSystem, AudioInputStream, AudioFormat). The API lets you read .wav files byte by byte, and you can also get bitrate, vbr, quality information from AudioFormat object. You can then draw this information with AWT, Swing or whatever you like.

cw22
A: 

Skip first 44 bytes from the wav file (header), then read data using this function:

private static double readLEShort(RandomAccessFile f) {
    try {
        byte b1 = (byte) f.read();
        byte b2 = (byte) f.read();
        return (double) (b2 << 8 | b1 & 0xFF) / 32767.0;
    } catch (IOException e) {
        e.printStackTrace();
    }
    return 0;
}

One value for each channel. This will give you number between -1 and 1, which you can draw on your graph. I believe someone else will help with drawing it.

tulskiy