]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.1.7
authorfred <fred>
Sun, 24 Mar 2002 19:53:16 +0000 (19:53 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:53:16 +0000 (19:53 +0000)
Documentation/INSTALL.pod
Documentation/lilypond.pod
Documentation/mi2mu.pod
lily/include/midi-item.hh
lily/include/midi-stream.hh
lily/include/note-performer.hh
lily/include/score.hh
lily/midi-item.cc
lily/midi-stream.cc

index 82d5e944fd7dafb64b593aa126666fa9b6f18b35..ae5da8da87f01b35b79bf8d5bab540c4871f62a6 100644 (file)
@@ -95,8 +95,8 @@ Although not strictly necessary, these are recommended to have.
 
 =item *
 
-Perl.  Most scripts are written in Perl. Most  documentation was created
-with the perl's Plain Old Documentation.
+Perl-5.  Most scripts are written in Perl. Most  documentation was created
+with the perl's Plain Old Documentation. (I use 5.003)
 
 =item *
 
@@ -311,18 +311,17 @@ permissions will not be set correctly, unfortunately)
 A Debian package is in the works
 
 
-=head1 WINDOZE
+=head1 WINDOWS NT/95
 
-Windows NT:
+So, you're stuck with Windows, eh?  Well, don't worry, you just 
+need (to get) Cygnus' windows32 port of gnu development stuff; 
+have a look at http://www.cygnus.com/gnu-win32.
 
-you need the cygnus windows32 gnu port development stuff; have a look
-at http://www.cygnus.com/gnu-win32.
-
-to make GNU LilyPond under, brr, aargh, shudder.. windows32, well,
+To make GNU LilyPond under, brr, aargh, shudder... windows32, well,
 simply type:
 
        bash configure
-       make windows32
+       make
 
 =head1 AUTHORS
 
index faa26928e4363234050abdb7608c4d73bbf6c7e5..c2d26569354600196d85ced6763d45a837a60b9f 100644 (file)
@@ -10,7 +10,7 @@ lilypond - the GNU music typesetter
 
 GNU LilyPond is a program which converts music definition files into
 visual or auditive output: it can typeset formatted sheet music to a
-TeX file and and (mechanical) performances to MIDI files.
+TeX file and play (mechanical) performances to MIDI files.
 
 =head1 OPTIONS
 
@@ -22,12 +22,12 @@ add F<FILE> to the search path for input files.
 
 =item B<-M,--midi>
 
-do midi output only
+do midi output only.
 
 =item B<-d,--debug>,
 
-Turn debugging info. GNU LilyPond will read the file F<.dstreamrc>, which
-tells for what functions and classes may produce copious debugging
+Turn debugging info on.  GNU LilyPond reads the file F<.dstreamrc>, 
+which lists what functions and classes may produce copious debugging
 output.
 
 =item B<-w,--warranty>,
@@ -41,11 +41,11 @@ Set the default output file to F<FILE>.
 
 =item B<-h,--help>,
 
-Show a summary of usage
+Show a summary of usage.
 
 =item B<-i,--init=>F<FILE>
 
-set init file to F<FILE> (default: F<symbol.ly>)
+set init file to F<FILE> (default: F<symbol.ly>).
 
 =item B<--include, -I>=F<DIRECTORY>
 
@@ -53,21 +53,21 @@ add F<DIRECTORY> to the search path for input files.
 
 =item B<--ignore-version, -V>
 
-make incompatible mudela version non-fatal 
+make incompatible mudela version non-fatal.
 
 =back
 
 =head1 FEATURES
 
-This is an overview of the features that GNU LilyPond supports. For
-details on how to use them, you should consult mudela(5)
+This is an overview of the features that GNU LilyPond supports.  For
+details on how to use them, you should consult mudela(5).
 
 =over 5
 
 =item *
 
 ASCII script input, with identifiers (for music reuse),
-customizable notenames, customizable fontset
+customizable notenames, customisable fontset.
 
 =item *
 
@@ -79,7 +79,7 @@ MIDI to Mudela conversion through the mi2mu program.
 
 =item *
 
-Multiple staffs in one score. Each staff can have a different meters.
+Multiple staffs in one score.  Each staff can have a different meters.
 
 =item *
 
@@ -90,11 +90,11 @@ transposition dynamics (both absolute and hairpin style)
 =item *
 
 multiple voices within one staff; beams optionally shared
