]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.36
authorfred <fred>
Sun, 24 Mar 2002 19:33:42 +0000 (19:33 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:33:42 +0000 (19:33 +0000)
NEWS
hdr/midiitem.hh
hdr/midiwalker.hh
src/midiitem.cc

diff --git a/NEWS b/NEWS
index bd29eda5ceabebc9160092b9171b1df56ae12c08..785c5bf38d15439f9a5641976b41c670ace27037 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,15 @@
+pl 36
+       - Jan's patches:
+       - do MIDI rests cleanly.
+       - lily/m2m: time and tempo fixed for metric timing
+Internal
+       - Midi_tempo
+       - m2m parses more midi stuff (all of bach-wtc); timing??
+       - m2m recognises some commandline options
+Examples
+       - fixed midi.ly
+
+*******
 pl 35
        - Register_group
 Bugfix
@@ -14,6 +26,11 @@ Internal
        - junked Midi_staff, Staff_column children, Midi_walker
        - Midi_output
 
+pl 33-1
+       - m2m parses midi
+Internal
+       - Binary_source_file
+       - Source_file::error_str simplified
 *******
 pl33
 Examples
index d30e6448fc6c6cfc339d6cc05caada003e6a3e9a..486637c367a56c8f62df81264635bf0ed1698214 100644 (file)
@@ -23,11 +23,10 @@ struct Midi_note : public Midi_item {
     /**
       Generate a note-event on a channel pitch.
 
-      @param #melreq_l# the pitch. If null, then output a silent C
-      #on_b# turn on?
+      @param #melreq_l# is the pitch. 
      */
     Midi_note( Melodic_req* melreq_l, int channel_i, bool on_b );
-       
+
     virtual String str();
 
     int channel_i_;
@@ -60,7 +59,16 @@ private:
 
 struct Midi_header : Midi_chunk {
     /* *************** */
-    Midi_header( int format_i, int tracks_i, int tempo_i );
+    Midi_header( int format_i, int tracks_i, int clocks_per_4_i );
+};
+
+struct Midi_tempo : Midi_item {
+    /* *************** */
+    Midi_tempo( int tempo_i );
+
+    virtual String str();
+
+    int tempo_i_;
 };
 
 struct Midi_track : Midi_chunk {
index 3673ae080b5bca9bfcc374df626aa195c9911be2..839ba11a7f893848d31e68fe0b25664ce49112ec 100644 (file)
@@ -26,6 +26,8 @@ class Midi_walker : public PCursor<Staff_column*> {
 
     /* *************** */
     void do_stop_notes(Moment);
+    
+    void output_event(Midi_item&, Moment);
 public:
     
     Midi_walker(Staff*, Midi_track*);
index b86eb95f1b09bbca1db49837906992544e9fbb32..0ce9ead5e0357c58e14db154da7c888642e239a6 100644 (file)
@@ -57,7 +57,7 @@ Midi_duration::str()
     return String( "<duration: " ) + String( seconds_f_ ) + ">";
 }
 
-Midi_header::Midi_header( int format_i, int tracks_i, int tempo_i )
+Midi_header::Midi_header( int format_i, int tracks_i, int clocks_per_4_i )
 {
     String str;
        
@@ -67,7 +67,7 @@ Midi_header::Midi_header( int format_i, int tracks_i, int tempo_i )
     String tracks_str = StringConversion::int2hex_str( tracks_i, 4, '0' );
     str += StringConversion::hex2bin_str( tracks_str );
 
-    String tempo_str = StringConversion::int2hex_str( tempo_i, 4, '0' );
+    String tempo_str = StringConversion::int2hex_str( clocks_per_4_i, 4, '0' );
     str += StringConversion::hex2bin_str( tempo_str );
 
     set( "MThd", str, "" );
@@ -103,12 +103,8 @@ Midi_item::output_midi( Midi_stream& midi_stream_r )
 
 Midi_note::Midi_note( Melodic_req* melreq_l, int channel_i, bool on_bo  )
 {
-
-    if (!melreq_l )
-       pitch_i_ = INT_MAX-1;   // any pitch. 
-    else
-        pitch_i_ = melreq_l->pitch() + c0_pitch_i_c_;
-    
+    assert(melreq_l);
+    pitch_i_ = melreq_l->pitch() + c0_pitch_i_c_;   
     channel_i_ = channel_i;
 
     // poor man-s staff dynamics:
@@ -130,6 +126,20 @@ Midi_note::str()
     return String( "" );
 }
 
+Midi_tempo::Midi_tempo( int tempo_i )
+{
+    tempo_i_ = tempo_i;
+}
+
+String
+Midi_tempo::str()
+{
+    int useconds_per_4_i = 60 * (int)1e6 / tempo_i_;
+    String str = "ff5103";
+    str += StringConversion::int2hex_str( useconds_per_4_i, 6, '0' );
+    return StringConversion::hex2bin_str( str );
+}
+
 Midi_track::Midi_track( int number_i )
 {
 //                4D 54 72 6B     MTrk
@@ -149,7 +159,7 @@ Midi_track::Midi_track( int number_i )
     number_i_ = number_i;
        
     char const* data_ch_c_l = "00" "ff58" "0404" "0218" "08"
-       "00" "ff51" "0307" "a120"
+//     "00" "ff51" "0307" "a120"
 // why a key at all, in midi?
 // key: C
        "00" "ff59" "02" "00" "00"
@@ -177,10 +187,8 @@ Midi_track::add( int delta_time_i, String event_str )
 void 
 Midi_track::add( Moment delta_time_moment, Midi_item* mitem_l )
 {
-    // silly guess: 24 midi clocks per 4 note
-    // huh?
-//     int delta_time_i = delta_time_moment / Moment( 1, 4 ) * Moment( 24 );
-    int delta_time_i = delta_time_moment / Moment( 1, 4 ) * Moment( 96 );
+    // use convention of 384 clocks per 4
+    int delta_time_i = delta_time_moment * Moment( 384 ) / Moment( 1, 4 );
     add( delta_time_i, mitem_l->str() );
 }