[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Problem to pass regular music as argument to a particular Scheme functio
From: |
Menu Jacques |
Subject: |
Problem to pass regular music as argument to a particular Scheme function |
Date: |
Mon, 4 May 2015 10:56:48 +0200 |
Hello folks,
Someone recently supplied on this list a way to draw large, colored brackets to
emphasize repeats, with fixed X offsets though.
I tried to go one step further by defining functions in order to be able to
specify the X offset at will.
\displayMusic showed me what to put in their body, but I bump into the fact
that the music itself is frozen is their code.
How can I get the example below to work with a regular note as extra argument?
I’d like to be able to write something such as:
\myColoredLeftBracket d’2. #-4.6
Or maybe would it be better and more in the LP spirit to be able to write:
d’2. \myColoredLeftBracket #-4.6
I don’t know how to get:
'duration
(ly:make-duration 0)
'pitch
(ly:make-pitch -1 0)
at the right place from a music argument such as d’2. .
The same question arises by the way for:
(list 1 0.647058823529412 0)
which is the orange color in this example.
Thanks for you help!
JM
%%%%%%%%%%%%
\version "2.19.17"
coloredLeftRepeatBracketPath = #'(
(moveto 1 -4.5)
(lineto 0 -2.5)
(lineto 0 2.5)
(lineto 1 4.5))
coloredRightRepeatBracketPath = #'(
(moveto -1 -4.5)
(lineto 0 -2.5)
(lineto 0 2.5)
(lineto -1 4.5))
% Variables with frozen X offsets
coloredLeftBracket =
-\tweak layer #-1
-\tweak extra-offset #'( -2.3 . -2.5)
^\markup {
\with-color #(x11-color "orange")
\with-dimensions #'(0 . 0) #'(0 . 0)
\path #1 #coloredLeftRepeatBracketPath
}
coloredRightBracket =
-\tweak layer #-1
-\tweak extra-offset #'(4.4 . -3.1)
^\markup {
\with-color #(x11-color "orange")
\with-dimensions #'(0 . 0) #'(0 . 0)
\path #1 #coloredRightRepeatBracketPath
}
% Attempts at parameterized functions instead of frozen X offsets
% Code obtained thru \displayMusic and adapted
myColoredLeftBracket =
#(define-music-function (parser location x-offset) (number?)
(make-music
'SequentialMusic
'elements
(list (make-music
'NoteEvent
'articulations
(list (make-music
'TextScriptEvent
'tweaks
(list (cons (quote layer) -1)
(cons (quote extra-offset) (cons x-offset -2.5)))
'direction
1
'text
(markup
#:line
(#:with-color
(list 1 0.647058823529412 0)
(#:with-dimensions
(cons 0 0)
(cons 0 0)
(#:path
1
(list (list (quote moveto) 1 -4.5)
(list (quote lineto) 0 -2.5)
(list (quote lineto) 0 2.5)
(list (quote lineto) 1 4.5))))))))
'duration
(ly:make-duration 0)
'pitch
(ly:make-pitch -1 0))))
)
myColoredRightBracket =
#(define-music-function (parser location x-offset) (number?)
(make-music
'SequentialMusic
'elements
(list (make-music
'NoteEvent
'articulations
(list (make-music
'TextScriptEvent
'tweaks
(list (cons (quote layer) -1)
(cons (quote extra-offset) (cons x-offset -3.1)))
'direction
1
'text
(markup
#:line
(#:with-color
(list 1 0.647058823529412 0)
(#:with-dimensions
(cons 0 0)
(cons 0 0)
(#:path
1
(list (list (quote moveto) -1 -4.5)
(list (quote lineto) 0 -2.5)
(list (quote lineto) 0 2.5)
(list (quote lineto) -1 4.5))))))))
'duration
(ly:make-duration 0)
'pitch
(ly:make-pitch -1 0))))
)
{
\displayMusic {c1 \coloredLeftBracket}
}
{
\displayMusic {d'2. \coloredRightBracket}
}
{
\displayMusic {d'2.}
}
{
\myColoredLeftBracket #-4.6
}
{
\myColoredRightBracket #6.0
}
%%%%%%%%%%%%
- Problem to pass regular music as argument to a particular Scheme function,
Menu Jacques <=