]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 0.1.12.jcn2: kliener pats
authorJan Nieuwenhuizen <janneke@gnu.org>
Fri, 5 Sep 1997 07:44:56 +0000 (09:44 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Fri, 5 Sep 1997 07:44:56 +0000 (09:44 +0200)
pl 12.jcn2
- typesetting abbreviation beams; abbreviation-*
- some simple abbrev fixes + code cleanup (dank je, lieverd)

pl 12.jcn1
- typesetting simple abbreviations: c4:16 === [c16 c c c]

47 files changed:
Documentation/lilypond.pod
NEWS
VERSION
bin/convert-mudela.in
init/engraver.ly
init/paper20.ly
init/symbol.ly
input/abbrev.ly [new file with mode: 0644]
input/cadenza.ly
input/collisions.ly
input/coriolan-alto.ly
input/fugue1.ly
input/keys.ly
input/kortjakje.ly
input/multi.ly
input/pedal.ly
input/prelude1.ly
input/rhythm.ly
input/scales.ly
input/scripts.ly
input/scsii-menuetto.ly
input/slurs.ly
input/standchen.ly
input/toccata-fuga-E.ly
input/twinkle-pop.ly
input/twinkle.ly
input/wohltemperirt.ly
lily/abbreviation-beam-engraver.cc [new file with mode: 0644]
lily/abbreviation-beam.cc [new file with mode: 0644]
lily/beam-grav.cc
lily/beam.cc
lily/include/abbreviation-beam-engraver.hh [new file with mode: 0644]
lily/include/abbreviation-beam.hh [new file with mode: 0644]
lily/include/beam.hh
lily/include/lily-proto.hh
lily/include/musical-request.hh
lily/include/my-lily-parser.hh
lily/include/stem-grav.hh
lily/include/stem-info.hh [new file with mode: 0644]
lily/include/stem.hh
lily/musical-request.cc
lily/my-lily-parser.cc
lily/parser.y
lily/stem-grav.cc
lily/stem-info.cc [new file with mode: 0644]
lily/stem.cc
mi2mu/mudela-stream.cc

index c2d26569354600196d85ced6763d45a837a60b9f..1142476eb95fc8261a3fb9998170d91464d29be3 100644 (file)
@@ -43,17 +43,17 @@ Set the default output file to F<FILE>.
 
 Show a summary of usage.
 
-=item B<-i,--init=>F<FILE>
+=item B<-i,--init=>F<FILE>,
 
-set init file to F<FILE> (default: F<symbol.ly>).
+Set init file to F<FILE> (default: F<symbol.ly>).
 
-=item B<--include, -I>=F<DIRECTORY>
+=item B<--include, -I>=F<DIRECTORY>,
 
-add F<DIRECTORY> to the search path for input files.
+Add F<DIRECTORY> to the search path for input files.
 
-=item B<--ignore-version, -V>
+=item B<--ignore-version, -V>,
 
-make incompatible mudela version non-fatal.
+Make incompatible mudela version non-fatal.
 
 =back
 
@@ -79,27 +79,27 @@ MIDI to Mudela conversion through the mi2mu program.
 
 =item *
 
-Multiple staffs in one score.  Each staff can have different meters.
+Multiple staffs in one score.  Each staff can have different meters.
 
 =item *
 
-beams, slurs, ties, chords, super/subscripts (accents and text),
+Beams, slurs, ties, chords, super/subscripts (accents and text)
 triplets, general n-plet (triplet, quadruplets, etc.), lyrics,
-transposition dynamics (both absolute and hairpin style)
+transposition dynamics (both absolute and hairpin style).
 
 =item *
 
-multiple voices within one staff; beams optionally shared
+Multiple voices within one staff; beams optionally shared
 between voices.  Up to four voices is handled cleanly.
 
 =item *
 
-multiple scores within one input file.  Each score is output to
+Multiple scores within one input file.  Each score is output to
 a different file.
 
 =item *
 
-clef changes, meter changes, cadenza-mode, key changes, repeat bars
+Clef changes, meter changes, cadenza-mode, key changes, repeat bars.
 
 =back
 
@@ -139,11 +139,11 @@ general, try to find out
 
 =item *
 
-if the bug has been fixed in a newer release.  
+If the bug has been fixed in a newer release.  
 
 =item *
 
-if the bug has been found earlier, consult F<TODO> and F<BUGS>
+If the bug has been found earlier, consult F<TODO> and F<BUGS>.
 
 =back 
 
@@ -152,20 +152,20 @@ If you have found a bug, then you should send a bugreport.
 =over 4
 
 =item *
-send a copy of the input which causes the error
+Send a copy of the input which causes the error.
 
 =item *
-send a description of the platform you use
+Send a description of the platform you use.
 
 =item *
-send a description of the LilyPond version you use (with
-compile/configure options please)
+Send a description of the LilyPond version you use (with
+compile/configure options please).
 
 =item *
-send a description of the bug itself.
+Send a description of the bug itself.
 
 =item *
-send it to bug-gnu-music@vuse.vanderbilt.edu
+Send it to bug-gnu-music@vuse.vanderbilt.edu.
 
 =back
 
diff --git a/NEWS b/NEWS
index d86ec1c927d7c25f6a427dafd62a17fcb58b68ed..a40a867874f812e6b09a3740d6e2b178bab3c13d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+pl 12.jcn2
+       - typesetting abbreviation beams; abbreviation-*
+       - some simple abbrev fixes + code cleanup (dank je, lieverd)
+
+pl 12.jcn1
+       - typesetting simple abbreviations: c4:16 === [c16 c c c]
+
 pl 12
        - bf: don't redefine tex primitives like \textfont and  \mathfont
        - nicer broken slurs (?)
diff --git a/VERSION b/VERSION
index 1ae5036c7daa8cd6db33d05c759c08bb49071ed3..d02c76a40aa0d4de1acafe52955030748d9a46c1 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -3,4 +3,4 @@ TOPLEVEL_MINOR_VERSION = 1
 TOPLEVEL_PATCH_LEVEL = 12
 
 # use to send patches, always empty for released version:
-TOPLEVEL_MY_PATCH_LEVEL = 
+TOPLEVEL_MY_PATCH_LEVEL = .jcn2
index bad1df51ec2d9ed9b92d89d974f37f022c51c1bf..98d858a308804007ef54f1920390c006c1df41d9 100644 (file)
@@ -19,7 +19,7 @@ Ugh . Perl sux. Anybody for Python?
 
 
 
-$convert_mudela_version = "0.1.1";
+$convert_mudela_version = "0.1.2";
 
 use Getopt::Long;
 
@@ -110,6 +110,7 @@ sub convert_0_1_0_to_0_1_1
 {
     s/\\tempo (.*):(.*);/\\tempo $1 = $2;/g
 }
+
 ###############################################################
 
 sub    last_conversion
@@ -135,7 +136,7 @@ sub identify
      . "  -h, --help             print this help\n"
      . "  -o, --output=FILE      name output file\n"
      . "  -s, --show-rules       print all known conversion rules\n"
-     . "  -t, --to=VERSION    convert to version VERSION\n"
+     . "  -t, --to=VERSION       convert to version VERSION\n"
   }
       
 
@@ -150,7 +151,8 @@ my %minor_conversions = ("0.0.50" => \&no_conv,
                         "0.0.59" => \&convert_0_0_58_to_0_0_59,
                         "0.0.60" => \&convert_0_0_59_to_0_0_60,
                         "0.0.61" => \&convert_0_0_60_to_0_0_61,
-                        "0.1.1" => \&convert_0_1_0_to_0_1_1
+                        "0.1.1" => \&convert_0_1_0_to_0_1_1,
+                        "0.1.2" => \&no_conv
                         );
  
 
