If this looked very magic, please take a look at the section Building
complicated
functions, which shows a systematic way to figure out what functions to
use.
/Mats
Gilles THIBAULT wrote:
I think you have to rewrite your own \tempo function.
I try this which seems to works.
%
\version 2.11.34
\include english.ly
tempoAlt = #(define-music-function (parser location Duration Tempo)
(string? string?)
(
let*(
(ptindex (string-index Duration #\. ))
;; position of . in 4. for exemple. #f if no ..
(ptnumber 0)
(val (string-number (if ptindex (substring Duration 0 ptindex)
Duration)))
;; val = 1 2 4 8 ... (without the .)
(dur (ly:intlog2 val))
;; dur = 0 1 2 3 ... (need for ly:make-duration)
(t (string-number Tempo))
)
;; find the number of . in Duration
(while ptindex (
begin
(set! ptnumber (1+ ptnumber))
(set! ptindex (string-index Duration #\. (1+ ptindex) ))
)
)
;; see tempo in ly-syntax-constructors.scm line 81
(tempo parser location (ly:make-duration dur ptnumber 1 1) t )
))
GRtempoMark =
#(define-music-function (parser location Padding TextDuration
PerMinute)
( number? string? string? string?)
#{
\once \override Score.MetronomeMark #'transparent = ##t
\tempoAlt $Duration $PerMinute
\once \override Score.RehearsalMark #'self-alignment-X = #left
\once \override Score.RehearsalMark #'padding = #$Padding
\mark \markup
{
\bold $Text
(
\smaller \general-align #Y #DOWN \note #$Duration #1
=
\smaller \general-align #Y #DOWN \italic ca.
\general-align #Y #DOWN $PerMinute
)
}
#}
)
\score
{
\new Staff \relative c'
{
\GRtempoMark #2 #Andante 2. 30
c'4
}
\layout {}
\midi {}
}
%%%
original message :
I'm having a problem setting the MIDI tempo from within a function.
When I
compile the file below, I get the error message:
GNU LilyPond 2.11.35
Processing `test.ly'
Parsing...
string:3:11: error: syntax error, unexpected SCM_TOKEN, expecting
DIGIT or
UNSIGNED or DURATION_IDENTIFIER
\tempo
#lilyvartmpb = \lilyvartmpc
test.ly:26:0: error: errors found, ignoring music expression
\relative c'
It seems that lilypond is complaining that the parameter Duration is
not a
number. I've tried various ways of getting around this, but it
doesn't seem
to work. If I comment out the \tempo line, I get a music file (
http://www.nabble.com/file/p14336623/test.png test.png ) with the
appropriate tempo marking, but it has no effect on the MIDI tempo.
Any ideas?
Cheers,
Garry.
-
\version 2.11.35
\include english.ly
GRtempoMark =
#(define-music-function (parser location Padding TextDuration
PerMinute)
( number? string? string?
string?)
#{
\once \override Score.MetronomeMark #'transparent = ##t
\tempo #$Duration = $PerMinute
\once \override Score.RehearsalMark #'self-alignment-X = #left
\once \override Score.RehearsalMark #'padding = #$Padding
\mark \markup
{
\bold $Text
(
\smaller \general-align #Y #DOWN \note #$Duration #1
=
\smaller \general-align #Y #DOWN \italic ca.
\general-align #Y #DOWN $PerMinute
)
}
#}
)
\relative c'
{
\GRtempoMark #2 #Andante #4 #60
c4
}
--
View this message in context:
http://www.nabble.com/Cannot-set-MIDI-tempo-Programmatically-tp14336623p14336623.html
Sent from the Gnu - Lilypond - User mailing list archive at Nabble.com.
___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user
___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user
--
=
Mats Bengtsson
Signal Processing
Signals, Sensors and Systems
Royal Institute of Technology
SE-100 44 STOCKHOLM
Sweden
Phone: (+46) 8 790 8463
Fax: (+46) 8 790 7260
Email: [EMAIL PROTECTED]
WWW: http://www.s3.kth.se/~mabe
=
___
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user