lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

glissando and how to create concise code


From: Brad Smith
Subject: glissando and how to create concise code
Date: Fri, 5 Oct 2012 19:48:36 -0400

Hi, I'm a little bit new to lilypond, and I'm trying to write a gliss
into a note and that works fine with something like the following:

: \hideNotes \grace f \glissando \unHideNotes c'

My question is how can I simplify this? I don't want to type this
whole thing every time I want this. I'd like to do something like:

: \glissin f c'

Am I correct to assume that the best way to do this is with
define-music-function? I am trying to write a function that takes two
arguments and works as if I typed the whole example above. The
following example contains my attempt, which does not compile:


\version "2.16.0"
\include "english.ly"

glissin =
    #(define-music-function
        (parser location notea noteb)
        (ly:music? ly:music?)
        #{
            \hideNotes \grace $notea \glissando \unHideNodes $noteb
        #})

tune = {
    c4 d e f |
    g \hideNotes \grace f \glissando \unHideNotes c' b a |
    c4 d e f |
    g \glissin f c' b a |
}

\score {
    \new Staff {
        \clef "treble_8"
        \time 4/4
        \tune
    }
}


When I compile, I get the following output:


Starting lilypond-windows.exe 2.16.0 [test.ly]...
Processing `c:/.../test.ly'
Parsing...
c:/.../test.ly:9:37: error: syntax error, unexpected EVENT_IDENTIFIER
            \hideNotes \grace $notea
                                     \glissando \unHideNodes $noteb

c:/.../test.ly:9:48: error: unknown escaped string: `\unHideNodes'
            \hideNotes \grace $notea \glissando
                                                \unHideNodes $noteb

c:/.../test.ly:16:20: error: error in #{ ... #}
    g \glissin f c'
                    b a |

c:/.../test.ly:20:4: error: errors found, ignoring music expression

    \new Staff {

fatal error: failed files: "c:\\...\\test.ly"
Exited with return code 1.


I notice that I can replace $notea with an immediate note like f, and
it will compile correctly. There seems to be a problem with how $notea
is being parsed in combination with \glissando that I don't
understand.

All I really want is something like a preprocessor macro to cut down
on boilerplate code, but something like this does not seem to be
available in lilypond. The define-music-function thing seems like it
would be a reasonable substitute for that if I could get it to work,
but I'm finding it hard to figure out what's going on. When trying to
solve this problem, I'm not sure where to start in the documentation.

Can anyone help?


-- Brad Smith



reply via email to

[Prev in Thread] Current Thread [Next in Thread]