]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.3.14.hwn1
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 19 Dec 1999 23:53:11 +0000 (00:53 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 19 Dec 1999 23:53:11 +0000 (00:53 +0100)
pl 14.hwn1
- specialize duration.cc for lily, move out of lib/
- stem cleanup
- more SCM typechecking
- stafflineleading -> staff_space
- bf: rod distances.
- junk some unused code.

73 files changed:
CHANGES
Documentation/topdocs/INSTALL.texi
TODO
VERSION
flower/include/acursor.hh
flower/include/full-storage.icc
flower/include/handle.hh
flower/include/iterate.hh
flower/include/nscalar.hh
flower/include/priorities.hh
flower/include/varray.icc
flower/nscalar.cc
lib/duration-convert.cc
lib/duration-iter.cc
lib/duration.cc
lib/include/duration-convert.hh
lib/include/duration-iter.hh
lib/include/duration.hh
lib/include/plet.hh
lib/include/thank-you-cygnus.hh
lib/plet.cc
lib/thank-you-cygnus.cc
lib/warn.cc
lily/axis-group-engraver.cc
lily/beam.cc
lily/bow.cc
lily/break-align-item.cc
lily/breathing-sign.cc
lily/chord-tremolo-engraver.cc
lily/clef-item.cc
lily/collision.cc
lily/duration.cc [new file with mode: 0644]
lily/gourlay-breaking.cc
lily/hara-kiri-vertical-group-spanner.cc
lily/include/chord-name.hh
lily/include/duration.hh [new file with mode: 0644]
lily/include/plet.hh [new file with mode: 0644]
lily/include/staff-symbol-referencer.hh
lily/include/staff-symbol.hh
lily/include/stem.hh
lily/item.cc
lily/key-item.cc
lily/local-key-item.cc
lily/midi-item.cc
lily/multi-measure-rest.cc
lily/note-column.cc
lily/note-head.cc
lily/parser.yy
lily/rest-collision.cc
lily/rest.cc
lily/score-element.cc
lily/separating-group-spanner.cc
lily/side-position-interface.cc
lily/spacing-spanner.cc
lily/staff-bar.cc
lily/staff-symbol-engraver.cc
lily/staff-symbol-referencer.cc
lily/staff-symbol.cc
lily/stem-engraver.cc
lily/stem-tremolo.cc
lily/stem.cc
lily/text-item.cc
lily/time-signature.cc
lily/translator-group.cc
lily/tuplet-spanner.cc
midi2ly/duration-convert.cc [new file with mode: 0644]
midi2ly/duration-iter.cc [new file with mode: 0644]
midi2ly/duration.cc [new file with mode: 0644]
midi2ly/include/duration-convert.hh [new file with mode: 0644]
midi2ly/include/duration-iter.hh [new file with mode: 0644]
midi2ly/include/duration.hh [new file with mode: 0644]
midi2ly/include/plet.hh [new file with mode: 0644]
midi2ly/plet.cc [new file with mode: 0644]

diff --git a/CHANGES b/CHANGES
index f0faef7864ad361cb2ac0be6f93b005085aa0a89..f0747050e808f46bf8ef25775d6e16fb62325b4a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,11 @@
+pl 14.hwn1
+       - specialize duration.cc for lily, move out of lib/
+       - stem cleanup
+       - more SCM typechecking
+       - stafflineleading -> staff_space
+       - bf: rod distances.
+       - junk some unused code.
+       
 pl 13.hwn2
        - paper/score column cleanups. Junk Score_column type
 
index bf9bce87a1844ab1c71cc823f587841d35798947..05c7cb45b12fe858770bfdee4c90fa6a47fd5ee9 100644 (file)
@@ -128,7 +128,7 @@ and plenty of RAM is recommended for comfortable use.
 The website is the most convenient form to use for reading the
 documentation on-line documentation. It is made by entering @example 
 
-  make website
+  make htmldoc
  
 @end example 
 This does require a  functioning  LilyPond. The binary doesn't have to
diff --git a/TODO b/TODO
index 128422b0d131ba5148357679b464b4481fd3f706..fe36f4a168d1fd5cb3c2fa9f5187736281f9a846 100644 (file)
--- a/TODO
+++ b/TODO
@@ -10,6 +10,7 @@ Grep -i for TODO, FIXME and ugh/ugr/urg.
 
 .* TODO
 . * use hash tabs iso. alist_ for elt property?
+. * TODO: junk dstream output.
 . * agressive type-checking for SCM stuff.
 . * use  "staff-space" and "half-space" iso interline,
     staff_line_leading () etc.
@@ -67,23 +68,18 @@ ChoirStaff bar line types in the rest of the scores
 . * make all Feta (including dynamics) available to the user in
     textual scripts. Examples: "D.S. al \coda", "\mf espress.".
 . * Write script that uses --find-old-relative to do auto relativization. 
-. * Junk shared cruft (duration, moment) in lib/
 
 
 .* Cleanups needed
 . * \$ and $ identifier syntax in examples. 
-. * Junk ghost positioning objects eg, Script leans on  Staffside
-    leans on Staff.
 . * Key_engraver, Local_key_item
 . * Think of comprehensive solution for "if (grace_b == self_grace_b_)"
 . * String[String.length] doesn't trap.
 . * Rhythmic_column and interaction stem/rhythmic_column/note_head/dots.
-. * Duration
 . * clef engraver 
 . * parser
 . * Lookup::text -> needs  to be TeX independent.
 . * junk Music_iterator::first_b_
-. * Bezier
 
 .* ACCIDENTALS
 . * half-sharps, half-flats
@@ -94,9 +90,7 @@ ChoirStaff bar line types in the rest of the scores
 .* Beams
 . * [c8. c16 c16 c16] in 6/8 timesig.
 . * Rewrite Stem, Beam (hairy)
-.  * general shaving on Beam and Stem
-.  * use plet grouping
-.  * beams over bars
+.  * beams over barlines
 . * Rests and beams don't work too well together. Example:
    [ r8 g''16 des'] [r8 c16 a] 
 . * autoBeamMelisma: if I explicitly beam notes in a staff with auto
diff --git a/VERSION b/VERSION
index ac3e15377adbd3b27dff5984303a181a5a01f1a4..1ac2696b96754fd375d4faf71a90167bbb7a48a8 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=3
 PATCH_LEVEL=14
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=hwn1
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
index b1dc91552572a14d5a6f76f0ecd6a2afbe661695..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,58 +0,0 @@
-/*
-  acursor.hh -- declare ACursor, PACursor 
-
-  source file of the Flower Library
-
-  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-
-#ifndef ACURSOR_HH
-#define ACURSOR_HH
-
-template<class T>
-class ACursor
-{
-protected:
-    int idx_;
-    Array<T> &arr_;
-public:
-    ACursor (ACursor const& s) 
-       :arr_(s.arr_)
-    {
-       idx_ = s.idx_;
-    }
-    ACursor (Array<T> const &arr)
-       arr_((Array<T>&)arr)
-    {
-       idx_ =0;
-    }
-    T thing() const { 
-       return arr_[idx_];
-    }
-    T& thing() { return arr_[idx_]; }
-    T& operator++(int) {
-       T&t = thing();
-       idx_ ++;
-       return t;
-    }
-    bool ok() { return idx_ >=0 && idx_ < arr_.size (); }
-};
-
-
-template<class T>
-class PACursor : public ACursor<T*>
-{
-public:
-    PACursor (Link_array<T> l)
-       : ACursor (l)
-    {
-    }
-    T* ptr() { return arr_[idx_]; }
-    T *operator->() {
-       return ptr();
-    }
-    
-};
-
-#endif // ACURSOR_HH
index 32590a055c7e6dd9c334142f449d17235301f08e..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,136 +0,0 @@
-/*
-  full-storage.icc -- implement Full_storage inline functions
-
-  source file of the Flower Library
-
-  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-
-#ifndef FULL_STORAGE_ICC
-#define FULL_STORAGE_ICC
-
-
-INLINE void
-Full_storage::init()
-{
-  els_p_p_=0;
-  band_i_ = 0;    
-  height_i_=width_i_=max_height_i_=max_width_i_=0;
-}
-
-INLINE bool
-Full_storage::valid (int i, int j) const
-{
-  return (i>=0 && i < height_i_)
-    && (j < width_i_ && j >=0);
-}
-
-
-INLINE
-Full_storage::Full_storage (Full_storage const&s)
-{
-  init();
-  (*this) = s;
-}
-
-INLINE Real& 
-Full_storage::elem (int i,int j)
-{
-  assert (valid (i,j));
-  return els_p_p_[i][j];
-}
-
-INLINE Real
-Full_storage::elem (int i, int j) const {
-  assert (valid (i,j));
-  return els_p_p_[i][j];
-}
-
-INLINE
-Full_storage::Full_storage() {
-  init();
-}
-
-
-INLINE int
-Full_storage::rows() const
-{
-  return height_i_;
-}
-
-INLINE int
-Full_storage::cols() const
-{
-  return width_i_;
-}
-
-INLINE int
-Full_storage::dim() const
-{
-  assert (rows()==cols ());
-  return rows();
-}
-
-INLINE void
-Full_storage::resize (int i)
-{
-  resize (i,i);
-}
-
-INLINE   
-Full_storage::Full_storage (int i,int j)
-{
-  init();
-  set_size (i,j);
-}
-
-INLINE 
-Full_storage::Full_storage (int i)
-{
-  init();
-  set_size (i);
-}
-
-
-INLINE
-bool
-Full_storage::mult_ok (int i, int ) const
-{
-  return i < height_i_;
-}
-
-INLINE
-bool
-Full_storage::trans_ok (int , int j) const
-{
-  return j < width_i_;
-} 
-
-
-INLINE
-void
-Full_storage::trans_next (int &i, int &j) const
-{
-  assert (trans_ok (i,j));
-  i++;
-  if (i >= height_i_) 
-    {
-      i= (0 >? j - band_i_);
-      j ++;
-    }
-}
-
-INLINE
-void
-Full_storage::mult_next (int &i, int &j) const
-{
-  assert (mult_ok (i,j));
-  j++;
-  if (j >= width_i_) 
-    {
-      j= 0 >? (i - band_i_);
-      i++;
-    }
-}
-#endif // FULL_STORAGE_ICC
index 4176325b15d75bfb2869e59687a6f3ec9cdff479..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,58 +0,0 @@
-#ifndef HANDLE_HH
-#define HANDLE_HH
-
-/// reference counting handle
-template<class T>
-class Handle {
-    T *obj;
-    int *refs;
-
-    /// let go of ref. Delete if necessary
-    void down() {
-       if (!(*refs--)) {
-           delete obj;
-           delete refs;
-       }
-       obj = 0;
-       refs = 0;
-    }
-    /// point to new object. 
-    void up (T *t, int *r) {
-       if (!r) {
-           refs = new int;
-           *refs = 1;
-       } else {
-           refs =r;
-           *refs++;
-       }
-       obj = t;
-    }
-    /// POST: *refs == 1
-    void copy() {
-       if (*refs != 1){
-           T * newobj = new T(*obj);
-           down();
-           up (newobj);
-       }
-    }
-    Handle (Handle const &src) {
-       up (src.obj, src.refs);
-    }
-    Handle (T & o) {
-       up (&o);
-    }
-    void operator=(Handle const& src) {
-       if (this == &src)
-           return;
-       down();
-       up (src.o, src.refs);
-    }
-    operator T const &() {
-       return *obj;
-    }
-    operator T&() {
-       copy();
-       return *obj;
-    }
-}
-#endif
index 90c9cd4f2f6132c258130837d2f69cca2d562290..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,30 +0,0 @@
-/*
-  iterate.hh -- define some list macros
-
-  source file of the flowerlib
-
-  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-
-#ifndef ITERATE_HH
-#define ITERATE_HH
-
-/*
- ugh.
- jcn: kjoet.
-      if we wouldn't have had this, things might have been 
-      just a little bit easier to read, imho.
-      (it does save quite some disk space, though)
- */
-
-#define iterator(set)          typeof ((set).top())
-#define iterator_bot(set)              typeof ((set).bottom())
-
-#define iter(init, var)                typeof (init) var (init)
-
-// should use top()
-#define iter_top(set,var)      iterator (set) var (set)
-#define iter_bot(set,var)      iterator (set) var (set.bottom())
-
-#endif // ITERATE_HH
index b68664ce14df5260bf1a2106930b45e6ed57e8d7..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,43 +0,0 @@
-/*
-  scalar.hh -- declare 
-
-  source file of the Flower Library
-
-  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-
-#ifndef SCALAR_HH
-#define SCALAR_HH
-
-struct Scalar {
-  String str_;
-  // Real real_;
-  int int_;
-  //  Rational rational_;
-
-
-  struct typebits {
-    string_bit: 1;
-    int_bit:1;
-  };
-private:
-
-  
-  //  operator Real();
-  operator int();
-  
-  /**   perl -like string to bool conversion.
-   */
-  //  operator bool() const;
-   
-  //Scalar (Real r) : String (r) {}
-  Scalar (int i) : String (i) {}
-  //  Scalar (char c) : String (c) {}
-  Scalar (char const *c) : String (c) {}    
-  Scalar (String s):String (s) {}
-  //Scalar (Rational);
-  static Scalar undefined ();
-};
-
-#endif // SCALAR_HH
index 95ffe5797be956679734ef2530ceb82f88d10b01..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,35 +0,0 @@
-/*
-  priorities.hh -- declare Priorities
-
-  source file of the Flower Library
-
-  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-
-#ifndef PRIORITIES_HH
-#define PRIORITIES_HH
-
-#include "array.hh"
-
-/**
-  A sorted (uni)set. Should connect with PQueue
- */
-template<class K>
-struct Priorities :    Array<K>
-{
-    void insert (K k) 
-    {
-       int i=0;
-       for (; i < size(); i++) {
-           if (elem (i) == k)
-               return;
-           if (elem (i) > k)
-               break;
-       }
-       Array<K>::insert (k, i);
-    }
-};
-#endif // PRIORITIES_HH
-
-       
index ae6b315fc88ff688fd56627fef7f46f16bc76ea6..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,67 +0,0 @@
-#error
-/*
-  (c) Han-Wen Nienhuys 1995,96,97,98
-
-  Distributed under GNU GPL
-*/
-
-
-#if 0
-#include "array.hh"
-#ifdef INLINE
-#undef INLINE
-#endif
-
-#define INLINE
-#endif
-
-/*
- functions with loops don't inline
- */
-
-template<class T> INLINE void 
-arrcpy (T*dest, T*src, int count)
-{
-  for (int i_shadows_local=0; i_shadows_local < count ; i_shadows_local++)
-    *dest++ = *src++;
-}
-
-template<class T> INLINE void
-Array<T>::insert (T k, int j) 
-{
-  assert (j >=0 && j<= size_);
-  set_size (size_+1);
-  for (int i=size_-1; i > j; i--)
-    array_p_[i] = array_p_[i-1];
-  array_p_[j] = k;
-}
-
-template<class T> INLINE void
-Array<T>::sort (int (*compare)(T const&,T const&),
-          int lower = -1, int upper = -1) 
-{
-  if (lower < 0) 
-    {
-      lower = 0 ;
-      upper = size () - 1;
-    }
-  if (lower >= upper)
-    return;
-  swap (lower, (lower+upper)/2);
-  int last = lower;
-  for (int i= lower +1; i <= upper; i++)
-    if (compare (array_p_[i], array_p_[lower]) < 0)
-      swap (++last,i);
-  swap (lower, last);
-  sort (compare, lower, last-1);
-  sort (compare, last+1, upper);
-}
-
-template<class T> INLINE void
-Array<T>::reverse () 
-{
-  int h = size_/2;
-  for (int i =0,j = size_-1; i < h; i++,j--)
-    swap (i,j);
-}
-
index 2e7df5b7efc501177d9885bea2d00e3a7be85192..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,8 +0,0 @@
-/*
-  scalar.cc -- implement 
-
-  source file of the Flower Library
-
-  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
index ac46fd7a608e18a5d4cc185a1712e6b2bfdc1406..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,200 +0,0 @@
-/*
-  duration-convert.cc -- implement Duration_convert
-
-  source file of the LilyPond music typesetter
-
-  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-          Jan Nieuwenhuizen <janneke@gnu.org>
-*/
-#include <assert.h>
-#include "duration-convert.hh"
-#include "duration-iter.hh"
-#include "warn.hh"
-
-// statics Duration_convert
-bool const Duration_convert::midi_as_plet_b_s = true;
-bool Duration_convert::no_quantify_b_s = false;
-bool Duration_convert::no_double_dots_b_s = false;
-bool Duration_convert::no_triplets_b_s = false;
-int Duration_convert::no_smaller_than_i_s = 0;
-Array<Duration> Duration_convert::dur_array_s;
-       
-String 
-Duration_convert::dur2_str (Duration dur)
-{
-  if (dur.ticks_i_)
-    return String ("[") + to_str (dur.ticks_i_) + "]";
-  
-  String str;
-  if (dur.durlog_i_ >= 0)
-    str = to_str ( type2_i (dur.durlog_i_) );
-  else if (dur.durlog_i_ == -1)
-    str = "\\breve";
-  else if (dur.durlog_i_ == -2)
-    str = "\\longa";
-  str += to_str ('.', dur.dots_i_);
-  if (dur.plet_b ())
-    str += String ("*") + to_str (dur.plet_.iso_i_)
-      + String ("/") + to_str (dur.plet_.type_i_);
-  return str;
-}
-
-int
-Duration_convert::dur2ticks_i (Duration dur)
-{
-  if (dur.ticks_i_)
-    return dur.ticks_i_;
-  return dur2_mom (dur) * Rational (Duration::division_1_i_s);
-}
-
-int
-Duration_convert::i2_type (int i)
-{
-  int t=0;
-  while (i && !(i & 1)) {
-    i >>= 1;
-    t++;
-  }
-  return t;
-}
-
-int
-Duration_convert::type2_i (int type)
-{
-  if (type<0)
-    return 0; 
-  else
-    return 1 << type;
-}
-
-Rational
-Duration_convert::dur2_mom (Duration dur)
-{
-  if (dur.ticks_i_)
-    return Rational (dur.ticks_i_, Duration::division_1_i_s);  
-
-  // or simply assert?
-  if (dur.durlog_i_<-10)
-    return Rational (0);
-  Rational mom;
-  if (dur.durlog_i_<0)
-    mom = Rational (type2_i (-dur.durlog_i_), 1);
-  else
-    mom = Rational (1 , type2_i (dur.durlog_i_));
-
-  Rational delta = mom;
-  while (dur.dots_i_--) 
-    {
-      delta /= 2.0;
-      mom += delta;
-    }
-
-  return mom * plet_factor_mom (dur);    
-}
-
-Duration
-Duration_convert::mom2_dur (Rational mom)
-{
-  if (!mom) 
-    {
-      Duration dur;
-      dur.set_plet (0,1);
-      return dur;
-    }
-       
-
-  Duration dur = mom2standardised_dur (mom);
-  //   if (!dur.mom () || (dur.mom () == mom))
-  if (!dur.length_mom () || (dur.length_mom () == mom))
-    return dur;
-  assert (midi_as_plet_b_s);
-
-  //   dur.set_plet (type_mom, Duration::division_1_i_s / 4); 
-
-  //   Rational as_plet_mom = mom / dur.mom ();
-  Rational as_plet_mom = mom / dur.length_mom ();
-  as_plet_mom *= dur.plet_.mom ();
-  long num = as_plet_mom.num ();
-  long den = as_plet_mom.den ();
-  dur.set_plet (num, den);
-  return dur;
-}
-
-Duration
-Duration_convert::mom2standardised_dur (Rational mom)
-{
-  //   if (!dur_array_s.length_i ())
-  if (!dur_array_s.size ())
-    set_array ();
-  assert (dur_array_s.size ());
-  for (int i = 0; i < dur_array_s.size () - 1; i++) 
-    {
-      Rational lower_mom = dur2_mom (dur_array_s[ i ]);
-      if (mom <= lower_mom) 
-       {
-         // all arbitrary, but 3/4 will get rid of the noise...
-         // kinda ok
-         if (i || (mom / lower_mom > Rational (3, 4)))
-           return dur_array_s[ i ];
-         else 
-           {
-             Duration d;
-             d.durlog_i_ = -100;
-             return d;
-           }
-       }
-      Rational upper_mom = dur2_mom (dur_array_s[ i + 1 ]);
-      if ((mom < upper_mom)
-         && ((mom - lower_mom) / lower_mom
-             < (upper_mom - mom) / upper_mom))
-       return dur_array_s[ i ];
-    }
-  return dur_array_s[ dur_array_s.size () - 1 ];
-}
-
-void
-Duration_convert::set_array ()
-{
-  dur_array_s.clear ();
-
-  Duration_iterator iter_dur;
-  assert (iter_dur);
-  while (iter_dur)
-    dur_array_s.push (iter_dur++);
-}
-
-
-Rational
-Duration_convert::plet_factor_mom (Duration dur)
-{
-  return dur.plet_.mom ();
-}
-
-Real
-Duration_convert::sync_f (Duration dur, Rational mom)
-{
-  return mom / dur2_mom (dur);
-}
-
-Duration
-Duration_convert::ticks2_dur (int ticks_i)
-{
-  Rational mom (ticks_i, Duration::division_1_i_s);
-  if (midi_as_plet_b_s)
-    return mom2_dur (mom);
-
-  Duration dur = mom2standardised_dur (mom);
-
-  if (dur.length_mom () == mom)
-    return dur;
-               
-  return mom2_dur (mom);
-}
-
-Duration
-Duration_convert::ticks2standardised_dur (int ticks_i)
-{
-  Rational mom (ticks_i, Duration::division_1_i_s);
-  Duration dur = mom2standardised_dur (mom);
-  return dur;
-}
index abb467d1c1fad5dea73d44e73117c570ee2f28a1..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,118 +0,0 @@
-/*
-  duration-convert.cc -- implement Duration_convert
-
-  source file of the LilyPond music typesetter
-
-  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-          Jan Nieuwenhuizen <janneke@gnu.org>
-*/
-#include <assert.h>
-#include "duration-convert.hh"
-#include "warn.hh"
-#include "duration-iter.hh"
-
-Duration_iterator::Duration_iterator ()
-{
-  cursor_dur_.durlog_i_ = 7;
-  if (Duration_convert::no_smaller_than_i_s)
-    cursor_dur_.durlog_i_ = Duration_convert::no_smaller_than_i_s;
-}
-
-Duration 
-Duration_iterator::operator ++(int)
-{
-  return forward_dur ();
-}
-
-Duration
-Duration_iterator::operator ()()
-{
-  return dur ();
-}
-
-Duration_iterator::operator bool ()
-{
-  return ok ();
-}
-
-Duration
-Duration_iterator::dur ()
-{
-  return cursor_dur_;
-}
-
-Duration
-Duration_iterator::forward_dur ()
-{
-  /* should do smart table? guessing: 
-     duration wholes
-     16        0.0625
-     32..      0.0703
-     8:2/3     0.0833
-     16.       0.0938
-     8 0.1250
-     16..      0.1406
-     4:2/3     0.1667
-     8.        0.1875
-               
-     */
-  assert (ok ());
-
-  Duration dur = cursor_dur_;
-
-  if (!cursor_dur_.dots_i_ && !cursor_dur_.plet_b ()) 
-    {
-      cursor_dur_.durlog_i_ += 1;
-      cursor_dur_.dots_i_ = 2;
-    }
-  else if (cursor_dur_.dots_i_ == 2) 
-    {
-      assert (!cursor_dur_.plet_b ());
-      cursor_dur_.dots_i_ = 0;
-      cursor_dur_.durlog_i_ -=2;
-      cursor_dur_.set_plet (2, 3);
-    }
-  else if (cursor_dur_.plet_b () 
-          && (cursor_dur_.plet_.iso_i_ == 2)
-          && (cursor_dur_.plet_.type_i_ == 3)) 
-    {
-      assert (!cursor_dur_.dots_i_);
-      cursor_dur_.set_plet (1, 1);
-      cursor_dur_.durlog_i_ += 1;
-      cursor_dur_.dots_i_ = 1;
-    }
-  else if (cursor_dur_.dots_i_ == 1) 
-    {
-      assert (!cursor_dur_.plet_b ());
-      cursor_dur_.dots_i_ = 0;
-      cursor_dur_.durlog_i_ -= 1;
-    }
-               
-  if (Duration_convert::no_triplets_b_s
-      && cursor_dur_.plet_b () && ok ())
-    forward_dur ();
-  if (Duration_convert::no_double_dots_b_s 
-      && (cursor_dur_.dots_i_ == 2) && ok ())
-    forward_dur ();
-  if (Duration_convert::no_smaller_than_i_s
-      && (cursor_dur_.durlog_i_ > Duration_convert::no_smaller_than_i_s) && ok ())
-    forward_dur ();
-  if (Duration_convert::no_smaller_than_i_s
-      && cursor_dur_.dots_i_
-      && (cursor_dur_.durlog_i_ >= Duration_convert::no_smaller_than_i_s)
-      && ok ())
-    forward_dur ();
-  if (Duration_convert::no_smaller_than_i_s
-      && (cursor_dur_.dots_i_ == 2)
-      && (cursor_dur_.durlog_i_ >= Duration_convert::no_smaller_than_i_s / 2)
-      && ok ())
-    forward_dur ();
-
-  return dur;
-}
-
-bool
-Duration_iterator::ok ()
-{
-  return cursor_dur_.length_mom () <= Rational (4);
-}
index b2a5f84643dd36cdec33b1b4675dc40cf597afd6..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,93 +0,0 @@
-/*
-  duration.cc -- implement Duration, Plet, 
-
-  source file of the LilyPond music typesetter
-
-  (c)  1997--1999 Jan Nieuwenhuizen <janneke@gnu.org>
-           Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
-
-  UGH. Duration is broken.
-*/
-
-#include <assert.h>
-
-#include "proto.hh"
-#include "string.hh"
-#include "source-file.hh"
-#include "source.hh"
-#include "rational.hh"
-#include "duration.hh"
-#include "duration-convert.hh"
-#include "duration-iter.hh"
-
-// statics Duration
-int Duration::division_1_i_s = 384 * 4;
-
-
-Duration::Duration ()
-{
-  durlog_i_ = 0;
-  dots_i_ = 0;
-  ticks_i_ = 0;
-}
-
-bool
-Duration::duration_type_b (int t)
-{
-  /*
-    ugh. Assuming behavior of conversion funcs on broken input.
-   */
-  return t == Duration_convert::type2_i (Duration_convert::i2_type (t));
-}
-
-void
-Duration::compress (Rational m)
-{
-  plet_.iso_i_ *= m.num_i ();
-  plet_.type_i_ *= m.den_i (); 
-}
-
-Rational
-Duration::length_mom () const
-{
-  return Duration_convert::dur2_mom (*this);
-}
-
-void
-Duration::set_plet (int i, int t)
-{
-  plet_.iso_i_ = i; 
-  plet_.type_i_ = t;
-}
-
-/*
-void
-Duration::set_plet (Duration d)
-{
-  plet_.iso_i_ = d.plet_.iso_i_; 
-  plet_.type_i_ = d.plet_.type_i_;
-}
-*/
-
-void
-Duration::set_ticks (int ticks_i)
-{
-  assert (durlog_i_ <10);
-  assert (!dots_i_);
-  ticks_i_ = ticks_i;
-}
-
-String
-Duration::str () const
-{
-  return Duration_convert::dur2_str (*this);
-}
-
-
-bool
-Duration::plet_b ()
-{
-  return !plet_.unit_b ();
-}
-
index 980c62a6f5e8ffd05bfe810b32529c8c56f9388c..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,79 +0,0 @@
-/*
-  duration-convert.hh -- declare Duration_convert
-
-  source file of the LilyPond music typesetter
-
-  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-
-#ifndef DURATION_CONVERT_HH
-#define DURATION_CONVERT_HH
-#include "duration.hh"
-#include "string.hh"
-#include "array.hh"
-
-/**
-       Duration_convert handles all conversions to -n fro Duration (dur).
-       That is including (integer + division) representation for MIDI,
-       and conversion from unexact time representation (best guess :-).
-
-       A Rational (mom) is a Rational that holds the time fraction 
-       compared to a whole note (before also called wholes).
-
-       [todo]
-       move all statics to real members, instantiate Duration_convert
-       object (s).
-*/
-struct Duration_convert {
-       
-  /* Urgh. statics.
-   */
-  static bool const midi_as_plet_b_s;
-  static bool no_quantify_b_s;
-  static bool no_double_dots_b_s;
-  static bool no_triplets_b_s;
-  static int no_smaller_than_i_s;
-  static Array<Duration> dur_array_s;
-
-  /// Return number of ticks in (ticks, division_1) representation
-  static int dur2ticks_i (Duration dur );
-       
-  /// Return the type_i representation of note length i
-  static int i2_type (int i);
-
-  /// Return the note length corresponding to the type_i representation
-  /// Return 0 if longer than whole note.
-  static int type2_i (int type);
-
-  /// Return Rational representation (fraction of whole note).
-  static Rational dur2_mom (Duration dur );
-
-  /// Return Mudela string representation.
-  static String dur2_str (Duration dur );
-
-  /// Return duration from Rational (fraction of whole) representation.
-  static Duration mom2_dur (Rational mom );
-
-  /// Return standardised duration, best guess if not exact.
-  static Duration mom2standardised_dur (Rational mom );
-  
-  /// Return plet factor (not a Rational: should use Rational?).
-  static Rational plet_factor_mom (Duration dur );
-
-  static void set_array ();
-
-  /** Return synchronisation factor for mom, so that
-      mom2_dur (mom / sync_f ) will return the duration dur.           
-  */ 
-  static Real sync_f (Duration dur, Rational mom );
-
-  /// Return exact duration, in midi-ticks if not-exact.
-  static Duration ticks2_dur (int ticks_i );
-
-  /// Return standardised duration, best guess if not exact.
-  static Duration ticks2standardised_dur (int ticks_i );
-};
-
-
-#endif // DURATION_CONVERT_HH
index 5dd9c4a6012cea86b4aff3b2563acb8cf0114e52..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,47 +0,0 @@
-/*   
-  duration-iter.hh -- declare Duration_iterator
-  
-  source file of the GNU LilyPond music typesetter
-  
-  (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.ruu.nl>
-  
- */
-
-#ifndef DURATION_ITER_HH
-#define DURATION_ITER_HH
-
-/// (iter_dur)
-struct Duration_iterator {
-  
-  /// start at shortest: 128:2/3
-  Duration_iterator ();
-
-  // **** what about these three here ?
-  /// return forward_dur ();
-  Duration operator ++(int); 
-
-  /// return ok ()
-  operator bool (); 
-
-  /// return dur ()
-  Duration operator ()(); 
-
-
-  /// return current dur
-  Duration dur ();
-
-  /// return dur (), step to next
-  Duration forward_dur ();
-
-  /// durations left?
-  bool ok ();
-
-private:
-
-  Duration cursor_dur_;
-};
-
-
-
-#endif /* DURATION_ITER_HH */
-
index 28580b63af32f93c5a0a56211c89a3b107700dbb..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,44 +0,0 @@
-/*
-  duration.hh -- declare Duration
-  
-  source file of the LilyPond music typesetter
-
-  (c)  1997--1999 Jan Nieuwenhuizen <janneke@gnu.org>
-
-*/
-
-// split into 4?
-
-#ifndef DURATION_HH
-#define DURATION_HH
-
-#include "fproto.hh"
-#include "rational.hh"
-#include "plet.hh"
-
-/**
-   Handle "musical" durations. This means: balltype 1,2,4,etc. and dots.
-   
-  (dur)
-  */
-struct Duration {
-  Duration ();
-  /// is the "plet factor" of this note != 1 ?
-  bool plet_b ();
-  String str () const;
-  void set_plet (int,int );
-  void compress (Rational);
-
-  static bool duration_type_b (int t);
-  void set_ticks (int ticks_i );
-  Rational length_mom () const ;
-  static int division_1_i_s;
-
-  /// Logarithm of the base duration.
-  int durlog_i_;
-  int dots_i_;
-  Plet plet_;
-  int ticks_i_;
-};
-#endif // DURATION_HH
-
index 42ef83b435d86cbbd9ac82d5a0894a14202134a0..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,27 +0,0 @@
-/*
-  plet.hh -- declare Plet
-
-  source file of the GNU LilyPond music typesetter
-
-  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-
-#ifndef PLET_HH
-#define PLET_HH
-#include "rational.hh"
-
-/** 
-  The type and replacement value of a  plet (triplet, quintuplet.) Conceptually the same as a rational, but 4/6 != 2/3.
-  
-  (plet)
- */
-struct Plet {
-  Plet ();
-  Rational mom () const;
-  bool unit_b () const;
-  int iso_i_;  // 2/3; 2 is not duration, maar of count!
-  int type_i_; 
-};
-
-#endif // PLET_HH
index 95d60bfc33ee99e8ab3ab1d852bf3edac9bdcc07..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,15 +0,0 @@
-//
-// windhoos-suck-suck-suck-thank-you-cygnus.hh
-//
-// mmap () should work now (cygnus beta 18), but let's keep it here
-// for people using old cygnus releases
-#if 0 //def _WINDOWS32
-#ifndef WINDHOOS_SUCK_SUCK_SUCK_HH
-#define WINDHOOS_SUCK_SUCK_SUCK_HH
-
-caddr_t mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset);
-
-int munmap (caddr_t addr, size_t len);
-
-#endif // WINDHOOS_SUCK_SUCK_SUCK_HH
-#endif // _WINDOWS32 //
index e567515b7ed1c43366f95fa1ef688ab5ffda815a..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,29 +0,0 @@
-/*
-  plet.cc -- implement Plet
-
-  source file of the GNU LilyPond music typesetter
-
-  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-#include "plet.hh"
-
-
-Plet::Plet ()
-{
-  type_i_ = 1;
-  iso_i_ = 1;
-}
-
-Rational
-Plet::mom () const
-{
-  return  Rational (iso_i_, type_i_);
-}
-
-bool
-Plet::unit_b () const
-{
-  return type_i_ == 1 && iso_i_ == 1;
-}
-
index 22cbb9d834c77b3eca42726337123c83fa2bad55..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,105 +0,0 @@
-//
-// windhoos.cc
-//
-// mmap () should work now (cygnus beta 18), but let's keep it here
-// for people using old cygnus releases
-#if 0 // def _WINDOWS32
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <winbase.h>
-#include "thank-you-cygnus.hh"
-
-/* 
-HANDLE CreateFileMapping (
-    HANDLE hFile,      // handle to file to map 
-    LPSECURITY_ATTRIBUTES lpFileMappingAttributes,     // optional security attributes 
-    DWORD flProtect,   // protection for mapping object 
-    DWORD dwMaximumSizeHigh,   // high-order 32 bits of object size  
-    DWORD dwMaximumSizeLow,    // low-order 32 bits of object size  
-    LPCTSTR lpName     // name of file-mapping object 
-);     
-
-LPVOID MapViewOfFile (
-    HANDLE hFileMappingObject, // file-mapping object to map into address space  
-    DWORD dwDesiredAccess,     // access mode 
-    DWORD dwFileOffsetHigh,    // high-order 32 bits of file offset 
-    DWORD dwFileOffsetLow,     // low-order 32 bits of file offset 
-    DWORD dwNumberOfBytesToMap         // number of bytes to map 
-);     
-
-io.h:
-long _get_osfhandle (int filehandle);
-*/
-
-// cygnus's gnu-win32-b17.1 does not have _get_osfhandle
-// however, after some hacking, it turns out that:
-
-static const int OSF_OFFSET_i = 72;  
-static const int OSF_BASE_i = -3;
-static const int OSF_FACTOR_i = 8;  
-// let-s hope bill doesn-t change his mind any time soon :-)
-
-// so that, while waiting for cygnus's mmap, we can write:
-
-// #define HAVE_GET_OSFHANDLE  // no we still cannot; works only with cl.exe
-long
-_get_osfhandle (int filedes_i)
-{
-    return (long)(OSF_OFFSET_i + (filedes_i + OSF_BASE_i) * OSF_FACTOR_i);
-}
-
-#ifdef HAVE_GET_OSFHANDLE
-
-#include <iostream.h>
-
-caddr_t
-mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
-{
-    (void)flags;
-    (void)prot;
-    (void)addr;
-    HANDLE osf = (HANDLE)_get_osfhandle (fd);
-    HANDLE file_handle = CreateFileMapping (osf, (void*)0, PAGE_READONLY,
-       0, len, 0); 
-    return (caddr_t)MapViewOfFile (file_handle, FILE_MAP_READ, 0, offset, len);
-}
-
-
-int
-munmap (caddr_t addr, size_t len)
-{
-    (void)len;
-    return UnmapViewOfFile (addr);
-}
-
-#else // ! HAVE_GET_OSFHANDLE //
-
-caddr_t
-mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
-{
-    (void)flags;
-    (void)prot;
-    (void)addr;
-    (void)offset;
-    char* ch_p = new char[ len ];
-    if (ch_p)
-        read (fd, (void*)ch_p, len);
-    return ch_p;
-}
-
-
-int
-munmap (caddr_t addr, size_t len)
-{
-    (void)len;
-    delete (char*)addr;
-    return 0;
-}
-
-#endif // !HAVE_GET_OSFHANDLE //
-
-
-#endif // _WINDOWS32 //
index 8128a58af7a8f5911987a86bdb8b949b2e632dda..1df7cda734ace777af149bb0cf9f8b48be95f857 100644 (file)
@@ -1,5 +1,6 @@
-#include "warn.hh"
 #include <stream.h>
