custom metronome-markup procedure causes weird goops-error
Greetings everybody, a few days ago Neil sent a new snippet to be added in input/new : "Adding text indications to metronome marks". It involved quite a lot of typing, so I tried to come up with a function that would be easier to use. Here's my code; it works quite well on simple examples, but on complex scores it triggers an error I've never seen: "goops-error: no applicable method for #< map (0)>" (see below for the complete message). #(define-markup-command (mvt layout props arg) (markup?) (interpret-markup layout props (markup #:huge #:bold arg))) #(define (string->duration strElt) ;; from LSR snippet 390 ( let*((ptindex (string-index strElt #\. )) (ptnumber 0) (val (string->number (if ptindex (substring strElt 0 ptindex) strElt))) (dur (ly:intlog2 val))) (while ptindex (begin (set! ptnumber (1+ ptnumber)) (set! ptindex (string-index strElt #\. (1+ ptindex) (ly:make-duration dur ptnumber 1 1))) mov = #(define-music-function (parser location text duration count) (string? string? integer?) (define (format-metronome-markup dur count context) (make-line-markup (list (markup #:mvt text #:hspace 1) (make-simple-markup "(") (make-general-align-markup Y DOWN (make-smaller-markup (make-note-by-number-markup (ly:duration-log dur) (ly:duration-dot-count dur) 1))) (make-simple-markup "=") (make-simple-markup (number->string count)) (make-simple-markup ")" (make-music 'ContextSpeccedMusic 'context-type 'Score 'element (make-music 'SequentialMusic 'elements (list (make-music 'PropertySet 'value (ly:duration-length (string->duration duration)) 'symbol 'tempoWholesPerMinute) (make-music 'PropertySet 'value (string->duration duration) 'symbol 'tempoUnitDuration) (make-music 'PropertySet 'value count 'symbol 'tempoUnitCount) \relative { \mov #"Largo" #"2." #140 c1 d \tempo 4 = 120 e } Now for the big message: /usr/local/lilypond/usr/bin/../share/guile/1.8/oop/goops.scm:100:3: In procedure scm-error in expression (scm-error (quote goops-error) #f ...): /usr/local/lilypond/usr/bin/../share/guile/1.8/oop/goops.scm:100:3: No applicable method for #< map (0)> in call (map # #) (element . #) (elements #) (symbol . tempoWholesPerMinute) (value . #))((display-methods #) (name . PropertySet) (types layout-instruction-event general-music) (iterator-ctor . #)) > #) (symbol . tempoUnitDuration) (value . #))((display-methods #) (name . PropertySet) (types layout-instruction-event general-music) (iterator-ctor . #)) > #) (symbol . tempoUnitCount) (value . 48))((display-methods #) (name . PropertySet) (types layout-instruction-event general-music) (iterator-ctor . #)) > ))((display-methods #) (name . SequentialMusic) (length-callback . #) (start-callback . #) (elements-callback . #) (iterator-ctor . #) (types general-music sequential-music)) > ) (context-type . Score))((display-methods # # # # # # # # # #) (name . ContextSpeccedMusic) (iterator-ctor . #) (length-callback . #) (start-callback . #) (types context-specification general-music music-wrapper-music)) > ) Can anyone help me? Cheers, Valentin ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: custom metronome-markup procedure causes weird goops-error
2008/4/25 Valentin Villenave <[EMAIL PROTECTED]>: > Here's my code; it works quite well on simple examples, but on complex > scores it triggers an error I've never seen: OK, I've fixed it; it actually involved using a different name for the metronomeMarkFormatter procedure: mov = #(define-music-function (parser location texte duration count music) (string? string? integer? ly:music?) (define (format-movement-markup dur count context) (make-line-markup (list (markup #:mvt texte #:hspace 1) (make-simple-markup "(") (make-general-align-markup Y DOWN (make-smaller-markup (make-note-by-number-markup (ly:duration-log dur) (ly:duration-dot-count dur) 1))) (make-simple-markup "=") (make-simple-markup (number->string count)) (make-simple-markup ")" (make-music 'SequentialMusic 'elements (list (make-music 'ContextSpeccedMusic 'context-type 'Score 'element (make-music 'PropertySet 'value format-movement-markup 'symbol 'metronomeMarkFormatter)) (make-music 'ContextSpeccedMusic 'context-type 'Score 'element (make-music 'SequentialMusic 'elements (list (make-music 'PropertySet 'value (ly:duration-length (string->duration duration)) 'symbol 'tempoWholesPerMinute) (make-music 'PropertySet 'value (string->duration duration) 'symbol 'tempoUnitDuration) (make-music 'PropertySet 'value count 'symbol 'tempoUnitCount music (make-music 'ContextSpeccedMusic 'context-type 'Score 'element (make-music 'PropertySet 'value format-metronome-markup 'symbol 'metronomeMarkFormatter) Now it works perfectly -- sorry for the noise! (by the way, if anyone has some clues to clean or optimize my code, feel free to suggest any improvements you can think of) Cheers, Valentin ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: custom metronome-markup procedure causes weird goops-error
On 25/04/2008, Valentin Villenave <[EMAIL PROTECTED]> wrote: > 2008/4/25 Valentin Villenave <[EMAIL PROTECTED]>: > > > > Here's my code; it works quite well on simple examples, but on complex > > scores it triggers an error I've never seen: > > > OK, I've fixed it; it actually involved using a different name for the > metronomeMarkFormatter procedure: > > mov = > #(define-music-function (parser location texte duration count music) > (string? string? integer? ly:music?) > (define (format-movement-markup dur count context) > (make-line-markup > (list > (markup #:mvt texte #:hspace 1) > > (make-simple-markup "(") > (make-general-align-markup Y DOWN (make-smaller-markup > (make-note-by-number-markup (ly:duration-log dur) > (ly:duration-dot-count dur) > 1))) > (make-simple-markup "=") > (make-simple-markup (number->string count)) > (make-simple-markup ")" > > (make-music 'SequentialMusic 'elements > (list (make-music 'ContextSpeccedMusic > 'context-type 'Score 'element > (make-music 'PropertySet > 'value format-movement-markup > 'symbol 'metronomeMarkFormatter)) > > (make-music 'ContextSpeccedMusic > 'context-type 'Score 'element > (make-music 'SequentialMusic 'elements > (list (make-music 'PropertySet > 'value (ly:duration-length (string->duration duration)) > 'symbol 'tempoWholesPerMinute) > (make-music 'PropertySet > 'value (string->duration duration) > 'symbol 'tempoUnitDuration) > (make-music 'PropertySet > 'value count > 'symbol 'tempoUnitCount > > music > > (make-music 'ContextSpeccedMusic > 'context-type 'Score 'element > > (make-music 'PropertySet > 'value format-metronome-markup > 'symbol 'metronomeMarkFormatter) > > > Now it works perfectly -- sorry for the noise! That's good, but there are two problems with it; one quite serious if you value having MIDI output. First, you haven't set tempoWholesPerMinute properly, unfortunately (it's the same problem I was scratching my head about in the original thread): the combination of the note value and beats per minute needs to be converted to a moment. In the example \mov #"Largo" #"2." #140 your code sets tempoWholesPerMinute to (ly:make-moment 3 4 1 1), ignoring the beats-per-minute value, whereas it should be converted to an integral value, i.e. (ly:make-moment 105 1 0 1) or (ly:make-moment 210 2 0 1). Second, unlike the helper function parse-simple-duration, string->duration doesn't account for durations longer than a semibreve since they can't be directly converted to a number. So, in conclusion, close but no cigar. ;) Regards, Neil ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: custom metronome-markup procedure causes weird goops-error
2008/4/25 Neil Puttock <[EMAIL PROTECTED]>: > That's good, but there are two problems with it; one quite serious if > you value having MIDI output. I don't, so I don't care :) > First, you haven't set tempoWholesPerMinute properly, unfortunately > (it's the same problem I was scratching my head about in the original > thread): the combination of the note value and beats per minute needs > to be converted to a moment. Yes. We need a string->moment function, as well as a better string->duration. > Second, unlike the helper function parse-simple-duration, > string->duration doesn't account for durations longer than a semibreve > since they can't be directly converted to a number. Ideal answer: oh yes, that is definitely a limitation. Pragmatic answer : hmm, do we really need \breve in metronome marks? > So, in conclusion, close but no cigar. ;) Hey, now it's your turn! The main issue I've been working on was: how to pass the text string as an argument to the metronomeMarkFormatter. Currently, it's a bit dirty (and heavy) but at least it produces a decent graphical output. I don't (yet) understand ly:make-duration and ly:make-moment well enough to improve the MIDI result. I have never been studying maths, programming or science (my studies were about ancient literature), so I'm learning everything from scratch here... Cheers, Valentin ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: custom metronome-markup procedure causes weird goops-error
On 25/04/2008, Valentin Villenave <[EMAIL PROTECTED]> wrote: > 2008/4/25 Neil Puttock <[EMAIL PROTECTED]>: > > > > That's good, but there are two problems with it; one quite serious if > > you value having MIDI output. > > > I don't, so I don't care :) > > > > First, you haven't set tempoWholesPerMinute properly, unfortunately > > (it's the same problem I was scratching my head about in the original > > thread): the combination of the note value and beats per minute needs > > to be converted to a moment. > > > > Yes. We need a string->moment function, as well as a better string->duration. Indeed, but in this case what's needed is a (string beat)->moment function. > > Second, unlike the helper function parse-simple-duration, > > string->duration doesn't account for durations longer than a semibreve > > since they can't be directly converted to a number. > > > Ideal answer: oh yes, that is definitely a limitation. > Pragmatic answer : hmm, do we really need \breve in metronome marks? I agree that it's not really a big issue, but on that rare occasion when somebody wants to use \breve or \longa, they'll get a nasty surprise and a failed file. This could be solved easily *if* parse-simple-duration can be made public , so it can be accessed from a .ly file. Then it's just a matter of changing string->duration to the following: #(define (string->duration duration) (let ((parsed (parse-simple-duration duration))) (ly:make-duration (car parsed) (cadr parsed))) ) Then again, there may be a good reason why it's not (define-public ...) already. > > So, in conclusion, close but no cigar. ;) > > > Hey, now it's your turn! The main issue I've been working on was: how > to pass the text string as an argument to the metronomeMarkFormatter. > Currently, it's a bit dirty (and heavy) but at least it produces a > decent graphical output. I don't (yet) understand ly:make-duration and > ly:make-moment well enough to improve the MIDI result. Well, I have been trying to work it out, but I think your scheme knowledge is much greater than mine at the moment (and I'm a bit preoccupied with \sacredHarpHeads; can you suggest any improvements to my code?) If the MIDI problem can be solved, I think this would prove a better snippet than the one I added, since it works under 2.10. Regards, Neil ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: custom metronome-markup procedure causes weird goops-error
On 25/04/2008, Neil Puttock <[EMAIL PROTECTED]> wrote: > If the MIDI problem can be solved, I think this would prove a better > snippet than the one I added, since it works under 2.10. It's almost too simple; I was thinking up all sorts of outlandish constructs to get the right value, but the answer's right there in ly-syntax-constructors.scm: mov = #(define-music-function (parser location texte duration count music) (string? string? integer? ly:music?) (define (format-movement-markup dur count context) (make-line-markup (list (markup #:mvt texte #:hspace 1) (make-simple-markup "(") (make-general-align-markup Y DOWN (make-smaller-markup (make-note-by-number-markup (ly:duration-log dur) (ly:duration-dot-count dur) 1))) (make-simple-markup "=") (make-simple-markup (number->string count)) (make-simple-markup ")" (make-music 'SequentialMusic 'elements (list (make-music 'ContextSpeccedMusic 'context-type 'Score 'element (make-music 'PropertySet 'value format-movement-markup 'symbol 'metronomeMarkFormatter)) (make-music 'ContextSpeccedMusic 'context-type 'Score 'element (make-music 'SequentialMusic 'elements (list (make-music 'PropertySet 'value (ly:moment-mul (ly:make-moment count 1) (ly:duration-length (string->duration duration))) 'symbol 'tempoWholesPerMinute) (make-music 'PropertySet 'value (string->duration duration) 'symbol 'tempoUnitDuration) (make-music 'PropertySet 'value count 'symbol 'tempoUnitCount music (make-music 'ContextSpeccedMusic 'context-type 'Score 'element (make-music 'PropertySet 'value format-metronome-markup 'symbol 'metronomeMarkFormatter) Regards, Neil ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: custom metronome-markup procedure causes weird goops-error
2008/4/25 Neil Puttock <[EMAIL PROTECTED]>: > This could be solved easily *if* parse-simple-duration can be made > public , so it can be accessed from a .ly file. Then it's just a > matter of changing string->duration to the following: I think you'd just need to ly:load the relevant file. 2008/4/25 Neil Puttock <[EMAIL PROTECTED]>: > It's almost too simple; I was thinking up all sorts of outlandish > constructs to get the right value, but the answer's right there in > ly-syntax-constructors.scm: Great! Well done! Cheers, Valentin ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: custom metronome-markup procedure causes weird goops-error
Am Freitag, 25. April 2008 schrieb Valentin Villenave: > > Second, unlike the helper function parse-simple-duration, > > string->duration doesn't account for durations longer than a semibreve > > since they can't be directly converted to a number. > > Ideal answer: oh yes, that is definitely a limitation. > Pragmatic answer : hmm, do we really need \breve in metronome marks? Lilypond-style answer: Show me an example: http://kainhofer.com/~lilypond/input/regression/musicxml/collated-files.html#03c-MetronomeMarks.ly Cheers, Reinhold -- -- Reinhold Kainhofer, Vienna University of Technology, Austria email: [EMAIL PROTECTED], http://reinhold.kainhofer.com/ * Financial and Actuarial Mathematics, TU Wien, http://www.fam.tuwien.ac.at/ * K Desktop Environment, http://www.kde.org, KOrganizer maintainer * Chorvereinigung "Jung-Wien", http://www.jung-wien.at/ ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: custom metronome-markup procedure causes weird goops-error
Le 29 avr. 08 à 11:52, Reinhold Kainhofer a écrit : Am Freitag, 25. April 2008 schrieb Valentin Villenave: Second, unlike the helper function parse-simple-duration, string->duration doesn't account for durations longer than a semibreve since they can't be directly converted to a number. Ideal answer: oh yes, that is definitely a limitation. Pragmatic answer : hmm, do we really need \breve in metronome marks? Lilypond-style answer: Show me an example: http://kainhofer.com/~lilypond/input/regression/musicxml/collated-files.html#03c-MetronomeMarks.ly For the record, here is a version without the breve limitation, and with nicer style. #(define ((make-format-movement-markup-function text) duration count context) (markup #:huge #:bold text #:hspace 1 #:concat ("(" #:general-align Y DOWN #:smaller #:note-by-number (ly:duration-log duration) (ly:duration-dot-count duration) 1) "=" #:concat ((number->string count) ")"))) #(define (string->duration duration-string) "Parse the `duration-string', e.g. ''4..'' or ''breve.'', and return a duration object." (let* ((length (string-length duration-string)) (dot-index (or (string-index duration-string #\.) length)) (len (substring duration-string 0 dot-index)) (dots (- length dot-index))) (ly:make-duration (cond ((string=? len "breve") -1) ((string=? len "longa") -2) ((string=? len "maxima") -3) (else (log2 (string->number len dots 1 1))) movement = #(define-music-function (parser location text duration count music) (string? string? integer? ly:music?) #{ \set Score . metronomeMarkFormatter = #(make-format-movement- markup-function $text) \set Score . tempoWholesPerMinute = #$(ly:duration-length (string- >duration duration)) \set Score . tempoUnitDuration = #$(string->duration duration) \set Score . tempoUnitCount = #$count $music \set Score . metronomeMarkFormatter = #format-metronome-markup #}) \relative c' { \time 3/4 \movement "Allegro" "2." #96 c2 e4 g2. \movement "Moderato" "4" #104 f4 e d \tempo 4 = 92 c2. } ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: custom metronome-markup procedure causes weird goops-error
2008/4/29 Nicolas Sceaux <[EMAIL PROTECTED]>: > For the record, here is a version without the breve limitation, > and with nicer style. Nicolas: I really like your code (I'm using it right now); however, 2.10 currently doesn't accept it :( If you can figure out a way to make it work on the LSR, I'll update the snippet. Cheers, Valentin ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: custom metronome-markup procedure causes weird goops-error
Le 29 avr. 08 à 12:57, Valentin Villenave a écrit : 2008/4/29 Nicolas Sceaux <[EMAIL PROTECTED]>: For the record, here is a version without the breve limitation, and with nicer style. Nicolas: I really like your code (I'm using it right now); however, 2.10 currently doesn't accept it :( If you can figure out a way to make it work on the LSR, I'll update the snippet. I think it's because there is no \concat markup command in 2.10. Untested: #(define ((make-format-movement-markup-function text) duration count context) (markup #:huge #:bold text #:hspace 1 "(" #:general-align Y DOWN #:smaller #:note-by-number (ly:duration-log duration) (ly:duration-dot-count duration) 1 "=" (number->string count) ")")) ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: custom metronome-markup procedure causes weird goops-error
2008/4/29 Nicolas Sceaux : > I think it's because there is no \concat markup command in 2.10. > > Untested: Looks nice. :-) It seems to work with .11 & .10. In fact, the results look better this way than with \concat. The space between the left parenthesis and the note head is better matched with the space between the number and the right parenthesis. If I may pick a nit a bit - with \concat there could be a small \hspace between the parenthesis and the note. I wouldn't have noticed it if you hadn't sent this version. :-) -Risto ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: custom metronome-markup procedure causes weird goops-error
2008/4/29 Risto Vääräniemi <[EMAIL PROTECTED]>: > It seems to work with .11 & .10. In fact, the results look better this > way than with \concat. The space between the left parenthesis and the > note head is better matched with the space between the number and the > right parenthesis. If I may pick a nit a bit - with \concat there > could be a small \hspace between the parenthesis and the note. I > wouldn't have noticed it if you hadn't sent this version. :-) I do like the version without \concat, but it actually looks my own first version, so I may be influenced... Nicolas: great! The LSR snippet has been updated. Many thanks. Cheers, Valentin ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: custom metronome-markup procedure causes weird goops-error
2008/4/29 Valentin Villenave <[EMAIL PROTECTED]>: > Nicolas: great! The LSR snippet has been updated. Many thanks. That's excellent. I've tagged it as docs so we can remove the snippet in input/new. For those who care about MIDI, I've fixed the snippet. :p Regards, Neil ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: custom metronome-markup procedure causes weird goops-error
2008/4/29 Neil Puttock <[EMAIL PROTECTED]>: > That's excellent. I've tagged it as docs so we can remove the snippet > in input/new. I didn't know what it felt like to have someone else taking care of the LSR... Feels great actually :-) Cheers, Valentin ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: custom metronome-markup procedure causes weird goops-error
On Apr 29, 2008, at 4:35 AM, Risto Vääräniemi wrote: 2008/4/29 Nicolas Sceaux : I think it's because there is no \concat markup command in 2.10. Untested: Looks nice. :-) It seems to work with .11 & .10. In fact, the results look better this way than with \concat. The space between the left parenthesis and the note head is better matched with the space between the number and the right parenthesis. If I may pick a nit a bit - with \concat there could be a small \hspace between the parenthesis and the note. I wouldn't have noticed it if you hadn't sent this version. :-) I've been too busy to keep up with the lists. My solution is slightly the reverse of this one which is to create simple tempo commands to add to any markup used like this (with parentheses): \markup{ Allegro \mm #"4" #"120" } or (without parentheses): \markup( Allegro con moto \MM #"2" #"132" } The code (without breve's but easily modifiable to include them) is in the attachment since I am on my Mac at the moment and I dcn't know how to cut and paste from XDarwin to the Mac GUI. mm.ly Description: Binary data I'll see if I can make the breve mod and create a snippet. Paul Scott ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: custom metronome-markup procedure causes weird goops-error
On May 3, 2008, at 7:35 PM, Paul Scott wrote: On Apr 29, 2008, at 4:35 AM, Risto Vääräniemi wrote: 2008/4/29 Nicolas Sceaux : I think it's because there is no \concat markup command in 2.10. Untested: Looks nice. :-) It seems to work with .11 & .10. In fact, the results look better this way than with \concat. The space between the left parenthesis and the note head is better matched with the space between the number and the right parenthesis. If I may pick a nit a bit - with \concat there could be a small \hspace between the parenthesis and the note. I wouldn't have noticed it if you hadn't sent this version. :-) I've been too busy to keep up with the lists. My solution is slightly the reverse of this one which is to create simple tempo commands to add to any markup used like this (with parentheses): \markup{ Allegro \mm #"4" #"120" } or (without parentheses): \markup( Allegro con moto \MM #"2" #"132" } Looking at the definition of "movement" in the LSR I see that the tempo must be a number. If it is a string then one can use variations like "ca. 120" to indicate approximate tempos, etc. Paul ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: custom metronome-markup procedure causes weird goops-error
On May 3, 2008, at 7:35 PM, Paul Scott wrote: On Apr 29, 2008, at 4:35 AM, Risto Vääräniemi wrote: 2008/4/29 Nicolas Sceaux : I think it's because there is no \concat markup command in 2.10. Untested: Looks nice. :-) It seems to work with .11 & .10. In fact, the results look better this way than with \concat. The space between the left parenthesis and the note head is better matched with the space between the number and the right parenthesis. If I may pick a nit a bit - with \concat there could be a small \hspace between the parenthesis and the note. I wouldn't have noticed it if you hadn't sent this version. :-) I've been too busy to keep up with the lists. My solution is slightly the reverse of this one which is to create simple tempo commands to add to any markup used like this (with parentheses): \markup{ Allegro \mm #"4" #"120" } or (without parentheses): \markup( Allegro con moto \MM #"2" #"132" } Looking at the definition of "movement" in the LSR I see that the tempo must be a number. If it is a string then one can use variations like "ca. 120" to indicate approximate tempos, etc. Paul ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user