-between voices. Up to four voices is handled cleanly.
+between voices.  Up to four voices is handled cleanly.
 
 =item *
 
-multiple scores within one input file. Each score is output to
+multiple scores within one input file.  Each score is output to
 a different file.
 
 =item *
@@ -105,11 +105,11 @@ clef changes, meter changes, cadenza-mode, key changes, repeat bars
 
 =head1 DISCLAIMER & COPYING POLICY
 
-GNU LilyPond is copyright 1996,97 by its authors. GNU LilyPond is
-distributed under the terms of the GNU General Public
-License. GNU LilyPond is provided without any warranty what so ever.
-GNU LilyPond may be freely distributed.  For further information consult
-the GNU General Public License, which is in the file F<COPYING>
+GNU LilyPond is copyright 1996, 1997 by its authors.  GNU LilyPond is
+distributed under the terms of the GNU General Public License.  GNU LilyPond 
+is provided without any warranty what so ever.
+GNU LilyPond may be freely distributed.  For further information consult 
+the GNU General Public License, from the file F<COPYING>.
 
 =head1 AUTHORS
 
@@ -132,7 +132,7 @@ Jan Nieuwenhuizen <jan@digicash.com>,  http://www.digicash.com/~jan.
 =head1 PROBLEMS
 
 
-There is an extensive list of todoes and bugs. See F<TODO>. In
+There is an extensive list of todoes and bugs.  See F<TODO>.  In
 general, try to find out 
 
 =over 4
@@ -159,7 +159,7 @@ send a description of the platform you use
 
 =item *
 send a description of the LilyPond version you use (with
-compile/config options please)
+compile/configure options please)
 
 =item *
 send a description of the bug itself.
@@ -171,8 +171,8 @@ send it to bug-gnu-music@vuse.vanderbilt.edu
 
 It does help if you can find out where the bug comes from: if GNU
 LilyPond bombs out, then please recompile using with debugging info
-turned on, and send gdb stacktrace of the crash. It also helps if you
-can print the values of the objects. So if your trace is
+turned on, and send gdb stacktrace of the crash.  It also helps if you
+can print the values of the objects.  So if your trace is
 
        received SIGSEGV 
        (gdb) backtrace 12
@@ -193,7 +193,7 @@ Than it would help if you send a dump of the Interval and the Item
 
 =item F<symbol.ly>
 
-The initialisation file with symbol tables etc. It
+The initialisation file with symbol tables etc.  It
 includes files from the directory F<init/>.
 
 =back
@@ -214,7 +214,7 @@ On technical details of LilyPond
 
 =item mudela-man
 
-On the input format. This is a LilyPond-enhanced LaTeX document.
+On the input format.  This is a LilyPond-enhanced LaTeX document.
 
 =item MANIFESTO
 
@@ -227,7 +227,7 @@ The GNU LilyPond FAQ list
 =item http://www.stack.nl/~hanwen/lilypond/index.html
 
 GNU LilyPond has her own webpage.  This webpage contains the MIDI, GIF
-and PS files for some standard music files. It also has the complete
+and PS files for some standard music files.  It also has the complete
 LilyPond documentation
 
 =back
@@ -235,7 +235,7 @@ LilyPond documentation
 GNU LilyPond is
 updated very frequently, the latest version is always available at:
 ftp://pcnov095.win.tue.nl/pub/lilypond and
-ftp://alpha.gnu.ai.mit.edu/gnu/
+ftp://alpha.gnu.ai.mit.edu/gnu/lilypond/
 
 
 For programs which are part of the GNU music project, the following
@@ -251,13 +251,13 @@ subject "subscribe" to info-gnu-music-request@vuse.vanderbilt.edu
 
 =item help-gnu-music@vuse.vanderbilt.edu
 
-For help with programs from the GNU music project. To subscribe: send
+For help with programs from the GNU music project.  To subscribe: send
 mail with subject "subscribe" to
 help-gnu-music-request@vuse.vanderbilt.edu
 
 =item bug-gnu-music@vuse.vanderbilt.edu
 
-If you have bugreports, you should send them to this list. If you want
+If you have bugreports, you should send them to this list.  If you want
 to read all bugreports, you should subscribe to this list.  To
 subscribe: send mail with subject "subscribe" to
 bug-gnu-music-request@vuse.vanderbilt.edu