index 359667459f40a3737f1608fe1fb478b972e35443..3c291a9113c6f570348490eb6bef1121d254f12c 100644 (file)
@@ -20,7 +20,8 @@ staff_engraver = \requesttranslator {
                          \alias "Voice_group";
                          \consists "Dynamic_engraver";
                          \consists "Stem_engraver";
-                       \consists "Beam_engraver";
+                         \consists "Beam_engraver";
+                         \consists "Abbreviation_beam_engraver";
                          \consists "Script_engraver";
                          \consists "Note_column_engraver";
                          \consists "Slur_engraver";
index e2878e6de7bbf2a4efe38794232975e485b3b98e..159628e57030b1ad6181adce1c50a2ffc56a243f 100644 (file)
@@ -19,7 +19,7 @@ paper_twenty = \paper {
         arithmetic_multiplier = 6.\pt;
        
        %
-       interbeam = 2.667\pt;
+       interbeam = 3.333\pt;
        gourlay_energybound = 100000.;
        gourlay_maxmeasures = 12.;
        
index 2474f20c432d7b15e0ca0d28119172a19abc4cde..3062d2d961bf906478011c77eebae52222b9e1ba 100644 (file)
@@ -1,6 +1,6 @@
 % symbol.ly
   
-\version "0.1.1";
+\version "0.1.2";
   
 breve = \duration { -1 0 }
 longa = \duration { -2 0 }
diff --git a/input/abbrev.ly b/input/abbrev.ly
new file mode 100644 (file)
index 0000000..d417267
--- /dev/null
@@ -0,0 +1,40 @@
+%{MudelaHeader
+
+ filename: abbrev.ly
+ title: 
+ description: 
+ composer(s): 
+ entered-by: jcn
+ copyright: PD
+
+ Tested Features: simple abbreviations
+EndMudelaHeader
+%}
+
+\version "0.1.2";
+
+\score{
+       \melodic{ 
+               \octave c'';
+               \meter 4/4;
+               'a1
+               'a1:32
+               'c4:8 c' 'c4:16 c'
+               [ 'c8:16 'c 'c 'c ] [ a a a a ]
+               [ 'c 'f 'b e ] 
+               [ 'c16:32 'c 'c 'c ] [ a16:32 a a a ]
+%%             % there's still some hairy beam bugfixing todo
+%%             [ c'8:16 g d 'a ]
+%%             [ c'16:32 g d 'a ]
+%%             [ 'c8:32 'f 'b e ]
+               [:16 c4 e]
+               [:16 e4 g]
+               [:16 e2 g]
+               [:16 e1 g]
+       }
+       \paper{ 
+       }
+% oeps
+       \midi{ }
+}
+
index 9c96602041f350f6893f371b2cac813ee2679170..d817aea062cb20610303790e4753274677060395 100644 (file)
@@ -11,7 +11,7 @@ copyright     public domain
 Tested Features: cadenza mode
 %}
 
-\version "0.1.1";
+\version "0.1.2";
 
 
 cad = \melodic  {\id "Staff" "french horn";
index 2a9505752b4b56ec4601028b320c4f7299f8a9ea..4bf20ce8c8526a3949c769f4d59feb73571afd4b 100644 (file)
@@ -10,7 +10,7 @@
  Tested Features:test the Collision resolution 
 EndMudelaHeader
 %}
-\version "0.1.1";
+\version "0.1.2";
 
 
 
index 8dc5c69796ddf8eb7a73906d725bd38cf784eeaa..ffee788c298e3a6a6a6e9d6bd95798bb1476259a 100644 (file)
@@ -17,7 +17,7 @@ EndMudelaHeader
 % (maybe even sooner :-)
 %
 
-\version "0.1.1";
+\version "0.1.2";
 
 alto = \melodic{ 
        
index f3d8fb0c03b635cf0d6b23ba5ef2faf06da22858..bc1ac70735bf2919a32cadc97257351b1a82aee4 100644 (file)
@@ -11,7 +11,7 @@ copyright             Public Domain
 %{
        
 %}
-\version "0.1.1";
+\version "0.1.2";
 
 
 global = 
index 5d79a702234766c00162a59cfe905d977d728dba..1b82f12361326ab6e629acd55391f66c8813e3ab 100644 (file)
@@ -10,7 +10,7 @@
  Tested Features: local key, key, forced accidentals
 EndMudelaHeader
 %}
-\version "0.1.1";
+\version "0.1.2";
 
 
 blah = \melodic{
index acba0091eb2d72a9ad9445e70ea9bb841aa14c6b..236d53ad366e0f14eca71dda956c36e15c898ade 100644 (file)
@@ -11,7 +11,7 @@ copyright             public domain
 Tested Features: example file with comments
 
 %}
-\version "0.1.1";
+\version "0.1.2";
 
 
 % the % is a comment.
index 6c0a8fe03f296afaf2084d7bbfde09e0030afbbb..de46690d5b58cda34205a7c02864318f8adbfb1a 100644 (file)
@@ -10,7 +10,7 @@ Tested Features: \multi
 %}
 
 
-\version "0.1.1";
+\version "0.1.2";
 
 \score{
        \melodic 
index 76ef37688453084b90352867f0e480e76859a25d..60ad7e12443e56a17e89f7346415d48ba4570286 100644 (file)
@@ -24,7 +24,7 @@
 % \lbheel \lbheel \lfheel \lftoe
 % \rbheel \rbtoe \rfheel \rftoe
 
-\version "0.1.1";
+\version "0.1.2";
 
 \score{
                \melodic {
index da66d87d813f51707e1b165c4a55f51a63589973..a032b943fa426e2d6f524126ad8de55d18beac48 100644 (file)
@@ -9,7 +9,7 @@ enteredby               Shay Rojansky
 copyright              Public Domain"
 }
 
-\version "0.1.1";
+\version "0.1.2";
 
                                     % should add \need{dutch.ini} for
                                     % correct parsing of note names
index 8f897af1263cf8dfcf8f76288bcb5d34f636cd8d..75c5f54e05c9c945ce8c96e8ec5bb7b213e0c489 100644 (file)
@@ -12,7 +12,7 @@ has to be revised for 0.1.12
 
 
 
-\version "0.1.1";
+\version "0.1.2";
 
 ritme = \melodic{ %\octave ;
        \partial 8;
index ce2c3ba854c9637919e3af665099acba052a52dd..86a8721c39ce357388211fab0a2043cbb1b8351a 100644 (file)
@@ -12,7 +12,7 @@ EndMudelaHeader
 % scales with accents.
 %
 
-\version "0.1.1";
+\version "0.1.2";
 blah =         \melodic {
                \meter 6/8;     
                \octave  'c ;
index 8e005edee9355bc089ca321d8824099b3548cffd..9e2cf7ab60bc05b301a5f51625923e619c6b39a6 100644 (file)
@@ -10,7 +10,7 @@
  Tested Features: scripts, text.
 EndMudelaHeader
 %}
-\version "0.1.1";
+\version "0.1.2";
 
 
 blah =         \melodic {
index 72d61415a1d6b840522732feaf4c59fa97a1865c..36af5c2cb7f563acbcc2eadd1885511b525a51ca 100644 (file)
@@ -13,7 +13,7 @@ copyright     public domain
  Tested Features:breaking algorithm, chords, multivoice, accents
 %}
 
-\version "0.1.1";
+\version "0.1.2";
 
 %% Stuff from MPP version
 % \lefttitle{Menuetto}
index b49616ff9e3109e641b160267cfcf446f79669c8..0113beffe2303dd7c323cb20e67b96b61cd278f2 100644 (file)
@@ -11,7 +11,7 @@
 EndMudelaHeader
 %}
 
-\version "0.1.1";
+\version "0.1.2";
 
 \score{
        \melodic{\octave c';
index 23bac1d8629eac2d7c3edb091312f3f24ecb943f..53ad10aa95178ffd88988daeadd0f94dd5df4ec4 100644 (file)
@@ -13,7 +13,7 @@ copyright     public domain
 multiple \paper{}s in one \score 
 %}
 
-\version "0.1.1";
+\version "0.1.2";
 
 commands = \melodic{
        \skip 2.*4;
index 4e75271f8fdfc4f2d1bb36587fd795ac0a715736..15aa64a7c005ff2354ab3d7eee93d3562ae2a667 100644 (file)
@@ -21,7 +21,7 @@ copyright     public domain
 %}
 
 
-\version "0.1.1";
+\version "0.1.2";
 
 toccata_commands = \melodic{
        \meter 4/4;
index 1feeeb2eec6f9d528ae2d4aaa43e11bd86928b24..0d2af26e6cd46a0d911cfe893c671a7ef93cce20 100644 (file)
@@ -12,7 +12,7 @@ copyright             public domain
 Tested Features                lyrics and chords
 %}
 
-\version "0.1.1";
+\version "0.1.2";
 
 melodie = \melodic {
         \clef"violin";
index 588b26a33e6cd231db80762d65e4459361873f81..0a77e1fcb48f037df4e94aae9768d8d2d6c7afa2 100644 (file)
@@ -14,7 +14,7 @@ copyright     public domain
 Tested Features: lyrics
 
 %}
-\version "0.1.1";
+\version "0.1.2";
 
 melody = \melodic{
        \clef violin;
index b3443e8a655188e5050b4470b6abd8dc7cc17d54..9159ed93bf9ac33f84b5c59caa450de2473e9b51 100644 (file)
@@ -12,7 +12,7 @@ copyright             Public Domain
  Tested Features: stem direction, multivoice, forced accidentals.
 %}
 
-\version "0.1.1";
+\version "0.1.2";
 
                                     % should add \need{dutch.ini} for
                                     % correct parsing of note names
diff --git a/lily/abbreviation-beam-engraver.cc b/lily/abbreviation-beam-engraver.cc
new file mode 100644 (file)
index 0000000..76d4e7e
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+  abbreviation-beam-engraver.cc -- implement Abbreviation_beam_engraver
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+           Jan Nieuwenhuizen <jan@digicash.com>
+*/
+
+#include "duration-convert.hh"
+#include "time-description.hh"
+#include "abbreviation-beam-engraver.hh"
+#include "stem.hh"
+#include "abbreviation-beam.hh"
+#include "musical-request.hh"
+#include "misc.hh"
+
+IMPLEMENT_IS_TYPE_B1 (Abbreviation_beam_engraver, Engraver);
+ADD_THIS_ENGRAVER (Abbreviation_beam_engraver);
+
+Abbreviation_beam_engraver::Abbreviation_beam_engraver ()
+{
+  span_reqs_drul_[LEFT] = span_reqs_drul_[RIGHT] = 0;
+  abeam_p_ = 0;
+}
+
+bool
+Abbreviation_beam_engraver::do_try_request (Request*r)
+{
+  Musical_req* mus_l = r->musical ();
+  if (!mus_l)
+    return false;
+  
+  Abbreviation_beam_req * b = mus_l->abbrev_beam ();
+
+  if (!b)
+    return false;
+    
+  if (bool (abeam_p_) == bool (b->spantype == Span_req::START))
+    return false;
+  
+  Direction d = (!abeam_p_) ? LEFT : RIGHT;
+  if (span_reqs_drul_[d] && !span_reqs_drul_[d]->equal_b (mus_l))
+    return false;
+  
+  span_reqs_drul_[d] = b;
+  return true;
+}
+
+void
+Abbreviation_beam_engraver::do_process_requests ()
+{
+  if (!abeam_p_ && span_reqs_drul_[LEFT]) {
+    abeam_p_ = new Abbreviation_beam;
+    announce_element (Score_elem_info (abeam_p_, span_reqs_drul_[LEFT]));
+  }
+}
+
+void
+Abbreviation_beam_engraver::do_pre_move_processing ()
+{
+  if (abeam_p_ && span_reqs_drul_[RIGHT]) {
+    typeset_element (abeam_p_);
+    abeam_p_ = 0;
+
+    span_reqs_drul_[RIGHT] =
+      span_reqs_drul_[LEFT] = 0;
+  }
+}
+
+void
+Abbreviation_beam_engraver::do_removal_processing ()
+{
+  if (abeam_p_) 
+    {
+      span_reqs_drul_[LEFT]->warning ("unterminated beam");
+      typeset_element (abeam_p_);
+      abeam_p_ = 0;
+    }
+}
+
+
+void
+Abbreviation_beam_engraver::acknowledge_element (Score_elem_info i)
+{
+  if (!abeam_p_ || !i.elem_l_->is_type_b (Stem::static_name ()))
+    return;
+
+  Stem* s = (Stem*)i.elem_l_->item ();
+//  Rhythmic_req *rhythmic_req = i.req_l_->musical ()->rhythmic ();
+//  s->flag_i_ = Duration_convert::type2_i (rhythmic_req->duration_.durlog_i_);
+  int type_i = span_reqs_drul_[LEFT]->type_i_;
+  s->flag_i_ = intlog2 (type_i) - 2;
+  if (span_reqs_drul_[RIGHT])
+    s->beams_left_i_ = s->flag_i_;
+  else
+    s->beams_right_i_ = s->flag_i_;
+  abeam_p_->add (s);
+} 
diff --git a/lily/abbreviation-beam.cc b/lily/abbreviation-beam.cc
new file mode 100644 (file)
index 0000000..e47407c
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+  abbreviation-beam.cc -- implement Abbreviation_beam
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+          Jan Nieuwenhuizen <jan@digicash.com>
+*/
+
+#include "p-col.hh"
+#include "varray.hh"
+#include "proto.hh"
+#include "dimen.hh"
+#include "abbreviation-beam.hh"
+#include "misc.hh"
+#include "debug.hh"
+#include "symbol.hh"
+#include "molecule.hh"
+#include "leastsquares.hh"
+#include "stem.hh"
+#include "paper-def.hh"
+#include "lookup.hh"
+#include "stem-info.hh"
+
+
+IMPLEMENT_IS_TYPE_B1 (Abbreviation_beam, Spanner);
+
+Abbreviation_beam::Abbreviation_beam ()
+  : Beam ()
+{
+}
+
+Molecule*
+Abbreviation_beam::brew_molecule_p () const 
+{
+  /* 
+   todo
+   */
+  return Beam::brew_molecule_p ();
+#if 0
+  Molecule *mol_p = new Molecule;
+  // huh? inter-what
+  //    Real inter_f = paper ()->interbeam_f ();
+  Real inter_f = paper ()->internote_f ();
+  Real x0 = stems[0]->hpos_f ();
+  for (int j=0; j <stems.size (); j++) 
+    {
+      Stem *i = stems[j];
+      Stem * prev = (j > 0)? stems[j-1] : 0;
+      Stem * next = (j < stems.size ()-1) ? stems[j+1] :0;
+
+      Molecule sb = stem_beams (i, next, prev);
+      Real  x = i->hpos_f ()-x0;
+      sb.translate (Offset (x, (x * slope  + left_pos)* inter_f));
+      mol_p->add (sb);
+    }
+  mol_p->translate (x0 - spanned_drul_[LEFT]->absolute_coordinate (X_AXIS), X_AXIS);
+  return mol_p;
+#endif
+}
+
+void
+Abbreviation_beam::do_print () const
+{
+#ifndef NPRINT
+  Beam::do_print ();
+  Spanner::do_print ();
+#endif
+}
+
+/*
+  beams to go with one stem.
+  */
+Molecule
+Abbreviation_beam::stem_beams (Stem *here, Stem *next, Stem *prev) const
+{
+  /* 
+   todo
+    - shorter beams (not reaching outer "stems") 
+      for [:16 c4 c4] and [:16 c1 c1]
+    - centered beam on [:16 c1 c1] heads, rather than "stems"
+   */
+  return Beam::stem_beams (here, next, prev);
+}
index dcdce829751a9f4533b749f6196e478a0b9df99f..d3fa191a6cb13137b3e113b6a94e5fbd3ad3af33 100644 (file)
@@ -100,31 +100,29 @@ Beam_engraver::do_removal_processing()
 void
 Beam_engraver::acknowledge_element (Score_elem_info i)
 {
-  if (beam_p_ && i.elem_l_->is_type_b (Stem::static_name()))
+  if (!beam_p_ || !i.elem_l_->is_type_b (Stem::static_name ()))
+    return;
+
+  Stem* s = (Stem*)i.elem_l_->item();
+  Rhythmic_req *rhythmic_req = i.req_l_->musical ()->rhythmic ();
+  if (rhythmic_req->duration_.durlog_i_<= 2) 
     {
-      Stem * s = (Stem*)i.elem_l_->item();
-      Rhythmic_req *rhythmic_req = i.req_l_->musical ()->rhythmic ();
-      if (rhythmic_req->duration_.durlog_i_<= 2) 
-       {
-         rhythmic_req->warning ("Stem doesn't fit in Beam");
-         return ;
-       }
-       
-      /*
-       TODO: do something sensible if it doesn't fit in the beam.
-       */
-      current_grouping_p_->add_child (get_staff_info().time_C_->whole_in_measure_,
-                                     rhythmic_req->duration());
-      /* 
-        TODO
-        should change rep. of flags too.k
-       */
-      s->flag_i_ = Duration_convert::type2_i
-       (rhythmic_req->duration_.durlog_i_);    
-      s->print_flag_b_ = false;
-      beam_p_->add (s);
+      rhythmic_req->warning ("Stem doesn't fit in Beam");
+      return;
     }
+  
+  /*
+    TODO: do something sensible if it doesn't fit in the beam.
+   */
+  current_grouping_p_->add_child (get_staff_info().time_C_->whole_in_measure_,
+                                 rhythmic_req->duration ());
+  /* 
+   TODO
+   should change repr. of flags too.
+   */
+  s->flag_i_ = Duration_convert::type2_i (rhythmic_req->duration_.durlog_i_);
+  beam_p_->add (s);
 } 
-       
+    
 IMPLEMENT_IS_TYPE_B1(Beam_engraver, Engraver);
 ADD_THIS_ENGRAVER(Beam_engraver);
index 927d85cd8d1b94f53f2b47124e08b49cb3cd4ac6..b2b2bc4f4fd4f76e90031c588a601e9e944eb0ea 100644 (file)
 #include "paper-def.hh"
 #include "lookup.hh"
 #include "grouping.hh"
+#include "stem-info.hh"
 
 
+IMPLEMENT_IS_TYPE_B1(Beam, Spanner);
 
-struct Stem_info {
-  Real x;
-  int dir_;
-  Real idealy_f_;
-  Real miny_f_;
-  int beams_i_;
-
-  Stem_info(){}
-  Stem_info (Stem const *);
-};
-
-Stem_info::Stem_info (Stem const *s)
+Beam::Beam()
 {
-  x = s->hpos_f();
-  dir_ = s->dir_;
-  beams_i_ = intlog2(s->flag_i_) - 2;
+  slope = 0;
+  left_pos = 0.0;
+}
 
-  /*
-    [todo] 
-    * get algorithm
-    * runtime
-
-    Breitkopf + H\"artel:
-    miny_f_ = interline + #beams * interbeam
-    ideal8 = 2 * interline + interbeam
-    ideal16,32,64,128 = 1.5 * interline + #beams * interbeam
-
-    * B\"arenreiter:
-    miny_f_ = interline + #beams * interbeam
-    ideal8,16 = 2 interline + #beams * interbeam
-    ideal32,64,128 = 1.5 interline + #beams * interbeam
-       
-    */
+void
+Beam::add (Stem*s)
+{
+  stems.push (s);
+  s->add_dependency (this);
+  s->beam_l_ = this;
 
-  Real notehead_y = s->paper()->interline_f ();
-  // huh? why do i need the / 2
-  //    Real interbeam_f = s->paper()->interbeam_f ();
-  Real interbeam_f = s->paper()->interbeam_f () / 2;
-         
-  /* well eh, huh?
-     idealy_f_  = dir_ * s->stem_start_f() + beams_i_ * interbeam_f; 
-     if (beams_i_ < 3)
-     idealy_f_ += 2 * interline_f;
-     else
-     idealy_f_ += 1.5 * interline_f;
-     */
-
-  idealy_f_  = dir_ * s->stem_end_f();
-
-  miny_f_ = dir_ * s->stem_start_f() + notehead_y + beams_i_ * interbeam_f;
-
-  idealy_f_ =  miny_f_ >? idealy_f_;
-  //    assert (miny_f_ <= idealy_f_);
+  if (!spanned_drul_[LEFT])
+    set_bounds(LEFT,s);
+  set_bounds(RIGHT,s);
 }
 
+Molecule*
+Beam::brew_molecule_p() const 
+{
+  Molecule *mol_p = new Molecule;
+  // huh? inter-what
+  //    Real inter_f = paper()->interbeam_f ();
+  Real inter_f = paper()->internote_f ();
+  Real x0 = stems[0]->hpos_f();
+  for (int j=0; j <stems.size(); j++) 
+    {
+      Stem *i = stems[j];
+      Stem * prev = (j > 0)? stems[j-1] : 0;
+      Stem * next = (j < stems.size()-1) ? stems[j+1] :0;
 
-/* *************** */
-
+      Molecule sb = stem_beams (i, next, prev);
+      Real  x = i->hpos_f()-x0;
+      sb.translate (Offset (x, (x * slope  + left_pos)* inter_f));
+      mol_p->add (sb);
+    }
+  mol_p->translate (x0 - spanned_drul_[LEFT]->absolute_coordinate(X_AXIS), X_AXIS);
+  return mol_p;
+}
 
 Offset
 Beam::center() const
@@ -96,23 +80,47 @@ Beam::center() const
   return Offset (w, (left_pos + w* slope)*paper()->internote_f ());
 }
 
+void
+Beam::do_pre_processing()
+{
+  if (!dir_)
+    set_default_dir();
+}
 
-Beam::Beam()
+void
+Beam::do_print() const
 {
-  slope = 0;
-  left_pos = 0.0;
+#ifndef NPRINT
+  DOUT << "slope " <<slope << "left ypos " << left_pos;
+  Spanner::do_print();
+#endif
 }
 
 void
-Beam::add (Stem*s)
+Beam::do_post_processing()
 {
-  stems.push (s);
-  s->add_dependency (this);
-  s->print_flag_b_ = false;
+  if (stems.size() < 2) 
+    {
+      warning ("Beam with less than 2 stems");
+      transparent_b_ = true;
+      return ;
+    }
+  solve_slope();    
+  set_stemlens();
+}
 
-  if (!spanned_drul_[LEFT])
-    set_bounds(LEFT,s);
-  set_bounds(RIGHT,s);
+void
+Beam::do_substitute_dependent (Score_elem*o,Score_elem*n)
+{
+  if (o->is_type_b (Stem::static_name())) 
+      stems.substitute ((Stem*)o->item(),  n?(Stem*) n->item ():0);
+}
+
+Interval
+Beam::do_width() const
+{
+  return Interval (stems[0]->hpos_f(),
+                  stems.top()->hpos_f ());
 }
 
 void
@@ -236,20 +244,6 @@ Beam::set_stemlens()
     }
 }
 
-
-void
-Beam::do_post_processing()
-{
-  if (stems.size() < 2) 
-    {
-      warning ("Beam with less than 2 stems");
-      transparent_b_ = true;
-      return ;
-    }
-  solve_slope();    
-  set_stemlens();
-}
-
 void
 Beam::set_grouping (Rhythmic_grouping def, Rhythmic_grouping cur)
 {
@@ -285,22 +279,6 @@ Beam::set_grouping (Rhythmic_grouping def, Rhythmic_grouping cur)
     }
 }
 
-void
-Beam::do_pre_processing()
-{
-  if (!dir_)
-    set_default_dir();
-
-}
-
-
-Interval
-Beam::do_width() const
-{
-  return Interval (stems[0]->hpos_f(),
-                  stems.top()->hpos_f ());
-}
-
 /*
   beams to go with one stem.
   */
@@ -368,49 +346,3 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const
   leftbeams.add (rightbeams);
   return leftbeams;
 }
