]> git.donarmstrong.com Git - lilypond.git/blob - lily/midi-stream.cc
patch::: 1.3.132.jcn1
[lilypond.git] / lily / midi-stream.cc
1 /*
2   midi-stream.cc -- implement Midi_stream
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
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
19 Midi_stream::Midi_stream (String filename)
20 {
21   filename_str_ = filename;
22   os_p_ = open_file_stream (filename, ios::out|ios::bin);
23 }
24
25 Midi_stream::~Midi_stream ()
26 {
27   close_file_stream (os_p_);
28 }
29
30 Midi_stream&
31 Midi_stream::operator << (String str)
32 {
33   *os_p_ << str;
34   return *this;
35 }
36
37 extern bool verbose_global_b;
38 Midi_stream&
39 Midi_stream::operator << (Midi_item const& midi_c_r)
40 {
41   String str = midi_c_r.str ();
42 #if 0
43   if (flower_dstream && !flower_dstream->silent_b ("Midistrings"))
44 #else    
45   if (verbose_global_b)
46 #endif    
47     {
48      str = String_convert::bin2hex_str (str) + "\n";
49     // ugh, should have separate debugging output with Midi*::print routines
50     int i = str.index_i ("0a");
51     while (i >= 0)
52       {
53         str[i] = '\n';
54         str[i + 1] = '\t';
55         i = str.index_i ("0a");
56       }
57     }
58
59   *os_p_ << str;
60   return *this;
61 }
62
63 Midi_stream&
64 Midi_stream::operator << (int i)
65 {
66   // output binary string ourselves
67   *this << Midi_item::i2varint_str (i);
68   return *this;
69 }
70