@@ -284,19 +284,19 @@ than the names being similar :-)
 (for a  detailed changelog, see F<NEWS>)
 
 GNU LilyPond's roots lie in MPP, a preprocessor to the rather arcane
-MusiXTeX macro package for TeX. A friend of mine, Jan Nieuwenhuizen
+MusiXTeX macro package for TeX.  A friend of mine, Jan Nieuwenhuizen
 wrote the first 44 versions (0.01 to 0.44), then his program caught my
 attention, and I was slowly sucked in to the interesting problem of
-easily producing beautifully printed music. I contributed some
-code. We soon realised that MPP's design was too fundamentally broken
+easily producing beautifully printed music.  I contributed some
+code.  We soon realised that MPP's design was too fundamentally broken
 to be repaired, so it was decided to rewrite MPP.  We debated a lot about
-the requirements to an inputformat (fall 1995). I sat down and started
+the requirements to an inputformat (fall 1995).  I sat down and started
 with a parser-first, bottom-up rewrite called mpp95 (which totally
 failed, obviously).
 
 After long and hard thinking, I came up with an algorithm for the
 horizontal spacing of multiple staffs (april 1996) I coded it (and did
-not test it). After starting with this fundamental piece, I slowly
+not test it).  After starting with this fundamental piece, I slowly
 added the stages which come before spacing, and after.  A half year
 later, I had a first working version, (october 1996).  I announced
 Patchlevel 0.0.7 (or 8) to the mutex list after asking some technical
@@ -304,7 +304,7 @@ details on spacing; it was downloaded approximately 4 times.  Then I
 got the hang of it, and in the subsequent two months, I coded until it
 had doubled in size (pl 23).
 
-Most the other history is described in the NEWS file. The first large
+Most the other history is described in the NEWS file.  The first large
 scale release (0.1) was done after approximately 78 patchlevels on
 August 1, 1997.
 
index 77a68f1f529298443a8749f02655eb21d825b5b2..1e35a7547a58be07cba89b078930dc4c8cc05162 100644 (file)
@@ -80,11 +80,11 @@ This is an overview of the features that Mi2mu supports.
 =head1
 DISCLAIMER & COPYING POLICY
 
-Mi2mu is copyright 1996,97 by its authors. Mi2mu is distributed 
+Mi2mu is copyright 1996, 1997 by its authors. Mi2mu is distributed 
 as part of GNU LilyPond, under the terms of the GNU General Public
 License.  Mi2mu is provided without any warranty what so ever.
 Mi2mu may be freely distributed.  For further information consult
-the GNU General Public License, which is in the file F<COPYING>.
+the GNU General Public License, from the file F<COPYING>.
 
 =head1 AUTHORS
 
index ed5cf51a59edfb4788970dcb4d91c2532d9a6c77..4906f27ba865678dad30e26c1e803fdbb7571c1c 100644 (file)
@@ -1,7 +1,8 @@
-//
-//  midiitem.hh -- part of GNU LilyPond
-//
-//  copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
+/*
+  midi-item.hh -- declare Midi items
+
+  (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
+ */
 
 #ifndef MIDI_ITEM_HH
 #define MIDI_ITEM_HH
@@ -9,6 +10,7 @@
 #include "string.hh"
 #include "lily-proto.hh"
 #include "virtual-methods.hh"
+#include "moment.hh"
 
 /**
   Any piece of midi information.
   Maybe use base classes for RIFF files?
  */
 struct Midi_item {
-    Midi_item() { }
     DECLARE_MY_RUNTIME_TYPEINFO;
+    Midi_item( Audio_item* audio_item_l ); 
     static String i2varint_str( int i );
-    virtual void output_midi( Midi_stream& midi_stream_r ) const;
+    void output( Midi_stream* midi_stream_l ) const;
     virtual String str() const = 0;
+
+    Audio_item* audio_item_l_;
+    int channel_i_;
+
 private:
-    Midi_item(Midi_item const&){}
-    void operator=(Midi_item const&){}
+    Midi_item( Midi_item const& );
+    Midi_item& operator =( Midi_item const& );
 };
 