-
-
-Molecule*
-Beam::brew_molecule_p() const 
-{
-  Molecule *mol_p = new Molecule;
-  // huh? inter-what
-  //    Real inter_f = paper()->interbeam_f ();
-  Real inter_f = paper()->internote_f ();
-  Real x0 = stems[0]->hpos_f();
-  for (int j=0; j <stems.size(); j++) 
-    {
-      Stem *i = stems[j];
-      Stem * prev = (j > 0)? stems[j-1] : 0;
-      Stem * next = (j < stems.size()-1) ? stems[j+1] :0;
-
-      Molecule sb = stem_beams (i, next, prev);
-      Real  x = i->hpos_f()-x0;
-      sb.translate (Offset (x, (x * slope  + left_pos)* inter_f));
-      mol_p->add (sb);
-    }
-  mol_p->translate (x0 - spanned_drul_[LEFT]->absolute_coordinate(X_AXIS), X_AXIS);
-  return mol_p;
-}
-
-
-IMPLEMENT_IS_TYPE_B1(Beam, Spanner);
-
-void
-Beam::do_print() const
-{
-#ifndef NPRINT
-  DOUT << "slope " <<slope << "left ypos " << left_pos;
-  Spanner::do_print();
-#endif
-}
-
-void
-Beam::do_substitute_dependent (Score_elem*o,Score_elem*n)
-{
-  if (o->is_type_b (Stem::static_name())) 
-    {
-      stems.substitute ((Stem*)o->item(),  n?(Stem*) n->item ():0);
-    }
-}
diff --git a/lily/include/abbreviation-beam-engraver.hh b/lily/include/abbreviation-beam-engraver.hh
new file mode 100644 (file)
index 0000000..ddea124
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+  abbreviation-beam-engraver.hh -- declare Abbreviation_beam_engraver
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+          Jan Nieuwenhuizen <jan@digicash.com>
+*/
+
+
+#ifndef ABBREVIATION_BEAM_ENGRAVER_HH
+#define ABBREVIATION_BEAM_ENGRAVER_HH
+
+#include "engraver.hh"
+#include "drul-array.hh"
+
+class Abbreviation_beam; // move me to lily-proto
+
+/**
+  Generate an abbreviation beam.  Eat stems.
+ */
+class Abbreviation_beam_engraver : public Engraver
+{
+public:
+  DECLARE_MY_RUNTIME_TYPEINFO;
+
+  Abbreviation_beam_engraver();
+
+protected:
+  virtual void do_removal_processing();
+  virtual void do_process_requests();
+  virtual bool do_try_request (Request*);
+  virtual void acknowledge_element (Score_elem_info);
+  virtual void do_pre_move_processing();
+
+private:
+  Drul_array<Abbreviation_beam_req *> span_reqs_drul_;
+  Abbreviation_beam* abeam_p_;
+};
+
+#endif // ABBREVIATION_BEAM_ENGRAVER_HH
diff --git a/lily/include/abbreviation-beam.hh b/lily/include/abbreviation-beam.hh
new file mode 100644 (file)
index 0000000..9a29de1
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+  abbreviation-beam-engraver.hh -- declare Abbreviation_beam_engraver
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+          Jan Nieuwenhuizen <jan@digicash.com>
+*/
+
+#ifndef ABBREVIATION_BEAM_HH
+#define ABBREVIATION_BEAM_HH
+
+#include "beam.hh"
+
+/** a beam connects multiple stems Beam adjusts the stems its owns to
+  make sure that they reach the beam and that point in the correct
+  direction */
+class Abbreviation_beam : public Beam {
+public:
+  DECLARE_MY_RUNTIME_TYPEINFO;
+
+  Abbreviation_beam();
+
+  SCORE_ELEM_CLONE(Abbreviation_beam);
+
+protected:
+  virtual void do_print() const;
+  virtual Molecule stem_beams (Stem *here, Stem *next, Stem *prev) const;
+  virtual Molecule* brew_molecule_p() const;
+};
+
+#endif // ABBREVIATION_BEAM_HH
+
index ad775b7a3c8e60db44ab0967c36a14fbd66d8005..c1b1b971b9dcae1f58838d753343d92a1531acf0 100644 (file)
@@ -31,20 +31,20 @@ public:
   void set_grouping (Rhythmic_grouping def, Rhythmic_grouping current);
   void set_stemlens();
   SCORE_ELEM_CLONE(Beam);
