class WavFile
{
public WavFile() {}
public void
read(URL location, byte[] buffer, short[] ch1, short[] ch2,
int max, int[] par)
{try
{URLConnection con = location.openConnection();
DataInputStream in =
new DataInputStream(con.getInputStream());
in.read(buffer);
in.close();
}
catch(Exception e) {;}
int i, m, bit=0, ch=0, fre=0, len=0;
try
{WindowsStream input =
new WindowsStream(new ByteArrayInputStream(buffer));
input.readLong(); // 8 Byte
input.readLong(); // 8 Byte
input.readInt(); // 4 Byte
input.readShort(); // 2 Byte
ch = input.readShort(); // ch, 2 Byte
fre = input.readInt(); // fre, 4 Byte
input.readInt(); // 4 Byte
input.readShort(); // 2 Byte
bit = input.readShort(); // 2 Byte
input.readInt(); //4 Byte
len = input.readInt()*8/ch/bit; //Len, 4 Byte
if (len>max) len = max;
if (bit == 16)
for (i = 0; i < len; i++)
{ch1[i] = input.readShort();
if (ch==2) ch2[i] = input.readShort();
}
if (bit == 8)
for (i = 0; i < len; i++)
{ch1[i] = (short)(input.readByte() - 128);
if (ch == 2) ch2[i] = (short)(input.readByte()-128);
}
}
catch(Exception e) {;}
par[0]=ch;
par[1]=fre;
par[2]=len;
par[3]=bit;
}
}
End of Listing