-struct Midi_key : public Midi_item {
-    Midi_key( int accidentals_i, int minor_i );
+/**
+  variable sized MIDI data
+ */
+struct Midi_chunk : Midi_item {
     DECLARE_MY_RUNTIME_TYPEINFO;
-       
+    Midi_chunk();
+
+    void add( String str );
+    void set( String header_str, String data_str, String footer_str );
     virtual String str() const;
-    /* *************** */
-    int accidentals_i_;
-    int minor_i_;
+
+private:
+    String data_str_;
+    String footer_str_;
+    String header_str_;
+};
+
+struct Midi_duration : public Midi_item {
+    DECLARE_MY_RUNTIME_TYPEINFO;
+    Midi_duration( Real seconds_f );
+
+    virtual String str() const;
+    Real seconds_f_;
+};
+
+struct Midi_header : Midi_chunk {
+    DECLARE_MY_RUNTIME_TYPEINFO;
+
+    Midi_header( int format_i, int tracks_i, int clocks_per_4_i );
+
 };
 
 /**
   Change instrument event
  */
 struct Midi_instrument : public Midi_item {
-    Midi_instrument( int channel_i, String instrument_str );
     DECLARE_MY_RUNTIME_TYPEINFO;
+    Midi_instrument( int channel_i, String instrument_str );
 
     virtual String str() const;
-
-    int channel_i_;
-    Byte program_byte_;
+    String instrument_str_;
 };
                                       
-struct Midi_note : public Midi_item {
-    /**
-      Generate a note-event on a channel.
 
-      @param #melreq_l# is the pitch. 
-     */
-    Midi_note( Melodic_req* melreq_l, int channel_i, bool on_b );
+struct Midi_key : public Midi_item {
     DECLARE_MY_RUNTIME_TYPEINFO;
-
+    Midi_key( Audio_item* audio_item_l );
+       
     virtual String str() const;
+};
 
-    /* *************** */
-    int const c0_pitch_i_c_ = 60;
-    Byte dynamic_byte_;
+struct Midi_meter : Midi_item {
 
-    int channel_i_;
-    int on_b_;
-    int pitch_i_;
+    DECLARE_MY_RUNTIME_TYPEINFO;
+    Midi_meter( Audio_item* audio_item_l ); 
+  
+    virtual String str() const;
+    int clocks_per_1_i_;
 };
 
-struct Midi_duration : public Midi_item {
-    Midi_duration( Real seconds_f );
+/**
+  Turn a note on (blond).
+ */
+struct Midi_note : public Midi_item {
     DECLARE_MY_RUNTIME_TYPEINFO;
+    Midi_note( Audio_item* audio_item_l ); 
 
+    Moment duration() const;
+    int pitch_i() const;
     virtual String str() const;
-    /* *************** */
-    Real seconds_f_;
+
+    int const c0_pitch_i_c_ = 60;
+    Byte dynamic_byte_;
 };
 
-struct Midi_chunk : Midi_item {
-    Midi_chunk();
+/**
+  Turn a note off (dark).
+ */
+struct Midi_note_off : public Midi_item {
     DECLARE_MY_RUNTIME_TYPEINFO;
+    Midi_note_off( Midi_note* midi_note_l ); 
 
-    void add( String str );
-    void set( String header_str, String data_str, String footer_str );
+    int pitch_i() const;
     virtual String str() const;
-private:
-    String data_str_;
-    String footer_str_;
-    String header_str_;
-};
 
-struct Midi_header : Midi_chunk {
-    /* *************** */
-    Midi_header( int format_i, int tracks_i, int clocks_per_4_i );
-    DECLARE_MY_RUNTIME_TYPEINFO;
+    Byte aftertouch_byte_;
 };
 
 struct Midi_text : Midi_item {
+    DECLARE_MY_RUNTIME_TYPEINFO;
     
     enum Type { 
        TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC, 
        MARKER, CUE_POINT
     };
     Midi_text( Midi_text::Type type, String text_str );
-    DECLARE_MY_RUNTIME_TYPEINFO;
-
+    Midi_text( Audio_item* audio_item_l );
+    
     virtual String str() const;
-    /* *************** */
+
     Type type_;
     String text_str_;
-    
 };
 
 struct Midi_tempo : Midi_item {
-    Midi_tempo( int per_minute_4_i );
     DECLARE_MY_RUNTIME_TYPEINFO;
-
+    Midi_tempo( int per_minute_4_i );
+    Midi_tempo( Audio_item* audio_item_l ); 
+  
     virtual String str() const;
-    /* *************** */
 
     int per_minute_4_i_;
 };
 
-struct Midi_time : Midi_item {
-
-    Midi_time( int num_i, int den_i, int clocks_per_1_i );
-    DECLARE_MY_RUNTIME_TYPEINFO;
-
-    virtual String str() const;
-
-    /* *************** */
-    int num_i_;
-    int den_i_;
-    int clocks_per_1_i_;
-};
-
 struct Midi_track : Midi_chunk {
+    DECLARE_MY_RUNTIME_TYPEINFO;
     int number_i_;
-    /* *************** */
+    
     Midi_track();
-    DECLARE_MY_RUNTIME_TYPEINFO;
 
     void add( int delta_time_i, String event );
     void add( Moment delta_time_moment, Midi_item* mitem_l );
 };
 
-#endif // MIDI_ITEM_HH //
-
+#endif // MIDI_ITEM_HH
index c18cb9c4e9761761c110996548c6de57b68f82d5..9fded298d5e0274ddc234614c3d54721ddb6cb12 100644 (file)
@@ -1,7 +1,8 @@
-//
-//  midistream.hh -- part of GNU LilyPond
-//
-//  copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
+/*
+  midi-stream.hh -- declare Midi_stream
+
+  (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
+ */
 
 #ifndef MIDI_STREAM_HH
 #define MIDI_STREAM_HH
 #include <iostream.h>
 #include "string.hh"
 
-/// Midi output
+/// Midi outputfile
 struct Midi_stream {
-    ostream* os_p_;
-    String filename_str_;
-    int clocks_per_4_i_;
-    int tracks_i_;
-    
-    Midi_stream( String filename_str, int tracks_i, int clocks_per_4_i_ );
+    Midi_stream( String filename_str );
     ~Midi_stream();
 
     Midi_stream& operator <<( String str );
     Midi_stream& operator <<( Midi_item const& mitem_c_r );
     Midi_stream& operator <<( int i );
 
-    void header();
     void open();
 
-//private:
-//    Midi_stream(Midi_stream const&);
+    ostream* os_p_;
+    String filename_str_;
 };
-#endif // MIDI_STREAM_HH //
+
+#endif // MIDI_STREAM_HH
index b925617e426d3421e3f465a1ec253c74d0d68d75..0fb8aecbd43fab4ae98831306d1ca4fe7b1f0b2d 100644 (file)
@@ -18,7 +18,6 @@ public:
     DECLARE_MY_RUNTIME_TYPEINFO;
 
     Note_performer();
-    ~Note_performer();
 
 protected:
     virtual void process_requests();
@@ -28,7 +27,6 @@ protected:
 
 private:
     Melodic_req * note_req_l_;
-    Moment off_mom_;
 };
 
 #endif // NOTE_PERFORMER_HH
index dea8806243156b51f33a561002822ef73cc68c1b..058fb173b0eb4fce16018a6f1049a7d595f3fbda 100644 (file)
@@ -26,7 +26,8 @@ public:
     Paper_def *paper_p_;
     Midi_def *midi_p_;
     Music * music_p_;
-    PScore *pscore_p_;
+    Paper_score *pscore_p_;
+    Audio_score* audio_score_p_;
 
     int errorlevel_i_;
     
@@ -34,6 +35,7 @@ public:
 
     /// construction
     Score();
+    Score(Score const&);
     ~Score();    
 
     /// do everything except outputting to file
@@ -42,7 +44,6 @@ public:
     /// output to file
     void output(String fn);
 
-    
     ///
     void set(Midi_def* midi_p);
     ///
@@ -50,11 +51,7 @@ public:
 
     void print() const;
 
-    Score(Score const&);
 private:
-
-
-
     void run_translator(Global_translator*);
     void midi_output();
     void paper_output();
@@ -68,7 +65,6 @@ private:
     // utils:
     PCursor<Score_column*> create_cols(Moment, PCursor<Score_column*> &last);
 
-
     /**
       make the pcol_l_ fields of each Score_column point to the correct PCol,
       remove any unnecessary Score_column's
index 4d29affb66199eecfd11a3af0de480d0fb62aa6c..88ac41f6b412f2b6cc52c27cbf58b7b983c019a3 100644 (file)
@@ -1,39 +1,38 @@
 /*
-  midi-item.cc -- implement various midi items.
+  midi-item.cc -- implement Midi items.
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
-*/
+  (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
+ */
 
-#include <limits.h>
 #include "proto.hh"
 #include "plist.hh"
-#include "p-col.hh"
 #include "debug.hh"
 #include "misc.hh"
 #include "string.hh"
 #include "string-convert.hh"
-#include "request.hh"
+#include "command-request.hh"
 #include "musical-request.hh"
-#include "music-list.hh"
 #include "midi-item.hh"
 #include "midi-stream.hh"
-
+#include "audio-item.hh"
 
 IMPLEMENT_IS_TYPE_B(Midi_item);
-IMPLEMENT_IS_TYPE_B1(Midi_key,Midi_item);
-IMPLEMENT_IS_TYPE_B1(Midi_note, Midi_item);
-IMPLEMENT_IS_TYPE_B1(Midi_duration, Midi_item);
 IMPLEMENT_IS_TYPE_B1(Midi_chunk, Midi_item);
+IMPLEMENT_IS_TYPE_B1(Midi_duration, Midi_item);
 IMPLEMENT_IS_TYPE_B1(Midi_header, Midi_chunk);
 IMPLEMENT_IS_TYPE_B1(Midi_instrument, Midi_item);
+IMPLEMENT_IS_TYPE_B1(Midi_key,Midi_item);
+IMPLEMENT_IS_TYPE_B1(Midi_meter, Midi_item);
+IMPLEMENT_IS_TYPE_B1(Midi_note, Midi_item);
+IMPLEMENT_IS_TYPE_B1(Midi_note_off, Midi_item);
 IMPLEMENT_IS_TYPE_B1(Midi_tempo, Midi_item);
 IMPLEMENT_IS_TYPE_B1(Midi_text, Midi_item);
-IMPLEMENT_IS_TYPE_B1(Midi_time, Midi_item);
 IMPLEMENT_IS_TYPE_B1(Midi_track, Midi_chunk);
 
 Midi_chunk::Midi_chunk()
+    : Midi_item( 0 )
 {
 }
 
@@ -64,6 +63,7 @@ Midi_chunk::str() const
 }
 
 Midi_duration::Midi_duration( Real seconds_f )
+    : Midi_item( 0 )
 {
     seconds_f_ = seconds_f;
 }
@@ -75,6 +75,7 @@ Midi_duration::str() const
 }
 
 Midi_header::Midi_header( int format_i, int tracks_i, int clocks_per_4_i )
+    : Midi_chunk()
 {
     String str;
        
@@ -258,25 +259,41 @@ char const* const instrument_name_sz_a_[ ] = {
 }; 
 
 Midi_instrument::Midi_instrument( int channel_i, String instrument_str )
+    : Midi_item( 0 )
 {
+    instrument_str_ = instrument_str;
+    instrument_str_.to_lower();
     channel_i_ = channel_i;
-    instrument_str.to_lower();
-    for ( int i = 0; instrument_name_sz_a_[i]; i++ )
-       if ( instrument_str == String(instrument_name_sz_a_[ i ] )) { 
-           program_byte_ = (Byte)i;
-           break;
-       }
 }
                                       
 String
 Midi_instrument::str() const
 {
-    if ( program_byte_ ) {
-       String str = String( (char)( 0xc0 + channel_i_ ) );
-       str += String( (char)program_byte_ );
-       return str;
-    }
-    return String( "" );
+    Byte program_byte = 0;
+    for ( int i = 0; instrument_name_sz_a_[i]; i++ )
+       if ( instrument_str_ == String(instrument_name_sz_a_[ i ] )) { 
+           program_byte = (Byte)i;
+           break;
+       }
+
+    if ( !program_byte )
+       return String( "" );
+
+    String str = String( (char)( 0xc0 + channel_i_ ) );
+    str += String( (char)program_byte );
+    return str;
+}
+
+Midi_item::Midi_item( Audio_item* audio_item_l )
+{
+    audio_item_l_ = audio_item_l;
+    channel_i_ = 0;
+}
+
+void
+Midi_item::output( Midi_stream* midi_stream_l ) const
+{
+    *midi_stream_l << str();
 }
 
 String
@@ -300,57 +317,122 @@ Midi_item::i2varint_str( int i )
     return str;
 }
 
-void 
-Midi_item::output_midi( Midi_stream& midi_stream_r ) const
+Midi_key::Midi_key( Audio_item* audio_item_l )
+    : Midi_item( audio_item_l )
 {
-    midi_stream_r << str();
 }
 
-Midi_key::Midi_key( int accidentals_i, int minor_i )
+String
+Midi_key::str() const
 {
-       accidentals_i_ = accidentals_i;
-       minor_i_ = minor_i;
+    Key_change_req* k = audio_item_l_->req_l_->command()->keychange();
+    int sharps_i = k->sharps_i();
+    int flats_i = k->flats_i();
+
+    // midi cannot handle non-conventional keys
+    if ( flats_i && sharps_i )
+       return "";
+    int accidentals_i = sharps_i - flats_i;
+
+    String str = "ff5902";
+    str += String_convert::i2hex_str( accidentals_i, 2, '0' );
+    int minor_i = k->minor_b();
+    str += String_convert::i2hex_str( minor_i, 2, '0' );
+    return String_convert::hex2bin_str( str );
+}
+
+Midi_meter::Midi_meter( Audio_item* audio_item_l )
+    : Midi_item( audio_item_l )
+{
+    clocks_per_1_i_ = 18;
 }
 
 String
-Midi_key::str() const
+Midi_meter::str() const
 {
-    String str = "ff5902";
-    str += String_convert::i2hex_str( accidentals_i_, 2, '0' );
-    str += String_convert::i2hex_str( minor_i_, 2, '0' );
+    Meter_change_req* m = audio_item_l_->req_l_->command()->meterchange();
+    int num_i = m->beats_i_;
+    int den_i = m->one_beat_i_;
+
+    String str = "ff5804";
+    str += String_convert::i2hex_str( num_i, 2, '0' );
+    str += String_convert::i2hex_str( intlog2( den_i ) , 2, '0' );
+    str += String_convert::i2hex_str( clocks_per_1_i_, 2, '0' );
+    str += String_convert::i2hex_str( 8, 2, '0' );
     return String_convert::hex2bin_str( str );
 }
 
-Midi_note::Midi_note( Melodic_req* melreq_l, int channel_i, bool on_bo  )
+Midi_note::Midi_note( Audio_item* audio_item_l )
+    : Midi_item( audio_item_l )
 {
-    assert(melreq_l);
-    pitch_i_ = melreq_l->pitch() + c0_pitch_i_c_;   
-    channel_i_ = channel_i;
-    
-    on_b_ = on_bo;
+    dynamic_byte_ = 0x7f;
+}
 
-    dynamic_byte_ = 0x64;
-    if ( on_b_ ) // poor man-s staff dynamics:
-       dynamic_byte_ -= 0x10 * channel_i_;
-    else
-       dynamic_byte_ += 0x32; // 0x64 is supposed to be neutral, but let-s try
+Moment
+Midi_note::duration() const
+{
+    return audio_item_l_->req_l_->musical()->rhythmic()->duration();
+}
+
+int
+Midi_note::pitch_i() const
+{
+    return audio_item_l_->req_l_->musical()->melodic()->pitch();
 }
 
 String
 Midi_note::str() const
 {
-    if ( pitch_i_ != INT_MAX ) {
-       Byte status_byte = ( on_b_ ? 0x90 : 0x80 ) + channel_i_;
-       String str = String( (char)status_byte );
-       str += (char)pitch_i_;
-       // poor man-s staff dynamics:
-       str += (char)dynamic_byte_;
-       return str;
-    }
-    return String( "" );
+    if ( pitch_i() == INT_MAX )
+       return String( "" );
+
+    Byte status_byte = (char)( 0x90 + channel_i_ );
+
+    String str = String( (char)status_byte );
+    str += (char)( pitch_i() + c0_pitch_i_c_ );
+
+    // poor man's staff dynamics:
+    str += (char)( dynamic_byte_ - 0x10 * channel_i_ );
+
+    return str;
+}
+
+Midi_note_off::Midi_note_off( Midi_note* midi_note_l )
+    : Midi_item( midi_note_l->audio_item_l_ )
+{
+    // 0x64 is supposed to be neutral, but let's try
+    aftertouch_byte_ = 0x64;
+    channel_i_ = midi_note_l->channel_i_;
+}
+
+int
+Midi_note_off::pitch_i() const
+{
+    return audio_item_l_->req_l_->musical()->melodic()->pitch();
+}
+
+String
+Midi_note_off::str() const
+{
+    if ( pitch_i() == INT_MAX )
+       return String( "" );
+
+    Byte status_byte = (char)( 0x80 + channel_i_ );
+
+    String str = String( (char)status_byte );
+    str += (char)( pitch_i() + Midi_note::c0_pitch_i_c_ );
+    str += (char)aftertouch_byte_;
+    return str;
+}
+
+Midi_tempo::Midi_tempo( Audio_item* audio_item_l )
+    : Midi_item( audio_item_l )
+{
+    per_minute_4_i_ = ( (Audio_tempo*)audio_item_l_ )->per_minute_4_i_;
 }
 
 Midi_tempo::Midi_tempo( int per_minute_4_i )
+    : Midi_item( 0 )
 {
     per_minute_4_i_ = per_minute_4_i;
 }
@@ -364,41 +446,32 @@ Midi_tempo::str() const
     return String_convert::hex2bin_str( str );
 }
 
-Midi_time::Midi_time( int num_i, int den_i, int clocks_per_1_i )
-{
-       num_i_ = num_i;
-       den_i_ = den_i;
-       clocks_per_1_i_ = clocks_per_1_i;
-}
-
-String
-Midi_time::str() const
+Midi_text::Midi_text( Audio_item* audio_item_l )
+    : Midi_item( audio_item_l )
 {
-       String str = "ff5804";
-       str += String_convert::i2hex_str( num_i_, 2, '0' );
-       str += String_convert::i2hex_str( intlog2( den_i_ ) , 2, '0' );
-       str += String_convert::i2hex_str( clocks_per_1_i_, 2, '0' );
-       str += String_convert::i2hex_str( 8, 2, '0' );
-       return String_convert::hex2bin_str( str );
+    text_str_ = ( (Audio_text*)audio_item_l_ )->text_str_;
+    type_ = (Type)( (Audio_text*)audio_item_l_ )->type_;
 }
 
 Midi_text::Midi_text( Midi_text::Type type, String text_str )
+    : Midi_item( 0 )
 {
-       type_ = type;
-       text_str_ = text_str;
+    text_str_ = text_str;
+    type_ = type;
 }
 
 String
 Midi_text::str() const
 {
-       String str = "ff" + String_convert::i2hex_str( type_, 2, '0' );
-       str = String_convert::hex2bin_str( str );
-       str += i2varint_str( text_str_.length_i() );
-       str += text_str_;
-       return str;
+    String str = "ff" + String_convert::i2hex_str( type_, 2, '0' );
+    str = String_convert::hex2bin_str( str );
+    str += i2varint_str( text_str_.length_i() );
+    str += text_str_;
+    return str;
 }
 
-Midi_track::Midi_track( )
+Midi_track::Midi_track()
+    : Midi_chunk()
 {
 //                4D 54 72 6B     MTrk
 //                00 00 00 3B     chunk length (59)
index 83d8b7aa6ce107066ed1137666a328fc0eb001ea..04777b50c881d078d171cddec9be3c49b1d421e5 100644 (file)
 #include "midi-stream.hh"
 #include "debug.hh"
 
-Midi_stream::Midi_stream( String filename_str, int tracks_i, int clocks_per_4_i ) 
+Midi_stream::Midi_stream( String filename_str )
 {
     filename_str_ = filename_str;
-    tracks_i_ = tracks_i;
-    clocks_per_4_i_ = clocks_per_4_i;
     os_p_ = 0;
     open();
-    header();
 }
 
 Midi_stream::~Midi_stream()
@@ -37,13 +34,18 @@ Midi_stream::operator <<( String str )
        str = String_convert::bin2hex_str( str );
     
     *os_p_ << str;
+
+    if ( check_debug )
+        *os_p_ << "\n";
+
     return *this;
 }
 
 Midi_stream&
 Midi_stream::operator <<( Midi_item const& mitem_c_r )
 {
-    mitem_c_r.output_midi( *this );
+//    *this << mitem_c_r.str();
+    mitem_c_r.output( this );
     if ( check_debug )
         *os_p_ << "\n";
     return *this;
@@ -57,20 +59,6 @@ Midi_stream::operator <<( int i )
     return *this;
 }
 
-void
-Midi_stream::header()
-{
-/*
-                4D 54 68 64     MThd
-    String str = "MThd";
-                00 00 00 06     chunk length
-                00 01   format 1
-                00 01   one track
-                00 60   96 per quarter-note
-*/
-      *this << Midi_header( 1, tracks_i_, clocks_per_4_i_ );
-}
-
 void
 Midi_stream::open()
 {