+
 protected:
-  virtual Interval do_width() const;    
-  virtual Offset center() const;
-  virtual void set_default_dir();
+  Interval do_width() const;    
+  Offset center() const;
+  void set_default_dir();
   virtual void do_pre_processing();
   virtual void do_post_processing();
   virtual void do_substitute_dependent (Score_elem*, Score_elem*);
 
   virtual void do_print() const;
 
-private:
-  Molecule stem_beams (Stem *here, Stem *next, Stem *prev) const;
-  void solve_slope();
-  Molecule*brew_molecule_p() const;
+  virtual Molecule stem_beams (Stem *here, Stem *next, Stem *prev) const;
+  virtual void solve_slope();
+  virtual Molecule*brew_molecule_p() const;
 };
 
 #endif // BEAM_HH
index f5aa4f56c980e6d1964c5941e0bc68e57109cd20..8e7c46c50a9e8f73bc1122265520221d309efd40 100644 (file)
@@ -12,6 +12,9 @@
 
 
 struct Absolute_dynamic_req;
+struct Abbreviation_req;
+struct Abbreviation_beam_req;
+struct Abbreviation_beam_engraver;
 struct Axis_group_element;
 struct Axis_group;
 struct Translator;
@@ -33,6 +36,7 @@ struct Bar_engraver;
 struct Bar_req;
 struct Barcheck_req;
 struct Beam;
