On Sun, Oct 12, 2014 at 5:59 PM, Hans Sommer <hansisom...@gmx.de> wrote:
> > David Nalesnik <david.nalesnik <at> gmail.com> writes: > > > > > Hi Hans, > > On Sun, Oct 12, 2014 at 4:38 AM, Hans Sommer <hansisommer <at> gmx.de> > wrote:Hello, > > I am relatively new to Lilypond. > > I try to check the total length of a SequentialMusic part, i.e. > > my_score_part = { c'4 d e f } > > I want to get the result 4 quarters (or any other numerical > representation) > > and for > > my_score_part2 = { c'4 d e f g8} > > > > > > (This isn't a valid name for a variable, so I changed it below.) > > > > > > > > should deliver 4 quarter and 1 eighth. > > I found in the documentation the property: > > length-callback (procedure): > > ly:music-sequence::cumulative-length-callback > > but I don't know how to use it. > > I would be very thankful, if anybody could provide an example. > > > > > > I'm not familiar with this property, but it's relatively easy to > determine > the length of a music expression. Try this: > > > > \version "2.19.10" > > > > my_score_part = { c'4 d e f } > > > > my_score_part_two = { c'4 d e f g8 } > > > > #(display (ly:music-length my_score_part)) > > > > #(display (ly:music-length my_score_part_two)) > > > > Hope this is helpful, > > David > > > > > > > > > > > > _______________________________________________ > > lilypond-user mailing list > > lilypond-user <at> gnu.org > > https://lists.gnu.org/mailman/listinfo/lilypond-user > > > > Thank you David, > > that was what I was looking for. > > When I use > #(display (ly:music-length my_score_part)) > I get in the lilypond log file (depending on the score length) someting > like > that: > > #<Mom 2> > > Is there a possibility to write the result in an extra text file (I want > to > process the result by a program, that is actually starting the lilypond > compilation. It should check the score length and eventually throw an > error). > Yes, you can specify a port for display: \version "2.19.10" my_score_part = { c'4 d e f } my_score_part_two = { c'4 d e f g8 } #(define out (open-output-file "music-length.txt")) #(display (ly:music-length my_score_part) out) #(display (ly:music-length my_score_part_two) out) %%% You could also use format for nicer output: #(format out "Length of my_score_part: ~a~%Length of my_score_part_two: ~a~%" (ly:music-length my_score_part) (ly:music-length my_score_part_two)) %%% I don't think you need to close the port, but you could add this: #(close-output-port out) --David
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user