2 midi-stream.cc -- implement Midi_stream
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2007 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "midi-stream.hh"
14 #include "international.hh"
16 #include "midi-chunk.hh"
18 #include "program-option.hh"
20 #include "string-convert.hh"
23 Midi_stream::Midi_stream (string file_name
)
25 file_name_string_
= file_name
;
26 out_file_
= fopen (file_name
.c_str (), "wb");
28 error (_f ("cannot open for write: %s: %s", file_name
, strerror (errno
)));
31 Midi_stream::~Midi_stream ()
37 Midi_stream::write (string str
)
39 size_t sz
= sizeof (Byte
);
40 size_t n
= str
.length ();
41 size_t written
= fwrite (str
.data (), sz
, n
, out_file_
);
43 if (written
!= sz
* n
)
44 warning (_ ("cannot write to file: `%s'"));
48 Midi_stream::write (Midi_chunk
const &midi
)
50 string str
= midi
.to_string ();