+struct Beam_engraver;
 struct Beam_req;
 struct Blank_req;
 struct Box;
index 64328afc97688b28d6875fc88c979f0a88d9e179..4531ff82cfb39fb5315163963691d892e4fba1ce 100644 (file)
@@ -28,6 +28,7 @@ public:
   virtual Melodic_req *melodic() { return 0; }
   virtual Slur_req *slur() { return 0 ; }
   virtual Beam_req *beam() { return 0 ; }
+  virtual Abbreviation_beam_req* abbrev_beam() { return 0 ; }
   virtual Rhythmic_req*rhythmic() { return 0; }
   virtual Musical_script_req*musicalscript() { return 0; }
   virtual Text_req*text() { return 0; }
@@ -37,6 +38,7 @@ public:
   virtual Absolute_dynamic_req * absdynamic() { return 0; }
   virtual Tie_req * tie() { return 0; }
   virtual Span_dynamic_req * span_dynamic() { return 0; }
+  virtual Abbreviation_req* abbrev() { return 0; }
   REQUESTMETHODS(Musical_req, musical);
 };
 
@@ -62,6 +64,7 @@ class Skip_req  : public Rhythmic_req  {
 public:
   REQUESTMETHODS(Skip_req, skip);
 };
+
 struct Spacing_req :virtual Request {
   Moment next;
   Real distance;
@@ -71,6 +74,12 @@ struct Spacing_req :virtual Request {
   REQUESTMETHODS(Spacing_req, spacing);
 };
 
+struct Abbreviation_req : public Musical_req {
+  REQUESTMETHODS (Abbreviation_req, abbrev);
+  Abbreviation_req ();
+  int type_i_;
+};
+
 class Blank_req  : public Spacing_req, Rhythmic_req  {
 public:
   REQUESTMETHODS(Spacing_req, spacing);
@@ -177,6 +186,18 @@ public:
   Beam_req();
 };
 
+/** 
+ Start / stop an abbreviation beam at this note. 
+ */
+class Abbreviation_beam_req : public Span_req  {
+public:
+  REQUESTMETHODS (Abbreviation_beam_req, abbrev_beam);
+
+  Abbreviation_beam_req ();
+
+  int type_i_;
+};
+
 /**
   Start a tie at this voice element, end it at the next
  */
index 7930c9c7a27a8a7d6ba9476ab24cf74f3ccc86ba..d1a4b779144ee78e2d1adb3c6c5f5593981bf87d 100644 (file)
@@ -33,9 +33,14 @@ class My_lily_parser {
 
   void set_last_duration (Duration const *);
   void set_default_duration (Duration const *);
+  void set_last_abbrev (int type_i);
+  void set_abbrev_beam (int type_i);
   void set_duration_mode (String s);
   friend int yyparse (void*);
+
 public:
+  int abbrev_beam_type_i_;
+  int default_abbrev_type_i_;
   int default_octave_i_;
   Duration default_duration_;
   Plet plet_;
index c5807f70be1c076271fa440b0768be67fe506ec6..36a3a0971c926ce268565a41d2d397440557df81 100644 (file)
@@ -20,9 +20,11 @@ class Stem_engraver : public Engraver
   Direction dir_;
   Stem *stem_p_;
   Rhythmic_req *rhythmic_req_l_;
+  Abbreviation_req* abbrev_req_l_;
 protected:
   virtual void acknowledge_element (Score_elem_info);
   virtual void do_pre_move_processing ();
+  virtual bool do_try_request (Request*);
   virtual void set_feature (Feature dir_i_);
 
 public:
diff --git a/lily/include/stem-info.hh b/lily/include/stem-info.hh
new file mode 100644 (file)
index 0000000..5fa4da6
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+  stem-info.hh -- declare Stem_info
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
+*/
+
+
+#ifndef STEM_INFO_HH
+#define STEM_INFO_HH
+
+#include "real.hh"
+
+struct Stem_info {
+  Real x;
+  int dir_;
+  Real idealy_f_;
+  Real miny_f_;
+  int beams_i_;
+
+  Stem_info();
+  Stem_info (Stem const *);
+};
+
+#endif // STEM_INFO_HH
index 4cf67df0e2daec57075d467984c161f6c2c9b317..12380ae48babc6c3a614a274f9a6fb326977e014 100644 (file)
@@ -9,6 +9,7 @@
 #include "item.hh"
 #include "varray.hh"
 #include "moment.hh"
+#include "molecule.hh"
 
 
 /**the rule attached to the ball.
@@ -27,6 +28,8 @@
   Stem size depends on flag.
   */
 class Stem : public Item {
+
+  Molecule abbrev_mol () const;
     
   Real stem_bottom_f_, stem_top_f_;
     
@@ -52,17 +55,22 @@ class Stem : public Item {
   Link_array<Note_head> rest_l_arr_;
     
 public:
+  /// abbrev flag? + count
+  int abbrev_flag_i_;
+
   /// flagtype? 4 none, 8 8th flag, 0 = beam.
   int flag_i_;
 
+  /** 
+    don't print flag when in beam.
+    our beam, for aligning abbrev flags
+   */
+  Beam* beam_l_;
+
   int beams_left_i_;
   int beams_right_i_;
 
-  /// false if in beam
-  bool print_flag_b_;
-    
   Direction dir_;
-
     
   /* *************** */
   Stem ();
index 9ffd4f494c1d6a8c12ce36d461b88ba09e07e620..f5748139270c4e012e43b92124cc42c0e426733e 100644 (file)
@@ -37,6 +37,8 @@ Span_req::do_print() const
 #endif
 }
 
+IMPLEMENT_IS_TYPE_B1(Spacing_req,Request);
+
 Spacing_req::Spacing_req()
 {
   next = 0;
@@ -44,8 +46,6 @@ Spacing_req::Spacing_req()
   strength = 0;
 }
 
-IMPLEMENT_IS_TYPE_B1(Spacing_req,Request);
-
 void
 Spacing_req::do_print() const
 {
@@ -54,6 +54,21 @@ Spacing_req::do_print() const
 #endif
 }
 
+IMPLEMENT_IS_TYPE_B1 (Abbreviation_req, Musical_req);
+
+Abbreviation_req::Abbreviation_req ()
+{
+  type_i_ = 0;
+}
+
+void
+Abbreviation_req::do_print() const
+{
+#ifndef NPRINT
+  DOUT << "type " << type_i_ << "\n";
+#endif
+}
+
 
 IMPLEMENT_IS_TYPE_B2(Blank_req,Spacing_req,Rhythmic_req);
 
@@ -243,21 +258,41 @@ Rest_req::do_print() const
 }
 
 /* *************** */
+
+IMPLEMENT_IS_TYPE_B1(Beam_req,Span_req);
+
 Beam_req::Beam_req()
 {
   nplet = 0;
 }
 
-IMPLEMENT_IS_TYPE_B1(Beam_req,Span_req);
 void
-Beam_req::do_print() const{}
+Beam_req::do_print() const
+{
+}
+
 /* *************** */
 
+IMPLEMENT_IS_TYPE_B1 (Abbreviation_beam_req, Span_req);
+
+Abbreviation_beam_req::Abbreviation_beam_req ()
+{
+  type_i_ = 0;
+}
+
+void
+Abbreviation_beam_req::do_print () const
+{
+}
+
 IMPLEMENT_IS_TYPE_B1(Slur_req,Span_req);
+
 void
-Slur_req::do_print() const{}
-/* *************** */
+Slur_req::do_print() const
+{
+}
 
+/* *************** */
 
 bool
 Span_req:: do_equal_b (Request*r) const
index 1f4d430f1795b241496bf621a3e816113afa15f1..9878369e16b96ae6d0d9ce4ec1c0748f54cd379d 100644 (file)
 #include "header.hh"
 
 
+My_lily_parser::My_lily_parser (Sources * source_l)
+{
+  first_b_ = true;
+  source_l_ = source_l;
+  lexer_p_ = 0;
+  abbrev_beam_type_i_ = 0;
+  default_abbrev_type_i_ = 0;
+  default_duration_.durlog_i_ = 2;
+  default_octave_i_ = 0;
+  textstyle_str_="roman";              // in lexer?
+  error_level_i_ = 0;
+  last_duration_mode_b_ = true;
+  fatal_error_i_ = 0;
+  default_header_p_ =0;
+}
+
+My_lily_parser::~My_lily_parser()
+{
+  delete lexer_p_;
+  delete default_header_p_;
+}
+  
+
 void
 My_lily_parser::clear_notenames()
 {
   lexer_p_->clear_notenames();
 }
+
 void
 My_lily_parser::set_version_check (bool ig)
 {
@@ -82,12 +106,6 @@ My_lily_parser::parse_file (String init, String s)
     }
 }
 
-My_lily_parser::~My_lily_parser()
-{
-  delete lexer_p_;
-  delete default_header_p_;
-}
-  
 void
 My_lily_parser::remember_spot()
 {
@@ -116,11 +134,24 @@ My_lily_parser::set_duration_mode (String s)
   last_duration_mode_b_ = (s== "LAST");
 }
 
+void
+My_lily_parser::set_abbrev_beam (int type_i)
+{
+  abbrev_beam_type_i_ = type_i;
+}
+
+void
+My_lily_parser::set_last_abbrev (int type_i)
+{
+  default_abbrev_type_i_ = type_i;
+}
+
 void
 My_lily_parser::set_default_duration (Duration const *d)
 {
   last_duration_mode_b_ = false;
   default_duration_ = *d;
+  set_last_abbrev (0);
 }
 
 
@@ -129,6 +160,7 @@ My_lily_parser::set_last_duration (Duration const *d)
 {
   if (last_duration_mode_b_)
     default_duration_ = *d;
+  set_last_abbrev (0);
 }
 
 
@@ -183,6 +215,13 @@ My_lily_parser::get_note_element (Note_req *rq, Duration * duration_p)
 
   v->add (rq);
   
+  // too bad parser reads (default) duration via member access,
+  // this hack will do for now..
+  if (abbrev_beam_type_i_)
+    {
+      assert (!duration_p->plet_b ());
+      duration_p->set_plet (1, 2);
+    }
   rq->set_duration (*duration_p);
   rq->set_spot (here_input());
   delete duration_p ;
@@ -202,11 +241,22 @@ My_lily_parser::get_parens_request (char c)
     case '[':
     case ']':
       {
-       Beam_req*b = new Beam_req;
-       int p_i=plet_.type_i_ ; // ugh . Should junk?
-       if (p_i!= 1)
-         b->nplet = p_i;
-       req_p = b;
+       if (!abbrev_beam_type_i_)
+         {
+           Beam_req*b = new Beam_req;
+           int p_i=plet_.type_i_ ; // ugh . Should junk?
+           if (p_i!= 1)
+             b->nplet = p_i;
+           req_p = b;
+         }
+       else
+         {
+           Abbreviation_beam_req* a = new Abbreviation_beam_req;
+           a->type_i_ = abbrev_beam_type_i_;
+           if (c==']')
+             abbrev_beam_type_i_ = 0;
+           req_p = a;
+         }
       }
     break;
 
@@ -253,20 +303,6 @@ My_lily_parser::get_parens_request (char c)
   return req_p;
 }
 
