6321N/A * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * @author Kara Kytle 0N/A * @author Jan Borgersen 0N/A private static final int bufferSize =
16384;
// buffersize for write 0N/A * Obtains the file types that this provider can write from the 0N/A * sequence specified. 0N/A * @param sequence the sequence for which midi file type support 0N/A * @return array of file types. If no file types are supported, 0N/A * returns an array of length 0. 0N/A // First get the fileStream from this sequence 0N/A // Done....return bytesWritten 0N/A //================================================================================= 0N/A // Determine the filetype to write 0N/A if (
tracks.
length <
1) {
// $$jb: 05.31.99: we _can_ write TYPE_1 if tracks.length==1 0N/A // Now build the file one track at a time 0N/A // Note that above we made sure that MIDI_TYPE_0 only happens 0N/A // if tracks.length==1 0N/A //bytesBuilt += trackStreams[i].getLength(); 0N/A // Now seqence the track streams 0N/A // fix for 5048381: NullPointerException when saving a MIDI sequence 0N/A // don't include failed track streams 0N/A // Now build the header... 0N/A // Write the magic number 0N/A // Write the header length 0N/A // Write the filetype 0N/A // Write the number of tracks 0N/A // Determine and write the timing format 0N/A // $$jb: 04.08.99: What to really do here? 0N/A // now construct an InputStream to become the FileStream 0N/A * Returns ONE_BYTE, TWO_BYTE, SYSEX, META, 0N/A * ERROR, or IGNORE (i.e. invalid for a MIDI file) 0N/A private final static long mask =
0x7F;
0N/A int shift=
63;
// number of bitwise left-shifts of mask 0N/A // first screen out leading zeros 0N/A // then write actual values 0N/A // ----------------------------- 0N/A // Write each event in the track 0N/A // ----------------------------- 0N/A // $$jb: this gets easier if we change all system-wide time to delta ticks 0N/A // get the status byte 0N/A // $$jb: 04.08.99: always write status for sysex 0N/A // $$jb: 10.18.99: we don't maintain length in 0N/A // the message data for SysEx (it is not transmitted 0N/A // over the line), so write the calculated length 0N/A // minus the status byte 0N/A // $$jb: 10.18.99: now write the rest of the 0N/A // $$jb: 10.18.99: getMessage() returns the 0N/A // entire valid midi message for a file, 0N/A // including the status byte and the var-length-int 0N/A // length value, so we can just write the data 0N/A // here. note that we must _always_ write the 0N/A // status byte, regardless of runningStatus. 0N/A // ignore this event 0N/A // ignore this event 0N/A // --------------------------------- 0N/A // End write each event in the track 0N/A // --------------------------------- 0N/A // Build Track header now that we know length 0N/A // Now sequence them