+#include "warn.hh"
+
 
 void
 error (String s)
@@ -34,9 +35,3 @@ programming_error (String s)
   cerr << _("programming error: ") << s << _(" (Continuing; cross thumbs)") << '\n';
 }
 
-void
-programming_warning (String m)
-{
-  cerr << _ ("programming warning: ") << m <<endl;
-
-}
index 22cfb5fdf3f4aba25acfb76700dbea873a31da39..9ae9db643886ebd331494387bfef89d138756714 100644 (file)
@@ -51,8 +51,10 @@ Axis_group_engraver::process_acknowledged ()
     {
       if (!elts_[i]->parent_l (Y_AXIS))
        staffline_p_->add_element (elts_[i]);
-      else if (elts_[i]->get_elt_property ("Axis_group_element::add_extra_element") == SCM_UNDEFINED
-              && ! dynamic_cast<Axis_group_element*> (elts_[i]->parent_l (Y_AXIS)))
+      else
+       if (
+           // elts_[i]->get_elt_property ("Axis_group_element::add_extra_element") == SCM_UNDEFINED &&
+           ! dynamic_cast<Axis_group_element*> (elts_[i]->parent_l (Y_AXIS)))
               
        {
          staffline_p_->add_element (elts_[i]);
index de137b9a380aa2a05148e620c46f62b941fa9d51..33584530760d4a1f8db774796890ec7117a2d71e 100644 (file)
@@ -175,7 +175,7 @@ Beam::set_stem_directions ()
     {
       Stem *s = stem (i);
       SCM force = s->remove_elt_property ("dir-forced");
-      if (force == SCM_UNDEFINED)
+      if (!gh_boolean_p (force) || !gh_scm2bool (force))
        s->set_direction (d);
     }
 } 
@@ -200,7 +200,7 @@ Beam::auto_knee (String gap_str, bool interstaff_b)
   bool knee_b = false;
   int knee_y = 0;
   SCM gap = get_elt_property (gap_str);
-  if (gap != SCM_UNDEFINED)
+  if (gh_number_p (gap))
     {
       int auto_gap_i = gh_scm2int (gap);
       for (int i=1; i < stem_count (); i++)
@@ -254,7 +254,7 @@ Beam::set_stem_shorten ()
     gh_int2scm (multiplicity), 
     SCM_UNDEFINED));
   Real shorten_f = gh_scm2double (shorten) 