-My_lily_parser::My_lily_parser (Sources * source_l)
-{
-  first_b_ = true;
-  source_l_ = source_l;
-  lexer_p_ = 0;
-  default_duration_.durlog_i_ = 2;
-  default_octave_i_ = 0;
-  textstyle_str_="roman";              // in lexer?
-  error_level_i_ = 0;
-  last_duration_mode_b_ = true;
-  fatal_error_i_ = 0;
-  default_header_p_ =0;
-}
-
 void
 My_lily_parser::add_requests (Chord*v)
 {
index a8612c44d41416ae975a989b6ba5fb6b088b565b..48aee8d856f507b84c10dd24397749219ccd475a 100644 (file)
@@ -12,7 +12,7 @@
 #include <iostream.h>
 
 // mmm
-#define MUDELA_VERSION "0.1.1"
+#define MUDELA_VERSION "0.1.2"
 
 #include "script-def.hh"
 #include "symtable.hh"
@@ -68,6 +68,7 @@
     Interval *interval;
     Lookup*lookup;
     Melodic_req * melreq;
+    Musical_req* musreq;
     Music_output_def * outputdef;
     Midi_def* midi;
     Moment *moment;
@@ -188,8 +189,10 @@ yylex(YYSTYPE *s,  void * v_l)
 %type <header>         mudela_header mudela_header_body
 %type <box>    box
 %type <c>      open_request_parens close_request_parens
+%type <c>      open_abbrev_parens
 %type <c>      open_plet_parens close_plet_parens
 %type <music>  simple_element music_elt full_element lyrics_elt command_elt
+%type <i>      abbrev_type
 %type <i>      int
 %type <i>      script_dir
 %type <id>     identifier_init
@@ -210,8 +213,8 @@ yylex(YYSTYPE *s,  void * v_l)
 %type <paper>  paper_block paper_body
 %type <real>   dim real
 %type <real>   unit
-%type <request>        post_request pre_request command_req verbose_command_req
 %type <request> abbrev_command_req
+%type <request>        post_request pre_request command_req verbose_command_req
 %type <request>        script_req  dynamic_req
 %type <score>  score_block score_body
 %type <script> script_definition script_body mudela_script gen_script_def
@@ -815,6 +818,18 @@ close_request_parens:
        }
        ;
 
