]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 0.1.9.jcn3: pats
authorJan Nieuwenhuizen <janneke@gnu.org>
Thu, 21 Aug 1997 07:06:57 +0000 (09:06 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Thu, 21 Aug 1997 07:06:57 +0000 (09:06 +0200)
pl 9.jcn3
- bf: standchen
- update 20pt table
- mi2mu: bf's, --key option
- removed Duration(int,int)
- bf: Duration_convert::dur2_str

20 files changed:
Documentation/mi2mu.pod
NEWS
VERSION
init/paper20.ly
init/table16.ly
init/table20.ly
input/standchen-20.ly
input/standchen-20.tex
input/standchen-part.ly
lib/duration-convert.cc
lib/duration.cc
lib/include/duration.hh
mi2mu/include/midi-parser.hh
mi2mu/include/mudela-item.hh
mi2mu/main.cc
mi2mu/midi-parser.cc
mi2mu/midi-score-parser.cc
mi2mu/midi-track-parser.cc
mi2mu/mudela-item.cc
mi2mu/mudela-score.cc

index 1e35a7547a58be07cba89b078930dc4c8cc05162..6ee3e13a165449d47b2adcd2cc3ba9ffeb966077 100644 (file)
@@ -31,6 +31,11 @@ Show a summary of usage.
 
 Add DIR to search path.
 
+=item B<-k, --key>=ACC[:MINOR],
+
+Set default key.  ACC > 0 sets number of sharps; ACC < 0 sets number 
+of flats.  A minor key is indicated by ":1".
+
 =item B<-n, --no-silly>,
 
 Assume no plets or double dots, assume smallest (reciprocal) duration 16.
diff --git a/NEWS b/NEWS
index 741694ca8d53b1da2ee92db5aa5ef09a732ab5c0..92dd2a081c4c11256e64dc653d9c1189ccaa51bc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+pl 9.jcn3
+       - bf: standchen
+       - update 20pt table
+       - mi2mu: bf's, --key option
+       - removed Duration(int,int)
+       - bf: Duration_convert::dur2_str
+
 pl 9.jcn2
        - redo of mi2mu frontend (midi-parser)
        - bf: String_convert::bin2_i; added bin2_u
diff --git a/VERSION b/VERSION
index 2f45472eddbab1b397a82ec56b3b81de2e7cd7b6..50e7c8c0950d9948d3ef956863122b16fd05e4e9 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -3,4 +3,4 @@ TOPLEVEL_MINOR_VERSION = 1
 TOPLEVEL_PATCH_LEVEL = 9
 
 # use to send patches, always empty for released version:
-TOPLEVEL_MY_PATCH_LEVEL = .jcn2
+TOPLEVEL_MY_PATCH_LEVEL = .jcn3
index 372a36d158dc1b07c1d9642ce898951b9605553f..b2f0b3ed225c604eea4a7db47c48ea973e333af8 100644 (file)
@@ -9,19 +9,21 @@ default_paper = \paper {
        linewidth = 15.0 \cm;
        rule_thickness = 0.4\pt;
        bar_size = 20.0 \pt;
-       interline = 4.\pt;
-       notewidth = 5.0\pt;
+       interline = 5.\pt;
+       notewidth = 6.0\pt;
        wholewidth = 4.8\pt;
        unitspace = 22.\pt;
 %      basicspace = 4.\pt;
 %      geometric = 1.414;
        geometric = 0.;
-       basicspace = 8.\pt;
        
+       arithmetic_basicspace = 2.5;
+        arithmetic_multiplier = 4.8\pt;
+
        %
        interbeam = 2.667\pt;
-       gourlay_energybound = 50000.;
-       gourlay_maxmeasures = 6.;
+       gourlay_energybound = 100000.;
+       gourlay_maxmeasures = 8.;
        
        castingalgorithm = \Gourlay;
        \symboltables { \table_twenty }
index ee008a3d85ffc8f08755d0b85450f36c735b375d..60e20ab0c009866fdf0d59a526005018cdf8ae56 100644 (file)
@@ -41,7 +41,7 @@ table_sixteen=
        }
 
      "style" = \table {
-               "roman" "\settext{%}"   0.0\pt  5.0\pt  0.0\pt  8.0\pt
+               "roman" "\settext{%}"   0.0\pt  6.0\pt  0.0\pt  8.0\pt
                "italic"        "\setitalic{%}" 0.0\pt  0.0\pt  0.0\pt  8.0\pt
                "dynamic"       "\setdynamic{%}"        0.0\pt  0.0\pt  0.0\pt  8.0\pt
      }
index 6d6f35330a6fd287295492e14d0ec9a1096a032b..d18a9a81f6ab5e8799cf7afa19a4d26c0c5e366e 100644 (file)
@@ -41,7 +41,7 @@ table_twenty =
        }
 
      "style" = \table {
-               "roman" "\settext{%}"   0.0\pt  5.0\pt  0.0\pt  8.0\pt
+               "roman" "\settext{%}"   0.0\pt  7.5\pt  0.0\pt  10.0\pt
                "italic"        "\setitalic{%}" 0.0\pt  0.0\pt  0.0\pt  8.0\pt
                "dynamic"       "\setdynamic{%}"        0.0\pt  0.0\pt  0.0\pt  8.0\pt
      }
