[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: parser.yy et al: Turn \transpose into a music function, make other m
From: |
dak |
Subject: |
Re: parser.yy et al: Turn \transpose into a music function, make other music functions use ly:pitch? (issue 4991049) |
Date: |
Sun, 11 Sep 2011 12:50:46 +0000 |
Reviewers: Reinhold, J_lowe,
Message:
Made the requested spacing changes and pushed.
Description:
parser.yy et al: Turn \transpose into a music function.
This removes \transpose from its special treatment in the parser.
Please review this at http://codereview.appspot.com/4991049/
Affected files:
M lily/lily-lexer.cc
M lily/parser.yy
M ly/music-functions-init.ly
M scm/ly-syntax-constructors.scm
M scm/modal-transforms.scm
Index: lily/lily-lexer.cc
diff --git a/lily/lily-lexer.cc b/lily/lily-lexer.cc
index
ba6429c3ea2798344702178363f200071c0f73cc..47fd1522dba266d794f86fd502f220d5fcae10e3
100644
--- a/lily/lily-lexer.cc
+++ b/lily/lily-lexer.cc
@@ -89,7 +89,6 @@ static Keyword_ent the_key_tab[]
{"tempo", TEMPO},
{"time", TIME_T},
{"times", TIMES},
- {"transpose", TRANSPOSE},
{"type", TYPE},
{"unset", UNSET},
{"with", WITH},
Index: lily/parser.yy
diff --git a/lily/parser.yy b/lily/parser.yy
index
176b4a08777375b8b17332cc8828283f931feb1b..f72b7c0958d44d7610c23dd98d458c591d8b5c72
100644
--- a/lily/parser.yy
+++ b/lily/parser.yy
@@ -216,7 +216,6 @@ void set_music_properties (Music *p, SCM a);
%token SKIP "\\skip"
%token TEMPO "\\tempo"
%token TIMES "\\times"
-%token TRANSPOSE "\\transpose"
%token TYPE "\\type"
%token UNSET "\\unset"
%token WITH "\\with"
@@ -1213,12 +1212,6 @@ prefix_composite_music:
$$ = MAKE_SYNTAX ("time-scaled-music", @$, $2, $3);
}
| repeated_music { $$ = $1; }
- | TRANSPOSE pitch_also_in_chords pitch_also_in_chords music {
- Pitch from = *unsmob_pitch ($2);
- Pitch to = *unsmob_pitch ($3);
- SCM pitch = pitch_interval (from, to).smobbed_copy ();
- $$ = MAKE_SYNTAX ("transpose-music", @$, pitch, $4);
- }
| mode_changing_head grouped_music_list {
if ($1 == ly_symbol2scm ("chords"))
{
Index: ly/music-functions-init.ly
diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly
index
b3a009860753c54d7ab7549617ab4ba6f32d3ae5..a0f232d66136fa6ca1bc088cb55f86ff14ba1fa1
100644
--- a/ly/music-functions-init.ly
+++ b/ly/music-functions-init.ly
@@ -517,7 +517,7 @@ makeClusters =
modalInversion =
#(define-music-function (parser location around to scale music)
- (ly:music? ly:music? ly:music? ly:music?)
+ (ly:pitch? ly:pitch? ly:music? ly:music?)
(_i "Invert @var{music} about @var{around} using @var{scale} and
transpose from @var{around} to @var{to}.")
(let ((inverter (make-modal-inverter around to scale)))
@@ -526,7 +526,7 @@ transpose from @var{around} to @var{to}.")
modalTranspose =
#(define-music-function (parser location from to scale music)
- (ly:music? ly:music? ly:music? ly:music?)
+ (ly:pitch? ly:pitch? ly:music? ly:music?)
(_i "Transpose @var{music} from pitch @var{from} to pitch @var{to}
using @var{scale}.")
(let ((transposer (make-modal-transposer from to scale)))
@@ -535,7 +535,7 @@ using @var{scale}.")
inversion =
#(define-music-function
- (parser location around to music) (ly:music? ly:music? ly:music?)
+ (parser location around to music) (ly:pitch? ly:pitch? ly:music?)
(_i "Invert @var{music} about @var{around} and
transpose from @var{around} to @var{to}.")
(music-invert around to music))
@@ -570,10 +570,10 @@ markups), or inside a score.")
octaveCheck =
-#(define-music-function (parser location pitch-note) (ly:music?)
+#(define-music-function (parser location pitch) (ly:pitch?)
(_i "Octave check.")
(make-music 'RelativeOctaveCheck
- 'pitch (pitch-of-note pitch-note)))
+ 'pitch pitch))
ottava =
#(define-music-function (parser location octave) (integer?)
@@ -843,18 +843,13 @@ removeWithTag =
music))
resetRelativeOctave =
-#(define-music-function (parser location reference-note) (ly:music?)
+#(define-music-function (parser location pitch) (ly:pitch?)
(_i "Set the octave inside a \\relative section.")
- (let* ((notes (ly:music-property reference-note 'elements))
- (pitch (ly:music-property (car notes) 'pitch)))
-
- (set! (ly:music-property reference-note 'elements) '())
- (set! (ly:music-property reference-note 'to-relative-callback)
- (lambda (music last-pitch)
- pitch))
-
- reference-note))
+ (make-music 'SequentialMusic
+ 'to-relative-callback
+ (lambda (music last-pitch)
+ pitch)))
retrograde =
#(define-music-function (parser location music)
@@ -875,16 +870,11 @@ rightHandFinger =
#(define-music-function (parser location finger) (number-or-string?)
(_i "Apply @var{finger} as a fingering indication.")
- (apply make-music
- (append
- (list
+ (make-music
'StrokeFingerEvent
- 'origin location)
- (if (string? finger)
- (list 'text finger)
- (list 'digit finger)))))
-
-
+ 'origin location
+ (if (string? finger) 'text 'digit)
+ finger))
scaleDurations =
#(define-music-function (parser location fraction music)
@@ -943,13 +933,22 @@ tag =
(ly:music-property arg 'tags)))
arg)
+transpose =
+#(define-music-function
+ (parser location from to music)
+ (ly:pitch? ly:pitch? ly:music?)
+
+ (_i "Transpose @var{music} from pitch @var{from} to pitch @var{to}.")
+ (make-music 'TransposedMusic
+ 'element (ly:music-transpose music (ly:pitch-diff to
from))))
+
transposedCueDuring =
#(define-music-function
- (parser location what dir pitch-note main-music)
- (string? ly:dir? ly:music? ly:music?)
+ (parser location what dir pitch main-music)
+ (string? ly:dir? ly:pitch? ly:music?)
(_i "Insert notes from the part @var{what} into a voice called
@code{cue},
-using the transposition defined by @var{pitch-note}. This happens
+using the transposition defined by @var{pitch}. This happens
simultaneously with @var{main-music}, which is usually a rest. The
argument @var{dir} determines whether the cue notes should be notated
as a first or second voice.")
@@ -960,15 +959,15 @@ as a first or second voice.")
'quoted-context-id "cue"
'quoted-music-name what
'quoted-voice-direction dir
- 'quoted-transposition (pitch-of-note pitch-note)))
+ 'quoted-transposition pitch))
transposition =
-#(define-music-function (parser location pitch-note) (ly:music?)
+#(define-music-function (parser location pitch) (ly:pitch?)
(_i "Set instrument transposition")
(context-spec-music
(make-property-set 'instrumentTransposition
- (ly:pitch-negate (pitch-of-note pitch-note)))
+ (ly:pitch-negate pitch))
'Staff))
tweak =
Index: scm/ly-syntax-constructors.scm
diff --git a/scm/ly-syntax-constructors.scm b/scm/ly-syntax-constructors.scm
index
540cc24d741ec655faebb126f7a19d841a3db496..e25539c469f794aaf6aa8fb7a04ef9c0f029bd52
100644
--- a/scm/ly-syntax-constructors.scm
+++ b/scm/ly-syntax-constructors.scm
@@ -89,10 +89,6 @@
'numerator (car fraction)
'denominator (cdr fraction)))
-(define-ly-syntax-simple (transpose-music pitch music)
- (make-music 'TransposedMusic
- 'element (ly:music-transpose music pitch)))
-
(define-ly-syntax (tempo parser location text . rest)
(let* ((unit (and (pair? rest)
(car rest)))
Index: scm/modal-transforms.scm
diff --git a/scm/modal-transforms.scm b/scm/modal-transforms.scm
index
151fb8c3be06edcea7e213291989398428d43fea..2d604fc948d1e56d8358bd997663c213f8be5441
100644
--- a/scm/modal-transforms.scm
+++ b/scm/modal-transforms.scm
@@ -176,21 +176,15 @@ Typically used to construct a scale for input to
transposer-factory
;; ------------- PUBLIC FUNCTIONS -----------------------------
-(define-public (make-modal-transposer from-pitch to-pitch scale)
+(define-public (make-modal-transposer from to scale)
"Wrapper function for transposer-factory."
- (let ((transposer (transposer-factory (make-extended-scale scale)))
- (from (car (extract-pitch-sequence from-pitch)))
- (to (car (extract-pitch-sequence to-pitch))))
-
+ (let ((transposer (transposer-factory (make-extended-scale scale))))
(lambda (p)
(transposer from to p))))
-(define-public (make-modal-inverter around-pitch to-pitch scale)
+(define-public (make-modal-inverter around to scale)
"Wrapper function for inverter-factory"
- (let ((inverter (inverter-factory (make-extended-scale scale)))
- (around (car (extract-pitch-sequence around-pitch)))
- (to (car (extract-pitch-sequence to-pitch))))
-
+ (let ((inverter (inverter-factory (make-extended-scale scale))))
(lambda (p)
(inverter around to p))))
@@ -231,9 +225,6 @@ and transposes from @var{around} to @var{to}."
(ly:pitch-transpose to (ly:pitch-diff around p))))
music))
-(define-public (music-invert around-pitch to-pitch music)
+(define-public (music-invert around to music)
"Applies pitch-invert to all pitches in @var{music}."
- (let ((around (car (extract-pitch-sequence around-pitch)))
- (to (car (extract-pitch-sequence to-pitch))))
- (music-map (lambda (x) (pitch-invert around to x)) music)))
-
+ (music-map (lambda (x) (pitch-invert around to x)) music))