【问题标题】:lilypond: define a macro containing \transpose?lilypond:定义一个包含 \transpose 的宏?
【发布时间】:2019-01-18 15:42:24
【问题描述】:

我有一些 Lilypond 文件,我将它们放在一起用于人声和吉他;我需要为他们中的一些人做变调夹。我正在使用 Carl Sorensen-3 在http://lilypond.1069038.n5.nabble.com/Newbie-Question-verse-and-chorus-td46241i20.html 的回复中的代码来打印变调夹和弦。

这行得通:

\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
    }
  }
}

现在:我想将转置放入一个宏中(保证我在指板上获得转置设置和转置和弦相同)。

用这个替换 \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

这是一件小事,但我可以把这个转置变成一个宏,这样我就可以定义一次了吗?

【问题讨论】:

    标签: lilypond


    【解决方案1】:

    我有同样的问题,并从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.
    

    【讨论】:

      猜你喜欢
      • 2017-12-21
      • 1970-01-01
      • 2012-04-26
      • 1970-01-01
      • 2010-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多