簡體   English   中英

lilypond:定義一個包含\\ transpose的宏?

[英]lilypond: define a macro containing \transpose?

我收集了一些Lilypond文件,用於人聲和吉他。 我需要為其中一些做投訴警察課。 我在http://lilypond.1069038.n5.nabble.com/Newbie-Question-verse-and-chorus-td46241i20.html中的Carl Sorensen-3答復中使用該代碼來打印變調夾和弦。

這有效:

\version "2.18.2"

\include "predefined-guitar-fretboards.ly"

% Carl Sorensen-3's reply in
% http://lilypond.1069038.n5.nabble.com/Newbie-Question-verse-and-chorus-td46241i20.html
parenthesizeAll =
 #(define-music-function (parser loc myMusic) (ly:music?)
  (music-map
    (lambda (ev)
      (if (or (memq 'note-event (ly:music-property ev 'types))
              (memq 'rest-event (ly:music-property ev 'types)))
          (set! (ly:music-property ev 'parenthesize) #t))
      ev)
    myMusic)
  myMusic)

theMelody = \relative g' { c1 }
theChords = \chordmode { c1 }
verseI = \lyricmode { See }

\score {
  <<
    \context ChordNames {
      \set instrumentName = #"Capo 3"
      \parenthesizeAll
      \transpose c a { \theChords }
    }
    \new FretBoards { \transpose c a { \theChords } }
    \new ChordNames { \theChords }
    \new Staff {\context Voice = "voiceMelody" { \theMelody }
    }
    \new Lyrics = "lyricsI"   { \lyricsto "voiceMelody" \verseI }
  >>

  \layout {
    % make the "Capo x" show up
    \context {
      \ChordNames \consists Instrument_name_engraver
    }
  }
}

現在:我想將移調放到一個宏中(確保我在Fretboards上獲得了移調設置,移調和弦相同)。

以此替換\\ score塊

% define once
tC = { \transpose c a }

\score {
  <<
    \context ChordNames {
      \set instrumentName = #"Capo 3"
      \parenthesizeAll
      \tC { \theChords }
    }
    \new FretBoards { \tC { \theChords } }
    \new ChordNames { \theChords }
    \new Staff {\context Voice = "voiceMelody" { \theMelody } }
    \new Lyrics = "lyricsI"   { \lyricsto "voiceMelody" \verseI }
  >>

  \layout {
    % make the "Capo x" show up
    \context {
      \ChordNames \consists Instrument_name_engraver
    }
  }
}

結果是:

/home/wegscd/mup/CapoTest.ly:23:23: error: syntax error, unexpected '}'
tC = { \transpose c a 
                      }
/home/wegscd/mup/CapoTest.ly:26:3: error: errors found, ignoring music expression

這是一件小事,但是我可以將此轉置到宏中,因此可以只定義一次?

我有同樣的問題,並從http://lsr.di.unimi.it/LSR/Item?id=787獲得了答案。

我正在使用它的一個小修改:

MyTranspose = 
#(define-music-function (parser location m)
  (ly:music?)
  #{ \transpose c c $m #})  % transposing c to c does nothing. Adjust as needed.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM