// test_byte_read.java test_byte_read ok.wav // reads bytes one at a time as an int import java.io.*; class test_byte_read { test_byte_read(String inp) { char riff[] = new char[4]; int sread, swrite; int fsize; char wave[] = new char[4]; char fmt[] = new char[4]; int nbytes; short ccode; short channels; int rate; int avgrate; short blockalign; short bps; // bits per sample char data[] = new char[4]; int csize; int ibyte; // byte of cound char more[] = new char[4]; int smin = 0; int smax = 0; int savg; int bad; // flags bad data in read int nbread; // number of bytes read System.out.println("test_read_byte.java running "); System.out.println("reading "+inp); try { FileInputStream ds = new FileInputStream(inp); sread = 4; for(int i=0; i127) ibyte = ibyte-256; savg = savg + ibyte; if(i==0) {smin=ibyte; smax=ibyte;} smin = ibytesmax?ibyte:smax; if(i<10 || i>csize-10) System.out.println("sound byte ="+ibyte); } savg = savg / csize; System.out.println("smin="+smin+", smax="+smax+", savg="+savg); nbread = nbread+csize; System.out.println(nbread+" bytes read so far"); // read rest of chunks while(nbread+17127) ibyte = ibyte-256; } nbread = nbread+8+csize; System.out.println(nbread+" bytes read so far"); } ds.close(); } catch(Exception e) { System.out.println("test_read_byte, some exception thrown"); } System.out.println("end test_byte_read.java"); } // end test_byte_read constructor public static void main (String[] args) { String inp = "ok.wav"; if(args.length>0) { inp = args[0]; } new test_byte_read(inp); } // end main } // end class test_byte_read of test_byte_read.java