Hi,
On Wed, May 10, 2017 at 9:31 AM, David Nalesnik
<david.nales...@gmail.com> wrote:
>
>
> On Wed, May 10, 2017 at 9:23 AM, daviau ewen <ewen.dav...@gmail.com> wrote:
>>
>> Is that okay ?
>> http://lilypond.1069038.n5.nabble.com/file/n203059/incdiato82.ly
>>>
>>>
>
> Yes, thank you.
>
Your original:
% ici on défini les points qu'on fait sur le piano
#(define (make-dot-list l1)
(if (null? l1)
empty-stencil
(ly:stencil-add
(make-dot (ly:pitch-notename (car l1)))
)))
OK, your function is intended to return a list of dots, but you only
call make-dot on the first element of the list.
You need to apply make-dot to every element of your pitch list, and
then combine these into a stencil. To combine stencils, I use reduce:
(Documentation here:
https://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/SRFI_002d1-Fold-and-Map.html#index-append_002dmap-3619).
I found reduce and fold somewhat difficult to grasp at first, but they
definitely repay study.
My rewrite:
#(define (make-dot-list l1)
(reduce
ly:stencil-add
empty-stencil
(map
(lambda (dl) (make-dot (ly:pitch-notename dl)))
l1)))
%%%%%%%%%%%%%
Your original:
#(define-markup-command (complete layout props the-chord)
(ly:music?)
(ly:stencil-scale
( ly:stencil-add
(engrave-back)
(make-dot-list (map (lambda (m) (ly:music-property m 'pitch))
(extract-named-music the-chord 'NoteEvent)))
)
1
1))
Here, the error messages are instructive. The function ly:stencil-add
expects its arguments to be individual stencils, but you are providing
it with *lists* of stencils (the result of calling engrave-back and
make-dot-list--the latter corrected as I show above, of course!)
The solution once again is to first create a list of stencils, then
combine them using reduce:
#(define-markup-command (complete layout props the-chord)
(ly:music?)
(ly:stencil-scale
(reduce
ly:stencil-add
empty-stencil
(cons
(make-dot-list (map (lambda (m) (ly:music-property m 'pitch))
(extract-named-music the-chord 'NoteEvent)))
(engrave-back)))
1 1))
%%%%%%
Of course, scaling the stencil to 100% is both axes is a bit redundant!
Another observation: the greenish dots are hard to see.
I've attached the whole file (with some formatting changes that helped
me read it better).
Hope this helps,
David
%2) On dessine les points
%------------------------------------------------------
% ici on défini les points qu'on fait sur le piano
#(define (make-dot-list l1)
(reduce
ly:stencil-add
empty-stencil
(map
(lambda (dl) (make-dot (ly:pitch-notename dl)))
l1)))
% ici on défini i on fait des ronds noirs ou blancs
#(define (make-dot key)
(ly:stencil-in-color
(ly:stencil-translate
(make-circle-stencil 0.25 0.1 #f)
(key-to-pos key))
(car (key-to-color key))
(cadr (key-to-color key))
(caddr (key-to-color key)))) % pour les ronds noirs
% ici on défini les couleurs R V B associés à chaque notes
#(define (key-to-color key )
(let ((keycolor (caddr (assq key Color-KEY-LIST))))
(if (not keycolor)
(ly:error (_ "Color diagram error - unkown note '~a'") key)
(caddr (assq key Color-KEY-LIST)))))
% ici on défini les positions des points du clavier en y
#(define (key-to-pos key )
(let ((keypos (assq key KEY-POS-LIST)))
(if (not keypos)
(ly:error (_ "keyboard diagram error - unkown note '~a'") key)
(caddr (assq key KEY-POS-LIST)))))
#(define KEY-POS-LIST
'(
(-8 . '( 0 . 0))
(-7 . '( 0 . 1))
(-6 . '( 0 . 2))
(-5 . '( 0 . 3))
(-4 . '( 1 . 0))
(-3 . '( 1 . 1))
(-2 . '( 1 . 2))
(-1 . '( 1 . 3))
(0 . '( 0 . 0))
(1 . '( 0 . 1))
(2 . '( 0 . 2))
(3 . '( 0 . 3))
(4 . '( 1 . 0))
(5 . '( 1 . 1))
(6 . '( 1 . 2))
(7 . '( 1 . 3))
(8 . '( 0.71 . 1))
(9 . '( 0.71 . 1))
(10 . '( 0.71 . 1))
(11 . '( 0.71 . 1))
(12 . '( 0.71 . 1))
(13 . '( 0.71 . 1))
(14 . '( 0.71 . 1))
(15 . '( 0.71 . 1))
(16 . '( 0.71 . 1))
(17 . '( 0.71 . 1))
(18 . '( 0.71 . 1))
(19 . '( 0.71 . 1))
(20 . '( 0.71 . 1))
(21 . '( 0.71 . 1))
(22 . '( 0.71 . 1))
(23 . '( 0.71 . 1))
))
#(define Color-KEY-LIST
'(
(-11 . '( 0.71 1 1))
(-10 . '( 0.71 1 1))
(-9 . '( 0.71 1 1))
(-8 . '( 0.71 1 1))
(-7 . '( 0.71 1 1))
(-6 . '( 0.71 0.2 1))
(-5 . '( 0.71 0.2 1))
(-4 . '( 0.71 0.2 1))
(-3 . '( 0.71 0.2 1))
(-2 . '( 0.71 0.2 1))
(-1 . '( 0.71 0.2 1))
(0 . '( 0.71 1 1))
(1 . '( 0.71 1 1))
(2 . '( 0.71 1 1))
(3 . '( 0.71 1 1))
(4 . '( 0.71 1 1))
(5 . '( 0.71 0.2 1))
(6 . '( 0.71 0.2 1))
(7 . '( 0.71 0.2 1))
(8 . '( 0.71 0.2 1))
(9 . '( 0.71 0.2 1))
(10 . '( 0.71 0.2 1))
(11 . '( 0.71 0.2 1))
(12 . '( 0.71 0.2 1))
(13 . '( 0.71 0.2 1))
(14 . '( 0.71 0.2 1))
(15 . '( 0.71 0.2 1))
(16 . '( 0.71 0.2 1))
(17 . '( 0.71 0.2 1))
(18 . '( 0.71 0.2 1))
(19 . '( 0.71 0.2 1))
(20 . '( 0.71 0.2 1))
(21 . '( 0.71 0.2 1))
(22 . '( 0.71 0.2 1))
(23 . '( 0.71 0.2 1))
))
#(define (engrave-back)
(map (lambda (p) (ly:stencil-in-color
(ly:stencil-translate
(make-circle-stencil 0.4 0 #f)
p)
0 0 0))
'((0 . 0)
(0 . 1)
(0 . 2)
(0 . 3)
(1 . 0)
(1 . 1)
(1 . 2)
(1 . 3)))
) % pour les ronds noirs
#(define-markup-command (complete layout props the-chord)
(ly:music?)
(ly:stencil-scale
(reduce
ly:stencil-add
empty-stencil
(cons
(make-dot-list (map (lambda (m) (ly:music-property m 'pitch))
(extract-named-music the-chord 'NoteEvent)))
(engrave-back)))
1 1))
diag=
#(define-music-function (parser location music)
(ly:music?)
(music-map
(lambda (m)
(if (music-is-of-type? m 'event-chord)
#{ <>^\markup \complete #m $m #}
m))
music))
global = {
\time 4/4
\key a \minor
\tempo 4=80
}
% ici on écrit la parto
melody = \relative c'' {
\global
\bar ".|:"a8 a16 b a g e g a8 g16 a c b a g d'8 d c16 b a g c d b8. b16 c b |
a8 a16 b a g e g a8 g16 a c b a g d'8 d c16 b a g c d b8. b16 c d \break|
e8 e d16 c b a d8 c16 d e c a b c8 b16 a d8 c16 b a b c d b8 c16 d|
e8 e d16 c b a d8 c16 d e c a b | c8 b16 a d c d e b8 a16 g a r8 r16|
\bar ":|."
}
chordNames =
\chordmode {
\global
c8 a4:m5 g8:5 a8:m5 a:m5 a:m5 a:m5 d:m5 d4:m7 d8:m7 f:5 g4:5 e8:m/b
a8:m5 a4:m5 g8:5 a8:m5 a:m5 a:m5 a:m5 d:m5 d4:m7 d8:m7 f:5 g4:5 g8:5
a8:m5 a4:m5 a8:m5 g8:5 a4:m5 a8:m5 f:5 f:5 d4:m7 f:5 g8:5 g8:5
c4:5 c4:5 d8:m7 d4:m7 d8:m7 f4:5 g4:5 f8:5 g8:5 a,4:m }
\score {
<<
\new ChordNames \with { \consists "Text_engraver" } \diag \chordNames
\new Staff { \melody }
>>
\layout {}
\midi { }
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user