-/*
- midi-chunk.cc -- implement Midi_chunk
-
- source file of the GNU LilyPond music typesetter
-
- (c) 2007--2008 Han-Wen Nienhuys <hanwen@lilypond.org>
+/*
+ This file is part of LilyPond, the GNU music typesetter.
+
+ Copyright (C) 2007--2011 Han-Wen Nienhuys <hanwen@lilypond.org>
+
+ LilyPond is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ LilyPond is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
*/
#include "midi-chunk.hh"
#include "std-string.hh"
#include "string-convert.hh"
-Midi_track::Midi_track ()
+Midi_track::Midi_track (int number, bool port)
+ : number_ (number)
{
// 4D 54 72 6B MTrk
// 00 00 00 3B chunk length (59)
// mi = 0: major key
// mi = 1: minor key
- number_ = 0;
-
char const *data_str0 = ""
// "00" "ff58" "0404" "0218" "08"
// "00" "ff51" "0307" "a120"
// only for format 0 (currently using format 1)?
data_string += String_convert::hex2bin (data_str0);
+ if (port)
+ {
+ string port = "00" "ff" "21" "01"
+ + String_convert::int2hex (number_, 2, '0');
+ data_string += String_convert::hex2bin (port);
+ }
+
char const *footer_str0 = "00" "ff2f" "00";
string footer_string = String_convert::hex2bin (footer_str0);
{
string delta_string = int2midi_varint_string (delta_ticks_);
string midi_string = midi_->to_string ();
- assert (midi_string.length ());
return delta_string + midi_string;
}
/****************************************************************