Exemple #1
0
 /**
  * Write the Track Chunk
  *
  * @param DataOutputStream dos
  * @param Track track - track to write
  * @exception IOException
  */
 private void writeTrackChunk(DataOutputStream odos, Track track) throws IOException {
   if (VERBOSE) System.out.println("Writing MIDI Track");
   // 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 aEnum = track.getEvtList().elements();
   aEnum = track.getEvtList().elements();
   // At this stage Except that all events are NoteOn events
   while (aEnum.hasMoreElements()) {
     Event evt = (Event) aEnum.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());
 }
Exemple #2
0
 /**
  * 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());
 }