Re: Customizing ottava text
2017-02-15 21:06 GMT+01:00 Urs Liska: > Hi all, > > is it really true that the text of the OttavaBracket can't be > customized? All I could find was the doc snippet > http://lilypond.org/doc/v2.19/Documentation/snippets/text#text-ottava-text > which suggests to manually set Staff.ottavation after the \ottava command. > > With this I created a function (overwriting the built-in function) > > #(define ottava >(let ((orig-ottava ottava) > (numbers '("15" "8" "" "8" "15"))) > (define-music-function (oct)(integer?) >#{ > #(orig-ottava oct) > #(if (not (= oct 0)) > #{ > \set Staff.ottavation = #(list-ref numbers (+ oct 2)) > #}) >#}))) > > > which actually does what I want (change "8va" to "8"), but I can't > believe that it is really necessary to go that long way for a seemingly > simple task. > > Any comments? > Urs Hi Urs, best I can currently think of: \version "2.19.52" %% Define new context-property 'ottavaText' #(define (define-translator-property symbol type? description) (if (not (and (symbol? symbol) (procedure? type?) (string? description))) (ly:error "error in call of define-translator-property")) (if (not (equal? (object-property symbol 'translation-doc) #f)) (ly:error (_ "symbol ~S redefined") symbol)) (set-object-property! symbol 'translation-type? type?) (set-object-property! symbol 'translation-doc description) symbol) #(for-each (lambda (x) (apply define-translator-property x)) `((ottavaText ,list? "An alist of pairs with ottavation-number and markup."))) %% Redefine 'make-ottava-set' #(define (make-ottava-set music) "Set context properties for an ottava bracket." (let ((octavation (ly:music-property music 'ottava-number)) (labels '((2 . "15ma") (1 . "8va") (0 . #f) (-1 . "8vb") (-2 . "15mb" (list (context-spec-music (make-apply-context (lambda (context) (let* ((offset (* -7 octavation)) (ctx-label-list (ly:context-property context 'ottavaText)) (string (assoc-get octavation (if (null? ctx-label-list) labels ctx-label-list (set! (ly:context-property context 'middleCOffset) offset) (set! (ly:context-property context 'ottavation) string) (ly:set-middle-C! context 'Staff %% Redefine 'ottava' ottava = #(define-music-function (octave) (integer?) (_i "Set the octavation.") (make-music 'OttavaMusic 'elements-callback make-ottava-set 'ottava-number octave)) % %% EXAMPLE % \layout { \context { \Staff ottavaText = #`((2 . ,(markup #:rounded-box "16.0")) (1 . "8.0") (0 . #f) (-1 . "8.0") (-2 . ,#{ \markup \rotate #90 "16.0" #})) } } { \ottava #2 c'' \ottava #1 c'' \ottava #0 c'' \ottava #-1 c'' \ottava #-2 c'' } HTH, Harm ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Customizing ottava text
Hi, as I got quite a few similar responses I'll reply at once. All the suggestions that manually set Staff.ottavation don't work because I want something that can be defined in a stylesheet without the user having to change the music content (by manually setting the ottava text for each case). So Joram's function is the only that would satisfy my needs, but then I'm already happy with the solution I had come up with in my initial post. So obviously there is no simpler solution available. What I would actually like to have is a property that can hold a list of strings to be used for the different octaves, so you could write \override Staff.OttavaBracket.labels = #'((2 . "16") ; (used by some publishers) (1 . "8") (0 . #f) (-1 . "8") (-2 . "16")) The following code (from define-music-callbacks.scm) is obviously responsible for producing the octavation. If someone could tell me how this can read a property from Staff.OttavaBracket from within the function I think I could make the ottava text configurable in LilyPond. (define (make-ottava-set music) "Set context properties for an ottava bracket." (let ((octavation (ly:music-property music 'ottava-number))) (list (context-spec-music (make-apply-context (lambda (context) (let ((offset (* -7 octavation)) (string (assoc-get octavation '((2 . "15ma") (1 . "8va") (0 . #f) (-1 . "8vb") (-2 . "15mb") (set! (ly:context-property context 'middleCOffset) offset) (set! (ly:context-property context 'ottavation) string) (ly:set-middle-C! context 'Staff Urs Am 15.02.2017 um 21:06 schrieb Urs Liska: > Hi all, > > is it really true that the text of the OttavaBracket can't be > customized? All I could find was the doc snippet > http://lilypond.org/doc/v2.19/Documentation/snippets/text#text-ottava-text > which suggests to manually set Staff.ottavation after the \ottava command. > > With this I created a function (overwriting the built-in function) > > #(define ottava >(let ((orig-ottava ottava) > (numbers '("15" "8" "" "8" "15"))) > (define-music-function (oct)(integer?) >#{ > #(orig-ottava oct) > #(if (not (= oct 0)) > #{ > \set Staff.ottavation = #(list-ref numbers (+ oct 2)) > #}) >#}))) > > > which actually does what I want (change "8va" to "8"), but I can't > believe that it is really necessary to go that long way for a seemingly > simple task. > > Any comments? > Urs > -- u...@openlilylib.org https://openlilylib.org http://lilypondblog.org ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Customizing ottava text
Hi, Am 15.02.2017 um 23:44 schrieb tisimst: > \set Staff.ottavation = That's what the code does, I posted before. It just does it depending on the ottavation. It does these two things: #(make-music 'OttavaMusic 'ottava-number octave)% = \ottava \set Staff.ottavation = ... % = change the text But of course you can do it by hand. Cheers, Joram ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Customizing ottava text
Urs, et al, On Wed, Feb 15, 2017 at 2:59 PM, Noeck [via Lilypond] < ml-node+s1069038n200168...@n5.nabble.com> wrote: > Hi Urs, > > yes, I think you can't set the text. But you can redefine the \ottava > function and still use the Staff.ottavation to do the work behind the > scenes. > Actually you can: http://lsr.di.unimi.it/LSR/Item?id=950 which shows: { c'2 \ottava #1 \set Staff.ottavation = #"8" c''2 \ottava #0 c'1 \ottava #1 \set Staff.ottavation = #"Text" c''1 } Best, Abraham -- View this message in context: http://lilypond.1069038.n5.nabble.com/Customizing-ottava-text-tp200163p200172.html Sent from the User mailing list archive at Nabble.com.___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Customizing ottava text
Hi Urs, yes, I think you can't set the text. But you can redefine the \ottava function and still use the Staff.ottavation to do the work behind the scenes. Here is my ottava function. It is extended to more than 2 octaves and has a custom text. I always wanted a true dotted line (round dots), but that's not so easy it seems. You asked for the line ending the bracket today. % define new ottava function with bold text and superscripts ottava = #(define-music-function (octave) (integer?) (_i "Set the octavation.") #{ #(make-music 'OttavaMusic 'ottava-number octave) \set Staff.ottavation = #(if (< octave -1) #{ \markup \concat { #(number->string (+ 1 (* -7 octave))) \fontsize #-2 "mb" } #} (if (= octave -1) #{ \markup \concat { "8" \fontsize #-2 "vb" } #} (if (= octave +0) #f (if (= octave +1) #{ \markup \concat { "8" \fontsize #-2 \translate-scaled #'(0 . 0.85) "va" } #} #{ \markup \concat { #(number->string (+ 1 (* 7 octave))) \fontsize #-2 \translate-scaled #'(0 . 0.85) "ma" } #} #}) \layout { \override Score.OttavaBracket.font-series = #'bold } \relative { a \ottava 1 a'' a \ottava -1 a,, a \ottava 3 a a } Cheers, Joram ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Customizing ottava text
Am 15.02.2017 um 21:55 schrieb Kieren MacMillan: > Hi Urs, > >> is it really true that the text of the OttavaBracket can't be customized? > \version "2.19.48" > \language "english" > > ottTest = > \once \override Staff.OttavaBracket.before-line-breaking = > #(lambda (grob) (ly:grob-set-property! grob 'text "testing")) > > { \ottTest \ottava #1 c'' } Clicking through to "text-interface" I also found the 'text property, but overriding it didn't seem to have an effect. > >> I can’t believe that it is really necessary to go that long way for a >> seemingly simple task. > +1 (even with my hack) Additionally, I'm not sure if I could tweak this approach to actually work with my requirements ... Urs > > Kieren. > > > Kieren MacMillan, composer > ‣ website: www.kierenmacmillan.info > ‣ email: i...@kierenmacmillan.info > -- u...@openlilylib.org https://openlilylib.org http://lilypondblog.org ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Customizing ottava text
Hi Urs, > is it really true that the text of the OttavaBracket can't be customized? \version "2.19.48" \language "english" ottTest = \once \override Staff.OttavaBracket.before-line-breaking = #(lambda (grob) (ly:grob-set-property! grob 'text "testing")) { \ottTest \ottava #1 c'' } > I can’t believe that it is really necessary to go that long way for a > seemingly simple task. +1 (even with my hack) Kieren. Kieren MacMillan, composer ‣ website: www.kierenmacmillan.info ‣ email: i...@kierenmacmillan.info ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Customizing ottava text
Hi all, is it really true that the text of the OttavaBracket can't be customized? All I could find was the doc snippet http://lilypond.org/doc/v2.19/Documentation/snippets/text#text-ottava-text which suggests to manually set Staff.ottavation after the \ottava command. With this I created a function (overwriting the built-in function) #(define ottava (let ((orig-ottava ottava) (numbers '("15" "8" "" "8" "15"))) (define-music-function (oct)(integer?) #{ #(orig-ottava oct) #(if (not (= oct 0)) #{ \set Staff.ottavation = #(list-ref numbers (+ oct 2)) #}) #}))) which actually does what I want (change "8va" to "8"), but I can't believe that it is really necessary to go that long way for a seemingly simple task. Any comments? Urs -- u...@openlilylib.org https://openlilylib.org http://lilypondblog.org ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user