@@ -76,9 +76,10 @@ table_twenty =
     }
 
     "balls" = \table {
-       "1"     "\wholeball"    0.0\pt  7.5\pt  -2.5\pt 2.5\pt
-       "2"     "\halfball"     0.0\pt  6.0\pt  -2.5\pt 2.5\pt
-       "4"     "\quartball"    0.0\pt  6.0\pt  -2.5\pt 2.5\pt
+       "-1"    "\breveball"    0.0\pt  7.5\pt  -2.5\pt 2.5\pt
+       "0"     "\wholeball"    0.0\pt  7.5\pt  -2.5\pt 2.5\pt
+       "1"     "\halfball"     0.0\pt  6.0\pt  -2.5\pt 2.5\pt
+       "2"     "\quartball"    0.0\pt  6.0\pt  -2.5\pt 2.5\pt
     }
 
     "slur" = \table {
@@ -99,10 +100,11 @@ table_twenty =
        "botlines"      "\botlines{%}"  -3.0\pt 9.0\pt  0.0\pt  0.0\pt
     }
 
+%      "|"     "\maatstreep{%}"        0.0\pt  5.0\pt  0.0\pt  20.0\pt
     "bars" = \table {
        "empty" "\emptybar"
        ""      ""                      0.0\pt  0.0\pt  0.0\pt  16.0\pt
-       "|"     "\maatstreep{%}"        0.0\pt  5.0\pt  0.0\pt  20.0\pt
+       "|"     "\maatstreep{%}"        0.0\pt  .64\pt  0.0\pt  20.0\pt
        "||"    "\doublebar{%}"         0.0\pt  4.0\pt  0.0\pt  20.0\pt
        "|."    "\finishbar{%}"         0.0\pt  2.0\pt  0.0\pt  20.0\pt
        ".|"    "\startbar{%}"          0.0\pt  4.0\pt  0.0\pt  20.0\pt
@@ -114,19 +116,19 @@ table_twenty =
      "rests" = \table {
        "-1o"   "\breverest"            0.0\pt  6.0\pt  0.0\pt  4.0\pt
        "-1"    "\breverest"            0.0\pt  6.0\pt  0.0\pt  4.0\pt
-        "1o"   "\outsidewholerest"     0.0\pt  6.0\pt  0.0\pt  2.0\pt
-        "1"    "\wholerest"            0.0\pt  6.0\pt  0.0\pt  2.0\pt
-        "2"    "\halfrest"             0.0\pt  6.0\pt  -2.0\pt 0.0\pt
-        "2o"   "\outsidehalfrest"              0.0\pt  6.0\pt  -2.0\pt 0.0\pt
-        "4o"   "\quartrest"            -5.0\pt 2.0\pt  -5.0\pt 5.0\pt
-        "8o"   "\eighthrest"           0.0\pt  5.0\pt  0.0\pt  8.0\pt
-        "16o"  "\sixteenthrest"                0.0\pt  6.0\pt  0.0\pt  12.0\pt
-        "4"    "\quartrest"            -5.0\pt 2.0\pt  -5.0\pt 5.0\pt
-        "8"    "\eighthrest"           0.0\pt  5.0\pt  0.0\pt  8.0\pt
-        "16"   "\sixteenthrest"                0.0\pt  6.0\pt  0.0\pt  12.0\pt
-        "32"   "\thirtysecondrest"     0.0\pt  6.0\pt  0.0\pt  16.0\pt
-        "64"   "\sixtyfourthrest"      0.0\pt  6.0\pt  0.0\pt  16.0\pt
-        "128"  "\hundredtwentyeighthrest"      0.0\pt  6.0\pt  0.0\pt  16.0\pt
+        "0o"   "\outsidewholerest"     0.0\pt  6.0\pt  0.0\pt  2.0\pt
+        "0"    "\wholerest"            0.0\pt  6.0\pt  0.0\pt  2.0\pt
+        "1"    "\halfrest"             0.0\pt  6.0\pt  -2.0\pt 0.0\pt
+        "1o"   "\outsidehalfrest"              0.0\pt  6.0\pt  -2.0\pt 0.0\pt
+        "2o"   "\quartrest"            -5.0\pt 2.0\pt  -5.0\pt 5.0\pt
+        "3o"   "\eighthrest"           0.0\pt  5.0\pt  0.0\pt  8.0\pt
+        "4o"   "\sixteenthrest"                0.0\pt  6.0\pt  0.0\pt  12.0\pt
+        "2"    "\quartrest"            -5.0\pt 2.0\pt  -5.0\pt 5.0\pt
+        "3"    "\eighthrest"           0.0\pt  5.0\pt  0.0\pt  8.0\pt
+        "4"    "\sixteenthrest"                0.0\pt  6.0\pt  0.0\pt  12.0\pt
+        "5"    "\thirtysecondrest"     0.0\pt  6.0\pt  0.0\pt  16.0\pt
+        "6   "\sixtyfourthrest"      0.0\pt  6.0\pt  0.0\pt  16.0\pt
+        "7"    "\hundredtwentyeighthrest"      0.0\pt  6.0\pt  0.0\pt  16.0\pt
      }
 
     "meters" = \table {
index d1016ea804eadca1850b0bd41befb95aa55ce1e5..2b25430c5250d95d7d5ab6a4df79cb85117b371d 100644 (file)
                % 20pt music uses whole pagewidth
                linewidth= 195.\mm;
                % 20pt music needs some space
-               unitspace= 12.\mm;
-               % we want gourlay, don't set geometric
-               % geometric= 1.4;
-               gourlay_maxmeasures = 9.;
+               unitspace= 13.\mm;
        }
        \midi{
                \tempo 4 = 54;
index 81edf924b67873bc3880b01bc943cebbd19422b6..a296f248d5c932690a36df6fe1ada3b85ddb9bd1 100644 (file)
@@ -16,6 +16,6 @@
 \instrument{M\"a\ss ig} % heu
 %#%\tempo{M\"a\ss ig}
 \maketit
-% \input standchen.out
+\def\startbar#1{}%huh?
 \input lelie.tex
 \end{document}
index cefc9922f3991914f47ccff13f1a7dad0be224f0..1e887c34723db9336d9da5928ec14d9dde209ad6 100644 (file)
@@ -472,28 +472,3 @@ tekstII = \lyric{
        
 }
 
-\score{
-       <       
-               <       \id "Lyric" "1";
-                       \tekstI
-                        \tekstII
-               >
-               < \id "Piano" "";
-                       \multi 2;
-                       \melodic < \melodie \commands >
-                       \melodic < \begeleiding \commands >
-               >
-       >
-       \paper{
-               linewidth= 160.\mm;
-               %castingalgorithm = \Wordwrap;
-               % on two pages...
-               unitspace= 8.\mm;
-               %geometric= 1.4;
-               gourlay_maxmeasures = 9.;
-               \output "standchen.out";
-       }
-       \midi{
-               \tempo 4 = 54;
-       }
-}
index c96273e5baee2e8ce7d495abcabe34761a806988..e64ca663eaa674fe4e8dce9c5309ec9cec318216 100644 (file)
@@ -25,8 +25,8 @@ Duration_convert::dur2_str( Duration dur )
                return String( "["  ) + String( dur.ticks_i_ ) + "]";
        
        String str;
-       if (dur.durlog_i_ >= 0)
-           str="breve";
+       if (dur.durlog_i_ <= 0)
+           str="\\breve";
        else
            str= String( type2_i(dur.durlog_i_) );
        str += String( '.', dur.dots_i_ );
index c26699c5bd773d3f38dc408a901feded7a24fe42..24ae6b5da69ad6f38275c649db1dad4a3d3b7212 100644 (file)
@@ -7,6 +7,7 @@
            Han-Wen Nienhuys <hanwen@stack.nl>
 */
 
+#include <assert.h>
 #include "proto.hh"
 #include "plist.hh"
 #include "string.hh"
@@ -27,13 +28,6 @@ Duration::Duration()
   ticks_i_ = 0;
 }
 
-Duration::Duration( int type_i, int dots_i = 0 )
-{
-  durlog_i_ = type_i;
-  dots_i_ = dots_i;
-  ticks_i_ = 0;
-}
-
 bool
 Duration::duration_type_b(int t)
 {
index c7f2ef3a47dd0986004346defb2d52766e84fc9b..0ae66d572ecf67db37d55fb720f30c2ceafe0f25 100644 (file)
@@ -29,7 +29,6 @@ struct Duration {
     Ctor of Duration. 
     */
   Duration();
-  Duration( int type_i, int dots_i = 0 );
   /// is the "plet factor" of this note != 1 ?
   bool plet_b();
   String str()const;
index 55c75a5a778caf2090ad0965299e69bae766ccf4..3c1b491f65bdaf5c2309530544578672c171a782 100644 (file)
@@ -37,6 +37,7 @@
 
 #include "proto.hh"
 #include "moment.hh"
+#include "mi2mu-proto.hh"
 
 struct Midi_parser_info
 {
@@ -48,6 +49,7 @@ struct Midi_parser_info
   Byte const* byte_L_;
   Byte const* end_byte_L_;
   Source_file* source_l_;
+  Mudela_score* score_l_;
   Moment bar_mom_;
 };
 
index ba0d77c5180264d1eeb55ded4fe65419f4a8611e..9423959b6dd9eef453b72718fcdb47c9be81140b 100644 (file)
@@ -39,10 +39,9 @@ public:
     String notename_str (int pitch_i);
     virtual String str();
 
-private:
+//private:
     int accidentals_i_;
     int minor_i_;
-    int key_i_;
 };
 
 class Mudela_meter : public Mudela_item 
@@ -121,7 +120,7 @@ public:
     Mudela_text (Mudela_text::Type type,  String str);
     virtual String str();
 
-private:
+//private:
     Type type_;
     String text_str_;
 };
index 25dfab069453c28284ec76733af06eac77339b82..8626213568eb953ffa413f83e9e99248d8e90a31 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "mi2mu-global.hh"
 #include "midi-score-parser.hh"
+#include "mudela-item.hh"
 #include "mudela-score.hh"
 #include "version.hh"
 
@@ -43,6 +44,7 @@ usage()
   "  -d, --debug            print lots of debugging stuff\n"
   "  -h, --help             this help\n"
   "  -I, --include=DIR      add DIR to search path\n"
+  "  -k, --key=ACC[:MINOR]  set key: ACC +sharps/-flats; :1 minor\n"
   "  -n, --no-silly         assume no plets or double dots, smallest is 32\n"
   "  -o, --output=FILE      set FILE as default output\n"
   "  -p, --no-plets         assume no plets\n"
@@ -88,6 +90,7 @@ notice()
 int
 main (int argc_i, char* argv_sz_a[])
 {
+  Mudela_key key (0, 0);
   rat_printer = print_rat;     
 
   Long_option_init long_option_init_a[] = 
@@ -95,6 +98,7 @@ main (int argc_i, char* argv_sz_a[])
        {0, "no-quantify", 'b'},
        {0, "debug", 'd'},
        {0, "help", 'h'},
+       {1, "key", 'k'},
        {0, "no-silly", 'n'},
        {1, "output", 'o'},
        {0, "no-plets", 'p'},
@@ -125,6 +129,15 @@ main (int argc_i, char* argv_sz_a[])
 //     case 'I':
 //         path->push (getopt_long.optional_argument_ch_C_);
 //         break;
+       case 'k':
+         { 
+           String str = getopt_long.optional_argument_ch_C_;
+           int i = str.index_i (':');
+           i = (i >=0 ? i : str.length_i ());
+           key.accidentals_i_ = String_convert::dec2_i (str.left_str (i));
+           key.minor_i_ = (int)(bool)String_convert::dec2_i (str.mid_str (i,1));
+           break;
+         }
        case 'n':
            Duration_convert::no_double_dots_b_s = true;
            Duration_convert::no_triplets_b_s = true;
@@ -185,6 +198,8 @@ main (int argc_i, char* argv_sz_a[])
        if (!score_p)
          return 1;
 
+       if (!score_p->mudela_key_l_)
+         score_p->mudela_key_l_ = &key;
        mudela_score_l_g = score_p;
        score_p->process();
 
index c63c95dfc21605868f22c0f1d5938ec0c7ca2363..d5e67277766020314b79a06477fea241cc8898bb 100644 (file)
@@ -20,6 +20,7 @@ Midi_parser_info::Midi_parser_info ()
   errorlevel_i_ = 0;
   byte_L_ = 0;
   end_byte_L_ = 0;
+  score_l_ = 0;
 }
 
 Midi_parser::Midi_parser ()
index d1a700069c8b4893d42ca7c0504d713a07ee00d1..ab5169da1210f33e11b8c530c0beeb1617f25ef1 100644 (file)
@@ -57,6 +57,8 @@ Midi_score_parser::parse_header ()
   info_l_->division_1_i_ = get_i (2) * 4;
   if (info_l_->division_1_i_ < 0)
     exit ("Cannot handle non-metrical time");
+  // ugh
+  Duration::division_1_i_s = info_l_->division_1_i_;
   forward_byte_L (length_i - 6);
 }
 
@@ -79,16 +81,18 @@ Midi_score_parser::find_earliest_i (Link_array<Midi_track_parser>& tracks)
 Mudela_score*
 Midi_score_parser::parse_score ()
 {
-  Mudela_meter m4 (1, 4, 0, 0);
+  int current_bar_i = 0;
+  Mudela_meter m4 (4, 2, 24, 8);
   Moment bar4_mom = m4.bar_mom ();
 
+  Mudela_score* score_p = new Mudela_score( 1, 1, 1 );
+  info_l_->score_l_ = score_p;
+
   Link_array<Midi_track_parser> tracks;
   for (int i = 0; i < info_l_->tracks_i_; i++)
     tracks.push (new Midi_track_parser (info_l_));
 
-  int current_bar_i = 0;
-
-  Mudela_score* score_p = new Mudela_score( 1, 1, 1 );
+  LOGOUT (NORMAL_ver) << "Parsing...\n";
   while (tracks.size ())
     {
       int i = find_earliest_i (tracks);
index 8f346f565b28fb77f439ec3a7eea6c091167190d..028c3face3f749a77e6ae86d8361577743a25180 100644 (file)
@@ -12,6 +12,7 @@
 #include "midi-track-parser.hh"
 #include "mudela-column.hh"
 #include "mudela-item.hh"
+#include "mudela-score.hh"
 #include "mudela-staff.hh"
 
 Midi_track_parser::Midi_track_parser (Midi_parser_info* info_l)
@@ -240,7 +241,15 @@ Midi_track_parser::parse_event (Mudela_column* col_l)
          int length_i = get_var_i ();
          String str = get_str (length_i);
          // LOGOUT (DEBUG_ver) << str << endl;
-         item_p = new Mudela_text ((Mudela_text::Type)byte, str);
+         Mudela_text::Type t = (Mudela_text::Type)byte;
+         Mudela_text* p = new Mudela_text (t, str);
+         item_p = p;
+         if (t == Mudela_text::COPYRIGHT) 
+            mudela_staff_p_->copyright_str_ = p->text_str_;
+         else if (t == Mudela_text::TRACK_NAME)
+            mudela_staff_p_->name_str_ = p->text_str_;
+         else if (t == Mudela_text::INSTRUMENT_NAME)
+            mudela_staff_p_->instrument_str_ = p->text_str_;
        }
       // END_OF_TRACK  [\x2f][\x00]
       else
@@ -258,7 +267,9 @@ Midi_track_parser::parse_event (Mudela_column* col_l)
              unsigned useconds_per_4_u = get_u (3);
              // $$ = new Mudela_tempo ( ($2 << 16) +  ($3 << 8) + $4);
              // LOGOUT (DEBUG_ver) << $$->str() << endl;
-             item_p = new Mudela_tempo ( useconds_per_4_u );
+             Mudela_tempo* p = new Mudela_tempo ( useconds_per_4_u );
+             item_p = p;
+             info_l_->score_l_->mudela_tempo_l_ = p;
            }
          // SMPTE_OFFSET       [\x54][\x05]
          else if ((byte == 0x54) && (next == 0x05))
@@ -280,6 +291,7 @@ Midi_track_parser::parse_event (Mudela_column* col_l)
              int count_32_i = (int)next_byte ();
              Mudela_meter* p = new Mudela_meter ( num_i, den_i, clocks_4_i, count_32_i );
              item_p = p;
+             info_l_->score_l_->mudela_meter_l_ = p;
              info_l_->bar_mom_ = p->bar_mom ();
            }
          // KEY                [\x59][\x02]
