4 // source file of the LilyPond music typesetter
6 // (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
12 #include "midi-item.hh"
13 #include "midi-stream.hh"
15 #include "string-convert.hh"
17 Midi_stream::Midi_stream( String filename_str
, int tracks_i
, int clocks_per_4_i
)
19 filename_str_
= filename_str
;
21 clocks_per_4_i_
= clocks_per_4_i
;
27 Midi_stream::~Midi_stream()
33 Midi_stream::operator <<( String str
)
37 str
= String_convert::bin2hex_str( str
);
38 // string now 1.0.26-2 handles binary streaming
44 Midi_stream::operator <<( Midi_item
& mitem_r
)
46 mitem_r
.output_midi( *this );
53 Midi_stream::operator <<( int i
)
55 // output binary string ourselves
56 *this << Midi_item::i2varint_str( i
);
63 // *os_p_ << "% Creator: " << get_version();
64 // *os_p_ << "% Automatically generated, at ";
66 // *os_p_ << ctime(&t);
69 // String str = "MThd";
70 // 00 00 00 06 chunk length
73 // 00 60 96 per quarter-note
75 // char const ch_c_l = "0000" "0006" "0001" "0001" "0060";
76 // str += String_convert::hex2bin_str( ch_c_l );
79 // *this << Midi_header( 1, 1, tempo_i_ );
80 *this << Midi_header( 1, tracks_i_
, clocks_per_4_i_
);
86 os_p_
= new ofstream( filename_str_
);
88 error ("can't open `" + filename_str_
+ "\'" );