]> git.donarmstrong.com Git - lilypond.git/blob - lily/midi-stream.cc
release: 0.1.13
[lilypond.git] / lily / midi-stream.cc
1 //
2 // midistream.cc
3 //
4 // source file of the GNU LilyPond music typesetter
5 //
6 // (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
7
8 #include <fstream.h>
9 #include <time.h>
10 #include "string.hh"
11 #include "string-convert.hh"
12 #include "main.hh"
13 #include "misc.hh"
14 #include "midi-item.hh"
15 #include "midi-stream.hh"
16 #include "debug.hh"
17
18 Midi_stream::Midi_stream (String filename_str)
19 {
20   filename_str_ = filename_str;
21   os_p_ = 0;
22   open();
23 }
24
25 Midi_stream::~Midi_stream()
26 {
27   delete os_p_;
28 }
29
30 Midi_stream&
31 Midi_stream::operator <<(String str)
32 {
33   if (check_debug && !monitor->silence("Midistrings"))
34     str = String_convert::bin2hex_str (str);
35   
36   *os_p_ << str;
37
38   if (check_debug && !monitor->silence("Midistrings"))
39     *os_p_ << "\n";
40
41   return *this;
42 }
43
44 Midi_stream&
45 Midi_stream::operator <<(Midi_item const& mitem_c_r)
46 {
47   //    *this << mitem_c_r.str();
48   mitem_c_r.output (this);
49   if (check_debug && !monitor->silence("Midistrings"))
50     *os_p_ << "\n";
51   return *this;
52 }
53
54 Midi_stream&
55 Midi_stream::operator <<(int i)
56 {
57   // output binary string ourselves
58   *this << Midi_item::i2varint_str (i);
59   return *this;
60 }
61
62 void
63 Midi_stream::open()
64 {
65   os_p_ = new ofstream (filename_str_);
66   if (!*os_p_)
67     error ("can't open `" + filename_str_ + "\'");
68 }