|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
Coloring note heads by pitchI've spent some time trying to figure this out, and I'm certain it's
possible; the only question is, what's the cleanest way to do it? I want to print out score with each note color coded (middle C in red, D in orange, E in green) to match a set of bells. Currently, I have a fairly straightforward setup, but exceedingly tedious: identify the bell AND give the music expression. What I'd like to do is make it that I can simply key in the music as is, and then have some scriptwork figure out what color to make each one based on its staffposition. Current code: % Is there an alternative to this shocking editor inheritance? bell = #(define-music-function (parser location bellnum mus) (integer? ly:music?) (if (eq? bellnum 1) #{ \once \override NoteHead #'color = #red \once \override Stem #'color = #red $mus #} (if (eq? bellnum 2) #{ \once \override NoteHead #'color = #orange \once \override Stem #'color = #orange $mus #} (if (eq? bellnum 3) #{ \once \override NoteHead #'color = #yellow \once \override Stem #'color = #yellow $mus #} (if (eq? bellnum 4) #{ \once \override NoteHead #'color = #green \once \override Stem #'color = #green $mus #} (if (eq? bellnum 5) #{ \once \override NoteHead #'color = #darkgreen \once \override Stem #'color = #darkgreen $mus #} (if (eq? bellnum 6) #{ \once \override NoteHead #'color = #cyan \once \override Stem #'color = #cyan $mus #} (if (eq? bellnum 7) #{ \once \override NoteHead #'color = #darkblue \once \override Stem #'color = #darkblue $mus #} (if (eq? bellnum 8) #{ \once \override NoteHead #'color = #magenta \once \override Stem #'color = #magenta $mus #} #{ #} ))))))))) ... and inside the Voice: % Every note must be entered as a bell identifier (#1 being the lowest bell, and #8 being the highest), % in addition to its note definition. s2 \bell #1 c8( \bell #2 d8) \bell #3 e2 \bell #3 e4 \bell #5 g4.( \bell #4 f8) \bell #3 e4 \bell #2 d4.( \bell #3 e8) \bell #4 f4 \bell #3 e2 r4 This is tedious and error-prone, as I have to give all information twice. I'm pretty certain that my failure is due to my lack of knowledge of the system, and that the experts on this list will be able to offer a solution - maybe there's one already built and ready! ChrisA Hopeful in the trusting, rather than futile, sense! :) _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
|
|
Re: Coloring note heads by pitchHi Chris
Does the example in the Learning Manual help? I think it does exactly what you want. See section 4.6.6. Trevor ----- Original Message ----- From: "Chris Angelico" <rosuav@...> To: <lilypond-user@...> Sent: Monday, November 02, 2009 7:05 PM Subject: Coloring note heads by pitch > I've spent some time trying to figure this out, and I'm certain > it's > possible; the only question is, what's the cleanest way to do it? > > I want to print out score with each note color coded (middle C in > red, > D in orange, E in green) to match a set of bells. Currently, I > have a > fairly straightforward setup, but exceedingly tedious: identify > the > bell AND give the music expression. What I'd like to do is make it > that I can simply key in the music as is, and then have some > scriptwork figure out what color to make each one based on its > staffposition. > > Current code: > > % Is there an alternative to this shocking editor inheritance? > bell = #(define-music-function (parser location bellnum mus) > (integer? > ly:music?) > (if (eq? bellnum 1) #{ \once \override NoteHead #'color = #red > \once \override Stem #'color = #red $mus #} > (if (eq? bellnum 2) #{ \once \override NoteHead #'color = > #orange > \once \override Stem #'color = #orange $mus #} > (if (eq? bellnum 3) #{ \once \override NoteHead #'color = > #yellow > \once \override Stem #'color = #yellow $mus #} > (if (eq? bellnum 4) #{ \once \override NoteHead #'color = > #green > \once \override Stem #'color = #green $mus #} > (if (eq? bellnum 5) #{ \once \override NoteHead #'color = > #darkgreen \once \override Stem #'color = #darkgreen $mus #} > (if (eq? bellnum 6) #{ \once \override NoteHead #'color = #cyan > \once \override Stem #'color = #cyan $mus #} > (if (eq? bellnum 7) #{ \once \override NoteHead #'color = > #darkblue \once \override Stem #'color = #darkblue $mus #} > (if (eq? bellnum 8) #{ \once \override NoteHead #'color = > #magenta > \once \override Stem #'color = #magenta $mus #} > #{ #} > ))))))))) > > > > ... and inside the Voice: > % Every note must be entered as a bell identifier > (#1 > being the lowest bell, and #8 being the highest), > % in addition to its note definition. > s2 > \bell #1 c8( > \bell #2 d8) > \bell #3 e2 > \bell #3 e4 > \bell #5 g4.( > \bell #4 f8) > \bell #3 e4 > \bell #2 d4.( > \bell #3 e8) > \bell #4 f4 > \bell #3 e2 > r4 > > This is tedious and error-prone, as I have to give all information > twice. I'm pretty certain that my failure is due to my lack of > knowledge of the system, and that the experts on this list will be > able to offer a solution - maybe there's one already built and > ready! > > ChrisA > Hopeful in the trusting, rather than futile, sense! :) > > > _______________________________________________ > lilypond-user mailing list > lilypond-user@... > http://lists.gnu.org/mailman/listinfo/lilypond-user > _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
|
|
RE: Coloring note heads by pitchHere's a solution I use for "easy" harp music where all C's and F's are red
and blue. I'm cutting and pasting from several different files, so this might not be in the right order, but at least it'll give you a good starting point: #(define (pitch-to-color pitch) (cond ((eqv? (ly:pitch-notename pitch) 0) (x11-color 'red)) ((eqv? (ly:pitch-notename pitch) 3) (x11-color 'RoyalBlue)) ) ) #(define (color-notehead-harp grob) "Color the notehead according to its pitch." (pitch-to-color (ly:event-property (ly:grob-property grob 'cause) 'pitch))) \layout { % Define the EasyHarpStaff context \context { \PianoStaff \type "Engraver_group" \name EasyHarpStaff \alias PianoStaff % Color C's red and F's blue \override NoteHead #'color = #color-notehead-harp } % Add EasyHarpStaff to Score \context { \Score \accepts EasyHarpStaff } } \score { \new EasyHarpStaff << c4 d e f | g a b c' | >> } --Steven -----Original Message----- From: lilypond-user-bounces+panteck=hotmail.com@... [mailto:lilypond-user-bounces+panteck=hotmail.com@...] On Behalf Of Chris Angelico Sent: Monday, November 02, 2009 11:05 AM To: lilypond-user@... Subject: Coloring note heads by pitch I've spent some time trying to figure this out, and I'm certain it's possible; the only question is, what's the cleanest way to do it? I want to print out score with each note color coded (middle C in red, D in orange, E in green) to match a set of bells. Currently, I have a fairly straightforward setup, but exceedingly tedious: identify the bell AND give the music expression. What I'd like to do is make it that I can simply key in the music as is, and then have some scriptwork figure out what color to make each one based on its staffposition. Current code: % Is there an alternative to this shocking editor inheritance? bell = #(define-music-function (parser location bellnum mus) (integer? ly:music?) (if (eq? bellnum 1) #{ \once \override NoteHead #'color = #red \once \override Stem #'color = #red $mus #} (if (eq? bellnum 2) #{ \once \override NoteHead #'color = #orange \once \override Stem #'color = #orange $mus #} (if (eq? bellnum 3) #{ \once \override NoteHead #'color = #yellow \once \override Stem #'color = #yellow $mus #} (if (eq? bellnum 4) #{ \once \override NoteHead #'color = #green \once \override Stem #'color = #green $mus #} (if (eq? bellnum 5) #{ \once \override NoteHead #'color = #darkgreen \once \override Stem #'color = #darkgreen $mus #} (if (eq? bellnum 6) #{ \once \override NoteHead #'color = #cyan \once \override Stem #'color = #cyan $mus #} (if (eq? bellnum 7) #{ \once \override NoteHead #'color = #darkblue \once \override Stem #'color = #darkblue $mus #} (if (eq? bellnum 8) #{ \once \override NoteHead #'color = #magenta \once \override Stem #'color = #magenta $mus #} #{ #} ))))))))) ... and inside the Voice: % Every note must be entered as a bell identifier (#1 being the lowest bell, and #8 being the highest), % in addition to its note definition. s2 \bell #1 c8( \bell #2 d8) \bell #3 e2 \bell #3 e4 \bell #5 g4.( \bell #4 f8) \bell #3 e4 \bell #2 d4.( \bell #3 e8) \bell #4 f4 \bell #3 e2 r4 This is tedious and error-prone, as I have to give all information twice. I'm pretty certain that my failure is due to my lack of knowledge of the system, and that the experts on this list will be able to offer a solution - maybe there's one already built and ready! ChrisA Hopeful in the trusting, rather than futile, sense! :) _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
|
|
Re: Coloring note heads by pitchOn Tue, Nov 3, 2009 at 6:27 AM, Trevor Daniels <t.daniels@...> wrote:
> Hi Chris > > Does the example in the Learning Manual help? I think it does exactly what > you want. See section 4.6.6. > > Trevor Strange. I just looked up the manual, and it doesn't HAVE a section 4.6.6... and then found out why. Seems that when you google for 'lilypond learning manual', the first hit is an older version. This is most peculiar, but it explains why I've been having trouble! Very interesting there. I had no idea I could /override with a function - guess that's obvious to anyone who's familiar with Scheme though! I've made some changes to the code, and now it looks like this: % override a couple colors to make them match our bells orange =3D #(rgb-color 1 0.5 0) yellow =3D #(rgb-color 1 1 0) % Taken straight from the docs and then tweaked very slightly #(define (bell-color grob) "Color the notehead according to its position on the staff." (case (ly:grob-property grob 'staff-position) ; Why these aren't 1-8 I'm not wholly sure ((-6) red ) ; for C ((-5) orange ) ; for D ((-4) yellow ) ; for E ((-3) green ) ; for F ((-2) darkgreen) ; for G ((-1) cyan ) ; for A (( 0) darkblue ) ; for B (( 1) magenta ) ; for >C ) ) \score { << \new Staff << \key c \major \time 3/4 \tempo "" 4 =3D 120 \new Voice \relative c' { \stemUp s2 % Arrange to obtain color from procedure above \override NoteHead #'color =3D #bell-color \override Stem #'color =3D #bell-color c8(d8) e2 e4 g4.(f8) e4 d4.(e8) f4 e2 r4 } >> >> \layout { } } This is working perfectly (and leaving black any note outside the range we can render) on the note heads. I guess it's not worth trying to color the stems as well? It doesn't seem to work, which I think might be because the stems don't have a staff-position attribute. Many thanks for the help! Knew I could rely on you :) ChrisA _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
|
|
Re: Coloring note heads by pitchChris Angelico wrote:
> I've spent some time trying to figure this out, and I'm certain it's > possible; the only question is, what's the cleanest way to do it? > > I want to print out score with each note color coded (middle C in red, > D in orange, E in green) to match a set of bells. Currently, I have a > fairly straightforward setup, but exceedingly tedious: identify the > bell AND give the music expression. What I'd like to do is make it > that I can simply key in the music as is, and then have some > scriptwork figure out what color to make each one based on its > staffposition. > > Current code: > > % Is there an alternative to this shocking editor inheritance? > bell = #(define-music-function (parser location bellnum mus) (integer? > ly:music?) > (if (eq? bellnum 1) #{ \once \override NoteHead #'color = #red > \once \override Stem #'color = #red $mus #} > (if (eq? bellnum 2) #{ \once \override NoteHead #'color = #orange > \once \override Stem #'color = #orange $mus #} > (if (eq? bellnum 3) #{ \once \override NoteHead #'color = #yellow > \once \override Stem #'color = #yellow $mus #} > (if (eq? bellnum 4) #{ \once \override NoteHead #'color = #green > \once \override Stem #'color = #green $mus #} > (if (eq? bellnum 5) #{ \once \override NoteHead #'color = > #darkgreen \once \override Stem #'color = #darkgreen $mus #} > (if (eq? bellnum 6) #{ \once \override NoteHead #'color = #cyan > \once \override Stem #'color = #cyan $mus #} > (if (eq? bellnum 7) #{ \once \override NoteHead #'color = > #darkblue \once \override Stem #'color = #darkblue $mus #} > (if (eq? bellnum 8) #{ \once \override NoteHead #'color = #magenta > \once \override Stem #'color = #magenta $mus #} > #{ #} > ))))))))) > > > > ... and inside the Voice: > % Every note must be entered as a bell identifier (#1 > being the lowest bell, and #8 being the highest), > % in addition to its note definition. > s2 > \bell #1 c8( > \bell #2 d8) > \bell #3 e2 > \bell #3 e4 > \bell #5 g4.( > \bell #4 f8) > \bell #3 e4 > \bell #2 d4.( > \bell #3 e8) > \bell #4 f4 > \bell #3 e2 > r4 > > This is tedious and error-prone, as I have to give all information > twice. I'm pretty certain that my failure is due to my lack of > knowledge of the system, and that the experts on this list will be > able to offer a solution - maybe there's one already built and ready! > > ChrisA > Hopeful in the trusting, rather than futile, sense! :) position. Just change "black" to your X11 color choice. Posted back on 9/12/09 Regards, Stephen Corey Roseville, California \version "2.12.1" %Association list of pitches to colors, C4 - C7 %Excludes Cb, Fb, E#, B# and double accidentals #(define color-mapping (list (cons (ly:make-pitch -1 0 0) (x11-color 'black)) ; C4 (cons (ly:make-pitch -1 0 1/2) (x11-color 'black)) ; C#4 (cons (ly:make-pitch -1 1 -1/2) (x11-color 'black)) ; (D flat) (cons (ly:make-pitch -1 1 0) (x11-color 'black)) ; D4 (cons (ly:make-pitch -1 1 1/2) (x11-color 'black)) ; D#4 (cons (ly:make-pitch -1 2 -1/2) (x11-color 'black)) ; (E flat) (cons (ly:make-pitch -1 2 0) (x11-color 'black)) ; E4 (cons (ly:make-pitch -1 3 0) (x11-color 'black)) ; F4 (cons (ly:make-pitch -1 3 1/2) (x11-color 'black)) ; F#4 (cons (ly:make-pitch -1 4 -1/2) (x11-color 'black)) ; (G flat) (cons (ly:make-pitch -1 4 0) (x11-color 'black)) ; G4 (cons (ly:make-pitch -1 4 1/2) (x11-color 'black)) ; G#4 (cons (ly:make-pitch -1 5 -1/2) (x11-color 'black)) ; (A flat) (cons (ly:make-pitch -1 5 0) (x11-color 'black)) ; A4 (cons (ly:make-pitch -1 5 1/2) (x11-color 'black)) ; A#4 (cons (ly:make-pitch -1 6 -1/2) (x11-color 'black)) ; (B flat) (cons (ly:make-pitch -1 6 0) (x11-color 'black)) ; B4 (cons (ly:make-pitch 0 0 0) (x11-color 'black)) ; C5 (cons (ly:make-pitch 0 0 1/2) (x11-color 'black)) ; C#5 (cons (ly:make-pitch 0 1 -1/2) (x11-color 'black)) ; (D flat) (cons (ly:make-pitch 0 1 0) (x11-color 'black)) ; D5 (cons (ly:make-pitch 0 1 1/2) (x11-color 'black)) ; D#5 (cons (ly:make-pitch 0 2 -1/2) (x11-color 'black)) ; (E flat) (cons (ly:make-pitch 0 2 0) (x11-color 'black)) ; E5 (cons (ly:make-pitch 0 3 0) (x11-color 'black)) ; F5 (cons (ly:make-pitch 0 3 1/2) (x11-color 'black)) ; F#5 (cons (ly:make-pitch 0 4 -1/2) (x11-color 'black)) ; (G flat) (cons (ly:make-pitch 0 4 0) (x11-color 'black)) ; G5 (cons (ly:make-pitch 0 4 1/2) (x11-color 'black)) ; G#5 (cons (ly:make-pitch 0 5 -1/2) (x11-color 'black)) ; (A flat) (cons (ly:make-pitch 0 5 0) (x11-color 'black)) ; A5 (cons (ly:make-pitch 0 5 1/2) (x11-color 'black)) ; A#5 (cons (ly:make-pitch 0 6 -1/2) (x11-color 'black)) ; (B flat) (cons (ly:make-pitch 0 6 0) (x11-color 'black)) ; B5 (cons (ly:make-pitch 1 0 0) (x11-color 'black)) ; C6 (cons (ly:make-pitch 1 0 1/2) (x11-color 'black)) ; C#6 (cons (ly:make-pitch 1 1 -1/2) (x11-color 'black)) ; (D flat) (cons (ly:make-pitch 1 1 0) (x11-color 'black)) ; D6 (cons (ly:make-pitch 1 1 1/2) (x11-color 'black)) ; D#6 (cons (ly:make-pitch 1 2 -1/2) (x11-color 'black)) ; (E flat) (cons (ly:make-pitch 1 2 0) (x11-color 'black)) ; E6 (cons (ly:make-pitch 1 3 0) (x11-color 'black)) ; F6 (cons (ly:make-pitch 1 3 1/2) (x11-color 'black)) ; F#6 (cons (ly:make-pitch 1 4 -1/2) (x11-color 'black)) ; (G flat) (cons (ly:make-pitch 1 4 0) (x11-color 'black)) ; G6 (cons (ly:make-pitch 1 4 1/2) (x11-color 'black)) ; G#6 (cons (ly:make-pitch 1 5 -1/2) (x11-color 'black)) ; (A flat) (cons (ly:make-pitch 1 5 0) (x11-color 'black)) ; A6 (cons (ly:make-pitch 1 5 1/2) (x11-color 'black)) ; A#6 (cons (ly:make-pitch 1 6 -1/2) (x11-color 'black)) ; (B flat) (cons (ly:make-pitch 1 6 0) (x11-color 'black)) ; B6 (cons (ly:make-pitch 2 0 0) (x11-color 'black)) ; C7 )) %Compare pitch and alteration and octave #(define (pitch-equals? p1 p2) (and (= (ly:pitch-alteration p1) (ly:pitch-alteration p2)) (= (ly:pitch-notename p1) (ly:pitch-notename p2)) (= (ly:pitch-octave p1) (ly:pitch-octave p2)))) #(define (pitch-to-color pitch) (let ((color (assoc pitch color-mapping pitch-equals?))) (if color (cdr color)))) #(define (color-notehead grob) (pitch-to-color (ly:event-property (event-cause grob) 'pitch))) #(set-global-staff-size 26) \header { title = "Handbell Color Template" subtitle = "" composer = "" arranger = "" } upper = \relative c' { \override NoteHead #'color = #color-notehead \override Staff.TimeSignature #'style = #'() \clef treble \key c \major \time 4/4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This forces bar numbers on every measure % \override Score.BarNumber #'break-visibility = #end-of-line-invisible %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% r1 r2 r4 d8 dis e f fis g gis a ais b c cis d dis e f fis g gis a ais b c b bes a aes g ges f e ees d des c b bes a aes g ges f e ees d des r2 r1 r \bar "|." } lower = \relative c { \override NoteHead #'color = #color-notehead \override Staff.TimeSignature #'style = #'() \clef bass \key c \major \time 4/4 c8 cis d dis e f fis g gis a ais b c cis r4 r1 r r r r r2 c8 b bes a aes g ges f e ees d des c1 } \score { \new PianoStaff << \new Staff = "upper" \upper \new Staff = "lower" \lower >> >> \layout { indent = 0.0 \cm } \midi { \context { \Score tempoWholesPerMinute = #(ly:make-moment 100 4) } } } _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
|
|
Re: Coloring note heads by pitchChris Angelico <rosuav@...> writes:
> On Tue, Nov 3, 2009 at 6:27 AM, Trevor Daniels <t.daniels@...> wrote: >> Hi Chris >> >> Does the example in the Learning Manual help? I think it does exactly what >> you want. See section 4.6.6. >> >> Trevor > > Strange. I just looked up the manual, and it doesn't HAVE a section > 4.6.6... and then found out why. Seems that when you google for > 'lilypond learning manual', the first hit is an older version. This is > most peculiar, but it explains why I've been having trouble! You have _installed_ a version of the HTML manual together with your software. It does not make sense at all to google for some online version that does not fit with the rest of your installation. Googling for software manuals accompanying the used software is one of the most insane practices I have come across: you might get any version from the time the software has been created. You are not alone in that. I have, as a maintainer, received bug reports from people who used configuration instructions more than 10 years old without hesitation, while having the correct documentation installed. It is really somewhat frustrating because you can't hope to improve age-old stuff left by somebody on an abandoned student account. -- David Kastrup _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
|
|
Re: Coloring note heads by pitchdavid,
> You have _installed_ a version of the HTML manual together with your > software. It does not make sense at all to google for some online > version that does not fit with the rest of your installation. > <SNIP> while i agree with your sentiments, would you mind pointing out _where_ the documentation is installed? here on my mac, there is NO documentation in /Applications/Lilypond.app/. on my linux box, i just installed 2.12.2 using the installer, and there is no HTML documentation in /usr/local/ as the attached shell grab shows. i've been using lily for over 5 years and the only way i've found local documentation is if i've actually compiled from source and generated the documentation myself. haven't done that for years, as the online documentation is a no-brainer to use (for me, YMMV). regards, sb <<< binabik@mintahoq:~/sources/lilypond$ su -c ./lilypond-2.12.2-1.linux-x86.sh Password: LilyPond installer for version 2.12.2 release 1. Use --help for help You're about to install lilypond in /usr/local/lilypond/ A script in /usr/local/bin/ will be created as a shortcut. Press ^C to abort, or Enter to proceed Making /usr/local/lilypond/ Creating script /usr/local/bin/lilypond Creating script /usr/local/bin/lilypond-wrapper.python Creating script /usr/local/bin/lilypond-wrapper.guile Creating script /usr/local/bin/uninstall-lilypond Untarring ./lilypond-2.12.2-1.linux-x86.sh To uninstall lilypond, run /usr/local//bin/uninstall-lilypond For license and warranty information, consult /usr/local/lilypond/license/README binabik@mintahoq:~/sources/lilypond$ cd /usr/local/ binabik@mintahoq:/usr/local$ !f find . -name *.html | grep lilypond binabik@mintahoq:/usr/local$ >>> _______________________________________________ lilypond-user mailing list lilypond-user@... http://lists.gnu.org/mailman/listinfo/lilypond-user |
| Free embeddable forum powered by Nabble | Forum Help |