From fbda0de6b70400e8cf9d44cdfaa75051891977d0 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 4 Feb 2006 13:39:18 +0000 Subject: [PATCH] * scm/music-functions.scm (pitch-of-note): new function. * ly/music-functions-init.ly: add \octave and \addquote * lily/parser.yy (music_function_chord_body): softcode \octave. (lilypond_header): softcode \addquote --- ChangeLog | 9 +++++++++ lily/beaming-info.cc | 3 +-- lily/lily-lexer.cc | 2 -- lily/parser.yy | 23 +++-------------------- ly/music-functions-init.ly | 17 +++++++++++++++++ scm/music-functions.scm | 11 +++++++++++ 6 files changed, 41 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9ccc5d06aa..6062291452 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-02-04 Han-Wen Nienhuys + + * scm/music-functions.scm (pitch-of-note): new function. + + * ly/music-functions-init.ly: add \octave and \addquote + + * lily/parser.yy (music_function_chord_body): softcode \octave. + (lilypond_header): softcode \addquote + 2006-02-03 Jan Nieuwenhuizen * flower/include/std-vector.hh[STD_VECTOR]: Do not include diff --git a/lily/beaming-info.cc b/lily/beaming-info.cc index c4444c17a6..27dcc68265 100644 --- a/lily/beaming-info.cc +++ b/lily/beaming-info.cc @@ -77,8 +77,7 @@ Beaming_info_list::beamify (Moment &beat_length, bool subdivide) do splits[d].beamify (beat_length, subdivide); - while (flip (&d) != LEFT) - ; + while (flip (&d) != LEFT); int middle_beams = (split ? 1 : min (splits[RIGHT].beam_extend_count (LEFT), diff --git a/lily/lily-lexer.cc b/lily/lily-lexer.cc index ddf8510e9d..c4f2731cac 100644 --- a/lily/lily-lexer.cc +++ b/lily/lily-lexer.cc @@ -26,7 +26,6 @@ static Keyword_ent the_key_tab[] = { {"accepts", ACCEPTS}, {"addlyrics", ADDLYRICS}, - {"addquote", ADDQUOTE}, {"alias", ALIAS}, {"alternative", ALTERNATIVE}, {"book", BOOK}, @@ -57,7 +56,6 @@ static Keyword_ent the_key_tab[] {"new", NEWCONTEXT}, {"notemode", NOTEMODE}, {"objectid", OBJECTID}, - {"octave", OCTAVE}, {"once", ONCE}, {"override", OVERRIDE}, {"paper", PAPER}, diff --git a/lily/parser.yy b/lily/parser.yy index 080406a08a..651ef44a52 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -450,9 +450,6 @@ object_id_setting: toplevel_expression: lilypond_header { THIS->lexer_->set_identifier (ly_symbol2scm ("$defaultheader"), $1); - } - | add_quote { - } | book_block { Book *book = $1; @@ -871,6 +868,7 @@ Alternative_music: Repeated_music: REPEAT simple_string bare_unsigned Music Alternative_music { + /*TODO: move to Scheme.*/ Music *beg = $4; int times = $3; SCM alts = scm_is_pair ($5) ? scm_car ($5) : SCM_EOL; @@ -1064,9 +1062,9 @@ Prefix_composite_music: } | TIMES fraction Music - { - int n = scm_to_int (scm_car ($2)); int d = scm_to_int (scm_cdr ($2)); + int n = scm_to_int (scm_car ($2)); + int d = scm_to_int (scm_cdr ($2)); Music *mp = $3; $$= MY_MAKE_MUSIC ("TimeScaledMusic"); @@ -1568,15 +1566,6 @@ music_function_chord_body: ; -add_quote: - ADDQUOTE string Music { - SCM adder = ly_lily_module_constant ("add-quotable"); - - scm_call_2 (adder, $2, $3->self_scm ()); - $3->unprotect(); - } - ; - command_element: command_event { $$ = MY_MAKE_MUSIC ("EventChord"); @@ -1592,12 +1581,6 @@ command_element: skip->set_spot (@$); $$ = skip; } - | OCTAVE pitch { - Music *m = MY_MAKE_MUSIC ("RelativeOctaveCheck"); - $$ = m; - $$->set_spot (@$); - $$->set_property ("pitch", $2); - } | E_BRACKET_OPEN { Music *m = MY_MAKE_MUSIC ("LigatureEvent"); m->set_property ("span-direction", scm_from_int (START)); diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index 77bdedc9fb..cf185485b6 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -406,3 +406,20 @@ Example: spacingTweaks = #(def-music-function (parser location parameters) (list?) (make-music 'SequentialMusic 'void #t)) + +octave = +#(def-music-function (parser location pitch-note) (ly:music?) + "octave check" + + (make-music 'RelativeOctaveCheck + 'origin location + 'pitch (pitch-of-note pitch-note) + )) + +addquote = +#(def-music-function (parser location name music) (string? ly:music?) + "Add a piece of music to be quoted " + (add-quotable name music) + (make-music 'SequentialMusic 'void #t)) + + diff --git a/scm/music-functions.scm b/scm/music-functions.scm index b0ff69a6db..724165a88f 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -963,3 +963,14 @@ use GrandStaff as a context. " (ly:make-duration 0 0) '()))) (ly:music-compress skip (ly:music-length mus)) skip)) + +(define-public (pitch-of-note event-chord) + + (let* + ((evs (filter (lambda (x) (memq 'note-event (ly:music-property x 'types))) + (ly:music-property event-chord 'elements)))) + + (if (pair? evs) + (ly:music-property (car evs) 'pitch) + #f))) + -- 2.39.2