[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: keyboard graphic
From: |
David Kastrup |
Subject: |
Re: keyboard graphic |
Date: |
Wed, 01 Jun 2016 16:28:45 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) |
Jim Tisdall <address@hidden> writes:
> I need to display small graphics of a piano keyboard with selected
> notes indicated by color.
>
> It will be used similarly as the guitar fret diagrams and actually
> in conjunction with them (and with standard and tablature notation,
> and explanatory comments) as guitarists examine chord voicings.
>
> I've found a few things but thought I'd ask here if some lilypond user
> has developed such a graphic in the system. Or, an expert advice on
> where to begin to develop one myself within lilypond, would be most
> appreciated.
>
> My wish list is parameters for range, width/height, and pressed keys;
> labels under the pressed keys would be a nice plus.
Here is something that is not a piano keyboard but has the advantage
that it works automatically. You'll need to redo the graphics, of
course.
\version "2.18.0"
#(define (c-griff start end pressed)
(define (add-circle prev n filled?)
#{ \markup \combine #prev
\translate #(cons (- 3 (modulo n 3))
(- (/ n 3)))
\draw-circle #0.35 #0.1 #filled? #})
(let loop ((i start)
(m #{ \markup \null #})
(pressed (member start (sort pressed <) <=)))
(if (> i end)
m
(loop (1+ i)
(add-circle m
(- i (- start (modulo start 3)))
(and (pair? pressed) (= (car pressed) i)))
(and pressed (member i pressed <))))))
Dia_engraver =
#(define-scheme-function ((parser location low hi) context)
(ly:pitch? ly:pitch?)
(let ((pitches '()) (cause #f))
(make-engraver
((start-translation-timestep engraver)
(set! pitches '())
(set! cause #f))
(listeners
((note-event engraver event)
(set! pitches (cons (ly:event-property event 'pitch) pitches))
(if (not cause)
(set! cause event))))
((process-music engraver)
(if cause
(let ((g (ly:engraver-make-grob engraver 'LyricText cause)))
(set! (ly:grob-property g 'text)
(c-griff (ly:pitch-semitones low)
(ly:pitch-semitones hi)
(map ly:pitch-semitones pitches)))))))))
#(use-modules (scm accreg))
treble =
\relative {
\tag full \clef "treble" \discant "10"
r8 s32 f'[ bes f] s e[ a e] s d[ g d] s16 e32[ a]
\discant "121"
<< { r16 <f bes> r <e a> r <d g> } \tag full \\
{ d r a r bes r } >> |
<cis e a>1
}
\new PianoStaff
<<
\new Lyrics \with { \consists \Dia_engraver a b' }
\removeWithTag full \treble
\new Staff \treble
\new Staff \relative
{ \clef "treble" \freeBass "1"
r8 d'32 s16. c32 s16. bes32 s16. a32[ cis] s16
\clef "bass" \stdBass "Master"
<< { r16 <f, bes d>^"b" r <e a c>^"am" r <d g bes>^"gm" |
<e a cis>1^"a" } \\
{ d8_"D" c_"C" bes_"B" | a1_"A" }
>>
}
>>
--
David Kastrup