+open_abbrev_parens:
+       '[' ':' INT {
+               $$ = '[';
+               if (!Duration::duration_type_b ($3))
+                       THIS->parser_error ("Not a duration");
+               else if ($3 < 8)
+                       THIS->parser_error ("Can't abbreviate");
+               else
+                       THIS->set_abbrev_beam ($3);
+       }
+       ;
+
 open_plet_parens:
        '[' INT '/' INT {
                $$ = '[';
@@ -833,6 +848,8 @@ open_request_parens:
        | '['   {
                $$='[';
        }
+       | open_abbrev_parens {
+       }
        | open_plet_parens {
        }
        ;
@@ -1012,12 +1029,35 @@ explicit_steno_duration:
        ;
 
 
+abbrev_type: 
+       /* */
+               {
+               $$ = THIS->default_abbrev_type_i_;
+       }
+       | ':' int {
+               if (!Duration::duration_type_b ($2))
+                       THIS->parser_error ("Not a duration");
+               else if ($2 < 8)
+                       THIS->parser_error ("Can't abbreviate");
+               else
+                       THIS->set_last_abbrev ($2);
+               $$ = THIS->default_abbrev_type_i_;
+       }
+       ;
+
 music_elt:
-       steno_note_req notemode_duration                {
-               if (!THIS->lexer_p_->note_state_b())
-                       THIS->parser_error("have to be in Note mode for notes");
+       steno_note_req notemode_duration abbrev_type {
+               if (!THIS->lexer_p_->note_state_b ())
+                       THIS->parser_error ("have to be in Note mode for notes");
                $1->set_duration (*$2);
-               $$ = THIS->get_note_element($1, $2);
+               int durlog_i = $2->durlog_i_;
+               Chord* c = THIS->get_note_element ($1, $2);
+               $$ = c;
+               if ($3) {
+                       Abbreviation_req* a = new Abbreviation_req;
+                       a->type_i_ = $3;
+                       c->add (a);
+               }
        }
        | RESTNAME notemode_duration            {
                $$ = THIS->get_rest_element(*$1, $2);
index c5d825cd8ad3142de7d5af3ce5fef0fa314d3e36..08f07ff59f4e39ab184269dfad1b1e6112b43b2a 100644 (file)
 #include "stem.hh"
 #include "musical-request.hh"
 #include "duration-convert.hh"
+#include "misc.hh"
 
 Stem_engraver::Stem_engraver()
 {
-  stem_p_ =0;
-  dir_ =CENTER;
+  abbrev_req_l_ = 0;
+  stem_p_ = 0;
+  dir_ = CENTER;
 }
 
 void
@@ -28,7 +30,11 @@ Stem_engraver::acknowledge_element(Score_elem_info i)
        {
          Rhythmic_req * r = i.req_l_->musical()->rhythmic();
          stem_p_ = new Stem;
-         stem_p_->flag_i_ = Duration_convert::type2_i(r->duration_.durlog_i_);
+         int durlog_i = r->duration_.durlog_i_;
+         stem_p_->flag_i_ = Duration_convert::type2_i(durlog_i);
+         if (abbrev_req_l_)
+           stem_p_->abbrev_flag_i_ = intlog2 (abbrev_req_l_->type_i_) 
+             - (durlog_i>? 2);
          announce_element (Score_elem_info (stem_p_, r));
        }
       stem_p_->add (h);
@@ -42,10 +48,27 @@ Stem_engraver::do_pre_move_processing()
     {
       if (dir_)
        stem_p_->dir_ = dir_;
-      
+
       typeset_element(stem_p_);
-      stem_p_ =0;
+      stem_p_ = 0;
     }
+  abbrev_req_l_ = 0;
+}
+
+bool
+Stem_engraver::do_try_request (Request* r)
+{
+  Musical_req* mus_l = r->musical ();
+  if (!mus_l)
+    return false;
+  
+  Abbreviation_req* a = mus_l->abbrev ();
+  if (!a)
+    return false;
+
+  abbrev_req_l_ = a;
+
+  return true;
 }
 
 void
diff --git a/lily/stem-info.cc b/lily/stem-info.cc
new file mode 100644 (file)
index 0000000..5e446b6
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+  stem-info.cc -- implement Stem_info
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
+
+*/
+
+#include "proto.hh"
+#include "dimen.hh"
+#include "misc.hh"
+#include "debug.hh"
+#include "symbol.hh"
+#include "stem.hh"
+#include "paper-def.hh"
+#include "lookup.hh"
+#include "stem-info.hh"
+
+Stem_info::Stem_info ()
+{
+}
+
+Stem_info::Stem_info (Stem const *s)
+{
+  x = s->hpos_f();
+  dir_ = s->dir_;
+  beams_i_ = intlog2(s->flag_i_) - 2;
+
+  /*
+    [todo] 
+    * get algorithm
+    * runtime
+
+    Breitkopf + H\"artel:
+    miny_f_ = interline + #beams * interbeam
+    ideal8 = 2 * interline + interbeam
+    ideal16,32,64,128 = 1.5 * interline + #beams * interbeam
+
+    * B\"arenreiter:
+    miny_f_ = interline + #beams * interbeam
+    ideal8,16 = 2 interline + #beams * interbeam
+    ideal32,64,128 = 1.5 interline + #beams * interbeam
+       
+    */
+
+  Real notehead_y = s->paper()->interline_f ();
+  // huh? why do i need the / 2
+  //    Real interbeam_f = s->paper()->interbeam_f ();
+  Real interbeam_f = s->paper()->interbeam_f () / 2;
+         
+  /* well eh, huh?
+     idealy_f_  = dir_ * s->stem_start_f() + beams_i_ * interbeam_f; 
+     if (beams_i_ < 3)
+     idealy_f_ += 2 * interline_f;
+     else
+     idealy_f_ += 1.5 * interline_f;
+     */
+
+  idealy_f_  = dir_ * s->stem_end_f();
+
+  miny_f_ = dir_ * s->stem_start_f() + notehead_y + beams_i_ * interbeam_f;
+
+  idealy_f_ =  miny_f_ >? idealy_f_;
+  //    assert (miny_f_ <= idealy_f_);
+}
+
index 62e1a8753776dd069935e5f30194895e7319a44b..e876f7a0203623d1690653551ab77cf5b0394148 100644 (file)
 #include "molecule.hh"
 #include "p-col.hh"
 #include "misc.hh"
+#include "beam.hh"
 
 const int STEMLEN=7;
 
-int
-Stem::min_head_i() const
-{
-  int m = 1000;
-  for (int i =0; i < head_l_arr_.size(); i++)
-    m = m <? head_l_arr_[i]->position_i_;
-  return m;
-}
+IMPLEMENT_IS_TYPE_B1 (Stem,Item);
 
-int
-Stem::max_head_i() const
-{
-  int m = -1000;
-  for (int i =0; i < head_l_arr_.size(); i++)
-    m = m >? head_l_arr_[i]->position_i_;
-  return m;
-  
-}
-/*
-  TODO: staff-size
- */
 Stem::Stem () 
 {
+  /*
+    TODO: staff-size
+   */
+  abbrev_flag_i_ = 0;
+  beam_l_ = 0;
   beams_left_i_ = 0;
   beams_right_i_ = 0;
 
@@ -49,35 +36,50 @@ Stem::Stem ()
   dir_ =CENTER;
   staff_size_i_ = 8;
 
-  print_flag_b_=true;
   stem_xoffset_f_ =0;
 }
 
+int
+Stem::min_head_i () const
+{
+  int m = 1000;
+  for (int i =0; i < head_l_arr_.size (); i++)
+    m = m <? head_l_arr_[i]->position_i_;
+  return m;
+}
 
-IMPLEMENT_IS_TYPE_B1(Stem,Item);
+int
+Stem::max_head_i () const
+{
+  int m = -1000;
+  for (int i =0; i < head_l_arr_.size (); i++)
+    m = m >? head_l_arr_[i]->position_i_;
+  return m;
+  
+}
 
 void
-Stem::do_print() const
+Stem::do_print () const
 {
 #ifndef NPRINT
-  DOUT << "flag "<< flag_i_ << " print_flag_b_ " << print_flag_b_;
+  DOUT << "flag "<< flag_i_ << " print_flag? " << !(bool)beam_l_ << "abbrev_flag_i_" << abbrev_flag_i_;
 #endif
 }
 
 Real 
-Stem::stem_length_f() const
+Stem::stem_length_f () const
 {
   return stem_top_f_-stem_bottom_f_ ;
 }
 
 Real
-Stem::stem_start_f() const
+Stem::stem_start_f () const
 {
   return (dir_ < 0)? stem_top_f_ : stem_bottom_f_;
 }
 
 Real
-Stem::stem_end_f() const
+Stem::stem_end_f () const
 {
   return (dir_ < 0)? stem_bottom_f_ : stem_top_f_;
 }
@@ -87,12 +89,12 @@ void
 Stem::set_stemend (Real se)
 {
   // todo: margins
-  if (!  ((dir_ > 0 && se >= max_head_i()) || 
-         (se <= min_head_i() && dir_ <0)))     
+  if (!  ((dir_ > 0 && se >= max_head_i ()) || 
+         (se <= min_head_i () && dir_ <0)))    
     warning ("Weird stem size; check for narrow beams");
 
-  stem_top_f_  = (dir_ < 0) ? max_head_i()           : se;
-  stem_bottom_f_  = (dir_ < 0) ? se  : min_head_i();
+  stem_top_f_  = (dir_ < 0) ? max_head_i () : se;
+  stem_bottom_f_  = (dir_ < 0) ? se  : min_head_i ();
 }
 
 void
@@ -100,22 +102,20 @@ Stem::add (Note_head *n)
 {
   n->add_dependency (this);
   if (n->rest_b_) 
-    {
       rest_l_arr_.push (n);
-    }
-  else if (n->balltype_i_ == 0) 
-    {
-      whole_l_arr_.push (n);
-      return;
-    }
-  else
-    {
+  else 
       head_l_arr_.push (n);
-    }
+
+#if 0
+  else if (1) //why different? (n->balltype_i_) 
+      head_l_arr_.push (n);
+  else
+      whole_l_arr_.push (n);
+#endif
 }
 
 bool
-Stem::invisible_b() const
+Stem::invisible_b () const
 {
   return !head_l_arr_.size();
 }
@@ -123,76 +123,81 @@ Stem::invisible_b() const
 // if dir_ is set we return fake values.
 
 int
-Stem::get_center_distance_from_top()
+Stem::get_center_distance_from_top ()
 {
   if (dir_)
     return (dir_ > 0) ? 0 : 1;
 
   int staff_center = staff_size_i_ / 2;
-  int max = max_head_i() - staff_center;
+  int max = max_head_i () - staff_center;
   return max >? 0;
 }
 
 // if dir_ is set we return fake values.
 int
-Stem::get_center_distance_from_bottom()
+Stem::get_center_distance_from_bottom ()
 {
   if (dir_)
     return (dir_ > 0) ? 1 : 0;
 
   int staff_center = staff_size_i_ / 2;
-  int min = staff_center - min_head_i();
+  int min = staff_center - min_head_i ();
   return min >? 0;
 }
 
 Direction
-Stem::get_default_dir()
+Stem::get_default_dir ()
 {
   if (dir_)
     return dir_;
-  return (get_center_distance_from_top() >=
-         get_center_distance_from_bottom()) ? -1 : 1;
+  return (get_center_distance_from_top () >=
+    get_center_distance_from_bottom ()) ? 
+    (Direction)-1 : (Direction)1;
 }
 
 
 void
-Stem::set_default_dir()
+Stem::set_default_dir ()
 {
-  dir_ = get_default_dir();
+  dir_ = get_default_dir ();
 }
 
 void
-Stem::set_default_stemlen()
+Stem::set_default_stemlen ()
 {
   if (!dir_)
-    set_default_dir();
+    set_default_dir ();
 
-  
   // ugh... how about non 5-line staffs?
-  if ((max_head_i() < -2 && dir_ == 1)
-      ||(min_head_i() > staff_size_i_ && dir_ == -1))
+  bool on_ledger_line_b = ((max_head_i () < -2 && dir_ == 1)
+//    || (min_head_i () > staff_size_i_ && dir_ == -1));
+    || (min_head_i () > staff_size_i_ + 3 && dir_ == -1));
+  if (on_ledger_line_b)
     {
-      set_stemend (staff_size_i_ /2 -1);
+      set_stemend (staff_size_i_ / 2 - 1);
     }
   else 
     {
-      set_stemend ((dir_ > 0) ? max_head_i() + STEMLEN : 
-                  min_head_i() - STEMLEN);
-
+      Real dy = paper ()->interbeam_f ();
+      Real len = STEMLEN;
+      // ugh, should get nice *rule* for this
+      if (abbrev_flag_i_ > 1)
+       len += (abbrev_flag_i_ - 1)* dy / 2;
+      set_stemend ((dir_ > 0) ? max_head_i () + len :
+                  min_head_i () - len);
     }
 }
 
-
 void
-Stem::set_default_extents()
+Stem::set_default_extents ()
 {
-  if (!stem_length_f())
-    set_default_stemlen();
+  if (!stem_length_f ())
+    set_default_stemlen ();
 
   set_stemend ((dir_< 0) ? 
-              max_head_i()-stem_length_f (): min_head_i () +stem_length_f ());
+              max_head_i ()-stem_length_f (): min_head_i () +stem_length_f ());
   if (dir_ > 0){       
-    stem_xoffset_f_ = paper()->note_width ()-paper ()->rule_thickness ();
+    stem_xoffset_f_ = paper ()->note_width ()-paper ()->rule_thickness ();
   }
   else
     stem_xoffset_f_ = 0;
@@ -205,19 +210,19 @@ Stem::set_default_extents()
 
   */
 void
-Stem::set_noteheads()
+Stem::set_noteheads ()
 {
-  if (!head_l_arr_.size())
+  if (!head_l_arr_.size ())
     return;
   head_l_arr_.sort (Note_head::compare);
   if (dir_ < 0) 
-    head_l_arr_.reverse();
+    head_l_arr_.reverse ();
   
   head_l_arr_[0]->extremal_i_ = -1;
-  head_l_arr_.top()->extremal_i_ = 1;
+  head_l_arr_.top ()->extremal_i_ = 1;
   int parity=1;
   int lastpos = head_l_arr_[0]->position_i_;
-  for (int i=1; i < head_l_arr_.size(); i ++) 
+  for (int i=1; i < head_l_arr_.size (); i ++) 
     {
       int dy =abs (lastpos- head_l_arr_[i]->position_i_);
        
@@ -234,77 +239,117 @@ Stem::set_noteheads()
 }
 
 void
-Stem::do_pre_processing()
+Stem::do_pre_processing ()
 {
   if (stem_bottom_f_== stem_top_f_)
-    set_default_extents();
-  set_noteheads();
+    set_default_extents ();
+  set_noteheads ();
   flag_i_ = dir_*abs (flag_i_);
-  transparent_b_ = invisible_b();
-  empty_b_ = invisible_b();
+  transparent_b_ = invisible_b ();
+  empty_b_ = invisible_b ();
 }
 
-
 Interval
-Stem::do_width() const
+Stem::do_width () const
 {
-  if (!print_flag_b_ || abs (flag_i_) <= 4)
+  if (beam_l_ || abs (flag_i_) <= 4)
     return Interval (0,0);     // TODO!
-  Paper_def*p= paper();
-  Interval r (p->lookup_l()->flag (flag_i_).dim.x ());
+  Paper_def*p= paper ();
+  Interval r (p->lookup_l ()->flag (flag_i_).dim.x ());
   r+= stem_xoffset_f_;
   return r;
 }
 
+Molecule
+Stem::abbrev_mol () const
+{
+  Real dy = paper ()->interbeam_f ();
+  Real w = 1.5 * paper ()->lookup_l ()->ball (2).dim.x ().length ();
+  Real beamdy = paper ()->interline_f () / 2;
+
+  int beams_i = 0;
+  Real slope = paper ()->internote_f () / 4;
+
+  if (beam_l_) {
+    // huh?
+    slope = 2 * beam_l_->slope;
+    // ugh, rather calc from Abbreviation_req
+    beams_i = beams_right_i_ >? beams_left_i_; 
+  }
+  paper()->lookup_l ()->beam (slope, 20 PT);
+
+  Molecule beams;
+  Atom a (paper ()->lookup_l ()->beam (slope, w));
+  a.translate (Offset(- w / 2, stem_end_f () - (w / 2 * slope)));
+  // ugh
+  if (!beams_i)
+    a.translate (dy + beamdy - dir_ * dy, Y_AXIS);
+  else
+    a.translate (2 * beamdy - dir_ * (beamdy - dy), Y_AXIS);
+       
+  for (int i = 0; i < abbrev_flag_i_; i++) 
+    {
+      Atom b (a);
+      b.translate (-dir_ * dy * (beams_i + i), Y_AXIS);
+      beams.add (b);
+    }
+
+  return beams;
+}
+
 Molecule*
-Stem::brew_molecule_p() const 
+Stem::brew_molecule_p () const 
 {
-  Molecule *out =0;
-      
   Real bot  = stem_bottom_f_;
   Real top = stem_top_f_;
   
   assert (bot!=top);
  
-  Paper_def *p =paper();
+  Paper_def *p =paper ();
 
-  Real dy = p->internote_f();
-  Symbol ss =p->lookup_l()->stem (bot*dy,top*dy);
+  Real dy = p->internote_f ();
+  Symbol ss =p->lookup_l ()->stem (bot*dy,top*dy);
 
-  out = new Molecule (Atom (ss));
+  Molecule* mol_p = new Molecule;
+  if (head_l_arr_.size() && head_l_arr_[0]->balltype_i_)
+    mol_p->add (Atom (ss));
 
-  if (print_flag_b_&&abs (flag_i_) > 4)
+  if (!beam_l_ && abs (flag_i_) > 4)
     {
-      Symbol fl = p->lookup_l()->flag (flag_i_);
+      Symbol fl = p->lookup_l ()->flag (flag_i_);
       Molecule m (fl);
       if (flag_i_ < -4){               
-       out->add_bottom (m);
+       mol_p->add_bottom (m);
       }
       else if (flag_i_ > 4) 
        {
-         out->add_top (m);
+         mol_p->add_top (m);
        }
       else
        assert (false); 
+      assert (!abbrev_flag_i_);
     }
 
-  out->translate (stem_xoffset_f_, X_AXIS);
-  return out;
+  if (abbrev_flag_i_)
+    mol_p->add (abbrev_mol ());
+
+  mol_p->translate (stem_xoffset_f_, X_AXIS);
+  return mol_p;
 }
 
 Real
-Stem::hpos_f() const
+Stem::hpos_f () const
 {
-  return Item::hpos_f() + stem_xoffset_f_;
+  return Item::hpos_f () + stem_xoffset_f_;
 }
 
 
 void
 Stem::do_substitute_dependency (Score_elem*o,Score_elem*n)
 {
-  Item * o_l = o->item();
-  Item * n_l = n? n->item():0;
-  whole_l_arr_.substitute ((Note_head*)o_l, (Note_head*)n_l);
+  Item * o_l = o->item ();
+  Item * n_l = n? n->item ():0;
+//  whole_l_arr_.substitute ((Note_head*)o_l, (Note_head*)n_l);
   head_l_arr_.substitute ((Note_head*)o_l, (Note_head*)n_l);
   rest_l_arr_.substitute ((Note_head*)o_l, (Note_head*)n_l);
 }
index 250d1bd0644fcd360933969370faf152a8dd51d4..8ec278983e631ccb3c8ba12149c817e10a5e27e6 100644 (file)
@@ -81,7 +81,7 @@ Mudela_stream::header()
   *os_p_ << filename_str_g;
   *os_p_ << "\n\n";    
   // ugh
-  *os_p_ << "\\version \"0.1.1\";\n";
+  *os_p_ << "\\version \"0.1.2\";\n";
 }
 
 void