@@ -288,7 +300,9 @@ Midi_track_parser::parse_event (Mudela_column* col_l)
              next_byte ();
              int accidentals_i = (int)next_byte ();
              int minor_i = (int)next_byte ();
-             item_p = new Mudela_key (accidentals_i, minor_i);
+             Mudela_key* p = new Mudela_key (accidentals_i, minor_i);
+             item_p = p;
+             info_l_->score_l_->mudela_key_l_ = p;
            }
          // SSME               [\0x7f][\x03]
          else if ((byte == 0x7f) && (next == 0x03))
@@ -299,7 +313,11 @@ Midi_track_parser::parse_event (Mudela_column* col_l)
              item_p = new Mudela_text ((Mudela_text::Type)byte, str);
            }
          else
-           exit ("Invalid MIDI meta-event");
+           {
+             next_byte ();
+             next_byte ();
+             warning ("Unimplemented MIDI meta-event");
+           }
        }
     }
   else
index 300ada5d4c01e36518d7048765ea87ff04c72d7c..7a69984b9a618825f010908bea1cf632ad36c4f9 100644 (file)
@@ -40,20 +40,21 @@ Mudela_key::Mudela_key (int accidentals_i, int minor_i)
 {
   accidentals_i_ = accidentals_i;
   minor_i_ = minor_i;
-  if (accidentals_i >= 0)
-       key_i_ =   ((accidentals_i % 7)[ "cgdaebf" ] - 'a' - 2) % 7;
-  else
-       key_i_ =   ((-accidentals_i % 7)[ "cfbeadg" ] - 'a' - 2) % 7;
 }
 
 String
 Mudela_key::str ()
 {
+  int key_i = 0;
+  if (accidentals_i_ >= 0)
+       key_i =   ((accidentals_i_ % 7)[ "cgdaebf" ] - 'a' - 2) % 7;
+  else
+       key_i =   ((-accidentals_i_ % 7)[ "cfbeadg" ] - 'a' - 2) % 7;
   String str = "\\key ";
   if (!minor_i_) 
-       str += String ((char)  ((key_i_ + 2) % 7 + 'A'));
+       str += String ((char)  ((key_i + 2) % 7 + 'A'));
   else // heu, -2: should be - 1 1/2: A -> fis
-       str += String ((char)  ((key_i_ + 2 - 2) % 7 + 'a'));
+       str += String ((char)  ((key_i + 2 - 2) % 7 + 'a'));
   str = String ("% \"") + str
        + String ('"') + "; % not supported yet\n"; 
   return str;
@@ -97,7 +98,7 @@ Mudela_key::notename_str (int pitch_i)
 Mudela_meter::Mudela_meter (int num_i, int den_i, int clocks_4_i, int count_32_i)
    : Mudela_item (0)
 {
-  sync_dur_.durlog_i_ = 3 ;
+  sync_dur_.durlog_i_ = 3;
   sync_f_ = 1.0;
   if (count_32_i != 8)
        warning (String ("#32 in quarter: ") + String (count_32_i));
@@ -110,7 +111,7 @@ Moment
 Mudela_meter::bar_mom ()
 {
   Duration d;
-  d.durlog_i_ =   den_i_;
+  d.durlog_i_ = den_i_;
   return Moment (num_i_) * Duration_convert::dur2_mom (d);
 }
 
index c8f575d04c4feac9173bda934b901a961c125a25..75205c2ddd93b785b9c745ef7f29b0734ba11871 100644 (file)
@@ -14,7 +14,7 @@
 #include "mudela-staff.hh"
 #include "mudela-stream.hh"
 
-static Mudela_key key_c (0, 0);
+//static Mudela_key key_c (0, 0);
 static Mudela_meter meter_4 (4, 2, 24, 8);
 // useconds per 4: 250000 === 60 4 per minute
 static Mudela_tempo tempo_60 (1000000);
@@ -25,7 +25,8 @@ Mudela_score::Mudela_score (int format_i, int tracks_i, int tempo_i)
   tracks_i_ = tracks_i;
   tempo_i_ = tempo_i;
   column_l_array_.push (new Mudela_column (this, Moment (0)));
-  mudela_key_l_ = &key_c;
+//  mudela_key_l_ = &key_c;
+  mudela_key_l_ = 0;
   mudela_meter_l_ = &meter_4;
   mudela_tempo_l_ = &tempo_60;
 }
@@ -49,11 +50,38 @@ Mudela_score::add_staff (Mudela_staff* mudela_staff_p)
 Mudela_column*
 Mudela_score::find_column_l (Moment mom)
 {
+#if 0
   // should do binary search
   for (int i = 0; i < column_l_array_.size (); i++ )
     if ( column_l_array_[i]->at_mom () == mom )
         return column_l_array_[i];
   return 0;
+#else
+  int upper_i = max (0, column_l_array_.size () - 1);
+  int lower_i = 0;
+  int i = 0; //upper_i;
+  while (1) 
+    {
+      Moment i_mom = column_l_array_ [i]->at_mom ();
+      if (i_mom == mom)
+       return column_l_array_ [i];
+      if (mom < i_mom)
+       upper_i = i;
+      else
+       lower_i = i;
+      if ((upper_i == lower_i) || (i == column_l_array_.size () - 1)) 
+       {
+         // we don't do inserts
+         assert (0);
+         Mudela_column* col_p = new Mudela_column (this, mom);
+         column_l_array_.push (col_p);
+         return col_p;
+        }
+      i = (upper_i + lower_i + 1 ) / 2;
+    }
+  assert (0);
+  return 0;
+#endif
 }
 
 Mudela_column*
@@ -156,17 +184,24 @@ Mudela_score::quantify_columns()
 
   LOGOUT(NORMAL_ver) << "\nQuantifying columns..." << endl;
 
+  int current_bar_i = 0;
+  Moment bar_mom = mudela_meter_l_->bar_mom();
+
   int n = 5 >? Duration_convert::no_smaller_than_i_s;
+  n = Duration_convert::type2_i (n);
   Moment s = Moment (1, n);
   Moment sh = Moment (1, 2 * n);
   for  (int i = 0; i < column_l_array_.size(); i++) 
     {
-//     Moment mom = column_l_array_[ i ]->at_mom();
-//     column_l_array_[ i ]->at_mom_ = Duration_convert::dur2_mom (dur);
-       column_l_array_[ i ]->at_mom_ =
-//         s * (int) ( (sh + column_l_array_[ i ]->at_mom()) / s);
-           s * (int) ( (column_l_array_[ i ]->at_mom()) / s);
-       LOGOUT(NORMAL_ver) << '.';
+      column_l_array_ [i]->at_mom_ =
+       s * (int) ( (column_l_array_ [i]->at_mom()) / s);
+
+      int bar_i = (int) (column_l_array_ [i]->at_mom () / bar_mom) + 1;
+      if (bar_i > current_bar_i) 
+       {
+         LOGOUT (NORMAL_ver) << '[' << bar_i << ']' << flush; 
+         current_bar_i = bar_i;
+       }
     }
   LOGOUT(NORMAL_ver) << endl;
 }
@@ -207,18 +242,18 @@ Mudela_score::settle_columns()
        if  (!start_i) 
          {
            start_i = end_i = i;
-           start_mom = column_l_array_[ i ]->at_mom();
+           start_mom = column_l_array_ [i]->at_mom();
            continue;
          }
 
        // find all columns within noise's distance
        while  ( (i < n)
-           &&  (column_l_array_[ i ]->at_mom() - start_mom < noise_mom))
+           &&  (column_l_array_ [i]->at_mom() - start_mom < noise_mom))
            end_i = ++i;
 
        // bluntly set all to time of first in group
        for  (int j = start_i; j < end_i; j++)
-           column_l_array_[ j ]->at_mom_ = start_mom;
+           column_l_array_ [j]->at_mom_ = start_mom;
 
        start_i = end_i = 0;
     }