4 // source file of the LilyPond music typesetter
6 // (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
11 #include "string-convert.hh"
14 #include "midi-item.hh"
15 #include "midi-stream.hh"
18 Midi_stream::Midi_stream( String filename_str, int tracks_i, int clocks_per_4_i )
20 filename_str_ = filename_str;
22 clocks_per_4_i_ = clocks_per_4_i;
28 Midi_stream::~Midi_stream()
34 Midi_stream::operator <<( String str )
38 str = String_convert::bin2hex_str( str );
39 // string now 1.0.26-2 handles binary streaming
45 Midi_stream::operator <<( Midi_item const& mitem_c_r )
47 mitem_c_r.output_midi( *this );
54 Midi_stream::operator <<( int i )
56 // output binary string ourselves
57 *this << Midi_item::i2varint_str( i );
64 // *os_p_ << "% Creator: " << get_version();
65 // *os_p_ << "% Automatically generated, at ";
67 // *os_p_ << ctime(&t);
70 // String str = "MThd";
71 // 00 00 00 06 chunk length
74 // 00 60 96 per quarter-note
76 // char const ch_C = "0000" "0006" "0001" "0001" "0060";
77 // str += String_convert::hex2bin_str( ch_C );
80 // *this << Midi_header( 1, 1, tempo_i_ );
81 *this << Midi_header( 1, tracks_i_, clocks_per_4_i_ );
87 os_p_ = new ofstream( filename_str_ );
89 error ("can't open `" + filename_str_ + "\'" );