/** * Write the Track Chunk * * @param DataOutputStream dos * @param Track track - track to write * @exception IOException */ @SuppressWarnings("rawtypes") private void writeTrackChunk(DataOutputStream odos, Track track) throws IOException { // Write to temporary stream to buffer disk writes and // calculate the number of bytes written to the stream ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); int header = 0x4D54726B; Enumeration en = track.getEvtList().elements(); en = track.getEvtList().elements(); // At this stage Except that all events are NoteOn events while (en.hasMoreElements()) { Event evt = (Event) en.nextElement(); evt.write(dos); if (DEBUG) evt.print(); } // Write to the real stream odos.writeInt(header); odos.writeInt(baos.size()); odos.write(baos.toByteArray(), 0, baos.size()); }
/** Convert a SMF into the jMusic data type */ @SuppressWarnings("rawtypes") public static void SMFToScore(Score score, SMFTools smf) { Enumeration<Track> en = smf.getTrackList().elements(); // Go through tracks while (en.hasMoreElements()) { Part part = new Part(); Track smfTrack = en.nextElement(); Vector evtList = smfTrack.getEvtList(); Vector phrVct = new Vector(); sortEvents(evtList, phrVct, smf, part); for (int i = 0; i < phrVct.size(); i++) { part.addPhrase((Phrase) phrVct.elementAt(i)); } score.addPart(part); score.clean(); } }