Re: Ambitus with shape notes
Lukas-Fabian Moser writes: >> >> > \version "2.19.44" >> > >> > #(define (nth n l) >> > (if (or (> n (length l)) (< n 0)) >> > (error "Index out of bounds.") >> > (if (eq? n 0) >> > (car l) >> > (nth (- n 1) (cdr l) >> >> Seriously? >> >> #(define (nth n l) (list-ref l n)) >> > > Of course not - being absolutely foreign to scheme, I searched the web > for a solution of the problem "get n-th element of list", There is your mistake. The first place to search should be the Guile manual. The second place the pertinent Scheme standard (incidentally being delivered as part of Guile, too). The "web" is organized by page rank, resulting in the blind leading the clueless. The Guile manual might not be consistently great, but it tends to beat a random search. -- David Kastrup ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Ambitus with shape notes
> > > \version "2.19.44" > > > > #(define (nth n l) > > (if (or (> n (length l)) (< n 0)) > > (error "Index out of bounds.") > > (if (eq? n 0) > > (car l) > > (nth (- n 1) (cdr l) > > Seriously? > > #(define (nth n l) (list-ref l n)) > Of course not - being absolutely foreign to scheme, I searched the web for a solution of the problem "get n-th element of list", and this was what I stumbled upon and used just because it worked. (I don't know why at the place where I found this, list-ref wasn't used - maybe it is a question of dialects?) Thanks for pointing this out! ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Ambitus with shape notes
Lukas-Fabian Moser writes: > Here is an improved version: > > > \version "2.19.44" > > #(define (nth n l) > (if (or (> n (length l)) (< n 0)) > (error "Index out of bounds.") > (if (eq? n 0) > (car l) > (nth (- n 1) (cdr l) Seriously? #(define (nth n l) (list-ref l n)) Which has the advantage of _not_ being O(n^2) because you check (length l) (which is O(n)) in every iteration. -- David Kastrup ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Ambitus with shape notes
2017-08-12 12:05 GMT+02:00 Lukas-Fabian Moser : > Here is an improved version: > > > \version "2.19.44" > > #(define (nth n l) > (if (or (> n (length l)) (< n 0)) > (error "Index out of bounds.") > (if (eq? n 0) > (car l) > (nth (- n 1) (cdr l) > > #(define (scale-notehead scale tonic) >(lambda (grob) > (let ((mod-position (modulo (- (ly:grob-property grob 'staff-position) > tonic) >7))) > (nth mod-position scale) > ) >) >) > > aiken = #(list 'do 're 'miMirror 'fa 'sol 'la 'ti) > sacredHarp = #(list 'fa 'sol 'la 'fa 'sol 'la 'mi) > > > % Standard definitions for \aikenHeads or \sacredHarpHeads may be > % found in lilypond/usr/share/lilypond/current/ly/property-init.ly: > % > % > % aikenHeads = \set shapeNoteStyles = ##(do re miMirror fa sol la ti) > % aikenHeadsMinor = \set shapeNoteStyles = ##(la ti do re miMirror fa sol) > % funkHeads = \set shapeNoteStyles = ##(doFunk reFunk miFunk faFunk solFunk > laFunk tiFunk) > % funkHeadsMinor = \set shapeNoteStyles = ##(laFunk tiFunk doFunk reFunk > miFunk faFunk solFunk) > % sacredHarpHeads = \set shapeNoteStyles = ##(fa sol la fa sol la mi) > % sacredHarpHeadsMinor = \set shapeNoteStyles = ##(la mi fa sol la fa sol) > % southernHarmonyHeads = \set shapeNoteStyles = ##(faThin sol laThin > faThin sol laThin miThin) > % southernHarmonyHeadsMinor = \set shapeNoteStyles = ##(laThin miThin > faThin sol laThin faThin sol) > % walkerHeads = \set shapeNoteStyles = ##(doWalker reWalker miWalker > faWalker solFunk laWalker tiWalker) > % walkerHeadsMinor = \set shapeNoteStyles = ##(laWalker tiWalker doWalker > reWalker miWalker faWalker solFunk) > > > \layout { > \context { > \Voice > \consists "Ambitus_engraver" > } > \override AmbitusNoteHead.style = #(scale-notehead sacredHarp 2) > } > > \relative { > \sacredHarpHeads > \clef violin > \key d \major > cis'4 d e fis g a b cis d > } > > The \override AmbitusNoteHead.style = #(scale-notehead sacredHarp 2) now > works in the following way: It expects a scale (I predefied sacredHarp and > aiken) and a number which gives the position of the tonic root of your key > in the staff - middle line is 0, and so on; I chose d major, and using > violin clef, a d is on position 2 (two steps above the middle line). > > The reason it has to be this way is, that at the time the ambitus is > printed, you know neither clef nor key signature; so it's easiest to specify > the desired graphic position of the tonic note. > > Best > Lukas Hi, just back from holidays, reading all the mails ... The code above causes an error (programming error: must have stem dir for note head) and the note-heads are wrongly rotated. See: \layout { \context { \Voice \consists "Ambitus_engraver" } \override AmbitusNoteHead.style = #(scale-notehead sacredHarp 1) } \relative { \sacredHarpHeads \clef violin \key c \major cis'4 d e fis g a b cis d } So I come up with the code below. It reads the tonic from the context as well as the 'shapeNoteStyles'-vector of note-head styles. I didn't figure how to circumvent the error mentioned above while setting 'style, so I recreated the stencil. \version "2.19.64" #(define (get-stencil font cands) (cond ((null? cands) point-stencil) ((ly:stencil-empty? (ly:font-get-glyph font (car cands)) X) (get-stencil font (cdr cands))) (else (ly:font-get-glyph font (car cands) shapedAmbitusNoteHead = \applyOutput Staff.AmbitusNoteHead #(lambda (grob ctx c) (let* ((tonic (ly:context-property ctx 'tonic)) (tonic-pitch-notename (ly:pitch-notename tonic)) (shape-note-styles (ly:context-property ctx 'shapeNoteStyles))) (if (vector? shape-note-styles) (ly:grob-set-property! grob 'before-line-breaking (lambda (grob) (let* ((staff-pos (ly:grob-property grob 'staff-position)) (note-head (vector-ref shape-note-styles (modulo (- staff-pos tonic-pitch-notename 1) 7))) (layout (ly:grob-layout grob)) (props (ly:grob-alist-chain grob)) (font (ly:paper-get-font layout props)) (note-head-candidates (list (format #f "noteheads.~a2~a" (if (> 0 staff-pos) "u" "d") note-head) (format #f "noteheads.s2~a" note-head) "noteheads.s2"))) (ly:grob-set-property! grob 'stencil (get-stencil font note-head-candidates % %% EXAMPLE % \layout { \context { \Voice \aikenHeads %\aikenHeadsMinor %\funkHeads %\funkHeadsMinor %\sacredHarpHeads
Re: Ambitus with shape notes
Here is an improved version: \version "2.19.44" #(define (nth n l) (if (or (> n (length l)) (< n 0)) (error "Index out of bounds.") (if (eq? n 0) (car l) (nth (- n 1) (cdr l) #(define (scale-notehead scale tonic) (lambda (grob) (let ((mod-position (modulo (- (ly:grob-property grob 'staff-position) tonic) 7))) (nth mod-position scale) ) ) ) aiken = #(list 'do 're 'miMirror 'fa 'sol 'la 'ti) sacredHarp = #(list 'fa 'sol 'la 'fa 'sol 'la 'mi) % Standard definitions for \aikenHeads or \sacredHarpHeads may be % found in lilypond/usr/share/lilypond/current/ly/property-init.ly: % % % aikenHeads = \set shapeNoteStyles = ##(do re miMirror fa sol la ti) % aikenHeadsMinor = \set shapeNoteStyles = ##(la ti do re miMirror fa sol) % funkHeads = \set shapeNoteStyles = ##(doFunk reFunk miFunk faFunk solFunk laFunk tiFunk) % funkHeadsMinor = \set shapeNoteStyles = ##(laFunk tiFunk doFunk reFunk miFunk faFunk solFunk) % sacredHarpHeads = \set shapeNoteStyles = ##(fa sol la fa sol la mi) % sacredHarpHeadsMinor = \set shapeNoteStyles = ##(la mi fa sol la fa sol) % southernHarmonyHeads = \set shapeNoteStyles = ##(faThin sol laThin faThin sol laThin miThin) % southernHarmonyHeadsMinor = \set shapeNoteStyles = ##(laThin miThin faThin sol laThin faThin sol) % walkerHeads = \set shapeNoteStyles = ##(doWalker reWalker miWalker faWalker solFunk laWalker tiWalker) % walkerHeadsMinor = \set shapeNoteStyles = ##(laWalker tiWalker doWalker reWalker miWalker faWalker solFunk) \layout { \context { \Voice \consists "Ambitus_engraver" } \override AmbitusNoteHead.style = #(scale-notehead sacredHarp 2) } \relative { \sacredHarpHeads \clef violin \key d \major cis'4 d e fis g a b cis d } The \override AmbitusNoteHead.style = #(scale-notehead sacredHarp 2) now works in the following way: It expects a scale (I predefied sacredHarp and aiken) and a number which gives the position of the tonic root of your key in the staff - middle line is 0, and so on; I chose d major, and using violin clef, a d is on position 2 (two steps above the middle line). The reason it has to be this way is, that at the time the ambitus is printed, you know neither clef nor key signature; so it's easiest to specify the desired graphic position of the tonic note. Best Lukas 2017-08-11 11:23 GMT+02:00 Barry Parsons : > Amazing, thanks Lukas! > > I'll play around with this later but at first glance it looks like it > ought to be able to do what I'd like. > > Regarding your point about key changes within a piece, it's luckily not > really relevant to me since the kind of music that's written using shape > notes almost never changes key. > > Cheers! > Barry > > > On 11 Aug 2017 10:07 am, "Lukas-Fabian Moser" wrote: > > Hi Barry, > > nevertheless, here is a working solution (derived from > http://lilypond.org/doc/v2.18/Documentation/learning/advance > d-tweaks-with-scheme). Beware though: The notehead style is chosen here > on a by-sounding-pitch basis, so it has to be adapted for pieces in another > key. But for the reasons I explained, I'm not sure that this is not > basically "right". > > Of course, there certainly is a way to write a routine in such a way that > you can give the desired style and desired key signature once while issuing > \override AmbitusNoteHead.style = ... - the routine then rotate the note > heads around accordingly - but this exceeds both my scheme skills and > available time :-). > > > \version "2.19.44" > > > #(define (style-sacredHarp-notehead grob) >"Change the notehead style according to pitch class." >(let ((mod-position (modulo (ly:grob-property grob 'staff-position) >7))) > (case mod-position >;; Return styles >((1) 'fa) ; for C >((2) 'sol) ; for D >((3) 'la) ; for E >((4) 'fa) ; for F >((5) 'sol) ; for G >((6) 'la) ; for A >((0) 'mi) ; for B >))) > > % Standard definitions for \aikenHeads or \sacredHarpHeads may be > % found in lilypond/usr/share/lilypond/current/ly/property-init.ly: > % > % > % aikenHeads = \set shapeNoteStyles = ##(do re miMirror fa sol la ti) > % aikenHeadsMinor = \set shapeNoteStyles = ##(la ti do re miMirror fa sol) > % funkHeads = \set shapeNoteStyles = ##(doFunk reFunk miFunk faFunk > solFunk laFunk tiFunk) > % funkHeadsMinor = \set shapeNoteStyles = ##(laFunk tiFunk doFunk reFunk > miFunk faFunk solFunk) > % sacredHarpHeads = \set shapeNoteStyles = ##(fa sol la fa sol la mi) > % sacredHarpHeadsMinor = \set shapeNoteStyles = ##(la mi fa sol la fa sol) > % southernHarmonyHeads = \set shapeNoteStyles = ##(faThin sol laThin > faThin sol laThin miThin) > % southernHarmonyHeadsMinor = \set shapeNoteStyles = ##(laThin miThin > faThin sol laThin faThin sol) > % walkerHeads = \set shapeNoteStyles = ##(doWalker reWalker miWalker > faWalker solFunk laWalker tiWalker)
Re: Ambitus with shape notes
Amazing, thanks Lukas! I'll play around with this later but at first glance it looks like it ought to be able to do what I'd like. Regarding your point about key changes within a piece, it's luckily not really relevant to me since the kind of music that's written using shape notes almost never changes key. Cheers! Barry On 11 Aug 2017 10:07 am, "Lukas-Fabian Moser" wrote: Hi Barry, nevertheless, here is a working solution (derived from http://lilypond.org/doc/v2.18/Documentation/learning/ advanced-tweaks-with-scheme). Beware though: The notehead style is chosen here on a by-sounding-pitch basis, so it has to be adapted for pieces in another key. But for the reasons I explained, I'm not sure that this is not basically "right". Of course, there certainly is a way to write a routine in such a way that you can give the desired style and desired key signature once while issuing \override AmbitusNoteHead.style = ... - the routine then rotate the note heads around accordingly - but this exceeds both my scheme skills and available time :-). \version "2.19.44" #(define (style-sacredHarp-notehead grob) "Change the notehead style according to pitch class." (let ((mod-position (modulo (ly:grob-property grob 'staff-position) 7))) (case mod-position ;; Return styles ((1) 'fa) ; for C ((2) 'sol) ; for D ((3) 'la) ; for E ((4) 'fa) ; for F ((5) 'sol) ; for G ((6) 'la) ; for A ((0) 'mi) ; for B ))) % Standard definitions for \aikenHeads or \sacredHarpHeads may be % found in lilypond/usr/share/lilypond/current/ly/property-init.ly: % % % aikenHeads = \set shapeNoteStyles = ##(do re miMirror fa sol la ti) % aikenHeadsMinor = \set shapeNoteStyles = ##(la ti do re miMirror fa sol) % funkHeads = \set shapeNoteStyles = ##(doFunk reFunk miFunk faFunk solFunk laFunk tiFunk) % funkHeadsMinor = \set shapeNoteStyles = ##(laFunk tiFunk doFunk reFunk miFunk faFunk solFunk) % sacredHarpHeads = \set shapeNoteStyles = ##(fa sol la fa sol la mi) % sacredHarpHeadsMinor = \set shapeNoteStyles = ##(la mi fa sol la fa sol) % southernHarmonyHeads = \set shapeNoteStyles = ##(faThin sol laThin faThin sol laThin miThin) % southernHarmonyHeadsMinor = \set shapeNoteStyles = ##(laThin miThin faThin sol laThin faThin sol) % walkerHeads = \set shapeNoteStyles = ##(doWalker reWalker miWalker faWalker solFunk laWalker tiWalker) % walkerHeadsMinor = \set shapeNoteStyles = ##(laWalker tiWalker doWalker reWalker miWalker faWalker solFunk) \layout { \context { \Voice \consists "Ambitus_engraver" } \override AmbitusNoteHead.style = #style-sacredHarp-notehead } \relative { \sacredHarpHeads c'4 d e b' } 2017-08-11 10:47 GMT+02:00 Lukas-Fabian Moser : > Hi Barry, > > unfortunately I do not have a ready-made solution - while it's possible to > change the ambitus note heads to a single specific sign by issuing (for > example) \override AmbitusNoteHead.style = #'do in the \layout block, this > is not a solution since it changes both ambitus note heads at the same time > -, I just want to point out an inherent problem: > As far as I understand, \sacredHarpHeads and \aikenHeads depend on the key > signature chosen (in much the same way that movable do syllables do). So, > it's a bit dodgy to issue ambitus information using these signs since the > key signature might change in the course of the piece. (Strictly speaking, > the ambitus signs occur at a place before a key signature is issued - but > this slight inconsistency applies to ambitus marks in general since they > show note heads *left* to the first clef ever encountered by the singer.) > > Best > Lukas > > > 2017-08-11 10:02 GMT+02:00 Barry Parsons : > >> Hi all, >> >> As a newbie to this wonderful software I have a slightly odd request. >> >> I set vocal music using shape notes (\sacredHarpHeads or \aikenHeads). >> I've recently discovered the ambitus function, which is really useful. >> >> I wonder, is it possible to add the correct shaped noteheads to the >> ambitus at the start of a score, instead of ordinary round noteheads? >> >> Thanks in advance, >> Barry >> >> >> ___ >> lilypond-user mailing list >> lilypond-user@gnu.org >> https://lists.gnu.org/mailman/listinfo/lilypond-user >> >> > ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Ambitus with shape notes
Hi Barry, nevertheless, here is a working solution (derived from http://lilypond.org/doc/v2.18/Documentation/learning/advanced-tweaks-with-scheme). Beware though: The notehead style is chosen here on a by-sounding-pitch basis, so it has to be adapted for pieces in another key. But for the reasons I explained, I'm not sure that this is not basically "right". Of course, there certainly is a way to write a routine in such a way that you can give the desired style and desired key signature once while issuing \override AmbitusNoteHead.style = ... - the routine then rotate the note heads around accordingly - but this exceeds both my scheme skills and available time :-). \version "2.19.44" #(define (style-sacredHarp-notehead grob) "Change the notehead style according to pitch class." (let ((mod-position (modulo (ly:grob-property grob 'staff-position) 7))) (case mod-position ;; Return styles ((1) 'fa) ; for C ((2) 'sol) ; for D ((3) 'la) ; for E ((4) 'fa) ; for F ((5) 'sol) ; for G ((6) 'la) ; for A ((0) 'mi) ; for B ))) % Standard definitions for \aikenHeads or \sacredHarpHeads may be % found in lilypond/usr/share/lilypond/current/ly/property-init.ly: % % % aikenHeads = \set shapeNoteStyles = ##(do re miMirror fa sol la ti) % aikenHeadsMinor = \set shapeNoteStyles = ##(la ti do re miMirror fa sol) % funkHeads = \set shapeNoteStyles = ##(doFunk reFunk miFunk faFunk solFunk laFunk tiFunk) % funkHeadsMinor = \set shapeNoteStyles = ##(laFunk tiFunk doFunk reFunk miFunk faFunk solFunk) % sacredHarpHeads = \set shapeNoteStyles = ##(fa sol la fa sol la mi) % sacredHarpHeadsMinor = \set shapeNoteStyles = ##(la mi fa sol la fa sol) % southernHarmonyHeads = \set shapeNoteStyles = ##(faThin sol laThin faThin sol laThin miThin) % southernHarmonyHeadsMinor = \set shapeNoteStyles = ##(laThin miThin faThin sol laThin faThin sol) % walkerHeads = \set shapeNoteStyles = ##(doWalker reWalker miWalker faWalker solFunk laWalker tiWalker) % walkerHeadsMinor = \set shapeNoteStyles = ##(laWalker tiWalker doWalker reWalker miWalker faWalker solFunk) \layout { \context { \Voice \consists "Ambitus_engraver" } \override AmbitusNoteHead.style = #style-sacredHarp-notehead } \relative { \sacredHarpHeads c'4 d e b' } 2017-08-11 10:47 GMT+02:00 Lukas-Fabian Moser : > Hi Barry, > > unfortunately I do not have a ready-made solution - while it's possible to > change the ambitus note heads to a single specific sign by issuing (for > example) \override AmbitusNoteHead.style = #'do in the \layout block, this > is not a solution since it changes both ambitus note heads at the same time > -, I just want to point out an inherent problem: > As far as I understand, \sacredHarpHeads and \aikenHeads depend on the key > signature chosen (in much the same way that movable do syllables do). So, > it's a bit dodgy to issue ambitus information using these signs since the > key signature might change in the course of the piece. (Strictly speaking, > the ambitus signs occur at a place before a key signature is issued - but > this slight inconsistency applies to ambitus marks in general since they > show note heads *left* to the first clef ever encountered by the singer.) > > Best > Lukas > > > 2017-08-11 10:02 GMT+02:00 Barry Parsons : > >> Hi all, >> >> As a newbie to this wonderful software I have a slightly odd request. >> >> I set vocal music using shape notes (\sacredHarpHeads or \aikenHeads). >> I've recently discovered the ambitus function, which is really useful. >> >> I wonder, is it possible to add the correct shaped noteheads to the >> ambitus at the start of a score, instead of ordinary round noteheads? >> >> Thanks in advance, >> Barry >> >> >> ___ >> lilypond-user mailing list >> lilypond-user@gnu.org >> https://lists.gnu.org/mailman/listinfo/lilypond-user >> >> > ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Ambitus with shape notes
Hi Barry, unfortunately I do not have a ready-made solution - while it's possible to change the ambitus note heads to a single specific sign by issuing (for example) \override AmbitusNoteHead.style = #'do in the \layout block, this is not a solution since it changes both ambitus note heads at the same time -, I just want to point out an inherent problem: As far as I understand, \sacredHarpHeads and \aikenHeads depend on the key signature chosen (in much the same way that movable do syllables do). So, it's a bit dodgy to issue ambitus information using these signs since the key signature might change in the course of the piece. (Strictly speaking, the ambitus signs occur at a place before a key signature is issued - but this slight inconsistency applies to ambitus marks in general since they show note heads *left* to the first clef ever encountered by the singer.) Best Lukas 2017-08-11 10:02 GMT+02:00 Barry Parsons : > Hi all, > > As a newbie to this wonderful software I have a slightly odd request. > > I set vocal music using shape notes (\sacredHarpHeads or \aikenHeads). > I've recently discovered the ambitus function, which is really useful. > > I wonder, is it possible to add the correct shaped noteheads to the > ambitus at the start of a score, instead of ordinary round noteheads? > > Thanks in advance, > Barry > > > ___ > lilypond-user mailing list > lilypond-user@gnu.org > https://lists.gnu.org/mailman/listinfo/lilypond-user > > ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user