-    * Staff_symbol_referencer_interface (this).staff_line_leading_f ();
+    * Staff_symbol_referencer_interface (this).staff_space ();
 
   /* cute, but who invented this -- how to customise ? */
   if (forced_fraction < 1)
@@ -265,7 +265,7 @@ Beam::set_stem_shorten ()
       Stem* s = stem (i);
       if (s->invisible_b ())
         continue;
-      if (s->get_elt_property ("shorten") == SCM_UNDEFINED)
+      if (gh_number_p (s->get_elt_property ("shorten")))
        s->set_elt_property ("shorten", gh_double2scm (shorten_f));
     }
 }
@@ -296,14 +296,14 @@ Beam::do_post_processing ()
 
   /* set or read dy as necessary */
   SCM s = get_elt_property ("height");
-  if (s != SCM_UNDEFINED)
+  if (gh_number_p (s))
     dy = gh_scm2double (s);
   else
     set_elt_property ("height", gh_double2scm (dy));
 
   /* set or read y as necessary */
   s = get_elt_property ("y-position");
-  if (s != SCM_UNDEFINED)
+  if (gh_number_p (s))
     {
       y = gh_scm2double (s);
       set_stem_length (y, dy);
@@ -404,7 +404,7 @@ Beam::calc_slope_damping_f (Real dy) const
 {
   SCM damp = get_elt_property ("damping"); // remove?
   int damping = 1;             // ugh.
-  if (damp != SCM_UNDEFINED)
+  if (gh_number_p (damp))
     damping = gh_scm2int (damp);
 
   if (damping)
@@ -516,7 +516,7 @@ Beam::quantise_dy_f (Real dy) const
     return dy;
 
   Staff_symbol_referencer_interface st (this);
-  Real interline_f = st.staff_line_leading_f ();
+  Real interline_f = st.staff_space ();
   
   Real staffline_f = paper_l ()->get_var ("stafflinethickness");
   Real beam_f = gh_scm2double (get_elt_property ("beam-thickness"));;
@@ -565,7 +565,7 @@ Beam::quantise_y_f (Real y, Real dy, int quant_dir)
    */
 
   Staff_symbol_referencer_interface sinf (this);
-  Real space = sinf.staff_line_leading_f ();
+  Real space = sinf.staff_space ();
   Real staffline_f = paper_l ()->get_var ("stafflinethickness");
   Real beam_f = gh_scm2double (get_elt_property ("beam-thickness"));;
 
@@ -709,7 +709,7 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const
       Real gap_f = 0;
 
       SCM gap = get_elt_property ("beam-gap");
-      if (gap != SCM_UNDEFINED)
+      if (gh_number_p (gap))
        {
          int gap_i = gh_scm2int ( (gap));
          int nogap = rwholebeams - gap_i;
index 04271c8e6cf1a03135e987a9fd65660fd9ece489..a87329fe785c42712a6b7f1b4b7f9cbaac2fe986 100644 (file)
@@ -30,10 +30,10 @@ Bow::do_brew_molecule_p () const
 
   Molecule a;
   SCM d =  get_elt_property ("dashed");
-  if (d == SCM_UNDEFINED)
-    a = lookup_l ()->slur (one, get_direction () * thick, thick);
-  else
+  if (gh_number_p (d))
     a = lookup_l ()->dashed_slur (one, thick, gh_scm2int (d));
+  else
+    a = lookup_l ()->slur (one, get_direction () * thick, thick);
   
   return new Molecule (a); 
 }
@@ -57,9 +57,6 @@ Bow::curve_extent (Axis a) const
 Bezier
 Bow::get_curve () const
 {
-
-
-  
   Bezier_bow b (paper_l (),
                get_encompass_offset_arr (), get_direction ());
   
index 7a5b9f9f0985d42b1d53094a1ac4f56ec3ada210..8caac78f6008e2a4d146e6b79d77360a26069c80 100644 (file)
@@ -95,10 +95,10 @@ Break_align_item::do_pre_processing()
 
   // urg
   SCM first_pair = elems[0]->get_elt_property ("minimum-space");
-  if (first_pair == SCM_UNDEFINED)
-    first_pair = gh_cons (gh_double2scm (0.0), gh_double2scm (0.0));
-  else
+  if (gh_pair_p (first_pair))
     first_pair = first_pair;
+  else
+    first_pair = gh_cons (gh_double2scm (0.0), gh_double2scm (0.0));
   
   scm_set_car_x (first_pair, gh_double2scm (-dists[0]));
   elems[0]->set_elt_property ("minimum-space", first_pair);
index bf1f8dea96e3207c4d7158f0266766a20fe6520a..9861ac19c557004e0df2574a1c1a112785c3314b 100644 (file)
@@ -33,7 +33,7 @@ Breathing_sign::do_brew_molecule_p () const
 {
   Staff_symbol_referencer_interface si (this);
   
-  Real dl = si.staff_line_leading_f();
+  Real dl = si.staff_space();
   Interval i1(0, dl / 6), i2(-dl / 2, dl / 2);
   Box b(i1, i2);
 
@@ -45,7 +45,7 @@ Breathing_sign::do_brew_molecule_p () const
 void
 Breathing_sign::do_post_processing()
 {
-  Real dl = Staff_symbol_referencer_interface (this).staff_line_leading_f();
+  Real dl = Staff_symbol_referencer_interface (this).staff_space();
 
   translate_axis(2.0 * dl * get_direction (), Y_AXIS);
 }
index 6c9f9e2bc890c88a137c26d72b1a3ead8be4f69e..6e914015b1d1bab53a2e6eb66dc9aa7f082d0c87 100644 (file)
@@ -7,7 +7,6 @@
            Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
-#include "duration-convert.hh"
 #include "timing-translator.hh"
 #include "chord-tremolo-engraver.hh"
 #include "stem.hh"
index 644735e28822797a5cb91e2602bbbaf367a4770b..4407b8767ea6a134b1cea9833948142be6043af6 100644 (file)
@@ -67,7 +67,7 @@ Clef_item::do_add_processing ()
          
          add_dependency (g);   // just to be sure.
          SCM my_vis = get_elt_property ("visibility-lambda");
-         if (my_vis != SCM_UNDEFINED)
+         if (gh_procedure_p (my_vis))
            g->set_elt_property ("visibility-lambda", my_vis);
                        
        }
index 1ee27e6c3707706bef3bd8e9dd696b6d50ad258d..91301c6ca698dc2f9ca1fe552bd19283b08a76d2 100644 (file)
@@ -194,7 +194,7 @@ Collision::forced_shift ()
       Score_element * se = unsmob_element ( gh_car (s));
 
       SCM force =  se->remove_elt_property ("force-hshift");
-      if (force != SCM_UNDEFINED)
+      if (gh_number_p (force))
        {
          tups. push (Shift_tup (se, gh_scm2double (force)));
        }
diff --git a/lily/duration.cc b/lily/duration.cc
new file mode 100644 (file)
index 0000000..ea63899
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+  duration.cc -- implement Duration, Plet, 
+
+  source file of the LilyPond music typesetter
+
+  (c)  1997--1999 Jan Nieuwenhuizen <janneke@gnu.org>
+           Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+*/
+
+#include <assert.h>
+
+#include "lily-proto.hh"
+#include "string.hh"
+#include "moment.hh"
+#include "duration.hh"
+
+Duration::Duration ()
+{
+  durlog_i_ = 0;
+  dots_i_ = 0;
+  tuplet_iso_i_ = 1;
+  tuplet_type_i_ = 1;
+}
+
+void
+Duration::compress (Rational m)
+{
+  tuplet_type_i_ *= m.num_i ();
+ tuplet_iso_i_ *= m.den_i (); 
+}
+
+Rational
+Duration::length_mom () const
+{
+  Rational mom (1 << abs (durlog_i_));
+
+  if (durlog_i_> 0)
+    mom = Moment (1)/mom;
+
+  Rational delta = mom;
+
+  for (int d = dots_i_; d; d--)
+    {
+      delta /= 2.0;
+      mom += delta;
+    }
+
+  return mom * Moment (tuplet_iso_i_, tuplet_type_i_);
+}
+
+void
+Duration::set_plet (int i, int t)
+{
+  tuplet_iso_i_ = i; 
+  tuplet_type_i_ = t;
+}
+
+
+String
+Duration::str () const
+{
+  return to_str (durlog_i_) + to_str ('.', dots_i_);
+}
+
+
+bool
+Duration::plet_b ()
+{
+  return tuplet_iso_i_ != 1 || tuplet_type_i_ != 1;
+}
+
+
index 9ea2b8259e319edc2ddc4ccf117a96381de56e1c..b8879bc45af8a50244c74dccb851fd41361e2000 100644 (file)
@@ -183,7 +183,7 @@ Gourlay_breaking::combine_demerits (Column_x_positions const &prev,
   if (pc->original_l_)
     {
       SCM pen = pc->get_elt_property ("penalty");
-      if (pen != SCM_UNDEFINED)
+      if (gh_number_p (pen))
        {
          break_penalties += gh_scm2double (pen);
        }
index 99293896dede11aadd21d668849e43e2379950ef..f5b1e472949a210d04056b4a79622183867b2c33 100644 (file)
@@ -31,7 +31,7 @@ void
 Hara_kiri_group_spanner::do_post_processing ()
 {
   SCM worth = get_elt_property ("items-worth-living");
-  if (worth != SCM_EOL && worth != SCM_UNDEFINED)
+  if (gh_pair_p (worth))
     return;
 
   Link_array<Score_element> childs = get_children ();
index f525b13cd55dbe443a067c232bdfd60ec233fa78..008944569478c8a904bc3fd9e8ec82ab951c9de5 100644 (file)
@@ -34,6 +34,11 @@ public:
   void banter (Array<Musical_pitch> pitch_arr, Chord_mol* name_p) const;
 
   Chord_name (Chord const& c);
+
+  /*
+    ugh. Junkme, I must be elt property.
+   */
+  
   Chord chord_;
 
 protected:
diff --git a/lily/include/duration.hh b/lily/include/duration.hh
new file mode 100644 (file)
index 0000000..0423d47
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+  duration.hh -- declare Duration
+  
+  source file of the LilyPond music typesetter
+
+  (c)  1997--1999 Jan Nieuwenhuizen <janneke@gnu.org>
+
+*/
+
+#ifndef DURATION_HH
+#define DURATION_HH
+
+#include "fproto.hh"
+#include "rational.hh"
+
+
+/**
+   A musical duration.
+  */
+struct Duration {
+  Duration ();
+  /// is the "plet factor" of this note != 1 ?
+  bool plet_b ();
+  String str () const;
+  void set_plet (int,int );
+  void compress (Rational);
+  Rational length_mom () const ;
+
+  /// Logarithm of the base duration.
+  int durlog_i_;
+  int dots_i_;
+  int tuplet_iso_i_;  // 2/3; 2 is not duration, maar of count!
+  int tuplet_type_i_; 
+
+};
+#endif // DURATION_HH
+
diff --git a/lily/include/plet.hh b/lily/include/plet.hh
new file mode 100644 (file)
index 0000000..3a3b234
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+  plet.hh -- declare Plet
+
+  source file of the GNU LilyPond music typesetter
+
+  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+
+#ifndef PLET_HH
+#define PLET_HH
+#include "rational.hh"
+
+/** 
+  The type and replacement value of a  plet (triplet, quintuplet.) Conceptually the same as a rational, but 4/6 != 2/3.
+  
+  (plet)
+ */
+struct Plet {
+  Plet ();
+  Rational mom () const;
+  bool unit_b () const;
+};
+
+#endif // PLET_HH
index a9cb5056cd2a45f53dbd7e917984db1d747460e7..589f73e0b49ee833f65d8f41194d09bbc5f58f15 100644 (file)
@@ -33,7 +33,7 @@ public:
      typeface. ie. leading is vertical space.
    */
   
-  Real staff_line_leading_f () const;
+  Real staff_space () const;
   Staff_symbol * staff_symbol_l () const;
   int lines_i () const;
   Real position_f () const;
index 89dc0d63cdb474ecf4f5559fab992422754e7aeb..c052e6220dfbf6c955208b92b259771bf6502389 100644 (file)
@@ -20,8 +20,8 @@ class Staff_symbol : public Spanner
 public:
   /// this many lines.
   int no_lines_i_;
-  Real staff_line_leading_f_;
-  Real staff_line_leading_f ();
+  Real staff_space_;
+  Real staff_space ();
   
   
   Staff_symbol ();
index 7da90a36493009e90690d4a1ab0b6d3943364217..b496614ebeb08b00d8c244836a55af073f7869d9 100644 (file)
 class Stem : public Item,
             public Directional_element
 {
-
-  /**extent of the stem (positions).
-    fractional, since Beam has to adapt them.
-    */
-  Interval yextent_;
-
 public:
   /// log of the duration. Eg. 4 -> 16th note -> 2 flags
   int flag_i () const;
@@ -64,6 +58,7 @@ public:
   Note_head * first_head () const;
   Score_element * support_head () const;
   Stem ();
+
   /// ensure that this Stem also encompasses the Notehead #n#
   void add_head (Rhythmic_head*n);
 
@@ -75,15 +70,14 @@ public:
   int type_i () const;
   void set_stemend (Real);
   Direction get_default_dir() const;
-
   int get_center_distance(Direction) const;
+  Real  get_default_stemlen() const;
+
+  void position_noteheads();
 
-  void set_default_stemlen();
-  void set_default_extents();
-  void set_noteheads();
+  Real stem_end_position () const;
 
-  Real stem_end_f() const;
-  Real stem_begin_f() const;
+  // todo: cleanup, naming
   Real note_delta_f () const;
 
   bool invisible_b() const;
index 247a26e4846af70a3f6f1c3a119af4f3e30e13d6..af2c9d63df882939582f0a12a9d68d8206f52f61 100644 (file)
@@ -72,7 +72,7 @@ void
 Item::try_visibility_lambda ()
 {
   SCM vis = remove_elt_property ("visibility-lambda");
-  if (vis != SCM_UNDEFINED)
+  if (gh_procedure_p (vis))
     {
       SCM args = scm_listify (gh_int2scm (break_status_dir ()), SCM_UNDEFINED);
       SCM result = gh_apply (vis, args);
index c39f0e4e5cfcec987d9f85ceec7844fcb8375bcd..0552e50e8f225f33106962ed0d04749f128bbe3d 100644 (file)
@@ -100,7 +100,7 @@ Key_item::do_brew_molecule_p() const
   Molecule*output = new Molecule;
 
   Staff_symbol_referencer_interface si (this);
-  Real inter = si.staff_line_leading_f ()/2.0;
+  Real inter = si.staff_space ()/2.0;
   
   int j;
   if ((break_status_dir () == LEFT || break_status_dir () == CENTER)
index 55f17551a7696240c8b9148aa7e1834afe790358..cdc25c0b438af41d0e03e982cee0c65de9085106 100644 (file)
@@ -69,7 +69,7 @@ Local_key_item::do_brew_molecule_p() const
 {
   Molecule*output = new Molecule;
   Staff_symbol_referencer_interface si (this);
-  Real note_distance = si.staff_line_leading_f ()/2;
+  Real note_distance = si.staff_space ()/2;
   Molecule *octave_mol_p = 0;
   int lastoct = -100;
   
index 2acff7c9f91d742724061965ae670553e11942bf..867b7bad2bb6d7b036b3c47a600426fc9ca99b7b 100644 (file)
@@ -88,7 +88,8 @@ Midi_event::Midi_event (Moment delta_mom, Midi_item* midi_p)
 String
 Midi_event::str () const
 {
-  int delta_i = delta_mom_ * Moment (Duration::division_1_i_s);
+  int delta_i = delta_mom_ * Moment (384 * 4); // ugh.
+
   String delta_str = Midi_item::i2varint_str (delta_i);
   String midi_str = midi_p_->str ();
   assert (midi_str.length_i ());
index 5edec8fc3e801a7180711211c68034cdbf3d9c87..0ab27b60f59763b90f93e7101449d09285282cd1 100644 (file)
@@ -72,7 +72,7 @@ Multi_measure_rest::do_brew_molecule_p () const
   Molecule s;
   bool rest_symbol=true;
   SCM alt_symbol_sym =get_elt_property ("alt-symbol");
-  if (alt_symbol_sym != SCM_UNDEFINED)
+  if (gh_string_p (alt_symbol_sym))
     {
       s = lookup_l () -> afm_find (ly_scm2string (alt_symbol_sym));
       rest_symbol = false;
@@ -90,7 +90,7 @@ Multi_measure_rest::do_brew_molecule_p () const
   
   mol_p->add_molecule (s);
   Real interline_f
-    = staff_symbol_referencer_interface (this).staff_line_leading_f ();
+    = staff_symbol_referencer_interface (this).staff_space ();
   if (measures_i_ == 1 && rest_symbol)
     {
       mol_p->translate_axis (interline_f, Y_AXIS);
index c1e1e6f1cca485b7c7fd2651ca30efe25521b63c..44020d62869f6e092825165806c2c0b3f63ff25f 100644 (file)
@@ -30,8 +30,8 @@ Note_column::shift_compare (Note_column *const &p1, Note_column*const&p2)
   SCM s1 = p1->get_elt_property ("horizontal-shift");
   SCM s2 = p2->get_elt_property ("horizontal-shift");
 
-  int h1 = (s1 == SCM_UNDEFINED) ? 0 : gh_scm2int (s1);
-  int h2 = (s2 == SCM_UNDEFINED) ? 0 : gh_scm2int (s2);
+  int h1 = (gh_number_p (s1))?  gh_scm2int (s1) :0;
+  int h2 = (gh_number_p (s2)) ? gh_scm2int (s2):0;
   return h1 - h2;
 }
 
@@ -122,7 +122,7 @@ Note_column::translate_rests (int dy_i)
       Score_element * se = unsmob_element (gh_car (s));
       Staff_symbol_referencer_interface si (se);
 
-      se->translate_axis (dy_i * si.staff_line_leading_f ()/2.0, Y_AXIS);
+      se->translate_axis (dy_i * si.staff_space ()/2.0, Y_AXIS);
     }
 }
 
@@ -162,11 +162,11 @@ Note_column::do_post_processing ()
   Real beam_y = 0;
 
   SCM s = b->get_elt_property ("height");
-  if (s != SCM_UNDEFINED)
+  if (gh_number_p (s))
     beam_dy = gh_scm2double (s);
   
   s = b->get_elt_property ("y-position");
-  if (s != SCM_UNDEFINED)
+  if (gh_number_p (s))
     beam_y = gh_scm2double (s);
 
   Real x0 = b->first_visible_stem ()->hpos_f ();
@@ -179,7 +179,7 @@ Note_column::do_post_processing ()
   Score_element * se = unsmob_element (gh_car (s));
   Staff_symbol_referencer_interface si (se);
 
-  Real staff_space = si.staff_line_leading_f ();      
+  Real staff_space = si.staff_space ();      
   Real rest_dim = extent (Y_AXIS)[d]*2.0  /staff_space ;
 
   Real minimum_dist
index 70834c191b000fbd06c16c05bb9d009806b04c02..6124b5a1fa6400805263c73a7db6e22819b81b51 100644 (file)
@@ -51,7 +51,7 @@ Note_head::do_brew_molecule_p() const
 {
   Staff_symbol_referencer_interface si (this);
   
-  Real inter_f = si.staff_line_leading_f ()/2;
+  Real inter_f = si.staff_space ()/2;
   int sz = si.lines_i ()-1;
   Real p = si.position_f ();
   int streepjes_i = abs (p) < sz 
@@ -60,7 +60,7 @@ Note_head::do_brew_molecule_p() const
 
  String type; 
   SCM style  = get_elt_property ("style");
-  if (style != SCM_UNDEFINED)
+  if (gh_string_p (style))
     {
       type = ly_scm2string (style);
     }
index 0d802fd2ff78f6a6d2a323e419de364018c58f15..58931e8277d8baee1a9e5e93e3fbf2305cb574f8 100644 (file)
@@ -30,7 +30,6 @@
 #include "translator-group.hh"
 #include "score.hh"
 #include "music-list.hh"
-#include "duration-convert.hh"
 #include "change-translator.hh"
 #include "file-results.hh"
 #include "scope.hh"
 // mmm
 Mudela_version oldest_version ("1.3.4");
 
+bool
+is_duration_b (int t)
+{
+  return t == 1 << intlog2(t);
+}
+
+
 
 
 void
@@ -920,7 +926,7 @@ abbrev_command_req:
                $$ =b;
        }
        | '[' ':' unsigned {
-               if (!Duration::duration_type_b ($3))
+               if (!is_duration_b ($3))
                  THIS->parser_error (_f ("not a duration: %d", $3));
                else if ($3 < 8)
                  THIS->parser_error (_ ("Can't abbreviate"));
@@ -1300,10 +1306,10 @@ duration_length:
                $$ = $1;
        }
        | duration_length '*' unsigned {
-               $$->plet_.iso_i_ *= $3;
+               $$->tuplet_iso_i_ *= $3;
        }
        | duration_length '/' unsigned {
-               $$->plet_.type_i_ *= $3;
+               $$->tuplet_type_i_ *= $3;
        }
        ;
 
@@ -1325,10 +1331,10 @@ optional_notemode_duration:
 steno_duration:
        unsigned                {
                $$ = new Duration;
-               if (!Duration::duration_type_b ($1))
+               if (!is_duration_b ($1))
                        THIS->parser_error (_f ("not a duration: %d", $1));
                else {
-                       $$->durlog_i_ = Duration_convert::i2_type ($1);
+                       $$->durlog_i_ = intlog2 ($1);
                     }
        }
        | DURATION_IDENTIFIER   {
@@ -1345,7 +1351,7 @@ abbrev_type:
                $$ =0;
        }
        | ':' unsigned {
-               if (!Duration::duration_type_b ($2))
+               if (!is_duration_b ($2))
                        THIS->parser_error (_f ("not a duration: %d", $2));
                else if ($2 < 8)
                        THIS->parser_error (_ ("Can't abbreviate"));
index 8dd85f8a4b9283132859453fc5ff5fa668a23076..18abd7604c07a09ac8277e4105b7d7fee1d5779c 100644 (file)
@@ -90,7 +90,7 @@ Rest_collision::do_pre_processing()
       Real staff_space = paper_l()->get_var ("interline");
 
        /* FIXME
-         staff_space =  rcol->rest_l_arr[0]->staff_line_leading_f ();
+         staff_space =  rcol->rest_l_arr[0]->staff_space ();
        */
       Real internote_f = staff_space/2;
       Real minimum_dist = paper_l ()->get_var ("restcollision_minimum_dist")
index 5caadb099980f7281846d1dd6f84b32355545561..8999559d5f7ef5bf1d69cae171c417099e9ae071 100644 (file)
@@ -51,7 +51,7 @@ Rest::do_brew_molecule_p () const
   
   String style; 
   SCM style_sym =get_elt_property ("style");
-  if (balltype_i () >= 2 && style_sym != SCM_UNDEFINED)
+  if (balltype_i () >= 2 &&gh_string_p ( style_sym))
     {
       style = ly_scm2string (style_sym);
     }
index b7d6ce8a794fd64d3dea31bf6184206b94aa833c..55f2b92c6f7834aee9cf11c39ea93745c5743920 100644 (file)
@@ -198,7 +198,7 @@ Score_element::lookup_l () const
     {
       Score_element * urg = (Score_element*)this;
       SCM sz = urg->remove_elt_property ("fontsize");
-      int i = (sz != SCM_UNDEFINED)
+      int i = (gh_number_p (sz))
        ? gh_scm2int  (sz)
        : 0;
 
index 4a3d0ccaa2e98c0eedcb1930c1f704c7057687b5..cc4fd64d35b5a3800f99fe8d61cf7ad5631d53d6 100644 (file)
@@ -39,8 +39,11 @@ Separating_group_spanner::get_rods () const
   
   for (SCM s = get_elt_property ("elements"); gh_pair_p (s) && gh_pair_p (gh_cdr (s)); s = gh_cdr (s))
     {
-      SCM elt = gh_car (s);
-      SCM next_elt = gh_cadr (s);
+      /*
+       Order of elements is reversed!
+       */
+      SCM elt = gh_cadr (s);
+      SCM next_elt = gh_car (s);
 
       Single_malt_grouping_item *l = dynamic_cast<Single_malt_grouping_item*> (unsmob_element (elt));
       Single_malt_grouping_item *r = dynamic_cast<Single_malt_grouping_item*> (unsmob_element ( next_elt));
index b458095aa01fe86755749d07092439921fc7da33..cbb7899ff4d19a9f3b1e77c26202ca8bb70500ef 100644 (file)
@@ -97,7 +97,7 @@ Side_position_interface::side_position (Dimension_cache const * c)
   Direction dir = Side_position_interface (me).get_direction ();
     
   SCM pad = me->remove_elt_property ("padding");
-  if (pad != SCM_UNDEFINED)
+  if (gh_number_p (pad))
     {
       off += gh_scm2double (pad) * dir;
     }
@@ -161,7 +161,7 @@ Side_position_interface::quantised_position (Dimension_cache const *c)
          rp += d;
        }
 
-      return (rp - p) * si.staff_line_leading_f () / 2.0;
+      return (rp - p) * si.staff_space () / 2.0;
     }
   return 0.0;
 }
index d906f84f562bf32f9d8f046dfe5d1fe74ca30cb3..e54f3f971b6e92dc228141b22794490d71209626 100644 (file)
@@ -81,7 +81,7 @@ Spacing_spanner::do_measure (Link_array<Paper_column> cols) const
          SCM next_stretch_hint = rc->get_elt_property ("stretch-distance");      
 
          Real left_distance;
-         if (hint != SCM_UNDEFINED)
+         if (gh_pair_p (hint))
            {
              left_distance = gh_scm2double (gh_cdr (hint)); 
            }
@@ -111,7 +111,7 @@ Spacing_spanner::do_measure (Link_array<Paper_column> cols) const
 
          
          Real right_dist = 0.0;
-         if (next_hint != SCM_UNDEFINED)
+         if (gh_pair_p (next_hint))
            {
              right_dist += - gh_scm2double (gh_car (next_hint));
            }
@@ -142,7 +142,7 @@ Spacing_spanner::do_measure (Link_array<Paper_column> cols) const
          else
            stretch_dist += left_distance;
          
-         if (next_stretch_hint != SCM_UNDEFINED)
+         if (gh_pair_p (next_stretch_hint))
            // see regtest spacing-tight
            stretch_dist += - gh_scm2double (gh_car  (next_stretch_hint));
          else
index bf62e781e0c8a0ec424e0d341e98652711089505..e47791433241b28d949a77d7c6014577db4f5ed3 100644 (file)
@@ -19,7 +19,7 @@ Staff_bar::get_bar_size () const
   else
     {
       Staff_symbol_referencer_interface si (this);
-      return (si.lines_i () -1) * si.staff_line_leading_f ();
+      return (si.lines_i () -1) * si.staff_space ();
     }
 }
 
index 9b2575a30fa8cee8efb34044e55cdf40d571ca3e..3bb94567713d49c31e43369cad1445768e60d999 100644 (file)
@@ -63,11 +63,11 @@ Staff_symbol_engraver::do_removal_processing()
   SCM sz (get_property ("staffLineLeading", 0));
   if (gh_number_p(sz))
     {
-      span_p_->staff_line_leading_f_ = gh_scm2double (sz);
+      span_p_->staff_space_ = gh_scm2double (sz);
     }
   else
     {
-      span_p_->staff_line_leading_f_ = paper_l ()->get_var ("interline");
+      span_p_->staff_space_ = paper_l ()->get_var ("interline");
     }
   span_p_->set_bounds(RIGHT,get_staff_info().command_pcol_l ());
   typeset_element (span_p_);
index 64a46b81170a231df59025f876e80ec34235f27d..5b1f6bba8c8d8f5b62a939ed818126cc0f30b585 100644 (file)
@@ -49,11 +49,11 @@ Staff_symbol_referencer_interface::staff_symbol_l () const
 }
 
 Real
-Staff_symbol_referencer_interface::staff_line_leading_f () const
+Staff_symbol_referencer_interface::staff_space () const
 {
   Staff_symbol * st = staff_symbol_l ();
   if (st)
-    return st->staff_line_leading_f_;
+    return st->staff_space_;
   else if (elt_l_->pscore_l_ && elt_l_->paper_l ())
     elt_l_->paper_l ()->get_var ("interline");
  
@@ -72,7 +72,7 @@ Staff_symbol_referencer_interface::position_f () const
       Real y = elt_l_->relative_coordinate (c, Y_AXIS)
        - st->relative_coordinate (c, Y_AXIS);
 
-      p += 2.0 * y / st->staff_line_leading_f ();
+      p += 2.0 * y / st->staff_space ();
     }
   else
     {
@@ -99,7 +99,7 @@ Staff_symbol_referencer_interface::callback (Dimension_cache const * c)
   Real off =0.0;
   if (gh_number_p (pos))
     {
-      Real space = staff_symbol_referencer_interface (sc).staff_line_leading_f ();
+      Real space = staff_symbol_referencer_interface (sc).staff_space ();
       off = gh_scm2double (pos) * space/2.0;
     }
   sc->set_elt_property ("staff-position", gh_double2scm (0.0));
index bd9d63bbcd93e8eed611ff519960380a1e045efa..7ba3c9e235f6503aa9f12d0034afefde93e87dd7 100644 (file)
@@ -17,7 +17,7 @@
 Staff_symbol::Staff_symbol ()
 {
   no_lines_i_ = 5;
-  staff_line_leading_f_ = 5.0 PT;
+  staff_space_ = 5.0 PT;
 }
 
 void
@@ -53,12 +53,12 @@ Staff_symbol::do_brew_molecule_p() const
   Molecule rule  = lookup_l ()->filledbox (Box (Interval (0,width),
                                                Interval (-t/2, t/2)));
 
-  Real height = (no_lines_i_-1) * staff_line_leading_f_ /2;
+  Real height = (no_lines_i_-1) * staff_space_ /2;
   Molecule * m = new Molecule;
   for (int i=0; i < no_lines_i_; i++)
     {
       Molecule a (rule);
-      a.translate_axis (height - i * staff_line_leading_f_, Y_AXIS);
+      a.translate_axis (height - i * staff_space_, Y_AXIS);
       m->add_molecule (a);
     }
 
@@ -73,7 +73,7 @@ Staff_symbol::steps_i() const
   return no_lines_i_*2;
 }
 Real
-Staff_symbol::staff_line_leading_f ()
+Staff_symbol::staff_space ()
 {
-  return staff_line_leading_f_;
+  return staff_space_;
 }
index 09e490bdff28f2bbd24217a5f3026d6300a94d78..3fa1d0ee0a4afa9acb11ba72cec2e8b8af998400 100644 (file)
@@ -11,7 +11,6 @@
 #include "note-head.hh"
 #include "stem.hh"
 #include "musical-request.hh"
-#include "duration-convert.hh"
 #include "misc.hh"
 #include "stem-tremolo.hh"
 #include "staff-info.hh"
index 700a491854e5410cff2a20177f142a08cb7cb6f7..e244c568acf8eeca533b1e822bb62b371143c821 100644 (file)
@@ -43,7 +43,7 @@ Stem_tremolo::dim_callback (Dimension_cache const *c)
 {
   Stem_tremolo * s = dynamic_cast<Stem_tremolo*> (c->element_l ());
   Real space = Staff_symbol_referencer_interface (s->stem_l ())
-    .staff_line_leading_f ();
+    .staff_space ();
   return Interval (-space, space);
 }
 
@@ -60,7 +60,7 @@ Stem_tremolo::do_brew_molecule_p () const
   
   Real interbeam_f = paper_l ()->interbeam_f (mult);
   Real w  = gh_scm2double (get_elt_property ("beam-width"));
-  Real space = Staff_symbol_referencer_interface (st).staff_line_leading_f ();
+  Real space = Staff_symbol_referencer_interface (st).staff_space ();
   Real internote_f = space / 2;
   Real beam_f = gh_scm2double (get_elt_property ("beam-thickness"));
 
@@ -71,7 +71,7 @@ Stem_tremolo::do_brew_molecule_p () const
     {
       Real dy = 0;
       SCM s = st->beam_l ()->get_elt_property ("height");
-      if (s != SCM_UNDEFINED)
+      if (gh_number_p (s))
        dy = gh_scm2double (s);
       Real dx = st->beam_l ()->last_visible_stem ()->hpos_f ()
        - st->beam_l ()->first_visible_stem ()->hpos_f ();
@@ -99,7 +99,7 @@ Stem_tremolo::do_brew_molecule_p () const
       if (st->beam_l ())
         {
          beams->translate (Offset(st->hpos_f () - hpos_f (),
-           st->stem_end_f () * internote_f - 
+           st->stem_end_position () * internote_f - 
            st->beam_l ()->get_direction () * beams_i * interbeam_f));
        }
       else
@@ -116,7 +116,7 @@ Stem_tremolo::do_brew_molecule_p () const
            ? -st->get_direction () * st->note_delta_f ()/2
            : 0.0;
 
-         dy += st->stem_end_f ();
+         dy += st->stem_end_position ();
          beams->translate (Offset(st->hpos_f () - hpos_f ()+
                                   whole_note_correction, dy));
        }
index b0ef277ba903918d8825c20448e2ce6ddf2b11c7..0f2c8761c3c9d555184fbb68896b2b4aeac10921 100644 (file)
@@ -75,35 +75,41 @@ Stem::head_positions () const
   return r;
 }
 
-Real
-Stem::stem_begin_f () const
-{
-  return yextent_[Direction(-get_direction ())];
-}
 
 Real
 Stem::chord_start_f () const
 {
   return head_positions()[get_direction ()]
-    * Staff_symbol_referencer_interface (this).staff_line_leading_f ()/2.0;
+    * Staff_symbol_referencer_interface (this).staff_space ()/2.0;
 }
 
 Real
-Stem::stem_end_f () const
+Stem::stem_end_position () const
 {
-  return yextent_[get_direction ()];
+  SCM p =get_elt_property ("stem-end-position");
+  Real len;
+  if (!gh_number_p (p))
+    {
+      Stem * me = (Stem*) this;
+      len = get_default_stemlen ();
+      me->set_elt_property ("stem-end-position", gh_double2scm (len));
+    }
+  else
+    len = gh_scm2double (p);
+
+  return len;
 }
 
 void
 Stem::set_stemend (Real se)
 {
   // todo: margins
-  if (get_direction () && get_direction () * head_positions()[get_direction ()] >= se*get_direction ())
+  Direction d= get_direction ();
+  
+  if (d && d * head_positions()[get_direction ()] >= se*d)
     warning (_ ("Weird stem size; check for narrow beams"));
 
-  
-  yextent_[get_direction ()]  =  se;
-  yextent_[Direction(-get_direction ())] = head_positions()[-get_direction ()];
+  set_elt_property ("stem-end-position", gh_double2scm (se));
 }
 
 int
@@ -139,7 +145,6 @@ Stem::first_head () const
   int pos = -inf;              
   Direction dir = get_direction ();
 
-
   Note_head *nh =0;
   for (SCM s = get_elt_property ("heads"); gh_pair_p (s); s = gh_cdr (s))
     {
@@ -149,6 +154,7 @@ Stem::first_head () const
       if (p > pos)
        {
          nh = n;
+         pos = p;
        }
     }
 
@@ -203,12 +209,12 @@ Stem::get_default_dir () const
   return Direction (int(paper_l ()->get_var ("stem_default_neutral_direction")));
 }
 
-void
-Stem::set_default_stemlen ()
+Real
+Stem::get_default_stemlen () const
 {
   Real length_f = 0.;
   SCM scm_len = get_elt_property("length");
-  if (scm_len != SCM_UNDEFINED)
+  if (gh_number_p (scm_len))
     {
       length_f = gh_scm2double (scm_len);
     }
@@ -222,10 +228,15 @@ Stem::set_default_stemlen ()
 
   /* URGURGURG
      'set-default-stemlen' sets direction too
-   */ 
-  if (!get_direction ())
-    set_direction (get_default_dir ());
-
+   */
+  Direction dir = get_direction ();
+  if (!dir)
+    {
+      Stem * me = (Stem*) this;
+      dir = get_default_dir ();
+      me->set_direction (dir);
+    }
+  
   /* 
     stems in unnatural (forced) direction should be shortened, 
     according to [Roush & Gourlay]
@@ -233,18 +244,24 @@ Stem::set_default_stemlen ()
   if (((int)chord_start_f ())
       && (get_direction () != get_default_dir ()))
     length_f -= shorten_f;
+
+  /*
+    UGK.!
+   */
  if (flag_i () >= 5)
     length_f += 2.0;
   if (flag_i () >= 6)
     length_f += 1.0;
+
+
   
-  set_stemend ((get_direction () > 0) ? head_positions()[BIGGER] + length_f:
-              head_positions()[SMALLER] - length_f);
+  Real st = head_positions()[-dir] + dir * length_f;
 
   bool no_extend_b = get_elt_property ("no-stem-extend") != SCM_UNDEFINED;
-  if (!grace_b && !no_extend_b && (get_direction () * stem_end_f () < 0))
-    set_stemend (0);
+  if (!grace_b && !no_extend_b && dir * st < 0)
+    st = 0.0;
+
+  return st;
 }
 
 int
@@ -254,16 +271,8 @@ Stem::flag_i () const
   return  (gh_number_p (s)) ? gh_scm2int (s) : 2;
 }
 
-//xxx
-void
-Stem::set_default_extents ()
-{
-  if (yextent_.empty_b ())
-    set_default_stemlen ();
-}
-
 void
-Stem::set_noteheads ()
+Stem::position_noteheads ()
 {
   if (!first_head ())
     return;
@@ -284,7 +293,7 @@ Stem::set_noteheads ()
       heads[i]->translate_axis (w - heads[i]->extent (X_AXIS)[dir], X_AXIS);
     }
   
-  bool parity= true;
+  bool parity= true;           // todo: make this settable.
   int lastpos = int (Staff_symbol_referencer_interface (heads[0]).position_f ());
   for (int i=1; i < heads.size (); i ++)
     {
@@ -310,9 +319,8 @@ Stem::set_noteheads ()
 void
 Stem::do_pre_processing ()
 {
-  if (yextent_.empty_b ())
-    set_default_extents ();
-  set_noteheads ();
+  get_default_stemlen ();      // ugh. Trigger direction calc.
+  position_noteheads ();
 
   if (invisible_b ())
     {
@@ -333,7 +341,6 @@ Stem::do_pre_processing ()
 
    TODO: more advanced: supply height of noteheads as well, for more advanced spacing possibilities
  */
-
 void
 Stem::set_spacing_hints () 
 {
@@ -393,9 +400,17 @@ Molecule*
 Stem::do_brew_molecule_p () const
 {
   Molecule *mol_p =new Molecule;
-  Interval stem_y = yextent_;
+
+  Staff_symbol_referencer_interface si (first_head ());
+  
+  Real y1 = si.position_f();
+  Real y2 = stem_end_position ();
+  
+  Interval stem_y(y1,y2);
+  stem_y.unite (Interval (y2,y1));
+
   Real dy = staff_symbol_referencer_interface (this)
-    .staff_line_leading_f ()/2.0;
+    .staff_space ()/2.0;
 
   Real head_wid = 0;
   if (support_head ())
@@ -472,17 +487,18 @@ Stem::calc_stem_info () const
     
   Stem_info info; 
   Real internote_f
-     = staff_symbol_referencer_interface (this).staff_line_leading_f ()/2;
-   Real interbeam_f = paper_l ()->interbeam_f (beam_l ()->get_multiplicity ());
+     = staff_symbol_referencer_interface (this).staff_space ()/2;
+  Real interbeam_f = paper_l ()->interbeam_f (beam_l ()->get_multiplicity ());
   Real beam_f = gh_scm2double (beam_l ()->get_elt_property ("beam-thickness"));
          
   info.idealy_f_ = chord_start_f ();
 
   // for simplicity, we calculate as if dir == UP
   info.idealy_f_ *= beam_dir;
-
-  bool grace_b = get_elt_property ("grace") != SCM_UNDEFINED;
-  bool no_extend_b = get_elt_property ("no-stem-extend") != SCM_UNDEFINED;
+  SCM grace_prop = get_elt_property ("grace");
+  bool grace_b = gh_boolean_p (grace_prop) && gh_scm2bool (grace_prop);
+  SCM extend_prop = get_elt_property ("no-stem-extend");
+  bool no_extend_b = gh_boolean_p (extend_prop) && gh_scm2bool (extend_prop);
 
   int stem_max = (int)rint(paper_l ()->get_var ("stem_max"));
   String type_str = grace_b ? "grace_" : "";
@@ -496,8 +512,8 @@ Stem::calc_stem_info () const
     {
       if (beam_l ()->get_multiplicity ())
        {
-         info.idealy_f_ += beam_f;
-         info.idealy_f_ += (beam_l ()->get_multiplicity () - 1) * interbeam_f;
+         info.idealy_f_ += beam_f
+           + (beam_l ()->get_multiplicity () - 1) * interbeam_f;
        }
       info.miny_f_ = info.idealy_f_;
       info.maxy_f_ = INT_MAX;
@@ -517,11 +533,15 @@ Stem::calc_stem_info () const
       */
       if (!grace_b && !no_extend_b)
        {
-         //highest beam of (UP) beam must never be lower than middle staffline
-         info.miny_f_ = info.miny_f_ >? 0;
-         //lowest beam of (UP) beam must never be lower than second staffline
-         info.miny_f_ = info.miny_f_ >? (- 2 * internote_f - beam_f
-                               + (beam_l ()->get_multiplicity () > 0) * beam_f + interbeam_f * (beam_l ()->get_multiplicity () - 1));
+         /* highest beam of (UP) beam must never be lower than middle staffline
+            
+            lowest beam of (UP) beam must never be lower than second staffline
+          */
+         info.miny_f_ =
+           info.miny_f_ >? 0
+           >? (- 2 * internote_f - beam_f
+               + (beam_l ()->get_multiplicity () > 0) * beam_f
+               + interbeam_f * (beam_l ()->get_multiplicity () - 1));
        }
     }
   else
@@ -534,19 +554,18 @@ Stem::calc_stem_info () const
       info.idealy_f_ -= stem_f;
       info.maxy_f_ -= min_stem_f;
     }
-
-  info.idealy_f_ = info.maxy_f_ <? info.idealy_f_;
-  info.idealy_f_ = info.miny_f_ >? info.idealy_f_;
-
-  Real interstaff_f = calc_interstaff_dist (this, beam_l ());
+  
+  info.idealy_f_ = (info.maxy_f_ <? info.idealy_f_) >? info.miny_f_;
 
   SCM s = beam_l ()->get_elt_property ("shorten");
-  if (s != SCM_UNDEFINED)
+  if (gh_number_p (s))
     info.idealy_f_ -= gh_double2scm (s);
 
-  info.idealy_f_ += interstaff_f * beam_dir;
-  info.miny_f_ += interstaff_f * beam_dir;
-  info.maxy_f_ += interstaff_f * beam_dir;
+  Real interstaff_f =  beam_dir* calc_interstaff_dist (this, beam_l ());
+
+  info.idealy_f_ += interstaff_f;
+  info.miny_f_ += interstaff_f;
+  info.maxy_f_ += interstaff_f ;
 
   return info;
 }
index d839410a7e9edd85dbfe7cb47a59f7d8d3ec2429..1d32e746a3f2cb123c3b772f8cc34fea7c63fa51 100644 (file)
@@ -17,7 +17,7 @@ Molecule*
 Text_item::do_brew_molecule_p () const
 {
   SCM style = get_elt_property ("style");
-  String st = (style == SCM_UNDEFINED) ? "" : ly_scm2string (style);
+  String st = gh_string_p (style) ?  ly_scm2string (style) : "";
   
   Molecule a= paper_l ()->lookup_l(0)->text (st, text_str_, paper_l ());
 
index 4ba3e65ab66dda247a4a502457818ceb21dd5c9c..456663699e90fffdaa8bfbdba47b429ea479dad0 100644 (file)
@@ -23,7 +23,7 @@ Time_signature::do_brew_molecule_p () const
 {
   SCM st = get_elt_property ("style");
   
-  if (st != SCM_UNDEFINED)
+  if (gh_string_p (st))
     {
       String style (ly_scm2string (st));
       if (style[0]=='1')
index fb5d6b449915c385572abe1ff07feb49fdb2e5dd..6271a01a7fff54ee5542db558fc3bbdf69b630d9 100644 (file)
@@ -129,9 +129,8 @@ Translator_group::find_existing_translator_l (String n, String id)
   if (is_alias_b (n) && (id_str_ == id || id.empty_b ()))
     return this;
 
-
   Translator_group* r = 0;
-  for (Cons<Translator> *p = trans_p_list_.head_; p; p = p->next_)
+  for (Cons<Translator> *p = trans_p_list_.head_; !r && p; p = p->next_)
     {
       if (Translator_group *trg =  dynamic_cast <Translator_group *> (p->car_))
        r = trg->find_existing_translator_l (n, id);
index 3b9565ce1102e9e089ed74aa8cdc4e62d46f9c3e..26cdb6948b8d98a772dfce0cf529f3fe7004b8b9 100644 (file)
@@ -140,11 +140,12 @@ Tuplet_spanner::get_default_dir () const
 {
   Direction d = UP;
   SCM dir_sym =get_elt_property ("dir-forced");
-  if (dir_sym != SCM_UNDEFINED) {
-    d= (Direction) gh_scm2int (dir_sym);
-    if (d != CENTER)
-      return d;
-  }
+  if (gh_number_p (dir_sym))
+    {
+      d= (Direction) gh_scm2int (dir_sym);
+      if (d != CENTER)
+       return d;
+    }
 
   for (SCM s = get_elt_property ("columns"); gh_pair_p (s); s = gh_cdr (s))
     {
diff --git a/midi2ly/duration-convert.cc b/midi2ly/duration-convert.cc
new file mode 100644 (file)
index 0000000..ac46fd7
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+  duration-convert.cc -- implement Duration_convert
+
+  source file of the LilyPond music typesetter
+
+  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+          Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+#include <assert.h>
+#include "duration-convert.hh"
+#include "duration-iter.hh"
+#include "warn.hh"
+
+// statics Duration_convert
+bool const Duration_convert::midi_as_plet_b_s = true;
+bool Duration_convert::no_quantify_b_s = false;
+bool Duration_convert::no_double_dots_b_s = false;
+bool Duration_convert::no_triplets_b_s = false;
+int Duration_convert::no_smaller_than_i_s = 0;
+Array<Duration> Duration_convert::dur_array_s;
+       
+String 
+Duration_convert::dur2_str (Duration dur)
+{
+  if (dur.ticks_i_)
+    return String ("[") + to_str (dur.ticks_i_) + "]";
+  
+  String str;
+  if (dur.durlog_i_ >= 0)
+    str = to_str ( type2_i (dur.durlog_i_) );
+  else if (dur.durlog_i_ == -1)
+    str = "\\breve";
+  else if (dur.durlog_i_ == -2)
+    str = "\\longa";
+  str += to_str ('.', dur.dots_i_);
+  if (dur.plet_b ())
+    str += String ("*") + to_str (dur.plet_.iso_i_)
+      + String ("/") + to_str (dur.plet_.type_i_);
+  return str;
+}
+
+int
+Duration_convert::dur2ticks_i (Duration dur)
+{
+  if (dur.ticks_i_)
+    return dur.ticks_i_;
+  return dur2_mom (dur) * Rational (Duration::division_1_i_s);
+}
+
+int
+Duration_convert::i2_type (int i)
+{
+  int t=0;
+  while (i && !(i & 1)) {
+    i >>= 1;
+    t++;
+  }
+  return t;
+}
+
+int
+Duration_convert::type2_i (int type)
+{
+  if (type<0)
+    return 0; 
+  else
+    return 1 << type;
+}
+
+Rational
+Duration_convert::dur2_mom (Duration dur)
+{
+  if (dur.ticks_i_)
+    return Rational (dur.ticks_i_, Duration::division_1_i_s);  
+
+  // or simply assert?
+  if (dur.durlog_i_<-10)
+    return Rational (0);
+  Rational mom;
+  if (dur.durlog_i_<0)
+    mom = Rational (type2_i (-dur.durlog_i_), 1);
+  else
+    mom = Rational (1 , type2_i (dur.durlog_i_));
+
+  Rational delta = mom;
+  while (dur.dots_i_--) 
+    {
+      delta /= 2.0;
+      mom += delta;
+    }
+
+  return mom * plet_factor_mom (dur);    
+}
+
+Duration
+Duration_convert::mom2_dur (Rational mom)
+{
+  if (!mom) 
+    {
+      Duration dur;
+      dur.set_plet (0,1);
+      return dur;
+    }
+       
+
+  Duration dur = mom2standardised_dur (mom);
+  //   if (!dur.mom () || (dur.mom () == mom))
+  if (!dur.length_mom () || (dur.length_mom () == mom))
+    return dur;
+  assert (midi_as_plet_b_s);
+
+  //   dur.set_plet (type_mom, Duration::division_1_i_s / 4); 
+
+  //   Rational as_plet_mom = mom / dur.mom ();
+  Rational as_plet_mom = mom / dur.length_mom ();
+  as_plet_mom *= dur.plet_.mom ();
+  long num = as_plet_mom.num ();
+  long den = as_plet_mom.den ();
+  dur.set_plet (num, den);
+  return dur;
+}
+
+Duration
+Duration_convert::mom2standardised_dur (Rational mom)
+{
+  //   if (!dur_array_s.length_i ())
+  if (!dur_array_s.size ())
+    set_array ();
+  assert (dur_array_s.size ());
+  for (int i = 0; i < dur_array_s.size () - 1; i++) 
+    {
+      Rational lower_mom = dur2_mom (dur_array_s[ i ]);
+      if (mom <= lower_mom) 
+       {
+         // all arbitrary, but 3/4 will get rid of the noise...
+         // kinda ok
+         if (i || (mom / lower_mom > Rational (3, 4)))
+           return dur_array_s[ i ];
+         else 
+           {
+             Duration d;
+             d.durlog_i_ = -100;
+             return d;
+           }
+       }
+      Rational upper_mom = dur2_mom (dur_array_s[ i + 1 ]);
+      if ((mom < upper_mom)
+         && ((mom - lower_mom) / lower_mom
+             < (upper_mom - mom) / upper_mom))
+       return dur_array_s[ i ];
+    }
+  return dur_array_s[ dur_array_s.size () - 1 ];
+}
+
+void
+Duration_convert::set_array ()
+{
+  dur_array_s.clear ();
+
+  Duration_iterator iter_dur;
+  assert (iter_dur);
+  while (iter_dur)
+    dur_array_s.push (iter_dur++);
+}
+
+
+Rational
+Duration_convert::plet_factor_mom (Duration dur)
+{
+  return dur.plet_.mom ();
+}
+
+Real
+Duration_convert::sync_f (Duration dur, Rational mom)
+{
+  return mom / dur2_mom (dur);
+}
+
+Duration
+Duration_convert::ticks2_dur (int ticks_i)
+{
+  Rational mom (ticks_i, Duration::division_1_i_s);
+  if (midi_as_plet_b_s)
+    return mom2_dur (mom);
+
+  Duration dur = mom2standardised_dur (mom);
+
+  if (dur.length_mom () == mom)
+    return dur;
+               
+  return mom2_dur (mom);
+}
+
+Duration
+Duration_convert::ticks2standardised_dur (int ticks_i)
+{
+  Rational mom (ticks_i, Duration::division_1_i_s);
+  Duration dur = mom2standardised_dur (mom);
+  return dur;
+}
diff --git a/midi2ly/duration-iter.cc b/midi2ly/duration-iter.cc
new file mode 100644 (file)
index 0000000..abb467d
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+  duration-convert.cc -- implement Duration_convert
+
+  source file of the LilyPond music typesetter
+
+  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+          Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+#include <assert.h>
+#include "duration-convert.hh"
+#include "warn.hh"
+#include "duration-iter.hh"
+
+Duration_iterator::Duration_iterator ()
+{
+  cursor_dur_.durlog_i_ = 7;
+  if (Duration_convert::no_smaller_than_i_s)
+    cursor_dur_.durlog_i_ = Duration_convert::no_smaller_than_i_s;
+}
+
+Duration 
+Duration_iterator::operator ++(int)
+{
+  return forward_dur ();
+}
+
+Duration
+Duration_iterator::operator ()()
+{
+  return dur ();
+}
+
+Duration_iterator::operator bool ()
+{
+  return ok ();
+}
+
+Duration
+Duration_iterator::dur ()
+{
+  return cursor_dur_;
+}
+
+Duration
+Duration_iterator::forward_dur ()
+{
+  /* should do smart table? guessing: 
+     duration wholes
+     16        0.0625
+     32..      0.0703
+     8:2/3     0.0833
+     16.       0.0938
+     8 0.1250
+     16..      0.1406
+     4:2/3     0.1667
+     8.        0.1875
+               
+     */
+  assert (ok ());
+
+  Duration dur = cursor_dur_;
+
+  if (!cursor_dur_.dots_i_ && !cursor_dur_.plet_b ()) 
+    {
+      cursor_dur_.durlog_i_ += 1;
+      cursor_dur_.dots_i_ = 2;
+    }
+  else if (cursor_dur_.dots_i_ == 2) 
+    {
+      assert (!cursor_dur_.plet_b ());
+      cursor_dur_.dots_i_ = 0;
+      cursor_dur_.durlog_i_ -=2;
+      cursor_dur_.set_plet (2, 3);
+    }
+  else if (cursor_dur_.plet_b () 
+          && (cursor_dur_.plet_.iso_i_ == 2)
+          && (cursor_dur_.plet_.type_i_ == 3)) 
+    {
+      assert (!cursor_dur_.dots_i_);
+      cursor_dur_.set_plet (1, 1);
+      cursor_dur_.durlog_i_ += 1;
+      cursor_dur_.dots_i_ = 1;
+    }
+  else if (cursor_dur_.dots_i_ == 1) 
+    {
+      assert (!cursor_dur_.plet_b ());
+      cursor_dur_.dots_i_ = 0;
+      cursor_dur_.durlog_i_ -= 1;
+    }
+               
+  if (Duration_convert::no_triplets_b_s
+      && cursor_dur_.plet_b () && ok ())
+    forward_dur ();
+  if (Duration_convert::no_double_dots_b_s 
+      && (cursor_dur_.dots_i_ == 2) && ok ())
+    forward_dur ();
+  if (Duration_convert::no_smaller_than_i_s
+      && (cursor_dur_.durlog_i_ > Duration_convert::no_smaller_than_i_s) && ok ())
+    forward_dur ();
+  if (Duration_convert::no_smaller_than_i_s
+      && cursor_dur_.dots_i_
+      && (cursor_dur_.durlog_i_ >= Duration_convert::no_smaller_than_i_s)
+      && ok ())
+    forward_dur ();
+  if (Duration_convert::no_smaller_than_i_s
+      && (cursor_dur_.dots_i_ == 2)
+      && (cursor_dur_.durlog_i_ >= Duration_convert::no_smaller_than_i_s / 2)
+      && ok ())
+    forward_dur ();
+
+  return dur;
+}
+
+bool
+Duration_iterator::ok ()
+{
+  return cursor_dur_.length_mom () <= Rational (4);
+}
diff --git a/midi2ly/duration.cc b/midi2ly/duration.cc
new file mode 100644 (file)
index 0000000..b2a5f84
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+  duration.cc -- implement Duration, Plet, 
+
+  source file of the LilyPond music typesetter
+
+  (c)  1997--1999 Jan Nieuwenhuizen <janneke@gnu.org>
+           Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+
+  UGH. Duration is broken.
+*/
+
+#include <assert.h>
+
+#include "proto.hh"
+#include "string.hh"
+#include "source-file.hh"
+#include "source.hh"
+#include "rational.hh"
+#include "duration.hh"
+#include "duration-convert.hh"
+#include "duration-iter.hh"
+
+// statics Duration
+int Duration::division_1_i_s = 384 * 4;
+
+
+Duration::Duration ()
+{
+  durlog_i_ = 0;
+  dots_i_ = 0;
+  ticks_i_ = 0;
+}
+
+bool
+Duration::duration_type_b (int t)
+{
+  /*
+    ugh. Assuming behavior of conversion funcs on broken input.
+   */
+  return t == Duration_convert::type2_i (Duration_convert::i2_type (t));
+}
+
+void
+Duration::compress (Rational m)
+{
+  plet_.iso_i_ *= m.num_i ();
+  plet_.type_i_ *= m.den_i (); 
+}
+
+Rational
+Duration::length_mom () const
+{
+  return Duration_convert::dur2_mom (*this);
+}
+
+void
+Duration::set_plet (int i, int t)
+{
+  plet_.iso_i_ = i; 
+  plet_.type_i_ = t;
+}
+
+/*
+void
+Duration::set_plet (Duration d)
+{
+  plet_.iso_i_ = d.plet_.iso_i_; 
+  plet_.type_i_ = d.plet_.type_i_;
+}
+*/
+
+void
+Duration::set_ticks (int ticks_i)
+{
+  assert (durlog_i_ <10);
+  assert (!dots_i_);
+  ticks_i_ = ticks_i;
+}
+
+String
+Duration::str () const
+{
+  return Duration_convert::dur2_str (*this);
+}
+
+
+bool
+Duration::plet_b ()
+{
+  return !plet_.unit_b ();
+}
+
diff --git a/midi2ly/include/duration-convert.hh b/midi2ly/include/duration-convert.hh
new file mode 100644 (file)
index 0000000..980c62a
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+  duration-convert.hh -- declare Duration_convert
+
+  source file of the LilyPond music typesetter
+
+  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+
+#ifndef DURATION_CONVERT_HH
+#define DURATION_CONVERT_HH
+#include "duration.hh"
+#include "string.hh"
+#include "array.hh"
+
+/**
+       Duration_convert handles all conversions to -n fro Duration (dur).
+       That is including (integer + division) representation for MIDI,
+       and conversion from unexact time representation (best guess :-).
+
+       A Rational (mom) is a Rational that holds the time fraction 
+       compared to a whole note (before also called wholes).
+
+       [todo]
+       move all statics to real members, instantiate Duration_convert
+       object (s).
+*/
+struct Duration_convert {
+       
+  /* Urgh. statics.
+   */
+  static bool const midi_as_plet_b_s;
+  static bool no_quantify_b_s;
+  static bool no_double_dots_b_s;
+  static bool no_triplets_b_s;
+  static int no_smaller_than_i_s;
+  static Array<Duration> dur_array_s;
+
+  /// Return number of ticks in (ticks, division_1) representation
+  static int dur2ticks_i (Duration dur );
+       
+  /// Return the type_i representation of note length i
+  static int i2_type (int i);
+
+  /// Return the note length corresponding to the type_i representation
+  /// Return 0 if longer than whole note.
+  static int type2_i (int type);
+
+  /// Return Rational representation (fraction of whole note).
+  static Rational dur2_mom (Duration dur );
+
+  /// Return Mudela string representation.
+  static String dur2_str (Duration dur );
+
+  /// Return duration from Rational (fraction of whole) representation.
+  static Duration mom2_dur (Rational mom );
+
+  /// Return standardised duration, best guess if not exact.
+  static Duration mom2standardised_dur (Rational mom );
+  
+  /// Return plet factor (not a Rational: should use Rational?).
+  static Rational plet_factor_mom (Duration dur );
+
+  static void set_array ();
+
+  /** Return synchronisation factor for mom, so that
+      mom2_dur (mom / sync_f ) will return the duration dur.           
+  */ 
+  static Real sync_f (Duration dur, Rational mom );
+
+  /// Return exact duration, in midi-ticks if not-exact.
+  static Duration ticks2_dur (int ticks_i );
+
+  /// Return standardised duration, best guess if not exact.
+  static Duration ticks2standardised_dur (int ticks_i );
+};
+
+
+#endif // DURATION_CONVERT_HH
diff --git a/midi2ly/include/duration-iter.hh b/midi2ly/include/duration-iter.hh
new file mode 100644 (file)
index 0000000..5dd9c4a
--- /dev/null
@@ -0,0 +1,47 @@
+/*   
+  duration-iter.hh -- declare Duration_iterator
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.ruu.nl>
+  
+ */
+
+#ifndef DURATION_ITER_HH
+#define DURATION_ITER_HH
+
+/// (iter_dur)
+struct Duration_iterator {
+  
+  /// start at shortest: 128:2/3
+  Duration_iterator ();
+
+  // **** what about these three here ?
+  /// return forward_dur ();
+  Duration operator ++(int); 
+
+  /// return ok ()
+  operator bool (); 
+
+  /// return dur ()
+  Duration operator ()(); 
+
+
+  /// return current dur
+  Duration dur ();
+
+  /// return dur (), step to next
+  Duration forward_dur ();
+
+  /// durations left?
+  bool ok ();
+
+private:
+
+  Duration cursor_dur_;
+};
+
+
+
+#endif /* DURATION_ITER_HH */
+
diff --git a/midi2ly/include/duration.hh b/midi2ly/include/duration.hh
new file mode 100644 (file)
index 0000000..28580b6
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+  duration.hh -- declare Duration
+  
+  source file of the LilyPond music typesetter
+
+  (c)  1997--1999 Jan Nieuwenhuizen <janneke@gnu.org>
+
+*/
+
+// split into 4?
+
+#ifndef DURATION_HH
+#define DURATION_HH
+
+#include "fproto.hh"
+#include "rational.hh"
+#include "plet.hh"
+
+/**
+   Handle "musical" durations. This means: balltype 1,2,4,etc. and dots.
+   
+  (dur)
+  */
+struct Duration {
+  Duration ();
+  /// is the "plet factor" of this note != 1 ?
+  bool plet_b ();
+  String str () const;
+  void set_plet (int,int );
+  void compress (Rational);
+
+  static bool duration_type_b (int t);
+  void set_ticks (int ticks_i );
+  Rational length_mom () const ;
+  static int division_1_i_s;
+
+  /// Logarithm of the base duration.
+  int durlog_i_;
+  int dots_i_;
+  Plet plet_;
+  int ticks_i_;
+};
+#endif // DURATION_HH
+
diff --git a/midi2ly/include/plet.hh b/midi2ly/include/plet.hh
new file mode 100644 (file)
index 0000000..42ef83b
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+  plet.hh -- declare Plet
+
+  source file of the GNU LilyPond music typesetter
+
+  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+
+#ifndef PLET_HH
+#define PLET_HH
+#include "rational.hh"
+
+/** 
+  The type and replacement value of a  plet (triplet, quintuplet.) Conceptually the same as a rational, but 4/6 != 2/3.
+  
+  (plet)
+ */
+struct Plet {
+  Plet ();
+  Rational mom () const;
+  bool unit_b () const;
+  int iso_i_;  // 2/3; 2 is not duration, maar of count!
+  int type_i_; 
+};
+
+#endif // PLET_HH
diff --git a/midi2ly/plet.cc b/midi2ly/plet.cc
new file mode 100644 (file)
index 0000000..e567515
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+  plet.cc -- implement Plet
+
+  source file of the GNU LilyPond music typesetter
+
+  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+#include "plet.hh"
+
+
+Plet::Plet ()
+{
+  type_i_ = 1;
+  iso_i_ = 1;
+}
+
+Rational
+Plet::mom () const
+{
+  return  Rational (iso_i_, type_i_);
+}
+
+bool
+Plet::unit_b () const
+{
+  return type_i_ == 1 && iso_i_ == 1;
+}
+