X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fmidi-chunk.cc;h=9e5a828a602908badd83f5ef0ec8bfb73fa399e7;hb=f4c712ec8d705f02d42c5c00724de44554edd97e;hp=ffd267425a3051237d30812890a47a9fb9e0e57a;hpb=0387f04497978e37b335a8b99eec905499d6ad0f;p=lilypond.git diff --git a/lily/midi-chunk.cc b/lily/midi-chunk.cc index ffd267425a..9e5a828a60 100644 --- a/lily/midi-chunk.cc +++ b/lily/midi-chunk.cc @@ -1,10 +1,21 @@ -/* - midi-chunk.cc -- implement Midi_chunk - - source file of the GNU LilyPond music typesetter - - (c) 2007--2008 Han-Wen Nienhuys - +/* + This file is part of LilyPond, the GNU music typesetter. + + Copyright (C) 2007--2012 Han-Wen Nienhuys + + + 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 . */ #include "midi-chunk.hh" @@ -13,7 +24,8 @@ #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) @@ -29,22 +41,27 @@ Midi_track::Midi_track () // mi = 0: major key // mi = 1: minor key - number_ = 0; - char const *data_str0 = "" - // "00" "ff58" "0404" "0218" "08" - // "00" "ff51" "0307" "a120" - // why a key at all, in midi? - // key: C - // "00" "ff59" "02" "00" "00" - // key: F (scsii-menuetto) - // "00" "ff59" "02" "ff" "00" - ; + // "00" "ff58" "0404" "0218" "08" + // "00" "ff51" "0307" "a120" + // why a key at all, in midi? + // key: C + // "00" "ff59" "02" "00" "00" + // key: F (scsii-menuetto) + // "00" "ff59" "02" "ff" "00" + ; string data_string; // 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); @@ -65,18 +82,17 @@ Midi_track::data_string () const { string str = Midi_chunk::data_string (); - for (vector::const_iterator i (events_.begin ()); - i != events_.end (); i ++) + for (vector::const_iterator i (events_.begin ()); + i != events_.end (); i++) { str += (*i)->to_string (); } return str; } - Midi_track::~Midi_track () { - junk_pointers (events_); + junk_pointers (events_); } /**************************************************************** @@ -93,12 +109,11 @@ Midi_event::to_string () const { string delta_string = int2midi_varint_string (delta_ticks_); string midi_string = midi_->to_string (); - assert (midi_string.length ()); return delta_string + midi_string; } /**************************************************************** header -*/ +*/ Midi_header::Midi_header (int format, int tracks, int clocks_per_4) { @@ -116,13 +131,12 @@ Midi_header::Midi_header (int format, int tracks, int clocks_per_4) set ("MThd", str, ""); } - /**************************************************************** chunk */ Midi_chunk::~Midi_chunk () { - + } void @@ -145,7 +159,7 @@ Midi_chunk::to_string () const string str = header_string_; string dat = data_string (); string length_string = String_convert::int2hex (dat.length () - + footer_string_.length (), 8, '0'); + + footer_string_.length (), 8, '0'); length_string = String_convert::hex2bin (length_string); str += length_string;