From 4975901229a1b074f6c93d812e15d653aa8e2952 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 15 Nov 2000 22:59:15 +0100 Subject: [PATCH] release: 1.3.108 ============ * Dropped ly_lists_equal for gh_equal_ * Removed Array from chord. * Small bugfix to lilypond-mode. * lily/part-combine-music-iterator.cc: fixed (switch `combineParts' property on), and removed Array. 1.3.107. --- CHANGES | 24 + Documentation/user/GNUmakefile | 2 +- VERSION | 4 +- debian/GNUmakefile | 4 +- debian/changelog | 7 + debian/control | 2 +- debian/watch | 2 +- lily/a2-engraver.cc | 2 +- lily/audio-item.cc | 2 +- lily/auto-change-iterator.cc | 8 +- lily/chord-name-engraver.cc | 118 ++-- lily/chord.cc | 830 +++++++++++++-------------- lily/command-request.cc | 6 +- lily/crescendo.cc | 22 +- lily/custos-engraver.cc | 2 +- lily/dynamic-engraver.cc | 19 +- lily/include/audio-item.hh | 6 +- lily/include/auto-change-iterator.hh | 2 +- lily/include/chord.hh | 71 +-- lily/include/command-request.hh | 4 +- lily/include/crescendo.hh | 4 +- lily/include/lily-proto.hh | 2 +- lily/include/local-key-item.hh | 4 +- lily/include/lyric-combine-music.hh | 4 +- lily/include/music-list.hh | 4 +- lily/include/music-sequence.hh | 6 +- lily/include/music-wrapper.hh | 6 +- lily/include/music.hh | 4 +- lily/include/musical-pitch.hh | 73 --- lily/include/musical-request.hh | 4 +- lily/include/my-lily-lexer.hh | 2 +- lily/include/my-lily-parser.hh | 10 +- lily/include/part-combine-music.hh | 4 +- lily/include/pitch.hh | 83 +++ lily/include/relative-music.hh | 6 +- lily/include/repeated-music.hh | 4 +- lily/include/transposed-music.hh | 6 +- lily/key-engraver.cc | 2 +- lily/lily-guile.cc | 2 - lily/local-key-item.cc | 8 +- lily/lyric-combine-music.cc | 8 +- lily/music-list.cc | 12 +- lily/music-sequence.cc | 16 +- lily/music-wrapper.cc | 6 +- lily/music.cc | 8 +- lily/musical-request.cc | 4 +- lily/note-performer.cc | 2 +- lily/parser.yy | 18 +- lily/part-combine-music-iterator.cc | 111 ++-- lily/part-combine-music.cc | 8 +- lily/{musical-pitch.cc => pitch.cc} | 122 ++-- lily/relative-octave-music.cc | 6 +- lily/repeated-music.cc | 10 +- lily/tie-engraver.cc | 4 +- lily/tie-performer.cc | 4 +- lily/transposed-music.cc | 6 +- lilypond-mode.el | 4 +- ly/catalan.ly | 2 +- make/out/lilypond.lsm | 8 +- make/out/lilypond.spec | 4 +- scm/backend-documentation-lib.scm | 81 +-- scm/documentation-lib.scm | 52 +- scm/element-descriptions.scm | 6 +- scm/engraver-documentation-lib.scm | 15 +- scm/generate-documentation.scm | 3 +- scm/interface.scm | 23 +- scm/translator-description.scm | 3 +- 67 files changed, 973 insertions(+), 948 deletions(-) create mode 100644 lily/include/pitch.hh rename lily/{musical-pitch.cc => pitch.cc} (70%) diff --git a/CHANGES b/CHANGES index b4796d80bc..e18b6da2e6 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,27 @@ +1.3.107.jcn3 +============ + +* Dropped ly_lists_equal for gh_equal_ + +* Removed Array from chord. + +* Small bugfix to lilypond-mode. + +* lily/part-combine-music-iterator.cc: fixed (switch `combineParts' +property on), and removed Array. + +1.3.107.uu1 +=========== + +* Bugfix: don't call Crescendo::brew_molecule () too early if there is +an absolute dynamic. + +* Rename class Crescendo to Hairpin. + +* Search/replace: Musical_pitch -> Pitch + +* More links in the backend documentation. + 1.3.106.jcn2 ============ diff --git a/Documentation/user/GNUmakefile b/Documentation/user/GNUmakefile index 98ee073466..bff671da11 100644 --- a/Documentation/user/GNUmakefile +++ b/Documentation/user/GNUmakefile @@ -44,7 +44,7 @@ local-WWW: $(HTML_FILES) $(datafiles) $(PS_GZ_FILES) $(DEEP_HTML_FILES) $(SHELL) $(buildscript-dir)/install-info-html.sh --dir=$(outdir) lilypond lilypond-internals $(MAKE) footify -mkdir $(outdir)/lilypond - ln -f $(outdir)/*.png $(outdir)/lilypond + cp -f $(outdir)/*.png $(outdir)/lilypond $(MAKE) deep-footify # $(PYTHON) $(step-bindir)/ls-latex.py --title 'User documentation' \ diff --git a/VERSION b/VERSION index d37b31e48c..e73b2c105e 100644 --- a/VERSION +++ b/VERSION @@ -1,8 +1,8 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=3 -PATCH_LEVEL=107 -MY_PATCH_LEVEL=mb1 +PATCH_LEVEL=108 +MY_PATCH_LEVEL= # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/debian/GNUmakefile b/debian/GNUmakefile index 7e67f9d823..00183578ad 100644 --- a/debian/GNUmakefile +++ b/debian/GNUmakefile @@ -6,10 +6,10 @@ NAME = debian at-dir = $(outdir)/ at-ext = -EXTRA_DIST_FILES = README.Debian TODO $(CONF_FILES) \ - control.foka CONF_FILES = changelog control copyright doc-base emacsen-startup \ preinst postinst postrm prerm rules watch +EXTRA_DIST_FILES = README.Debian TODO $(CONF_FILES) \ + control.foka #OUTCONF_FILES = $(addprefix $(outdir)/, $(basename $(CONF_FILES))) $(OUTIN_FILES) OUTCONF_FILES = $(OUTIN_FILES) OUT_DIST_FILES = $(OUTIN_FILES) diff --git a/debian/changelog b/debian/changelog index dc55185130..672ef00d2a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +lilypond1.3 (1.3.107) unstable; urgency=low + + * Fixed watch location. + * Hmm, what about ``add-log-mailing-address: "foka@debian.org"''? + + -- Jan Nieuwenhuizen Mon, 13 Nov 2000 13:33:53 +0100 + lilypond1.3 (1.3.103) unstable; urgency=low * Re-enabled info doc rules. diff --git a/debian/control b/debian/control index 3e6d361154..f373046dc0 100644 --- a/debian/control +++ b/debian/control @@ -1,5 +1,5 @@ Source: lilypond1.3 -Build-Depends: debhelper (>= 2.0.71), python-base (>= 1.5.2-4), libguile6-dev, tetex-bin, tetex-devel, tetex-extra, flex (>= 2.5.4a-1), bison (>= 1:1.28-1), texinfo (>= 4.0-1), groff, gs, netpbm, pnmtopng, m4, gettext (>= 0.10.35-13) +Build-Depends: debhelper (>= 2.0.71), python-base (>= 1.5.2-4), libguile9-dev, tetex-bin, tetex-devel, tetex-extra, flex (>= 2.5.4a-1), bison (>= 1:1.28-1), texinfo (>= 4.0-1), groff, gs, netpbm, pnmtopng, m4, gettext (>= 0.10.35-13) Section: tex Priority: optional Maintainer: Anthony Fok diff --git a/debian/watch b/debian/watch index 2d48c588b0..589895ff83 100644 --- a/debian/watch +++ b/debian/watch @@ -2,4 +2,4 @@ # Rename this file to "watch" and then you can run the "uscan" command # to check for upstream updates and more. # Site Directory Pattern Version Script -ftp.cs.uu.nl /pub/GNU/LilyPond/v1.1 lilypond-*.tar.gz debian uupdate +ftp.cs.uu.nl /pub/GNU/LilyPond/v1.3 lilypond-*.tar.gz debian uupdate diff --git a/lily/a2-engraver.cc b/lily/a2-engraver.cc index 4c84ff402e..ee33e68d75 100644 --- a/lily/a2-engraver.cc +++ b/lily/a2-engraver.cc @@ -135,7 +135,7 @@ A2_engraver::acknowledge_element (Score_element_info i) if (Stem::has_interface (i.elem_l_) || Slur::has_interface (i.elem_l_) // || Text_item::has_interface (i.elem_l_) - //|| Crescendo::has_interface (i.elem_l_) + //|| Hairpin::has_interface (i.elem_l_) ) { /* diff --git a/lily/audio-item.cc b/lily/audio-item.cc index b4d358c7f7..05b101eabd 100644 --- a/lily/audio-item.cc +++ b/lily/audio-item.cc @@ -20,7 +20,7 @@ Audio_item::Audio_item () audio_column_l_ = 0; } -Audio_note::Audio_note (Musical_pitch p, Moment m, int transposing_i) +Audio_note::Audio_note (Pitch p, Moment m, int transposing_i) { pitch_ = p; length_mom_ = m; diff --git a/lily/auto-change-iterator.cc b/lily/auto-change-iterator.cc index 183c5fece4..5db9f69033 100644 --- a/lily/auto-change-iterator.cc +++ b/lily/auto-change-iterator.cc @@ -77,11 +77,11 @@ Auto_change_iterator::change_to (Music_iterator *it, String to_type, PRECONDITION: this->ok() holds. */ -Array +Array Auto_change_iterator::pending_pitch (Moment m) const { Music_iterator * iter = child_iter_p_ ->clone (); - Array ps; + Array ps; while (1) { SCM muses = iter->get_music (m); @@ -112,12 +112,12 @@ Auto_change_iterator::process (Moment m) first we get the pitches, then we do the real work. Music_wrapper_iterator::process() might process (and throw away) pitches we need. */ - Array ps = pending_pitch (m); + Array ps = pending_pitch (m); Music_wrapper_iterator::process (m); if (ps.size ()) { - Musical_pitch p = ps[0]; + Pitch p = ps[0]; Direction s = Direction (sign(p.steps ())); if (s != where_dir_) { diff --git a/lily/chord-name-engraver.cc b/lily/chord-name-engraver.cc index 50ece53329..877d7c988c 100644 --- a/lily/chord-name-engraver.cc +++ b/lily/chord-name-engraver.cc @@ -16,7 +16,8 @@ #include "main.hh" #include "dimensions.hh" #include "item.hh" -#include "musical-pitch.hh" +#include "pitch.hh" +#include "protected-scm.hh" class Chord_name_engraver : public Engraver { @@ -32,14 +33,16 @@ protected: private: void create_chord_name (); - - Array pitch_arr_; + Item* chord_name_p_; - Chord* chord_p_; - Chord* last_chord_p_; - Tonic_req* tonic_req_; - Inversion_req* inversion_req_; - Bass_req* bass_req_; + Protected_scm pitches_; + + Protected_scm chord_; + Protected_scm last_chord_; + + Protected_scm tonic_req_; + Protected_scm inversion_req_; + Protected_scm bass_req_; }; ADD_THIS_TRANSLATOR (Chord_name_engraver); @@ -47,18 +50,19 @@ ADD_THIS_TRANSLATOR (Chord_name_engraver); Chord_name_engraver::Chord_name_engraver () { chord_name_p_ = 0; - tonic_req_ = 0; - inversion_req_ = 0; - bass_req_ = 0; - chord_p_ = 0; - last_chord_p_ = 0; + pitches_ = SCM_EOL; + tonic_req_ = SCM_EOL; + inversion_req_ = SCM_EOL; + bass_req_ = SCM_EOL; + chord_ = SCM_EOL; + last_chord_ = SCM_EOL; } void Chord_name_engraver::acknowledge_element (Score_element_info i) { if (Note_req* n = dynamic_cast (i.req_l_)) - pitch_arr_.push (* unsmob_pitch (n->get_mus_property ("pitch"))); + pitches_ = gh_cons (n->get_mus_property ("pitch"), pitches_); } bool @@ -66,22 +70,22 @@ Chord_name_engraver::do_try_music (Music* m) { if (Note_req* n = dynamic_cast (m)) { - pitch_arr_.push (* unsmob_pitch (n->get_mus_property ("pitch"))); + pitches_ = gh_cons (n->get_mus_property ("pitch"), pitches_); return true; } if (Tonic_req* t = dynamic_cast (m)) { - tonic_req_ = t; + tonic_req_ = t->get_mus_property ("pitch"); return true; } if (Inversion_req* i = dynamic_cast (m)) { - inversion_req_ = i; + inversion_req_ = i->get_mus_property ("pitch"); return true; } if (Bass_req* b = dynamic_cast (m)) { - bass_req_ = b; + bass_req_ = b->get_mus_property ("pitch"); return true; } return false; @@ -90,47 +94,41 @@ Chord_name_engraver::do_try_music (Music* m) void Chord_name_engraver::do_process_music () { - if (chord_name_p_) - return; - - if (!pitch_arr_.size ()) - return; - - bool find_inversion_b = false; - SCM chord_inversion = get_property ("chordInversion"); - if (gh_boolean_p (chord_inversion)) - find_inversion_b = gh_scm2bool (chord_inversion); - - chord_p_ = new Chord (to_chord (pitch_arr_, - tonic_req_, inversion_req_, bass_req_, - find_inversion_b)); - - create_chord_name (); - announce_element (chord_name_p_, 0); - SCM s = get_property ("drarnChords"); //FIXME! - if (to_boolean (s) && last_chord_p_ && !compare (chord_p_, last_chord_p_)) - chord_name_p_->set_elt_property ("begin-of-line-visible", SCM_BOOL_T); + if (!chord_name_p_ && pitches_ != SCM_EOL) + { + bool find_inversion_b = false; + SCM chord_inversion = get_property ("chordInversion"); + if (gh_boolean_p (chord_inversion)) + find_inversion_b = gh_scm2bool (chord_inversion); + + chord_ = Chord::pitches_and_requests_to_chord (pitches_, + tonic_req_, + inversion_req_, + bass_req_, + find_inversion_b); + + create_chord_name (); + announce_element (chord_name_p_, 0); + SCM s = get_property ("drarnChords"); //FIXME! + if (to_boolean (s) && last_chord_ != SCM_EOL && + gh_equal_p (chord_, last_chord_)) + chord_name_p_->set_elt_property ("begin-of-line-visible", SCM_BOOL_T); + } } void Chord_name_engraver::create_chord_name () { - assert (chord_p_); chord_name_p_ = new Item (get_property ("ChordName")); - /* - Hmm, why not represent complete chord as list? - ((tonic third fifth) (inversion bass)) - */ - SCM plist = SCM_EOL; - for (int i= chord_p_->pitch_arr_.size (); i--; ) - plist = gh_cons (chord_p_->pitch_arr_[i].smobbed_copy (), plist); - - chord_name_p_->set_elt_property ("pitches", plist); - if (chord_p_->inversion_b_) - chord_name_p_->set_elt_property ("inversion", - chord_p_->inversion_pitch_.smobbed_copy ()); - if (chord_p_->bass_b_) - chord_name_p_->set_elt_property ("bass", chord_p_->bass_pitch_.smobbed_copy ()); + + SCM pitches = gh_car (chord_); + SCM modifiers = gh_cdr (chord_); + SCM inversion = gh_car (modifiers); + SCM bass = gh_cdr (modifiers); + /* Hmm, maybe chord-name should use (pitches (inversion . base)) too? */ + chord_name_p_->set_elt_property ("pitches", pitches); + chord_name_p_->set_elt_property ("inversion", inversion); + chord_name_p_->set_elt_property ("inversion", bass); } void @@ -140,13 +138,13 @@ Chord_name_engraver::do_pre_move_processing () { typeset_element (chord_name_p_); } - pitch_arr_.clear (); chord_name_p_ = 0; - tonic_req_ = 0; - inversion_req_ = 0; - bass_req_ = 0; - delete last_chord_p_; - last_chord_p_ = chord_p_; - chord_p_ = 0; + + pitches_ = SCM_EOL; + tonic_req_ = SCM_EOL; + inversion_req_ = SCM_EOL; + bass_req_ = SCM_EOL; + last_chord_ = chord_; + chord_ = SCM_EOL; } diff --git a/lily/chord.cc b/lily/chord.cc index 26602a5e78..6f4e565ace 100644 --- a/lily/chord.cc +++ b/lily/chord.cc @@ -13,315 +13,221 @@ #include "music-list.hh" #include "musical-request.hh" -/* - UGH - - should compare SCM lists. - */ -int -compare (Chord* left, Chord* right) -{ - assert (left); - assert (right); - - return !(left->inversion_b_ == right->inversion_b_ - && left->bass_b_ == right->bass_b_ - && !compare (&left->pitch_arr_, &right->pitch_arr_)); -} - -/* - FIXME: should use SCM iso. arrays and have-to-delete pointers. - - FIXME: a real function looks like - +/* some SCM abbrevs - Return_value func (Input_value), + zijn deze nou handig? + zijn ze er al in scheme, maar heten ze anders? */ - not - void func (Input_value *); - - FIXME: - - pitch is really a tuple, hence an immutable object. We - should remove all mutating operations. - - */ - -/* - construct from parser output -*/ -Chord -to_chord (Musical_pitch tonic, Array* add_arr_p, Array* sub_arr_p, Musical_pitch* inversion_p, Musical_pitch* bass_p) +/* Remove doubles from (sorted) list */ +SCM +ly_unique (SCM list) { - // urg: catch dim modifier: 3rd, 5th, 7th, .. should be lowered - bool dim_b = false; - for (int i=0; i < add_arr_p->size (); i++) + SCM unique = SCM_EOL; + for (SCM i = list; gh_pair_p (i); i = gh_cdr (i)) { - Musical_pitch* p = &(*add_arr_p)[i]; - if (p->octave_i () == -100) - { - p->octave_i_ = 0; - dim_b = true; - } + if (!gh_pair_p (gh_cdr (i)) + || !gh_equal_p (gh_car (i), gh_cadr (i))) + unique = gh_cons (gh_car (i), unique); } - Chord::rebuild_transpose (add_arr_p, tonic, true); - Chord::rebuild_transpose (sub_arr_p, tonic, true); - - Musical_pitch fifth = Chord::base_arr (tonic).top (); + return gh_reverse (unique); +} - /* - remove double adds (urg: sus4) - */ - for (int i = add_arr_p->size () - 1; i >= 0 ; i--) +/* Hmm, rewrite this using ly_split_list? */ +SCM +ly_remove_member (SCM s, SCM list) +{ + SCM removed = SCM_EOL; + for (SCM i = list; gh_pair_p (i); i = gh_cdr (i)) { - int j = Chord::find_pitch_i (add_arr_p, (*add_arr_p)[i]); - if ((j != -1) && (i != j)) - { - add_arr_p->get (i); - } + if (!gh_equal_p (gh_car (i), s)) + removed = gh_cons (gh_car (i), removed); } + return gh_reverse (removed); +} - /* - default chord includes upto 5: <1, 3, 5> - */ - add_arr_p->insert (tonic, 0); - Array tmp = *add_arr_p; - int highest_step = Chord::step_i (tonic, tmp.top ()); - if (highest_step < 5) - tmp.push (fifth); - else if (dim_b) - { - Musical_pitch* p = &add_arr_p->top (); - p->alteration_i_--; - } +SCM +ly_last (SCM list) +{ + return gh_car (scm_last_pair (list)); +} - /* - find missing thirds - */ - Array missing_arr = Chord::missing_thirds_pitch_arr (&tmp); - if (highest_step < 5) - missing_arr.push (fifth); +/* tail add */ +SCM +ly_snoc (SCM s, SCM list) +{ + return gh_append2 (list, gh_list (s, SCM_UNDEFINED)); +} - /* - if dim modifier is given: lower all missing - */ - if (dim_b) - { - for (int i=0; i < missing_arr.size (); i++) - { - missing_arr[i].alteration_i_--; - } - } - /* - if additions include some 3, don't add third - */ - Musical_pitch third = Chord::base_arr (tonic)[1]; - if (Chord::find_notename_i (add_arr_p, third) != -1) - { - int i = Chord::find_pitch_i (&missing_arr, third); - if (i != -1) - missing_arr.get (i); - } - - /* - if additions include 4, assume sus4 and don't add third implicitely - C-sus (4) = c f g (1 4 5) - */ - Musical_pitch sus = tonic; - sus.transpose (Musical_pitch (0,3,0)); - if (Chord::find_pitch_i (add_arr_p, sus) != -1) +/* Split list at member s, removing s. + Return (BEFORE . AFTER) */ +SCM +ly_split_list (SCM s, SCM list) +{ + SCM before = SCM_EOL; + SCM after = list; + for (; gh_pair_p (after);) { - int i = Chord::find_pitch_i (&missing_arr, third); - if (i != -1) - missing_arr.get (i); + SCM i = gh_car (after); + after = gh_cdr (after); + if (gh_equal_p (i, s)) + break; + before = gh_cons (i, before); } + return gh_cons (gh_reverse (before), after); +} - /* - if additions include some 5, don't add fifth - */ - if (Chord::find_notename_i (add_arr_p, fifth) != -1) - { - int i = Chord::find_pitch_i (&missing_arr, fifth); - if (i != -1) - missing_arr.get (i); - } - - - /* - complete the list of thirds to be added - */ - add_arr_p->concat (missing_arr); - add_arr_p->sort (Musical_pitch::compare); - - Array pitch_arr; - /* - add all that aren't subtracted - */ - for (int i = 0; i < add_arr_p->size (); i++) - { - Musical_pitch p = (*add_arr_p)[i]; - int j = 0; - for (; j < sub_arr_p->size (); j++) - if (p == (*sub_arr_p)[j]) - { - sub_arr_p->del (j); - j = -1; - break; - } - if (j == sub_arr_p->size ()) - pitch_arr.push (p); - } - pitch_arr.sort (Musical_pitch::compare); +/* Construct from list of pitches and requests: - for (int i = 0; i < sub_arr_p->size (); i++) - warning (_f ("invalid subtraction: not part of chord: %s", - (*sub_arr_p)[i].str ())); - - return Chord (pitch_arr, inversion_p, bass_p); -} + (PITCHES . (INVERSION . BASS)) -/* - Construct from list of pitches and requests - */ -Chord -to_chord (Array pitch_arr, Tonic_req* tonic_req, Inversion_req* inversion_req, Bass_req* bass_req, bool find_inversion_b) + + Note, the pitches here, are all inclusive. + We must identify tonic, filter-out (and maybe detect) inversion and bass. */ + +SCM +Chord::pitches_and_requests_to_chord (SCM pitches, + SCM tonic_req, + SCM inversion_req, + SCM bass_req, + bool find_inversion_b) { - Musical_pitch* inversion_p = 0; - Musical_pitch* bass_p = 0; + pitches = scm_sort_list (pitches, + scm_eval2 (ly_symbol2scm ("Pitch::less_p"), + SCM_EOL)); - if (bass_req) + + if (bass_req != SCM_EOL) { - assert (pitch_arr[0].notename_i_ == unsmob_pitch (bass_req->get_mus_property ("pitch"))->notename_i_); - bass_p = new Musical_pitch (pitch_arr.get (0)); + assert (unsmob_pitch (gh_car (pitches))->notename_i_ + == unsmob_pitch (bass_req)->notename_i_); + pitches = gh_cdr (pitches); } - if (inversion_req) + if (inversion_req != SCM_EOL) { - assert (pitch_arr[0].notename_i_ == unsmob_pitch (inversion_req->get_mus_property ("pitch"))->notename_i_); - inversion_p = new Musical_pitch (* unsmob_pitch (inversion_req->get_mus_property ("pitch"))); - assert (tonic_req); - int tonic_i = Chord::find_notename_i (&pitch_arr, - *unsmob_pitch (tonic_req->get_mus_property ("pitch"))); - if (tonic_i) - Chord::rebuild_insert_inversion (&pitch_arr, tonic_i); + assert (unsmob_pitch (gh_car (pitches))->notename_i_ + == unsmob_pitch (inversion_req)->notename_i_); + /* huh ? */ + assert (tonic_req != SCM_EOL); + + SCM tonic = member_notename (tonic_req, pitches); + if (tonic != SCM_EOL) + pitches = rebuild_insert_inversion (pitches); //, tonic); } - - if (find_inversion_b && !inversion_p) + else if (find_inversion_b) { - int tonic_i = tonic_req - ? Chord::find_notename_i (&pitch_arr, *unsmob_pitch (tonic_req->get_mus_property ("pitch"))) - : Chord::find_tonic_i (&pitch_arr); + SCM tonic = (tonic_req != SCM_EOL) + ? member_notename (pitches, tonic_req) + : guess_tonic (pitches); - if (tonic_i) + if (tonic != SCM_EOL) { - inversion_p = &pitch_arr[0]; - Chord::rebuild_insert_inversion (&pitch_arr, tonic_i); + inversion_req = gh_car (pitches); + pitches = rebuild_insert_inversion (pitches); //, tonic); } } - if (tonic_req) - { - assert (pitch_arr[0].notename_i_ == unsmob_pitch (tonic_req->get_mus_property ("pitch"))->notename_i_); - } - - return Chord (pitch_arr, inversion_p, bass_p); -} + if (tonic_req != SCM_EOL) + assert (unsmob_pitch (gh_car (pitches))->notename_i_ + == unsmob_pitch (tonic_req)->notename_i_); -Chord::Chord () -{ - inversion_b_ = false; - bass_b_ = false; + return gh_cons (pitches, gh_cons (inversion_req, bass_req)); } -Chord::Chord (Array pitch_arr, Musical_pitch* inversion_p, Musical_pitch* bass_p) -{ - pitch_arr_ = pitch_arr; - inversion_b_ = false; - bass_b_ = false; - if (inversion_p) - { - inversion_pitch_ = *inversion_p; - inversion_b_ = true; - } - if (bass_p) - { - bass_pitch_ = *bass_p; - bass_b_ = true; - } -} - -Chord::Chord (Chord const& chord) -{ - pitch_arr_ = chord.pitch_arr_; - inversion_b_ = chord.inversion_b_; - inversion_pitch_ = chord.inversion_pitch_; - bass_b_ = chord.bass_b_; - bass_pitch_ = chord.bass_pitch_; -} - - /* JUNKME. do something smarter. + zoals? */ -Array -Chord::base_arr (Musical_pitch p) +SCM +Chord::base_pitches (SCM tonic) { - Array base; - base.push (p); - p.transpose (Musical_pitch (0,2,0)); - base.push (p); - p.transpose (Musical_pitch (0, 2, -1)); - base.push (p); - return base; + SCM base = SCM_EOL; + + SCM major = Pitch (0, 2, 0).smobbed_copy (); + SCM minor = Pitch (0, 2, -1).smobbed_copy (); + + base = gh_cons (tonic, base); + base = gh_cons (Pitch::transpose (gh_car (base), major), base); + base = gh_cons (Pitch::transpose (gh_car (base), minor), base); + + return gh_reverse (base); } -void -Chord::rebuild_transpose (Array* pitch_arr_p, Musical_pitch tonic, bool fix7_b) +SCM +Chord::transpose_pitches (SCM tonic, SCM pitches) { - for (int i = 0; i < pitch_arr_p->size (); i++) + /* map? + hoe doe je lambda in C? + */ + SCM transposed = SCM_EOL; + for (SCM i = pitches; gh_pair_p (i); i = gh_cdr (i)) { - Musical_pitch p = tonic; - Musical_pitch q = (*pitch_arr_p)[i]; - p.transpose (q); - // duh, c7 should mean - if (fix7_b && (step_i (tonic, p) == 7)) - p.alteration_i_--; - (*pitch_arr_p)[i] = p; + transposed = gh_cons (Pitch::transpose (tonic, gh_car (i)), + transposed); } - pitch_arr_p->sort (Musical_pitch::compare); + return gh_reverse (transposed); } -int -Chord::find_pitch_i (Array const* pitch_arr_p, Musical_pitch p) +/* + burp, in SCM duw je gewoon een (if (= (step x) 7) (...)) door pitches + + Lower step STEP. + If step == 0, lower all. + */ +SCM +Chord::lower_step (SCM tonic, SCM pitches, SCM step) { - for (int i = 0; i < pitch_arr_p->size (); i++) - if (p == (*pitch_arr_p)[i]) - return i; - return -1; + SCM lowered = SCM_EOL; + for (SCM i = pitches; gh_pair_p (i); i = gh_cdr (i)) + { + SCM p = gh_car (i); + if (gh_equal_p (step_scm (tonic, gh_car (i)), step) + || gh_scm2int (step) == 0) + { +#if 0 + Pitch x = *unsmob_pitch (p); + x.alteration_i_--; + p = x.smobbed_copy (); +#else + p = Pitch::transpose (p, Pitch (0, 0, -1).smobbed_copy ()); +#endif + } + lowered = gh_cons (p, lowered); + } + return gh_reverse (lowered); } -int -Chord::find_notename_i (Array const* pitch_arr_p, Musical_pitch p) +/* Return member that has same notename, disregarding octave or accidentals */ +SCM +Chord::member_notename (SCM p, SCM pitches) { - int i = find_pitch_i (pitch_arr_p, p); - if (i == -1) + /* If there's an exact match, make sure to return that */ + SCM member = gh_member (p, pitches); + if (member == SCM_BOOL_F) { - for (int i = 0; i < pitch_arr_p->size (); i++) + for (SCM i = pitches; gh_pair_p (i); i = gh_cdr (i)) { - p.octave_i_ = (*pitch_arr_p)[i].octave_i () ; - if (p == (*pitch_arr_p)[i]) - return i; + /* + Urg, eindelijk gevonden: () != #f, kan maar niet aan wennen. + Anders kon iets korter... + */ + if (unsmob_pitch (p)->notename_i_ + == unsmob_pitch (gh_car (i))->notename_i_) + { + member = gh_car (i); + break; + } } } - return i; + return member; } int -Chord::step_i (Musical_pitch tonic, Musical_pitch p) +Chord::step_i (Pitch tonic, Pitch p) { int i = p.notename_i_ - tonic.notename_i_ + (p.octave_i () - tonic.octave_i () ) * 7; @@ -331,90 +237,105 @@ Chord::step_i (Musical_pitch tonic, Musical_pitch p) return i; } +SCM +Chord::step_scm (SCM tonic, SCM p) +{ + return gh_int2scm (step_i (*unsmob_pitch (tonic), *unsmob_pitch (p))); +} + /* - JUNKME. - do something smarter. + docme */ -Array -Chord::missing_thirds_pitch_arr (Array const* pitch_arr_p) +SCM +Chord::missing_thirds (SCM pitches) { - Array thirds; - + SCM thirds = SCM_EOL; + /* is the third c-e, d-f, etc. small or large? */ - int minormajor_a[] = {0, -1, -1, 0,0,-1,-1}; + int minormajor_a[] = {0, -1, -1, 0, 0, -1, -1}; for (int i=0; i < 7; i++) - thirds.push (Musical_pitch( 0, 2, minormajor_a[i])); - - Musical_pitch tonic = (*pitch_arr_p)[0]; - Musical_pitch last = tonic; - Array missing_arr; + thirds = gh_cons (Pitch (0, 2, minormajor_a[i]).smobbed_copy (), + thirds); + thirds = scm_vector (gh_reverse (thirds)); + + SCM tonic = gh_car (pitches); + SCM last = tonic; + SCM missing = SCM_EOL; - for (int i = 0; i < pitch_arr_p->size ();) + for (SCM i = pitches; gh_pair_p (i);) { - Musical_pitch p = (*pitch_arr_p)[i]; - int step = step_i (tonic, p); - if (last.notename_i_ == p.notename_i_) - last.transpose (thirds[(last.notename_i_ - tonic.notename_i_ + 7) % 7]); - if (step > step_i (tonic, last)) + SCM p = gh_car (i); + int step = gh_scm2int (step_scm (tonic, p)); + + if (unsmob_pitch (last)->notename_i_ == unsmob_pitch (p)->notename_i_) + { + int third = (unsmob_pitch (last)->notename_i_ + - unsmob_pitch (tonic)-> notename_i_ + 7) % 7; + last = Pitch::transpose (last, scm_vector_ref (thirds, gh_int2scm (third))); + } + + if (step > gh_scm2int (step_scm (tonic, last))) { - while (step > step_i (tonic, last)) + while (step > gh_scm2int (step_scm (tonic, last))) { - if ((last.notename_i_ - tonic.notename_i_ + 7) % 7 == 6) - { - Musical_pitch special_seven = last; - Musical_pitch lower (0, 0, -1); - special_seven.transpose (lower); - missing_arr.push (special_seven); - } - else - { - missing_arr.push (last); - } - last.transpose (thirds[(last.notename_i_ - tonic.notename_i_ + 7) % 7]); + missing = gh_cons (last, missing); + int third = (unsmob_pitch (last)->notename_i_ + - unsmob_pitch (tonic)->notename_i_ + 7) % 7; + last = Pitch::transpose (last, scm_vector_ref (thirds, + gh_int2scm (third))); } } else { - i++; + i = gh_cdr (i); } } - return missing_arr; + + return lower_step (tonic, missing, gh_int2scm (7)); } /* - Mangle into list of pitches. + Mangle + + (PITCHES . (INVERSION . BASS)) + + into list of pitches. + For normal chord entry, inversion and bass pitches are retained in - specific *_requests - */ -Array -Chord::to_pitch_arr () const + specific *_requests */ + +SCM +Chord::to_pitches (SCM chord) { - Array pitch_arr = pitch_arr_; - if (inversion_b_) + SCM pitches = gh_car (chord); + SCM modifiers = gh_cdr (chord); + SCM inversion = gh_car (modifiers); + SCM bass = gh_cdr (modifiers); + if (inversion != SCM_EOL) { - int i = 0; - for (; i < pitch_arr.size (); i++) + Pitch inversion_pitch = *unsmob_pitch (inversion); + SCM i = pitches; + for (; gh_pair_p (i); i = gh_cdr (i)) { - if ((pitch_arr[i].notename_i_ == inversion_pitch_.notename_i_) - && (pitch_arr[i].alteration_i_ == inversion_pitch_.alteration_i_)) + Pitch p = *unsmob_pitch (gh_car (i)); + if ((p.notename_i_ == inversion_pitch.notename_i_) + && (p.alteration_i_ == inversion_pitch.alteration_i_)) break; } - if (i == pitch_arr.size ()) - { - warning (_f ("invalid inversion pitch: not part of chord: %s", - inversion_pitch_.str ())); - } + if (gh_pair_p (i)) + pitches = rebuild_with_bass (pitches, gh_car (i)); else - rebuild_with_bass (&pitch_arr, i); + warning (_f ("invalid inversion pitch: not part of chord: %s", + unsmob_pitch (inversion)->str ())); } - if (bass_b_) + if (bass != SCM_EOL) { - pitch_arr.insert (bass_pitch_, 0); - rebuild_with_bass (&pitch_arr, 0); + pitches = gh_cons (bass, pitches); + pitches = rebuild_with_bass (pitches, bass); } - return pitch_arr; + return pitches; } /* @@ -423,179 +344,224 @@ Chord::to_pitch_arr () const This is only used for chords that are entered as simultaneous notes, chords entered in \chord mode are fully defined. */ -int -Chord::find_tonic_i (Array const* pitch_arr_p) -{ - /* - find tonic - - first try: base of longest line of thirds - */ - int tonic_i = 0; - int longest_i = 0; - for (int i = 0; i < pitch_arr_p->size (); i++) - { - int no_third_i = 0; - int last_i = (*pitch_arr_p)[i % pitch_arr_p->size ()].notename_i_; - int j = 0; - for (; j < pitch_arr_p->size (); j++) - { - int cur_i = (*pitch_arr_p)[(i + j + 1) % pitch_arr_p->size ()].notename_i_; - int gap = cur_i - last_i; - while (gap < 0) - gap += 7; - gap %= 7; - if (gap == 2) - last_i = cur_i; - else - no_third_i++; - } - if (j - no_third_i > longest_i) - { - longest_i = j - no_third_i; - tonic_i = i; - } - } - /* - second try: note after biggest gap - */ - int biggest_i = 0; - // if (longest_i) - if (longest_i <= 1) - for (int i = 0; i < pitch_arr_p->size (); i++) - { - int gap = (*pitch_arr_p)[i].notename_i_ - - (*pitch_arr_p)[(i - 1 + pitch_arr_p->size ()) - % pitch_arr_p->size ()].notename_i_; - while (gap < 0) - gap += 7; - gap %= 7; - if (gap > biggest_i) - { - biggest_i = gap; - tonic_i = i; - } - } - return tonic_i; -} +SCM +Chord::guess_tonic (SCM pitches) +{ + return gh_car (scm_sort_list (pitches, Pitch::less_p_proc)); +} -void -Chord::rebuild_from_base (Array* pitch_arr_p, int base_i) +SCM +Chord::rebuild_from_base (SCM pitches, SCM base) { - assert (base_i >= 0); - Musical_pitch last (0, 0, -5); - Array new_arr; - for (int i = 0; i < pitch_arr_p->size (); i++) + SCM split = ly_split_list (base, pitches); + SCM before = gh_car (split); + SCM after = gh_cdr (split); + + SCM last = Pitch (0, 0, -5).smobbed_copy (); + SCM rebuilt = SCM_EOL; + rebuilt = gh_cons (base, rebuilt); + for (SCM i = gh_append2 (after, before); gh_pair_p (i); i = gh_cdr (i)) { - Musical_pitch p = (*pitch_arr_p)[(base_i + i) % pitch_arr_p->size ()]; - if (p < last) + SCM p = gh_car (i); + if (Pitch::less_p (p, last) == SCM_BOOL_T) { - p.octave_i_ = last.octave_i () ; - if (p < last) - p.octave_i_++; + // UHUHUrg + p = Pitch (unsmob_pitch (last)->octave_i_, + unsmob_pitch (p)->notename_i_, + unsmob_pitch (p)->alteration_i_).smobbed_copy (); + if (Pitch::less_p (p, last)) + p = Pitch::transpose (p, Pitch (1, 0, 0).smobbed_copy ()); } - new_arr.push (p); + rebuilt = gh_cons (p, rebuilt); last = p; } - *pitch_arr_p = new_arr; + + return gh_reverse (rebuilt); } -void -Chord::rebuild_insert_inversion (Array* pitch_arr_p, int tonic_i) +SCM +Chord::rebuild_insert_inversion (SCM pitches) //, SCM tonic) { - assert (tonic_i > 0); - Musical_pitch inversion = pitch_arr_p->get (0); - rebuild_from_base (pitch_arr_p, tonic_i - 1); - if (pitch_arr_p->size ()) + SCM inversion = gh_car (pitches); + pitches = gh_cdr (pitches); + SCM tonic = gh_car (pitches); + pitches = rebuild_from_base (pitches, tonic); + if (pitches != SCM_EOL) { - inversion.octave_i_ = (*pitch_arr_p)[0].octave_i () - 1; - while (inversion < (*pitch_arr_p)[0]) - inversion.octave_i_++; + // UHUHUrg + inversion = Pitch (unsmob_pitch (gh_car (pitches))->octave_i_-1, + unsmob_pitch (inversion)->notename_i_, + unsmob_pitch (inversion)->alteration_i_).smobbed_copy (); + while (Pitch::less_p (inversion, gh_car (pitches)) == SCM_BOOL_T) + inversion = Pitch::transpose (inversion, Pitch (1, 0, 0).smobbed_copy ()); } - for (int i = 0; i < pitch_arr_p->size (); i++) - if ((*pitch_arr_p)[i] > inversion) - { - pitch_arr_p->insert (inversion, i); - break; - } + pitches = gh_cons (inversion, pitches); + return scm_sort_list (pitches, + scm_eval2 (ly_symbol2scm ("Pitch::less_p"), + SCM_EOL)); } -void -Chord::rebuild_with_bass (Array* pitch_arr_p, int bass_i) +SCM +Chord::rebuild_with_bass (SCM pitches, SCM bass) { - assert (bass_i >= 0); - Musical_pitch bass = pitch_arr_p->get (bass_i); + pitches = ly_remove_member (bass, pitches); // is lowering fine, or should others be raised? - if (pitch_arr_p->size ()) - while (bass > (*pitch_arr_p)[0]) - bass.octave_i_--; - pitch_arr_p->insert (bass, 0); + if (pitches != SCM_EOL) + while (Pitch::less_p (gh_car (pitches), bass) == SCM_BOOL_T) + bass = Pitch::transpose (bass, Pitch (-1, 0, 0).smobbed_copy ()); + return gh_cons (bass, pitches); } -// junk me -Simultaneous_music * -get_chord (SCM stonic, - SCM sadd_arr_p, - SCM ssub_arr_p, - SCM sinversion_p, - SCM sbass_p, - SCM dur) + +/*********************************/ +/* Parser stuff */ + +/* Construct from parser output: + + (PITCHES . (INVERSION . BASS)) */ +SCM +Chord::tonic_add_sub_inversion_bass_to_scm (SCM tonic, SCM add, SCM sub, + SCM inversion, SCM bass) { - Musical_pitch tonic = *unsmob_pitch (stonic); + SCM less = scm_eval2 (ly_symbol2scm ("Pitch::less_p"), SCM_EOL); + + /* urg: catch dim modifier: 3rd, 5th, 7th, .. should be lowered */ + bool dim_b = false; + for (SCM i = add; gh_pair_p (i); i = gh_cdr (i)) + { + Pitch* p = unsmob_pitch (gh_car (i)); + if (p->octave_i () == -100) + { + p->octave_i_ = 0; + dim_b = true; + } + } + add = transpose_pitches (tonic, add); + add = lower_step (tonic, add, gh_int2scm (7)); + add = scm_sort_list (add, less); + add = ly_unique (add); - Musical_pitch *inversion_p = unsmob_pitch( sinversion_p); - Musical_pitch *bass_p = unsmob_pitch (sbass_p); - - Array add_arr_p; - Array sub_arr_p; + sub = transpose_pitches (tonic, sub); + sub = lower_step (tonic, sub, gh_int2scm (7)); + sub = scm_sort_list (sub, less); + + /* default chord includes upto 5: <1, 3, 5> */ + add = gh_cons (tonic, add); + SCM tmp = add; + + SCM fifth = ly_last (base_pitches (tonic)); + int highest_step = gh_scm2int (step_scm (tonic, ly_last (tmp))); + if (highest_step < 5) + tmp = ly_snoc (fifth, tmp); + else if (dim_b) + add = lower_step (tonic, add, gh_int2scm (5)); + + /* find missing thirds */ + SCM missing = missing_thirds (tmp); + if (highest_step < 5) + missing = ly_snoc (fifth, missing); - for (SCM s = sadd_arr_p ; gh_pair_p (s); s = gh_cdr (s)) - add_arr_p.push (*unsmob_pitch (gh_car (s))); - for (SCM s = ssub_arr_p ; gh_pair_p (s); s = gh_cdr (s)) - sub_arr_p.push (*unsmob_pitch (gh_car (s))); + /* if dim modifier is given: lower all missing */ + if (dim_b) + missing = lower_step (tonic, missing, gh_int2scm (0)); + + /* if additions include any 3, don't add third */ + SCM third = gh_cadr (base_pitches (tonic)); + if (member_notename (third, add) != SCM_BOOL_F) + missing = ly_remove_member (third, missing); + + /* if additions include any 4, assume sus4 and don't add third implicitely + C-sus (4) = c f g (1 4 5) */ + SCM sus = Pitch::transpose (tonic, Pitch (0, 3, 0).smobbed_copy ()); + if (member_notename (sus, add) != SCM_BOOL_F) + missing = ly_remove_member (third, missing); + + /* if additions include some 5, don't add fifth */ + if (member_notename (fifth, add) != SCM_BOOL_F) + missing = ly_remove_member (fifth, missing); + + /* complete the list of thirds to be added */ + add = gh_append2 (missing, add); + add = scm_sort_list (add, less); - sub_arr_p.reverse (); - add_arr_p.reverse (); + SCM pitches = SCM_EOL; + /* Add all that aren't subtracted */ + for (SCM i = add; gh_pair_p (i); i = gh_cdr (i)) + { + SCM p = gh_car (i); + SCM s = member_notename (p, sub); + if (s != SCM_BOOL_F) + sub = ly_remove_member (s, sub); + else + pitches = gh_cons (p, pitches); + } + pitches = scm_sort_list (pitches, less); + + for (SCM i = sub; gh_pair_p (i); i = gh_cdr (i)) + warning (_f ("invalid subtraction: not part of chord: %s", + unsmob_pitch (gh_car (i))->str ())); - /* - UARGAUGRAGRUAUGRUINAGRAUGIRNA + return gh_cons (pitches, gh_cons (inversion, bass)); +} - ugh - */ - Chord chord = to_chord (tonic, &add_arr_p, &sub_arr_p, inversion_p, bass_p); - inversion_p = 0; - bass_p = 0; +/* + junk me + + snapnie + + Een chord invoer bestaat uit een naam. Maar, we willen een aantal + pitch-requests doen, zodat na het parsen van een chord geen verschil + meer is met een gewoon accoord. Die vertaalslag is behoorlijk + harig, hoe wil je dit junken? Nouja, cleanup lijkt me aardige + eerste stap enniewee. + + + --Het lijkt me dat dit in het paarse gedeelte moet. + + Zo-en-zo, lijktme dat je ipv. Inversion_req een (inversion . #t) aan + de betreffende Noot_req kan hangen +*/ + +Simultaneous_music * +Chord::get_chord (SCM tonic, SCM add, SCM sub, SCM inversion, SCM bass, SCM dur) +{ + SCM chord = tonic_add_sub_inversion_bass_to_scm (tonic, add, sub, + inversion, bass); + Tonic_req* t = new Tonic_req; - t->set_mus_property ("pitch", tonic.smobbed_copy ()); + t->set_mus_property ("pitch", tonic); SCM l = gh_cons (t->self_scm (), SCM_EOL); + SCM modifiers = gh_cdr (chord); + inversion = gh_car (modifiers); + bass = gh_cdr (modifiers); + //urg - if (chord.inversion_b_ - && Chord::find_notename_i (&chord.pitch_arr_, chord.inversion_pitch_) > 0) + if (inversion != SCM_EOL) { Inversion_req* i = new Inversion_req; - i->set_mus_property ("pitch", chord.inversion_pitch_.smobbed_copy ()); + i->set_mus_property ("pitch", inversion); l = gh_cons (i->self_scm (), l); scm_unprotect_object (i->self_scm ()); } - if (chord.bass_b_) + if (bass != SCM_EOL) { Bass_req* b = new Bass_req; - b->set_mus_property ("pitch", chord.bass_pitch_.smobbed_copy ()); + b->set_mus_property ("pitch", bass); l = gh_cons (b->self_scm (), l); scm_unprotect_object (b->self_scm ()); } - Array pitch_arr = chord.to_pitch_arr (); - for (int i = pitch_arr.size (); --i >= 0;) + SCM pitches = Chord::to_pitches (chord); + for (SCM i = pitches; gh_pair_p (i); i = gh_cdr (i)) { Note_req* n = new Note_req; - n->set_mus_property ("pitch", pitch_arr[i].smobbed_copy ()); + n->set_mus_property ("pitch", gh_car (i)); n->set_mus_property ("duration", dur); l = gh_cons (n->self_scm (), l); diff --git a/lily/command-request.cc b/lily/command-request.cc index aef049e980..0b615681a4 100644 --- a/lily/command-request.cc +++ b/lily/command-request.cc @@ -49,7 +49,7 @@ Key_change_req::do_equal_b (Request const * req) const void -Key_change_req::transpose (Musical_pitch p) +Key_change_req::transpose (Pitch p) { SCM newlist = SCM_EOL; SCM pa = get_mus_property ("pitch-alist"); @@ -59,7 +59,7 @@ Key_change_req::transpose (Musical_pitch p) SCM alter = gh_cdar (s); if (gh_pair_p (key)) { - Musical_pitch orig (gh_scm2int (gh_car (key)), + Pitch orig (gh_scm2int (gh_car (key)), gh_scm2int (gh_cdr (key)), gh_scm2int (alter)); @@ -73,7 +73,7 @@ Key_change_req::transpose (Musical_pitch p) } else if (gh_number_p (key)) { - Musical_pitch orig (0, gh_scm2int (key), gh_scm2int (alter)); + Pitch orig (0, gh_scm2int (key), gh_scm2int (alter)); orig.transpose (p); key =gh_int2scm (orig.notename_i_); diff --git a/lily/crescendo.cc b/lily/crescendo.cc index 9bfbf02eff..32c9d07f28 100644 --- a/lily/crescendo.cc +++ b/lily/crescendo.cc @@ -1,5 +1,5 @@ /* - crescendo.cc -- implement Crescendo + crescendo.cc -- implement Hairpin source file of the GNU LilyPond music typesetter @@ -15,10 +15,10 @@ #include "debug.hh" #include "paper-column.hh" -MAKE_SCHEME_CALLBACK (Crescendo, brew_molecule, 1); +MAKE_SCHEME_CALLBACK (Hairpin, brew_molecule, 1); SCM -Crescendo::brew_molecule (SCM smob) +Hairpin::brew_molecule (SCM smob) { Score_element *me= unsmob_element (smob); Spanner *span = dynamic_cast(me); @@ -35,7 +35,7 @@ Crescendo::brew_molecule (SCM smob) } Direction grow_dir = to_dir (s); - + Real padding = gh_scm2double (me->get_elt_property ("padding")); Real width = span->spanner_length (); width -= span->get_broken_left_end_align (); @@ -47,11 +47,19 @@ Crescendo::brew_molecule (SCM smob) } Drul_array broken; + Drul_array extra_off; Direction d = LEFT; do { - Paper_column* s = dynamic_cast (span->get_bound (d)); // UGH - broken[d] = (!s->musical_b ()); + Item *b = span->get_bound (d); + broken[d] = b->break_status_dir () != CENTER; + + if (!broken [d]) + { + Real r = b->extent (b, X_AXIS)[-d] + padding; + width += d * r; + extra_off[d] = r; + } } while (flip (&d) != LEFT); @@ -69,7 +77,7 @@ Crescendo::brew_molecule (SCM smob) Box b (Interval (0, width), Interval (-2*height, 2*height)); Molecule mol (b, hairpin); - mol.translate_axis (broken_left, X_AXIS); + mol.translate_axis (broken_left + extra_off[LEFT], X_AXIS); return mol.smobbed_copy (); } diff --git a/lily/custos-engraver.cc b/lily/custos-engraver.cc index 77e354d632..02ffd1f46d 100644 --- a/lily/custos-engraver.cc +++ b/lily/custos-engraver.cc @@ -36,7 +36,7 @@ private: Item * create_custos(); bool custos_permitted; Link_array custos_arr_; - Array pitches_; + Array pitches_; }; Custos_engraver::Custos_engraver () diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index ee1aea2fbf..57e35bd730 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -266,17 +266,10 @@ Dynamic_engraver::do_process_music () SCM_UNDEFINED); } } - - Score_element *cc = unsmob_element (get_property ("currentMusicalColumn")); - cresc_p_->set_bound (LEFT, cc); - - if (script_p_) - { - Side_position::set_direction (script_p_, LEFT); - Side_position::set_axis (script_p_, X_AXIS); - Side_position::add_support (script_p_, cresc_p_); - } - + cresc_p_->set_bound (LEFT, script_p_ + ? script_p_ + : unsmob_element (get_property ("currentMusicalColumn"))); + Axis_group_interface::add_element (line_spanner_, cresc_p_); announce_element (cresc_p_, accepted_spanreqs_drul_[START]); } @@ -312,6 +305,10 @@ Dynamic_engraver::typeset_all () { if (finished_cresc_p_) { + finished_cresc_p_->set_bound (RIGHT, script_p_ + ? script_p_ + : unsmob_element (get_property ("currentMusicalColumn"))); + typeset_element (finished_cresc_p_); finished_cresc_p_ =0; } diff --git a/lily/include/audio-item.hh b/lily/include/audio-item.hh index e8ced6a64b..72281b52da 100644 --- a/lily/include/audio-item.hh +++ b/lily/include/audio-item.hh @@ -12,7 +12,7 @@ #include "string.hh" #include "audio-element.hh" -#include "musical-pitch.hh" +#include "pitch.hh" #include "moment.hh" #include "drul-array.hh" @@ -61,11 +61,11 @@ public: class Audio_note : public Audio_item { public: - Audio_note (Musical_pitch p, Moment m, int transposing_i = 0); + Audio_note (Pitch p, Moment m, int transposing_i = 0); void tie_to (Audio_note*); - Musical_pitch pitch_; + Pitch pitch_; Moment length_mom_; Moment delayed_mom_; Moment delayed_until_mom_; diff --git a/lily/include/auto-change-iterator.hh b/lily/include/auto-change-iterator.hh index aba977192f..74558ab4df 100644 --- a/lily/include/auto-change-iterator.hh +++ b/lily/include/auto-change-iterator.hh @@ -25,7 +25,7 @@ protected: virtual void process (Moment); - Array pending_pitch (Moment)const; + Array pending_pitch (Moment)const; private: diff --git a/lily/include/chord.hh b/lily/include/chord.hh index 98290e29c2..c062efb6ac 100644 --- a/lily/include/chord.hh +++ b/lily/include/chord.hh @@ -9,56 +9,37 @@ #ifndef CHORD_HH #define CHORD_HH -#include "array.hh" -#include "musical-pitch.hh" -#include "lily-proto.hh" - - +#include "pitch.hh" /* - Slightly on the hairy side? In any case COMMENTME. + ``chord'' is encoded: + (PITCHES . (INVERSION . BASS)) + + Chord:: namespace... */ class Chord { public: - static Array base_arr (Musical_pitch p); - static int find_tonic_i (Array const*); - static int find_pitch_i (Array const*, Musical_pitch p); - static int find_notename_i (Array const*, Musical_pitch p); - static Array missing_thirds_pitch_arr (Array const* pitch_arr_p); - static void rebuild_from_base (Array*, int base_i); - static void rebuild_insert_inversion (Array*, int tonic_i); - static void rebuild_transpose (Array*, Musical_pitch tonic, bool fix7_b); - static void rebuild_with_bass (Array*, int bass_i); - static int step_i (Musical_pitch tonic, Musical_pitch p); - - - Chord (); - Chord (Array pitch_arr, Musical_pitch* inversion_p, Musical_pitch* bass_p); - Chord (Chord const&); - - Array to_pitch_arr () const; - - Array pitch_arr_; - bool inversion_b_; - Musical_pitch inversion_pitch_; - bool bass_b_; - Musical_pitch bass_pitch_; + static SCM pitches_and_requests_to_chord (SCM pitches, + SCM tonic_req, + SCM inversion_req, + SCM bass_req, + bool find_inversion_b); + static SCM base_pitches (SCM tonic); + static SCM transpose_pitches (SCM tonic, SCM pitches); + static SCM lower_step (SCM tonic, SCM pitches, SCM step); + static SCM member_notename (SCM p, SCM pitches); + static int step_i (Pitch tonic, Pitch p); + static SCM step_scm (SCM tonic, SCM p); + static SCM missing_thirds (SCM pitches); + static SCM to_pitches (SCM chord); + static SCM guess_tonic (SCM pitches); + static SCM rebuild_from_base (SCM pitches, SCM base); + static SCM rebuild_insert_inversion (SCM pitches); //, SCM tonic); + static SCM rebuild_with_bass (SCM pitches, SCM bass); + static SCM tonic_add_sub_inversion_bass_to_scm (SCM tonic, SCM add, SCM sub, + SCM inversion, SCM bass); + static Simultaneous_music *get_chord (SCM tonic, SCM add, SCM sub, SCM inversion, SCM bass, SCM dur); }; -Chord to_chord (Musical_pitch tonic, Array* add_arr_p, Array* sub_arr_p, Musical_pitch* inversion_p, Musical_pitch* bass_p); - -Chord to_chord (Array pitch_arr, Tonic_req* tonic_req, Inversion_req* inversion_req, Bass_req* bass_req, bool find_inversion_b); - -int compare (Chord*, Chord*); - -Simultaneous_music *get_chord (SCM tonic, - SCM add_arr_p, - SCM sub_arr_p, - SCM inversion_p, - SCM bass_p, - SCM d); - - - -#endif // CHORD_HH +#endif /* CHORD_HH */ diff --git a/lily/include/command-request.hh b/lily/include/command-request.hh index 2acf5d4ba1..5415808e58 100644 --- a/lily/include/command-request.hh +++ b/lily/include/command-request.hh @@ -13,7 +13,7 @@ #include "request.hh" #include "array.hh" #include "duration.hh" -#include "musical-pitch.hh" +#include "pitch.hh" #include "protected-scm.hh" class Break_req : public Request { @@ -68,7 +68,7 @@ public: protected: VIRTUAL_COPY_CONS(Music); - void transpose (Musical_pitch d); + void transpose (Pitch d); bool do_equal_b (Request const * )const; }; diff --git a/lily/include/crescendo.hh b/lily/include/crescendo.hh index c487894bc2..b34ccc56df 100644 --- a/lily/include/crescendo.hh +++ b/lily/include/crescendo.hh @@ -1,5 +1,5 @@ /* - crescendo.hh -- declare Crescendo + crescendo.hh -- declare Hairpin source file of the GNU LilyPond music typesetter @@ -14,7 +14,7 @@ /** The hairpin symbol. */ -struct Crescendo +struct Hairpin { public: DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM)); diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index 5dea72d5b5..b1fba08ddd 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -116,7 +116,7 @@ class Music_output_def; class Music_sequence; class Music_wrapper; class Music_wrapper_iterator; -class Musical_pitch; +class Pitch; class Musical_req; class My_lily_lexer; class Note_performer; diff --git a/lily/include/local-key-item.hh b/lily/include/local-key-item.hh index 88b76d7b46..9eb8c92b9f 100644 --- a/lily/include/local-key-item.hh +++ b/lily/include/local-key-item.hh @@ -9,14 +9,14 @@ #include "array.hh" -#include "musical-pitch.hh" +#include "pitch.hh" class Local_key_item { static Molecule parenthesize (Score_element*me, Molecule) ; public: DECLARE_SCHEME_CALLBACK(brew_molecule, (SCM )); - static void add_pitch (Score_element*me, Musical_pitch, bool cautionary, bool natural); + static void add_pitch (Score_element*me, Pitch, bool cautionary, bool natural); static bool has_interface (Score_element*); static void set_interface (Score_element*); }; diff --git a/lily/include/lyric-combine-music.hh b/lily/include/lyric-combine-music.hh index 9b121ff0d7..d28a8c5fe3 100644 --- a/lily/include/lyric-combine-music.hh +++ b/lily/include/lyric-combine-music.hh @@ -19,11 +19,11 @@ public: Music * lyrics_l () const; Lyric_combine_music (Music*, Music*); - virtual void transpose (Musical_pitch); + virtual void transpose (Pitch); VIRTUAL_COPY_CONS(Music); virtual Moment length_mom () const; - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); virtual void compress (Moment); }; #endif /* LYRIC_COMBINE_MUSIC_HH */ diff --git a/lily/include/music-list.hh b/lily/include/music-list.hh index 63d39edc37..b0a0017a15 100644 --- a/lily/include/music-list.hh +++ b/lily/include/music-list.hh @@ -21,7 +21,7 @@ class Simultaneous_music : public Music_sequence public: VIRTUAL_COPY_CONS(Music); Simultaneous_music(SCM); - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); virtual Moment length_mom () const; }; @@ -33,7 +33,7 @@ class Request_chord : public Simultaneous_music { public: VIRTUAL_COPY_CONS(Music); - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); Request_chord(SCM list); }; diff --git a/lily/include/music-sequence.hh b/lily/include/music-sequence.hh index 6e88236e33..67ce044dee 100644 --- a/lily/include/music-sequence.hh +++ b/lily/include/music-sequence.hh @@ -24,8 +24,8 @@ public: void append_music (Music *); VIRTUAL_COPY_CONS(Music); - Musical_pitch do_relative_octave (Musical_pitch p, bool b); - virtual void transpose (Musical_pitch ); + Pitch do_relative_octave (Pitch p, bool b); + virtual void transpose (Pitch ); void truncate (int k); virtual void compress (Moment); int length_i () const; @@ -33,7 +33,7 @@ public: Moment maximum_length () const; protected: - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); }; diff --git a/lily/include/music-wrapper.hh b/lily/include/music-wrapper.hh index d5227830a7..4f6546c405 100644 --- a/lily/include/music-wrapper.hh +++ b/lily/include/music-wrapper.hh @@ -11,7 +11,7 @@ #define MUSIC_WRAPPER_HH #include "music.hh" -#include "musical-pitch.hh" +#include "pitch.hh" /** A Music that modifies an existing Music. This data structure corresponds to a production that takes a single Music argument, @@ -24,12 +24,12 @@ class Music_wrapper : public Music public: Music_wrapper (Music*); Music * element () const; - virtual void transpose (Musical_pitch); + virtual void transpose (Pitch); VIRTUAL_COPY_CONS(Music); virtual Moment length_mom () const; - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); virtual void compress (Moment); }; diff --git a/lily/include/music.hh b/lily/include/music.hh index dbcfccf687..a139ae28d4 100644 --- a/lily/include/music.hh +++ b/lily/include/music.hh @@ -44,14 +44,14 @@ public: void set_mus_pointer (const char*, SCM val); SCM remove_mus_property (const char* nm); - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); /// The duration of this piece of music virtual Moment length_mom () const; void print() const; /// Transpose, with the interval central C to #p# - virtual void transpose (Musical_pitch p); + virtual void transpose (Pitch p); /// Scale the music in time by #factor#. virtual void compress (Moment factor); diff --git a/lily/include/musical-pitch.hh b/lily/include/musical-pitch.hh index a78973b563..e69de29bb2 100644 --- a/lily/include/musical-pitch.hh +++ b/lily/include/musical-pitch.hh @@ -1,73 +0,0 @@ -/* - musical-pitch.hh -- declare Musical_pitch - - source file of the GNU LilyPond music typesetter - - (c) 1998--2000 Han-Wen Nienhuys - - */ - -#ifndef MUSICAL_PITCH_HH -#define MUSICAL_PITCH_HH - -#include "lily-proto.hh" -#include "smobs.hh" - -/** A "tonal" pitch. This is a pitch as it figures in diatonal western - music (12 semitones in an octave), as opposed to a frequence in Hz - or a integer number of semitones. - - - - -*/ -class Musical_pitch -{ -public: // fixme - - /// 0 is c, 6 is b - int notename_i_; - - /// 0 natural, 1 sharp, etc - int alteration_i_; - - /// 0 is central c - int octave_i_; -public: - - int octave_i () const; - int notename_i () const; - int alteration_i () const; - - /* - Musical_pitch is lexicographically ordered by (octave, notename, - alteration). - */ - Musical_pitch (int octave, int notename,int accidental); - Musical_pitch (); - - Musical_pitch to_relative_octave (Musical_pitch); - void transpose (Musical_pitch); - static int compare (Musical_pitch const&,Musical_pitch const&); - /// return large part of interval from central c - int steps() const; - /// return pitch from central c (in halfnotes) - int semitone_pitch() const; - void up_to (int); - void down_to (int); - String str () const; - - SCM smobbed_copy () const; - DECLARE_SCHEME_CALLBACK(less_p, (SCM a, SCM b)); - DECLARE_SIMPLE_SMOBS(Musical_pitch,); -}; - -Musical_pitch* unsmob_pitch (SCM); - -#include "compare.hh" -INSTANTIATE_COMPARE(Musical_pitch, Musical_pitch::compare); - -int compare (Array*, Array*); - -#endif /* MUSICAL_PITCH_HH */ - diff --git a/lily/include/musical-request.hh b/lily/include/musical-request.hh index f98b1bee86..f3d1adcbb1 100644 --- a/lily/include/musical-request.hh +++ b/lily/include/musical-request.hh @@ -13,7 +13,7 @@ #include "lily-proto.hh" #include "request.hh" #include "duration.hh" -#include "musical-pitch.hh" +#include "pitch.hh" #include "array.hh" /** a request with a duration. @@ -75,7 +75,7 @@ struct Melodic_req :virtual Request { protected: /// transpose. #delta# is relative to central c. - virtual void transpose (Musical_pitch delta); + virtual void transpose (Pitch delta); virtual bool do_equal_b (Request const*) const; VIRTUAL_COPY_CONS(Music); diff --git a/lily/include/my-lily-lexer.hh b/lily/include/my-lily-lexer.hh index a76957edf6..dbe59c6ccd 100644 --- a/lily/include/my-lily-lexer.hh +++ b/lily/include/my-lily-lexer.hh @@ -18,7 +18,7 @@ #include "string.hh" #include "includable-lexer.hh" #include "duration.hh" -#include "musical-pitch.hh" +#include "pitch.hh" #include "protected-scm.hh" bool busy_parsing(); diff --git a/lily/include/my-lily-parser.hh b/lily/include/my-lily-parser.hh index 7832bb3c07..bd5b82159b 100644 --- a/lily/include/my-lily-parser.hh +++ b/lily/include/my-lily-parser.hh @@ -16,7 +16,7 @@ #include "lily-proto.hh" #include "lily-proto.hh" #include "duration.hh" -#include "musical-pitch.hh" +#include "pitch.hh" #include "string.hh" #include "array.hh" #include "input.hh" @@ -66,13 +66,13 @@ private: char const* here_ch_C() const; - Simultaneous_music * get_chord (Musical_pitch tonic, Array* add_arr_p, - Array* sub_arr_p, Musical_pitch* inversion_p, - Musical_pitch* bass_p, Duration d); + Simultaneous_music * get_chord (Pitch tonic, Array* add_arr_p, + Array* sub_arr_p, Pitch* inversion_p, + Pitch* bass_p, Duration d); void set_chord_tremolo (int type_i); void set_last_duration (Duration const *); - void set_last_pitch (Musical_pitch const *); + void set_last_pitch (Pitch const *); friend int yyparse (void*); }; diff --git a/lily/include/part-combine-music.hh b/lily/include/part-combine-music.hh index cccfaaa1d3..ed0b560a9f 100644 --- a/lily/include/part-combine-music.hh +++ b/lily/include/part-combine-music.hh @@ -22,10 +22,10 @@ public: Music * first_l () const; Music * second_l () const; - virtual void transpose (Musical_pitch); + virtual void transpose (Pitch); virtual Moment length_mom () const; - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); virtual void compress (Moment); }; diff --git a/lily/include/pitch.hh b/lily/include/pitch.hh new file mode 100644 index 0000000000..0ad15815ee --- /dev/null +++ b/lily/include/pitch.hh @@ -0,0 +1,83 @@ +/* + pitch.hh -- declare Pitch + + source file of the GNU LilyPond music typesetter + + (c) 1998--2000 Han-Wen Nienhuys + + */ + +#ifndef MUSICAL_PITCH_HH +#define MUSICAL_PITCH_HH + +#include "lily-proto.hh" +#include "smobs.hh" + +/** A "tonal" pitch. This is a pitch as it figures in diatonal western + music (12 semitones in an octave), as opposed to a frequence in Hz + or a integer number of semitones. + +*/ +class Pitch +{ +public: // fixme + /* + TODO: use SCM -- (make private?) + */ + + /// 0 is c, 6 is b + int notename_i_; + + /// 0 natural, 1 sharp, etc + int alteration_i_; + + /// 0 is central c + int octave_i_; + /* + mutators, so JUNKME. + */ + void transpose (Pitch); + void up_to (int); + void down_to (int); + +public: + + int octave_i () const; + int notename_i () const; + int alteration_i () const; + + /* + Pitch is lexicographically ordered by (octave, notename, + alteration). + */ + Pitch (int octave, int notename,int accidental); + Pitch (); + + Pitch to_relative_octave (Pitch); + + static int compare (Pitch const&,Pitch const&); + /// return large part of interval from central c + int steps() const; + /// return pitch from central c (in halfnotes) + int semitone_pitch() const; + String str () const; + + static SCM transpose (SCM p, SCM delta); + + SCM smobbed_copy () const; + DECLARE_SCHEME_CALLBACK(less_p, (SCM a, SCM b)); + DECLARE_SIMPLE_SMOBS(Pitch,); + + +}; + +Pitch* unsmob_pitch (SCM); + +#include "compare.hh" +INSTANTIATE_COMPARE(Pitch, Pitch::compare); + +int compare (Array*, Array*); + +#endif /* MUSICAL_PITCH_HH */ + + diff --git a/lily/include/relative-music.hh b/lily/include/relative-music.hh index a861d451bc..071b34152b 100644 --- a/lily/include/relative-music.hh +++ b/lily/include/relative-music.hh @@ -15,13 +15,13 @@ class Relative_octave_music : public Music_wrapper { public: - Musical_pitch last_pitch_; + Pitch last_pitch_; - Relative_octave_music (Music*, Musical_pitch); + Relative_octave_music (Music*, Pitch); VIRTUAL_COPY_CONS(Music); - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); }; diff --git a/lily/include/repeated-music.hh b/lily/include/repeated-music.hh index b222111fe4..b2deaee08f 100644 --- a/lily/include/repeated-music.hh +++ b/lily/include/repeated-music.hh @@ -54,7 +54,7 @@ public: /// how often do we repeat? int repeat_count( ) const; - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); Moment body_length_mom () const; Moment alternatives_length_mom (bool fold) const; @@ -64,7 +64,7 @@ public: DECLARE_SCHEME_CALLBACK(folded_music_length, (SCM)); /// Transpose, with the interval central C to #p# - virtual void transpose (Musical_pitch p); + virtual void transpose (Pitch p); /// Scale the music in time by #factor#. virtual void compress (Moment factor); diff --git a/lily/include/transposed-music.hh b/lily/include/transposed-music.hh index a559feb2bb..1c3defee06 100644 --- a/lily/include/transposed-music.hh +++ b/lily/include/transposed-music.hh @@ -16,13 +16,13 @@ class Transposed_music : public Music_wrapper { public: - Musical_pitch transpose_to_pitch_; + Pitch transpose_to_pitch_; - Transposed_music (Music*, Musical_pitch); + Transposed_music (Music*, Pitch); VIRTUAL_COPY_CONS(Music); - virtual Musical_pitch to_relative_octave (Musical_pitch); + virtual Pitch to_relative_octave (Pitch); }; #endif /* TRANSPOSED_MUSIC_HH */ diff --git a/lily/key-engraver.cc b/lily/key-engraver.cc index 5546180906..4b1e204a83 100644 --- a/lily/key-engraver.cc +++ b/lily/key-engraver.cc @@ -15,7 +15,7 @@ #include "staff-symbol-referencer.hh" #include "translator-group.hh" #include "engraver.hh" -#include "musical-pitch.hh" +#include "pitch.hh" #include "protected-scm.hh" #include "clef.hh" diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index 39dfa8c57e..09447caa19 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -30,8 +30,6 @@ ly_str02scm (char const*c) return gh_str02scm ((char*)c); } - - /* Pass string to scm parser, evaluate one expression. Return result value and #chars read. diff --git a/lily/local-key-item.cc b/lily/local-key-item.cc index 5caf337451..47e3c4180e 100644 --- a/lily/local-key-item.cc +++ b/lily/local-key-item.cc @@ -1,5 +1,5 @@ /* - local-key-item.cc -- implement Local_key_item, Musical_pitch + local-key-item.cc -- implement Local_key_item, Pitch source file of the GNU LilyPond music typesetter @@ -18,7 +18,7 @@ static SCM pitch_less (SCM p1, SCM p2) { - return Musical_pitch::less_p (gh_car (p1), gh_car (p2)); + return Pitch::less_p (gh_car (p1), gh_car (p2)); } static SCM pitch_less_proc; @@ -33,7 +33,7 @@ ADD_SCM_INIT_FUNC(lkpitch,init_pitch_funcs); void -Local_key_item::add_pitch (Score_element*me, Musical_pitch p, bool cautionary, bool natural) +Local_key_item::add_pitch (Score_element*me, Pitch p, bool cautionary, bool natural) { SCM acs = me->get_elt_property ("accidentals"); SCM pitch = p.smobbed_copy (); @@ -82,7 +82,7 @@ Local_key_item::brew_molecule (SCM smob) for (SCM s = accs; gh_pair_p (s); s = gh_cdr (s)) { - Musical_pitch p (*unsmob_pitch (gh_caar (s))); + Pitch p (*unsmob_pitch (gh_caar (s))); SCM opts = gh_cdar (s); // do one octave diff --git a/lily/lyric-combine-music.cc b/lily/lyric-combine-music.cc index f474443bca..4b9ca36048 100644 --- a/lily/lyric-combine-music.cc +++ b/lily/lyric-combine-music.cc @@ -9,7 +9,7 @@ #include "lyric-combine-music.hh" #include "lyric-combine-music-iterator.hh" -#include "musical-pitch.hh" +#include "pitch.hh" Lyric_combine_music::Lyric_combine_music (Music * m, Music * l) { @@ -22,7 +22,7 @@ Lyric_combine_music::Lyric_combine_music (Music * m, Music * l) void -Lyric_combine_music::transpose (Musical_pitch p) +Lyric_combine_music::transpose (Pitch p) { music_l ()->transpose (p); lyrics_l () ->transpose (p); @@ -35,8 +35,8 @@ Lyric_combine_music::length_mom () const return music_l ()->length_mom (); } -Musical_pitch -Lyric_combine_music::to_relative_octave ( Musical_pitch p ) +Pitch +Lyric_combine_music::to_relative_octave ( Pitch p ) { p = music_l ()->to_relative_octave (p); return lyrics_l () ->to_relative_octave (p); diff --git a/lily/music-list.cc b/lily/music-list.cc index 1a1847783e..a2a82aeccc 100644 --- a/lily/music-list.cc +++ b/lily/music-list.cc @@ -8,7 +8,7 @@ #include "music-list.hh" #include "music-wrapper.hh" -#include "musical-pitch.hh" +#include "pitch.hh" #include "request.hh" #include "musical-request.hh" #include "music-iterator.hh" @@ -45,8 +45,8 @@ Sequential_music::length_mom () const return cumulative_length (); } -Musical_pitch -Simultaneous_music::to_relative_octave (Musical_pitch p) +Pitch +Simultaneous_music::to_relative_octave (Pitch p) { return do_relative_octave (p, true); } @@ -58,15 +58,15 @@ Request_chord::Request_chord(SCM s) Request_chord_iterator::constructor_cxx_function); } -Musical_pitch -Request_chord::to_relative_octave (Musical_pitch last) +Pitch +Request_chord::to_relative_octave (Pitch last) { for (SCM s = music_list (); gh_pair_p (s); s = gh_cdr (s)) { Music * mus = unsmob_music (gh_car (s)); if (Melodic_req *m= dynamic_cast (mus)) { - Musical_pitch pit = *unsmob_pitch (m->get_mus_property ("pitch")); + Pitch pit = *unsmob_pitch (m->get_mus_property ("pitch")); pit.to_relative_octave (last); m->set_mus_property ("pitch", pit.smobbed_copy()); diff --git a/lily/music-sequence.cc b/lily/music-sequence.cc index d8089ad74d..5fd6206da3 100644 --- a/lily/music-sequence.cc +++ b/lily/music-sequence.cc @@ -8,7 +8,7 @@ */ #include "music-list.hh" #include "debug.hh" -#include "musical-pitch.hh" +#include "pitch.hh" void @@ -57,7 +57,7 @@ Music_sequence::Music_sequence(SCM h) } void -Music_sequence::transpose (Musical_pitch rq) +Music_sequence::transpose (Pitch rq) { for (SCM s = music_list (); gh_pair_p (s); s = gh_cdr (s)) unsmob_music (gh_car (s))->transpose (rq); @@ -75,8 +75,8 @@ Music_sequence::cumulative_length () const return last; } -Musical_pitch -Music_sequence::to_relative_octave (Musical_pitch p) +Pitch +Music_sequence::to_relative_octave (Pitch p) { return do_relative_octave (p, false); } @@ -97,13 +97,13 @@ Music_sequence::length_i () const return scm_ilength (music_list ()); } -Musical_pitch -Music_sequence::do_relative_octave (Musical_pitch p, bool ret_first) +Pitch +Music_sequence::do_relative_octave (Pitch p, bool ret_first) { - Musical_pitch retval; + Pitch retval; int count=0; - Musical_pitch last = p; + Pitch last = p; for (SCM s = music_list (); gh_pair_p (s); s = gh_cdr (s)) { last = unsmob_music (gh_car (s))->to_relative_octave (last); diff --git a/lily/music-wrapper.cc b/lily/music-wrapper.cc index ffcba96336..801af5b8e9 100644 --- a/lily/music-wrapper.cc +++ b/lily/music-wrapper.cc @@ -14,7 +14,7 @@ void -Music_wrapper::transpose (Musical_pitch p) +Music_wrapper::transpose (Pitch p) { if (element ()) element ()-> transpose (p); @@ -33,8 +33,8 @@ Music_wrapper::length_mom () const return element ()->length_mom (); } -Musical_pitch -Music_wrapper::to_relative_octave (Musical_pitch p) +Pitch +Music_wrapper::to_relative_octave (Pitch p) { return element ()->to_relative_octave (p); } diff --git a/lily/music.cc b/lily/music.cc index e12ea41ea5..b807dec07e 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -10,7 +10,7 @@ #include "music.hh" #include "music-list.hh" #include "debug.hh" -#include "musical-pitch.hh" +#include "pitch.hh" #include "ly-smobs.icc" SCM @@ -90,15 +90,15 @@ Music::print_smob(SCM s, SCM p, scm_print_state*) return 1; } -Musical_pitch -Music::to_relative_octave (Musical_pitch m) +Pitch +Music::to_relative_octave (Pitch m) { return m; } void -Music::transpose (Musical_pitch ) +Music::transpose (Pitch ) { } diff --git a/lily/musical-request.cc b/lily/musical-request.cc index 15c881df04..ef2b193979 100644 --- a/lily/musical-request.cc +++ b/lily/musical-request.cc @@ -18,9 +18,9 @@ Tremolo_req::Tremolo_req () void -Melodic_req::transpose (Musical_pitch delta) +Melodic_req::transpose (Pitch delta) { - Musical_pitch p = *unsmob_pitch (get_mus_property ("pitch")); + Pitch p = *unsmob_pitch (get_mus_property ("pitch")); p.transpose (delta); diff --git a/lily/note-performer.cc b/lily/note-performer.cc index 946b604c00..d452ae5e87 100644 --- a/lily/note-performer.cc +++ b/lily/note-performer.cc @@ -36,7 +36,7 @@ Note_performer::do_process_music () while (note_req_l_arr_.size ()) { Note_req* n = note_req_l_arr_.pop (); - Musical_pitch pit = * unsmob_pitch (n->get_mus_property ("pitch")); + Pitch pit = * unsmob_pitch (n->get_mus_property ("pitch")); Audio_note* p = new Audio_note (pit, n->length_mom (), transposing_i); Audio_element_info info (p, n); announce_element (info); diff --git a/lily/parser.yy b/lily/parser.yy index 8b1fd7b85b..6f6b260081 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -1180,12 +1180,12 @@ steno_musical_pitch: $$ = $1; } | NOTENAME_PITCH sup_quotes { - Musical_pitch p = *unsmob_pitch ($1); + Pitch p = *unsmob_pitch ($1); p.octave_i_ += $2; $$ = p.smobbed_copy (); } | NOTENAME_PITCH sub_quotes { - Musical_pitch p =* unsmob_pitch ($1); + Pitch p =* unsmob_pitch ($1); p.octave_i_ += -$2; $$ = p.smobbed_copy (); @@ -1202,12 +1202,12 @@ steno_tonic_pitch: $$ = $1; } | TONICNAME_PITCH sup_quotes { - Musical_pitch p = *unsmob_pitch ($1); + Pitch p = *unsmob_pitch ($1); p.octave_i_ += $2; $$ = p.smobbed_copy (); } | TONICNAME_PITCH sub_quotes { - Musical_pitch p =* unsmob_pitch ($1); + Pitch p =* unsmob_pitch ($1); p.octave_i_ += -$2; $$ = p.smobbed_copy (); @@ -1222,7 +1222,7 @@ musical_pitch: | MUSICAL_PITCH embedded_scm { if (!unsmob_pitch ($2)) THIS->parser_error (_f ("Expecting musical-pitch value", 3)); - Musical_pitch m; + Pitch m; $$ = m.smobbed_copy (); } ; @@ -1533,7 +1533,7 @@ FIXME chord: steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass { - $$ = get_chord ($1, $3, $4, $5, $6, $2); + $$ = Chord::get_chord ($1, $3, $4, $5, $6, $2); $$->set_spot (THIS->here_input ()); }; @@ -1597,7 +1597,7 @@ chord_step: chord_note: bare_unsigned { - Musical_pitch m; + Pitch m; m.notename_i_ = ($1 - 1) % 7; m.octave_i_ = $1 > 7 ? 1 : 0; m.alteration_i_ = 0; @@ -1605,7 +1605,7 @@ chord_note: $$ = m.smobbed_copy (); } | bare_unsigned '+' { - Musical_pitch m; + Pitch m; m.notename_i_ = ($1 - 1) % 7; m.octave_i_ = $1 > 7 ? 1 : 0; m.alteration_i_ = 1; @@ -1614,7 +1614,7 @@ chord_note: $$ = m.smobbed_copy (); } | bare_unsigned CHORD_MINUS { - Musical_pitch m; + Pitch m; m.notename_i_ = ($1 - 1) % 7; m.octave_i_ = $1 > 7 ? 1 : 0; m.alteration_i_ = -1; diff --git a/lily/part-combine-music-iterator.cc b/lily/part-combine-music-iterator.cc index 1f813a7445..235b64452e 100644 --- a/lily/part-combine-music-iterator.cc +++ b/lily/part-combine-music-iterator.cc @@ -11,32 +11,9 @@ #include "translator-group.hh" #include "musical-request.hh" #include "music-sequence.hh" +#include "lily-guile.hh" #include "warn.hh" - -/* - DOCUMENTME - */ -int -compare (Array const * left, Array const * right) -{ - assert (left); - assert (right); - - if (left->size () == right->size ()) - { - for (int i = 0; i < left->size (); i++) - { - int r = Duration::compare ((*left)[i], (*right)[i]); - if (r) - return r; - } - } - else - return 1; - return 0; -} - Part_combine_music_iterator::Part_combine_music_iterator () { first_iter_p_ = 0; @@ -131,8 +108,9 @@ Part_combine_music_iterator::change_to (Music_iterator *it, String to_type, } +// SCM*, moet / kan dat niet met set_x ofzo? static void -get_music_info (Moment m, Music_iterator* iter, Array *pitches, Array *durations) +get_music_info (Moment m, Music_iterator* iter, SCM *pitches, SCM *durations) { if (iter->ok ()) { @@ -140,9 +118,9 @@ get_music_info (Moment m, Music_iterator* iter, Array *pitches, A { Music *m = unsmob_music (gh_car (i)); if (Melodic_req *r = dynamic_cast (m)) - pitches->push (*unsmob_pitch (r->get_mus_property("pitch"))); + *pitches = gh_cons (r->get_mus_property("pitch"), *pitches); if (Rhythmic_req *r = dynamic_cast (m)) - durations->push (*unsmob_duration (r->get_mus_property("duration"))); + *durations = gh_cons (r->get_mus_property("duration"), *durations); } } } @@ -199,35 +177,46 @@ Part_combine_music_iterator::get_state (Moment) pending = first_iter->pending_moment () pending_moment (); last_pending = pending; - Array first_pitches; - Array first_durations; - get_music_info (pending, first_iter, &first_pitches, &first_durations); + SCM first_pitches = SCM_EOL; + SCM first_durations = SCM_EOL; + get_music_info (pending, first_iter, + &first_pitches, &first_durations); - Array second_pitches; - Array second_durations; - get_music_info (pending, second_iter, &second_pitches, &second_durations); + SCM second_pitches = SCM_EOL; + SCM second_durations = SCM_EOL; + get_music_info (pending, second_iter, + &second_pitches, &second_durations); - if (first_pitches.size () && second_pitches.size ()) + if (first_pitches != SCM_EOL && second_pitches != SCM_EOL) { - first_pitches.sort (Musical_pitch::compare); - second_pitches.sort (Musical_pitch::compare); - interval = gh_int2scm (first_pitches.top ().steps () - - second_pitches[0].steps ()); + scm_sort_list_x (first_pitches, + scm_eval2 (ly_str02scm ("Pitch::less_p"), + SCM_EOL)); + scm_sort_list_x (second_pitches, + scm_eval2 (ly_str02scm ("Pitch::less_p"), + SCM_EOL)); + interval = gh_int2scm (unsmob_pitch (gh_car (first_pitches))->steps () + - unsmob_pitch (gh_car (scm_last_pair (second_pitches)))->steps ()); } - if (first_durations.size ()) + + if (first_durations != SCM_EOL) { - first_durations.sort (Duration::compare); - first_mom += first_durations.top ().length_mom (); + scm_sort_list_x (first_durations, + scm_eval2 (ly_str02scm ("Duration::less_p"), + SCM_EOL)); + first_mom += unsmob_duration (gh_car (first_durations))->length_mom (); } - - if (second_durations.size ()) + + if (second_durations != SCM_EOL) { - second_durations.sort (Duration::compare); - second_mom += second_durations.top ().length_mom (); + scm_sort_list_x (second_durations, + scm_eval2 (ly_str02scm ("Duration::less_p"), + SCM_EOL)); + second_mom += unsmob_duration (gh_car (second_durations))->length_mom (); } - - if (!first_pitches.empty () && second_pitches.empty () - && !(second_until_ > now)) + + if (first_pitches != SCM_EOL && second_pitches == SCM_EOL + && !(second_until_ > now)) { state |= UNRELATED; state &= ~UNISILENCE; @@ -237,7 +226,7 @@ Part_combine_music_iterator::get_state (Moment) else state &= ~SOLO1; - if (first_pitches.empty () && !second_pitches.empty () + if (first_pitches == SCM_EOL && second_pitches != SCM_EOL && !(first_until_ > now)) { state |= UNRELATED; @@ -248,7 +237,7 @@ Part_combine_music_iterator::get_state (Moment) else state &= ~SOLO2; - if (!compare (&first_durations, &second_durations)) + if (gh_equal_p (first_durations, second_durations)) { state &= ~UNISILENCE; if (!(state & ~(UNIRHYTHM | UNISON))) @@ -257,8 +246,8 @@ Part_combine_music_iterator::get_state (Moment) else state &= ~(UNIRHYTHM | UNISILENCE); - if (!first_pitches.empty () - &&!compare (&first_pitches, &second_pitches)) + if (first_pitches != SCM_EOL + && gh_equal_p (first_pitches, second_pitches)) { state &= ~UNISILENCE; if (!(state & ~(UNIRHYTHM | UNISON))) @@ -267,7 +256,7 @@ Part_combine_music_iterator::get_state (Moment) else state &= ~(UNISON); - if (first_pitches.empty () && second_pitches.empty ()) + if (first_pitches == SCM_EOL && second_pitches == SCM_EOL) { if (!(state & ~(UNIRHYTHM | UNISILENCE))) state |= UNISILENCE; @@ -294,9 +283,9 @@ Part_combine_music_iterator::get_state (Moment) state &= ~(SPLIT_INTERVAL); } - if (first && !first_pitches.empty ()) + if (first && first_pitches != SCM_EOL) first_until_ = first_mom; - if (first && !second_pitches.empty ()) + if (first && second_pitches != SCM_EOL) second_until_ = second_mom; first = false; @@ -374,13 +363,17 @@ Part_combine_music_iterator::process (Moment m) if (combine_b != previously_combined_b) change_to (second_iter_p_, w, (combine_b ? "one" : "two") + suffix_); - + Translator_group *first_translator = first_iter_p_->report_to_l ()->find_create_translator_l (w, "one" + suffix_); Translator_group *second_translator = second_iter_p_->report_to_l ()->find_create_translator_l (w, "two" + suffix_); + - /* - hmm - */ + /* Hmm */ + first_translator->set_property ("combineParts", SCM_BOOL_T); + second_translator ->set_property ("combineParts", SCM_BOOL_T); + + + /* hmm */ SCM b = (state & UNIRHYTHM) ? SCM_BOOL_T : SCM_BOOL_F; first_translator->set_property ("unirhythm", b); second_translator->set_property ("unirhythm", b); diff --git a/lily/part-combine-music.cc b/lily/part-combine-music.cc index 91c351fc02..ea53d706b5 100644 --- a/lily/part-combine-music.cc +++ b/lily/part-combine-music.cc @@ -9,7 +9,7 @@ #include "part-combine-music.hh" #include "part-combine-music-iterator.hh" -#include "musical-pitch.hh" +#include "pitch.hh" Part_combine_music::Part_combine_music (SCM what, Music * f, Music * s) { @@ -26,7 +26,7 @@ Part_combine_music::Part_combine_music (SCM what, Music * f, Music * s) } void -Part_combine_music::transpose (Musical_pitch p) +Part_combine_music::transpose (Pitch p) { first_l ()->transpose (p); second_l () ->transpose (p); @@ -40,8 +40,8 @@ Part_combine_music::length_mom () const return first_l ()->length_mom (); } -Musical_pitch -Part_combine_music::to_relative_octave (Musical_pitch p) +Pitch +Part_combine_music::to_relative_octave (Pitch p) { p = first_l ()->to_relative_octave (p); return second_l ()->to_relative_octave (p); diff --git a/lily/musical-pitch.cc b/lily/pitch.cc similarity index 70% rename from lily/musical-pitch.cc rename to lily/pitch.cc index fad725bb23..a6447b5f26 100644 --- a/lily/musical-pitch.cc +++ b/lily/pitch.cc @@ -1,38 +1,19 @@ /* - musical-pitch.cc -- implement Musical_pitch + musical-pitch.cc -- implement Pitch source file of the GNU LilyPond music typesetter (c) 1998--2000 Han-Wen Nienhuys */ -#include "musical-pitch.hh" +#include "pitch.hh" #include "debug.hh" #include "main.hh" #include "ly-smobs.icc" -int -compare (Array* left, Array* right) -{ - assert (left); - assert (right); - - if (left->size () == right->size ()) - { - for (int i = 0; i < left->size (); i++) - { - int r = Musical_pitch::compare ((*left)[i], (*right)[i]); - if (r) - return r; - } - } - else - return 1; - return 0; -} -Musical_pitch::Musical_pitch (int o, int n, int a) +Pitch::Pitch (int o, int n, int a) { notename_i_ = n; alteration_i_ = a; @@ -48,7 +29,7 @@ Musical_pitch::Musical_pitch (int o, int n, int a) } } -Musical_pitch::Musical_pitch () +Pitch::Pitch () { notename_i_ = 0; alteration_i_ = 0; @@ -56,7 +37,7 @@ Musical_pitch::Musical_pitch () } int -Musical_pitch::compare (Musical_pitch const &m1, Musical_pitch const &m2) +Pitch::compare (Pitch const &m1, Pitch const &m2) { int o= m1.octave_i_ - m2.octave_i_; int n = m1.notename_i_ - m2.notename_i_; @@ -72,7 +53,7 @@ Musical_pitch::compare (Musical_pitch const &m1, Musical_pitch const &m2) } int -Musical_pitch::steps () const +Pitch::steps () const { return notename_i_ + octave_i_*7; } @@ -83,13 +64,14 @@ Musical_pitch::steps () const static Byte pitch_byte_a[ ] = { 0, 2, 4, 5, 7, 9, 11 }; int -Musical_pitch::semitone_pitch () const +Pitch::semitone_pitch () const { return pitch_byte_a[ notename_i_ % 7 ] + alteration_i_ + octave_i_ * 12; } +/* WHugh, wat een intervaas */ void -Musical_pitch::transpose (Musical_pitch delta) +Pitch::transpose (Pitch delta) { int old_pitch = semitone_pitch (); int delta_pitch = delta.semitone_pitch (); @@ -109,6 +91,9 @@ Musical_pitch::transpose (Musical_pitch delta) } + + +/* FIXME */ #if 0 // nice test for internationalisation strings char const *accname[] = {"double flat", "flat", "natural", @@ -118,7 +103,7 @@ char const *accname[] = {"eses", "es", "", "is" , "isis"}; #endif String -Musical_pitch::str () const +Pitch::str () const { int n = (notename_i_ + 2) % 7; String s = to_str (char(n + 'a')); @@ -146,17 +131,17 @@ Musical_pitch::str () const change me to relative, counting from last pitch p return copy of resulting pitch */ -Musical_pitch -Musical_pitch::to_relative_octave (Musical_pitch p) +Pitch +Pitch::to_relative_octave (Pitch p) { int oct_mod = octave_i_ + 1; // account for c' = octave 1 iso. 0 4 - Musical_pitch up_pitch (p); - Musical_pitch down_pitch (p); + Pitch up_pitch (p); + Pitch down_pitch (p); up_pitch.alteration_i_ = alteration_i_; down_pitch.alteration_i_ = alteration_i_; - Musical_pitch n = *this; + Pitch n = *this; up_pitch.up_to (notename_i_); down_pitch.down_to (notename_i_); @@ -173,7 +158,7 @@ Musical_pitch::to_relative_octave (Musical_pitch p) } void -Musical_pitch::up_to (int notename) +Pitch::up_to (int notename) { if (notename_i_ > notename) { @@ -183,7 +168,7 @@ Musical_pitch::up_to (int notename) } void -Musical_pitch::down_to (int notename) +Pitch::down_to (int notename) { if (notename_i_ < notename) { @@ -192,26 +177,42 @@ Musical_pitch::down_to (int notename) notename_i_ = notename; } +///MAKE_SCHEME_CALLBACK (Pitch, transpose, 2); +///transpose_proc? +SCM +Pitch::transpose (SCM p, SCM delta) +{ + Pitch t = *unsmob_pitch (p); + t.transpose (*unsmob_pitch (delta)); + return t.smobbed_copy (); +} + +static SCM +pitch_transpose (SCM p, SCM delta) +{ + return Pitch::transpose (p, delta); +} + /****************************************************************/ -IMPLEMENT_TYPE_P(Musical_pitch, "pitch?"); -IMPLEMENT_UNSMOB(Musical_pitch, pitch); +IMPLEMENT_TYPE_P(Pitch, "pitch?"); +IMPLEMENT_UNSMOB(Pitch, pitch); SCM -Musical_pitch::mark_smob (SCM ) +Pitch::mark_smob (SCM ) { return SCM_EOL; } -IMPLEMENT_SIMPLE_SMOBS(Musical_pitch); +IMPLEMENT_SIMPLE_SMOBS(Pitch); int -Musical_pitch::print_smob (SCM s, SCM port, scm_print_state *) +Pitch::print_smob (SCM s, SCM port, scm_print_state *) { - Musical_pitch *r = (Musical_pitch *) gh_cdr (s); + Pitch *r = (Pitch *) gh_cdr (s); - scm_puts ("#str().ch_C()), port); scm_puts (" >", port); @@ -219,10 +220,10 @@ Musical_pitch::print_smob (SCM s, SCM port, scm_print_state *) } SCM -Musical_pitch::equal_p (SCM a , SCM b) +Pitch::equal_p (SCM a , SCM b) { - Musical_pitch *p = (Musical_pitch *) gh_cdr (a); - Musical_pitch *q = (Musical_pitch *) gh_cdr (b); + Pitch *p = (Pitch *) gh_cdr (a); + Pitch *q = (Pitch *) gh_cdr (b); bool eq = p->notename_i_ == q->notename_i_ && p->octave_i_ == q->octave_i_ @@ -231,12 +232,12 @@ Musical_pitch::equal_p (SCM a , SCM b) return eq ? SCM_BOOL_T : SCM_BOOL_F; } -MAKE_SCHEME_CALLBACK(Musical_pitch, less_p, 2); +MAKE_SCHEME_CALLBACK(Pitch, less_p, 2); SCM -Musical_pitch::less_p (SCM p1, SCM p2) +Pitch::less_p (SCM p1, SCM p2) { - Musical_pitch *a = unsmob_pitch (p1); - Musical_pitch *b = unsmob_pitch (p2); + Pitch *a = unsmob_pitch (p1); + Pitch *b = unsmob_pitch (p2); if (compare(*a, *b) < 0 ) return SCM_BOOL_T; @@ -251,7 +252,7 @@ Musical_pitch::less_p (SCM p1, SCM p2) static SCM make_pitch (SCM o, SCM n, SCM a) { - Musical_pitch p; + Pitch p; p.octave_i_ = gh_scm2int (o); p.notename_i_ = gh_scm2int (n); p.alteration_i_ = gh_scm2int (a); @@ -261,7 +262,7 @@ make_pitch (SCM o, SCM n, SCM a) static SCM pitch_octave (SCM pp) { - Musical_pitch *p = unsmob_pitch (pp); + Pitch *p = unsmob_pitch (pp); int q = 0; if (!p) warning ("Not a pitch"); @@ -274,7 +275,7 @@ pitch_octave (SCM pp) static SCM pitch_alteration (SCM pp) { - Musical_pitch *p = unsmob_pitch (pp); + Pitch *p = unsmob_pitch (pp); int q = 0; if (!p) warning ("Not a pitch"); @@ -287,7 +288,7 @@ pitch_alteration (SCM pp) static SCM pitch_notename (SCM pp) { - Musical_pitch *p = unsmob_pitch (pp); + Pitch *p = unsmob_pitch (pp); int q = 0; if (!p) warning ("Not a pitch"); @@ -300,7 +301,7 @@ pitch_notename (SCM pp) static SCM pitch_semitones (SCM pp) { - Musical_pitch *p = unsmob_pitch (pp); + Pitch *p = unsmob_pitch (pp); int q = 0; if (!p) warning ("Not a pitch"); @@ -313,36 +314,39 @@ pitch_semitones (SCM pp) static void add_funcs() { + // should take list?: (make-pitch '(octave name accidental)) scm_make_gsubr ("make-pitch", 3, 0, 0, (Scheme_function_unknown)make_pitch); + scm_make_gsubr ("pitch-octave", 1, 0, 0, (Scheme_function_unknown)pitch_octave); scm_make_gsubr ("pitch-notename", 1, 0, 0, (Scheme_function_unknown)pitch_notename); scm_make_gsubr ("pitch-alteration", 1, 0, 0, (Scheme_function_unknown)pitch_alteration); scm_make_gsubr ("pitch-semitones", 1, 0, 0, (Scheme_function_unknown)pitch_semitones); + scm_make_gsubr ("Pitch::transpose", 2, 0, 0, (Scheme_function_unknown) pitch_transpose); } ADD_SCM_INIT_FUNC(pitch, add_funcs); SCM -Musical_pitch::smobbed_copy ()const +Pitch::smobbed_copy ()const { - Musical_pitch * p = new Musical_pitch (*this); + Pitch * p = new Pitch (*this); return p->smobbed_self (); } int -Musical_pitch::octave_i ()const +Pitch::octave_i ()const { return octave_i_; } int -Musical_pitch::notename_i () const +Pitch::notename_i () const { return notename_i_; } int -Musical_pitch::alteration_i () const +Pitch::alteration_i () const { return alteration_i_; } diff --git a/lily/relative-octave-music.cc b/lily/relative-octave-music.cc index f339aa92ca..2c7480bdc9 100644 --- a/lily/relative-octave-music.cc +++ b/lily/relative-octave-music.cc @@ -10,14 +10,14 @@ #include "relative-music.hh" #include "debug.hh" -Musical_pitch -Relative_octave_music::to_relative_octave (Musical_pitch) +Pitch +Relative_octave_music::to_relative_octave (Pitch) { return last_pitch_; } -Relative_octave_music::Relative_octave_music(Music*p,Musical_pitch def) +Relative_octave_music::Relative_octave_music(Music*p,Pitch def) : Music_wrapper (p) { last_pitch_ = element ()->to_relative_octave (def); diff --git a/lily/repeated-music.cc b/lily/repeated-music.cc index 6f2a0913be..fec8d7be73 100644 --- a/lily/repeated-music.cc +++ b/lily/repeated-music.cc @@ -9,7 +9,7 @@ #include "repeated-music.hh" #include "music-list.hh" -#include "musical-pitch.hh" +#include "pitch.hh" #include "debug.hh" Music * @@ -48,13 +48,13 @@ Repeated_music::Repeated_music (Repeated_music const &s) } -Musical_pitch -Repeated_music::to_relative_octave (Musical_pitch p) +Pitch +Repeated_music::to_relative_octave (Pitch p) { if (body ()) p = body ()->to_relative_octave (p); - Musical_pitch last = p ; + Pitch last = p ; if (alternatives ()) for (SCM s = alternatives ()->music_list (); gh_pair_p (s); s = gh_cdr (s)) unsmob_music (gh_car (s))->to_relative_octave (p); @@ -64,7 +64,7 @@ Repeated_music::to_relative_octave (Musical_pitch p) } void -Repeated_music::transpose (Musical_pitch p) +Repeated_music::transpose (Pitch p) { if (body ()) body ()->transpose (p); diff --git a/lily/tie-engraver.cc b/lily/tie-engraver.cc index 277a4206e2..576e465317 100644 --- a/lily/tie-engraver.cc +++ b/lily/tie-engraver.cc @@ -146,7 +146,7 @@ Tie_engraver::process_acknowledged () while (i >= 0 && j >=0) { int comp - = Musical_pitch::compare (*unsmob_pitch (now_heads_[i].req_l_->get_mus_property ("pitch") ), + = Pitch::compare (*unsmob_pitch (now_heads_[i].req_l_->get_mus_property ("pitch") ), *unsmob_pitch (stopped_heads_[j].req_l_->get_mus_property ("pitch"))); if (comp) @@ -294,7 +294,7 @@ CHead_melodic_tuple::pitch_compare (CHead_melodic_tuple const&h1, SCM p1 = h1.req_l_->get_mus_property ("pitch"); SCM p2 = h2.req_l_->get_mus_property ("pitch"); - return Musical_pitch::equal_p (p1,p2) == SCM_BOOL_T; + return Pitch::equal_p (p1,p2) == SCM_BOOL_T; } int diff --git a/lily/tie-performer.cc b/lily/tie-performer.cc index feb335d6e8..521ac201c4 100644 --- a/lily/tie-performer.cc +++ b/lily/tie-performer.cc @@ -74,7 +74,7 @@ Tie_performer::process_acknowledged () while ( i < now_notes_.size () && j < stopped_notes_.size ()) { int comp - = Musical_pitch::compare (*unsmob_pitch (now_notes_[i].req_l_->get_mus_property ("pitch") ), + = Pitch::compare (*unsmob_pitch (now_notes_[i].req_l_->get_mus_property ("pitch") ), *unsmob_pitch (stopped_notes_[j].req_l_->get_mus_property ("pitch"))); if (comp) @@ -159,7 +159,7 @@ CNote_melodic_tuple::pitch_compare (CNote_melodic_tuple const&h1, { SCM p1 = h1.req_l_->get_mus_property ("pitch"); SCM p2 = h2.req_l_->get_mus_property ("pitch"); - return Musical_pitch::compare (*unsmob_pitch (p1), + return Pitch::compare (*unsmob_pitch (p1), *unsmob_pitch (p2)); } diff --git a/lily/transposed-music.cc b/lily/transposed-music.cc index e22f19f8f2..74aa3006ec 100644 --- a/lily/transposed-music.cc +++ b/lily/transposed-music.cc @@ -10,7 +10,7 @@ #include "transposed-music.hh" #include "debug.hh" -Transposed_music::Transposed_music (Music *p, Musical_pitch pit) +Transposed_music::Transposed_music (Music *p, Pitch pit) : Music_wrapper (p) { transpose_to_pitch_ = pit; @@ -19,8 +19,8 @@ Transposed_music::Transposed_music (Music *p, Musical_pitch pit) } -Musical_pitch -Transposed_music::to_relative_octave (Musical_pitch p) +Pitch +Transposed_music::to_relative_octave (Pitch p) { return p; } diff --git a/lilypond-mode.el b/lilypond-mode.el index 6e3de95f4d..c833e3b0b8 100644 --- a/lilypond-mode.el +++ b/lilypond-mode.el @@ -114,7 +114,7 @@ in LilyPond-include-path." ;; This is the major configuration variable. (defcustom LilyPond-command-alist - '( + `( ("LilyPond" . ("lilypond %s" . "TeX")) ("TeX" . ("tex '\\nonstopmode\\input %t'" . "View")) @@ -122,7 +122,7 @@ in LilyPond-include-path." ("SmartView" . ("xdvi %d" . "LilyPond")) ;; refreshes when kicked USR1 - ("View" . ((concat LilyPond-xdvi-command " %d") . "LilyPond")) + ("View" . (,(concat LilyPond-xdvi-command " %d") . "LilyPond")) ) "AList of commands to execute on the current document. diff --git a/ly/catalan.ly b/ly/catalan.ly index 403494d2cb..c55565c8d0 100644 --- a/ly/catalan.ly +++ b/ly/catalan.ly @@ -17,7 +17,7 @@ % For using "sostingut" notation, which is also correct -\notenames #'( +\notenames #`( (dobb . ,(make-pitch -1 0 -2 )) (dob . ,(make-pitch -1 0 -1 )) (do . ,(make-pitch -1 0 0 )) diff --git a/make/out/lilypond.lsm b/make/out/lilypond.lsm index db406f7cce..af983620e8 100644 --- a/make/out/lilypond.lsm +++ b/make/out/lilypond.lsm @@ -1,15 +1,15 @@ Begin3 Title: LilyPond -Version: 1.3.107 -Entered-date: 13NOV00 +Version: 1.3.108 +Entered-date: 15NOV00 Description: Keywords: music notation typesetting midi fonts engraving Author: hanwen@cs.uu.nl (Han-Wen Nienhuys) janneke@gnu.org (Jan Nieuwenhuizen) Maintained-by: hanwen@stack.nl (Han-Wen Nienhuys) Primary-site: sunsite.unc.edu /pub/Linux/apps/sound/convert - 1000k lilypond-1.3.107.tar.gz + 1000k lilypond-1.3.108.tar.gz Original-site: ftp.cs.uu.nl /pub/GNU/LilyPond/development/ - 1000k lilypond-1.3.107.tar.gz + 1000k lilypond-1.3.108.tar.gz Copying-policy: GPL End diff --git a/make/out/lilypond.spec b/make/out/lilypond.spec index a984ef4172..6c4f55c114 100644 --- a/make/out/lilypond.spec +++ b/make/out/lilypond.spec @@ -1,11 +1,11 @@ %define info yes Name: lilypond -Version: 1.3.107 +Version: 1.3.108 Release: 1 License: GPL Group: Applications/Publishing -Source0: ftp.cs.uu.nl:/pub/GNU/LilyPond/development/lilypond-1.3.107.tar.gz +Source0: ftp.cs.uu.nl:/pub/GNU/LilyPond/development/lilypond-1.3.108.tar.gz Summary: A program for printing sheet music. URL: http://www.cs.uu.nl/~hanwen/lilypond # Icon: lilypond-icon.gif diff --git a/scm/backend-documentation-lib.scm b/scm/backend-documentation-lib.scm index e61b2ac07b..33ca2f2a19 100644 --- a/scm/backend-documentation-lib.scm +++ b/scm/backend-documentation-lib.scm @@ -1,4 +1,3 @@ - ;;; backend-documentation-lib.scm -- Functions for backend documentation ;;; ;;; source file of the GNU LilyPond music typesetter @@ -10,43 +9,53 @@ ;;; This file generates documentation for the backend of lilypond. ;; alist of property descriptions -;; when called by First level Interface description, desc == '() -;; CDR "not set" is only used for Second level Element description -(define (document-element-property prop desc) - (let ((handle (assoc (car prop) desc))) - (cons - (string-append "@code{" (symbol->string (car prop)) "} " - "(" (type-name (cadr prop)) ")" - (if (equal? desc '()) "" ":")) - (string-append (if (equal? desc '()) - (caddr prop) - (if (pair? handle) - (string-append (caddr prop) - "\ndefault value: @code{" - (scm->string (cdr handle)) - "}") - "not set")))))) -;; First level Interface description -;; Second level, part of element description -(define (document-interface level interface element-description) - (let* ((name (car interface)) + +(define (document-element-property property-def element-description only-doc-if-set) + " +" + (let* ( + (handle (assoc (car property-def) element-description)) + (def-val-str (if (eq? handle #f) + "not set" + (scm->texi (cdr handle)))) + + (name (symbol->string (car property-def))) + (type (type-name (cadr property-def))) + (desc (caddr property-def)) + ) + + (if (and (eq? handle #f) only-doc-if-set) + '("" . "") + (cons (string-append "@code{" name "} " + "(" type ")" + ":" ) + (string-append desc + "\nDefault value: " + def-val-str)) + )) + ) + +(define (document-interface where interface element-description) + " + +" + (let* ((level (if (eq? where 'element) 3 2)) + (name (car interface)) (desc (cadr interface)) (props (caddr interface)) - (docs (map (lambda (x) - (document-element-property x element-description)) - props))) + (docfun (lambda (x) + (document-element-property + x element-description (eq? where 'element)))) + (docs (map docfun props)) + ) (string-append - (section level (string-append (interface-name (symbol->string name)))) + (texi-section level (string-append (interface-name (symbol->string name))) (eq? where 'element)) ;gur. desc - (description-list - ;; filter-out entries with CDR "not set" - (apply append - (map (lambda (x) - (if (string-match "not set" (cdr x)) '() (list x))) - docs)))))) + (description-list->texi docs) + ))) ;; First level Interface description (define (document-separate-interface interface) @@ -54,7 +63,7 @@ (processing name) (string-append (node (interface-name name)) - (document-interface 2 interface '())))) + (document-interface 'self interface '())))) ;; First level element description (define (document-element iname description) @@ -68,12 +77,12 @@ (name (cdr (assoc 'name meta))) (ifaces (cdr (assoc 'interface-descriptions meta))) - (ifacedoc (map (lambda (x) (document-interface 3 x description)) + (ifacedoc (map (lambda (x) (document-interface 'element x description)) (reverse ifaces)))) (string-append (node (element-name name)) - (section 2 (element-name name)) + (texi-section 2 (element-name name) #f) "\n" (let* ((element (string->symbol name)) @@ -131,8 +140,10 @@ (load "lily.scm"))) (use-modules (ice-9 string-fun)) + +(define interface-file-str (string-append (ly-gulp-file "interface.scm") "\n(define ")) (define (list-interface-names) - (let* ((text (string-append (ly-gulp-file "interface.scm") "\n(define ")) + (let* ((text interface-file-str) (r (make-regexp "\n[(](define *([a-z-]*-interface)*)*[^\n]*")) (t (regexp-substitute/global #f r text 2 " " 'post)) diff --git a/scm/documentation-lib.scm b/scm/documentation-lib.scm index 7e1648846c..e94a23de9a 100644 --- a/scm/documentation-lib.scm +++ b/scm/documentation-lib.scm @@ -1,4 +1,4 @@ -;;; +;; ;;; documentation-lib.scm -- Assorted Functions for generated documentation ;;; ;;; source file of the GNU LilyPond music typesetter @@ -28,11 +28,16 @@ ;; ) ;; x2)) + + +(define (scm->texi x) + (string-append "@code{" (texify (scm->string x)) "}") + ) + (define (scm->string val) (string-append (if (self-evaluating? val) "" "'") - (texify - (call-with-output-string (lambda (port) (display val port)))) + (call-with-output-string (lambda (port) (display val port))) )) (define (node name) @@ -42,7 +47,7 @@ "\n@end html" "\n@node " name ",,,")) -(define section-alist +(define texi-section-alist '( ;; Hmm, texinfo doesn't have ``part'' (0 . "@top") @@ -53,15 +58,34 @@ (5 . "@unnumberedsubsubsec") )) -(define (section level name) - (string-append "\n" (cdr (assoc level section-alist)) " " name "\n")) - -(define (description-list items-alist) +(define (texi-section level name ref) + "texi sectioning command (lower LEVEL means more significant). +Add a ref if REF is set +" + + (string-append + "\n" (cdr (assoc level texi-section-alist)) " " + (if ref + (string-append "@ref{" name "}") + name) + "\n")) + + +(define (one-item->texi label-desc-pair) + "Document one (LABEL . DESC); return empty string if LABEL is empty string. +" + (if (eq? (car label-desc-pair) "") + "" + (string-append "\n@item " (car label-desc-pair) "\n" (cdr label-desc-pair)) + )) + + +(define (description-list->texi items-alist) + "Document ITEMS-ALIST in a table. entries contain (item-label . string-to-use) +" (string-append "\n@table @samp\n" - (apply string-append - (map (lambda (x) (string-append "\n@item " (car x) "\n" (cdr x))) - items-alist)) + (apply string-append (map one-item->texi items-alist)) "\n@end table\n")) (define (texi-menu items-alist) @@ -74,7 +98,7 @@ ;; Menus don't appear in html, so we make a list ourselves "\n@ignore\n" "\n@ifhtml\n" - (description-list (map (lambda (x) (cons (reffy (car x)) (cdr x))) + (description-list->texi (map (lambda (x) (cons (reffy (car x)) (cdr x))) items-alist)) "\n@end ifhtml\n" "\n@end ignore\n")) @@ -83,7 +107,7 @@ (define (texi-node-menu name items-alist) (string-append (node name) - (section 1 name) + (texi-section 1 name #f) (texi-menu items-alist))) (define (texi-file-head name file-name top items-alist) @@ -93,7 +117,7 @@ "\n@settitle " name (node "Top") top "\n@top" - (section 1 name) + (texi-section 1 name #f) (texi-menu items-alist) "\n@contents" )) diff --git a/scm/element-descriptions.scm b/scm/element-descriptions.scm index 0b0e552b2f..0fba22b977 100644 --- a/scm/element-descriptions.scm +++ b/scm/element-descriptions.scm @@ -105,9 +105,9 @@ )) (Crescendo . ( - (molecule-callback . ,Crescendo::brew_molecule) + (molecule-callback . ,Hairpin::brew_molecule) (thickness . 1.0) - (shorten-for-letter . 4.0) + (padding . 1.0) (height . 0.6666) (dash-thickness . 1.2) (dash-length . 4.0) @@ -291,7 +291,7 @@ (font-family . roman) (meta . ,(element-description "NoteName" note-name-interface font-interface - general-element-interface)) + )) )) (OctavateEight . ( diff --git a/scm/engraver-documentation-lib.scm b/scm/engraver-documentation-lib.scm index 1fcc5914b3..b98483a04e 100644 --- a/scm/engraver-documentation-lib.scm +++ b/scm/engraver-documentation-lib.scm @@ -19,9 +19,10 @@ ;; First level Engraver description and ;; second level Context description -(define (document-engraver level engraver-descr) +(define (document-engraver where engraver-descr) (let* ( + (level (if (eq? where 'context) 3 2)) (props (car (cdddr engraver-descr))) (name (car engraver-descr)) (desc (cadr engraver-descr)) @@ -29,14 +30,14 @@ ) (string-append - (section level (engraver-name name)) + (texi-section level (engraver-name name) (eq? where 'context)) desc "\n\n" (if (null? props) "" (string-append - (section (+ level 1) "Properties") - (description-list + (texi-section (+ level 1) "Properties" #f) + (description-list->texi (map (lambda (x) (document-translator-property x)) props)))) (if (null? objs) "" @@ -74,7 +75,7 @@ (processing name) (string-append (node (engraver-name name)) - (document-engraver 2 description)))) + (document-engraver 'self description)))) ;; Second level, part of Context description (define (document-engraver-by-name name) @@ -85,7 +86,7 @@ (if (eq? eg #f) (string-append "Engraver " name ", not documented.\n") - (document-engraver 3 (cdr eg)) + (document-engraver 'context (cdr eg)) ) )) @@ -127,7 +128,7 @@ (processing name) (string-append (node (context-name name)) - (section 2 (context-name name)) + (texi-section 2 (context-name name) #f) doc))) (define (document-paper name) diff --git a/scm/generate-documentation.scm b/scm/generate-documentation.scm index 09a8a72ee6..22253f66e4 100644 --- a/scm/generate-documentation.scm +++ b/scm/generate-documentation.scm @@ -33,7 +33,8 @@ (document-paper "LilyPond interpretation contexts") (document-all-engravers "LilyPond engravers") (document-all-elements "LilyPond backend") - (document-all-interfaces "LilyPond interfaces")) + (document-all-interfaces "LilyPond interfaces") + ) ) (name "lilypond-internals") (outname (string-append name ".texi")) diff --git a/scm/interface.scm b/scm/interface.scm index 7a5683c887..ddc17acb9a 100644 --- a/scm/interface.scm +++ b/scm/interface.scm @@ -131,14 +131,8 @@ more than this (in staffspace)") 'note-column-interface "Stem and noteheads combined" (list - (elt-property-description 'horizontal-shift integer? "integer that identifies ranking of note-column for horizontal shifting.") - (elt-property-description 'force-hshift number? "amount of collision_note_width that overides automatic collision settings.") - (elt-property-description 'merge-differently-dotted boolean? "merge black noteheads with differing dot count in collisions. - -Merge noteheads in collisions, even if they have a different number of -dots. This normal notation for polyphonic guitar music. - -") + (elt-property-description 'horizontal-shift integer? "integer that identifies ranking of note-column for horizontal shifting. This is used by @ref{note-collision-interface}") + (elt-property-description 'force-hshift number? "amount of collision_note_width that overides automatic collision settings. This is used by @ref{note-collision-interface}") )) ) @@ -387,12 +381,13 @@ Align_interface::center_on_element). ") (elt-property-description 'grow-direction dir? "crescendo or decrescendo?") (elt-property-description 'thickness number? "thickness, measured in stafflinethickness") (elt-property-description 'height number? "height, measured in staffspace.") + (elt-property-description 'padding number? "horizontal padding. This is useful if a crescendo is set next to a text like `mf'") ))) (define arpeggio-interface (lily-interface 'arpeggio-interface - "arpeggio" + "Functions and settings for drawing an arpeggio symbol (a wavy line left to noteheads." (list (elt-property-description 'stems list? "list of stem objects, corresponding to the notes that the arpeggio has to be before.") ) @@ -402,8 +397,16 @@ Align_interface::center_on_element). ") (define note-collision-interface (lily-interface 'note-collision-interface - "note collision" + "An object that handles collisions between notes with different +stem directions and horizontal shifts. Most of the interesting +properties are to be set in @ref{note-column-interface}" (list + (elt-property-description 'merge-differently-dotted boolean? " +Merge noteheads in collisions, even if they have a different number of +dots. This normal notation for some types of polyphonic music. The +value of this setting is used by @ref{note-collision-interface} + +") (elt-property-description 'note-width 'number? "unit for horizontal translation, measured in staff-space.") ) ) ) diff --git a/scm/translator-description.scm b/scm/translator-description.scm index 5cad9dbf56..fad552e139 100644 --- a/scm/translator-description.scm +++ b/scm/translator-description.scm @@ -880,8 +880,7 @@ defaultBarType, barAlways, barNonAuto and measurePosition. (translator-property-description 'barAlways boolean? " If set to true a bar line is drawn after each note. ") - (translator-property-description 'defaultBarType string? "Sets the default type of bar line. See Section XREF-barlines [FIXME] - for a list of available bar types. + (translator-property-description 'defaultBarType string? "Sets the default type of bar line. Available bar types: [FIXME] ") (translator-property-description 'skipBars boolean? " Set to true to skip the empty bars that are produced by multimeasure notes and rests. These bars will not appear on the -- 2.39.5