public void read(InputStream is)
            throws IOException {
        //Given the small size of MIDI files read all
        //data into a ByteArrayStream for further processing
        byte[] fileData = new byte[is.available()];
        is.read(fileData);
        ByteArrayInputStream bais =
                new ByteArrayInputStream(fileData);
        DataInputStream dis = new DataInputStream(bais);
        //clear any SMF data
        if (!this.trackList.isEmpty()) {
            this.trackList.removeAllElements(); //remove any previous tracks
        }
        //check header for MIDIfile validity
        if (dis.readInt() != 0x4D546864) {//Check for MIDI track validity
            throw new IOException("This is NOT a MIDI file !!!");
        } else {//If MIDI file passes skip length bytes
            dis.readInt(); //skip over Length info
        }
        //get SMF Class data
        try {
            fileType = dis.readShort();
            if (VERBOSE) System.out.println("MIDI file type = " + fileType);
            this.numOfTracks = dis.readShort();
            if (VERBOSE) System.out.println("Number of tracks = " + numOfTracks);
            this.ppqn = dis.readShort();
            if (VERBOSE) System.out.println("ppqn = " + ppqn);
        } catch (IOException e) {
            System.out.println(e);
            e.printStackTrace();
        }

        // skip the tempo track fro type 1 files
        /*
		if(fileType == 1) {
		    skipATrack(dis);
		    numOfTracks--;
		}
		*/
        //Read all track chunks
        for (int i = 0; i < numOfTracks; i++) {
            readTrackChunk(dis);
        }
        is.close();
        dis.close();
    }