lilypond-1.3.154
[lilypond.git] / lily / midi-stream.cc
blobb353f92dc7af742d5aef3c44f088d9cc05254f1e
1 /*
2 midi-stream.cc -- implement Midi_stream
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
9 #include <fstream.h>
10 #include "paper-stream.hh"
11 #include "string.hh"
12 #include "string-convert.hh"
13 #include "main.hh"
14 #include "misc.hh"
15 #include "midi-item.hh"
16 #include "midi-stream.hh"
17 #include "debug.hh"
18 #include "scm-option.hh"
20 Midi_stream::Midi_stream (String filename)
22 filename_str_ = filename;
23 #if __GCC__ > 2
24 os_p_ = open_file_stream (filename, ios::out|ios::bin);
25 #else
26 os_p_ = open_file_stream (filename, ios::out|ios::binary);
27 #endif
30 Midi_stream::~Midi_stream ()
32 close_file_stream (os_p_);
35 Midi_stream&
36 Midi_stream::operator << (String str)
38 *os_p_ << str;
39 return *this;
42 Midi_stream&
43 Midi_stream::operator << (Midi_item const& midi_c_r)
45 String str = midi_c_r.str ();
48 if (midi_debug_global_b)
50 str = String_convert::bin2hex_str (str) + "\n";
51 // ugh, should have separate debugging output with Midi*::print routines
52 int i = str.index_i ("0a");
53 while (i >= 0)
55 str[i] = '\n';
56 str[i + 1] = '\t';
57 i = str.index_i ("0a");
61 *os_p_ << str;
62 return *this;
65 Midi_stream&
66 Midi_stream::operator << (int i)
68 // output binary string ourselves
69 *this << Midi_item::i2varint_str (i);
70 return *this;