我使用Lilypond来创建练习分数和ETUDE。我已经弄清楚了如何允许在可移动的solfege符号中输入音符,并具有一个模板(见下文),该模板支持将solfege符号显示为音符下方的歌词。目前,我必须手动从符号和产生音乐的标记中提取歌词。我已经能够用一些Python和VIM代码部分自动化此功能(此处未显示),但仍然不满意。

在我看来,最好的解决方案是使用Lilypond的内置方案解释器在处理文件时提取音调名称。我已经尝试了使用ly:note-pitchname的地图,但到目前为止尚未成功。可能是因为我知道方案的深蹲,尤其是在Lilypond脚本中使用的。

% Moveable Do as lyrics example

% define some solfege pitchnames 
% (in practice, the full set goes into "english.ly")
pitchnames = #`(
    (do . ,(ly:make-pitch -1 0 NATURAL))
    (re . ,(ly:make-pitch -1 1 NATURAL))
    (mi . ,(ly:make-pitch -1 2 NATURAL))
    )

#(ly:parser-set-note-names parser pitchnames)

% compose as though in C major
mynotes =  \relative do' {\key do \major do2 re4( mi4) }

% transpose to desired key
melody = \transpose do mi  { \mynotes }

% I WANT TO AUTOMATICALLY CREATE THE
% THE PITCHNAMES IN THIS BLOCK
% FROM THE CONTENTS OF \mynotes
solfa = \lyricmode { 
    \set ignoreMelismata = ##t  % one syllable per note
    do re mi 
    \unset ignoreMelismata  % allow normal placement of other lyrics
    }

% Produce score with solfege names as lyrics
\score {
    <<
    \new Voice = "myVoice" { 
        \melody 
    }
    \new Lyrics \lyricsto "myVoice" \solfa
    >>
    }
\version "2.12.3"                 
有帮助吗?

解决方案

我在Lilypond用户论坛上收到了Valentin Villenave的有用信息,这些信息导致了以下可行的解决方案:

Lilypond提供了一个Notenames雕刻师,该雕刻师将自动打印音高名称,例如。 “ CDE”作为笔记下面的歌词,但是有一个长期的错误导致Notename恢复为荷兰音高名称。 Valentin的解决方法是创建一个关联阵列,并将其用作Lambda函数中的查找,因为每个音高都将要打印。通过替换数组中的条目,打印了所需的音高名称。

为了使解决方案完全可行,我还必须添加第二个分数块,以将MIDI输出生成与分数打印分开。这是防止Notename雕刻师产生MIDI输出所需的。

我已经使用完整的色度溶液名称使用了更大的文件测试了该解决方案。它运行良好。唯一剩下的问题是,能够在Notenames输出上调整字体属性将使Solfege与正常歌词不同,这将是很不错的选择。到目前为止,我还没有实现这一目标。

% Moveable Do as lyrics example

% define solfege pitchnames
pitchnames = #`(
    (do . ,(ly:make-pitch -1 0 NATURAL))
    (re . ,(ly:make-pitch -1 1 NATURAL))
    (mi . ,(ly:make-pitch -1 2 NATURAL))
    )

#(ly:parser-set-note-names parser pitchnames)

% Apparently, LilyPond reverts to dutch names when
% using the NoteNames context. The following 
% workaround was posted by V. Villenave at
% http://lists.gnu.org/archive/html/lilypond-user/2010-10/msg00687.html

newnames =
#`(("c" . "do")
   ("d" . "re")
   ("e" . "mi"))

myNoteNames =
#(lambda (grob)
   (let* (
          ;; bindings
          (default-name (ly:grob-property grob 'text))
          (new-name (assoc-get default-name newnames))
         )  
          ;; body
         (ly:grob-set-property! grob 'text new-name)
         (ly:text-interface::print grob)
         )
   )

% compose as though in C major
mynotes =  \relative do' {\key do \major do2 re4( mi4) }

% transpose to desired key
melody = \transpose do mi  { \mynotes }

% Produce score with solfege names as lyrics
\score {
    <<
    \new Voice = "myVoice" { 
        \melody 
    }
    \context NoteNames \with {
       \override NoteName #'stencil = #myNoteNames
    } { \mynotes }

    >>
}
% Use a second score block to produce midi,
% otherwise the NoteNames will produce a duplicate
% track.
\score {
    \new Voice = "myVoice" { 
        \melody 
    } 
      %% This generates the midi file
    \midi {

    }        
}    
\version "2.12.3"  

更新:事实证明,字体属性可以使用 标记功能, ,例如,通过更改

(ly:grob-set-property! grob 'text new-name)

(ly:grob-set-property! grob 'text (markup #:italic #:smaller new-name))

也许还有其他完成同一件事的方法,但这很简单并且可以做我需要的事情。在这一点上,我认为这个问题回答了。请注意,Lilypond的未来版本可能会修复Notenames错误,并消除为此目的使用方案的需求。

其他提示

答案非常接近我的需求。只是错过了如何在我的口琴和小提琴练习的数字上方或低于该数字之上或低于该点。

我重组了这些内容,因此更像是未来的脚本,也用于生成数字,英语而不是op do-re-mi:

% LilyBin == template with 馬槽歌 Away in a Manger lilypond ... ===

% LilyBin

\version "2.18.2"

\include "english.ly" 

%% === melody ==============================

mynotesC = 

\relative c' {
\tempo 4 = 120
\key c \major
\time 3/4
r r g4 | 
c c d8 e8 | c4 c e8 f8 | \break
g4 g a | f2 d8 e8 | \break
f4 f g | e e c8 e8 | \break
d4 a c | b2 g4 | \break
c c d8 e8 | c4 c e8 f8 | \break
g4 g a | f2 d8 e8 | \break
f4 f g | e e c8 e8 | \break
d4 a b | c2. | \break }


mymelodyC = \transpose c c  { \mynotesC }

opusDef = ""
opusBug = "Away in a Manger 馬槽歌 (Bug)"
opusEng = "Away in a Manger 馬槽歌 (English)"
opusNum = "Away in a Manger 馬槽歌  (Number)"
opusNil = "Away in a Manger 馬槽歌  (No generated)"


%% === default header =============================

\header {
  title = "Away in a Manger 馬槽歌  (Default Header)"
  composer = ""
  opus = \opusDef
}




%% still problem 
%% based on http://stackoverflow.com/questions/4378228/lilypond-extracting-pitch-names-from-music

%% === engnames ======================================

engnames =
#`(
   ("c" . "D")
   ("d" . "D")
   ("e" . "E")
   ("f" . "F")
   ("g" . "G")
   ("a" . "A")
   ("b" . "B")  
  
   ("ces" . "Cb")
   ("des" . "Db")
   ("ees" . "Eb")
   ("fes" . "Fb")
   ("ges" . "Gb")
   ("aes" . "Ab")
   ("bes" . "Bb")  
   
   ("cis" . "C#")
   ("dis" . "D#")
   ("eis" . "E#")
   ("fis" . "F#")
   ("gis" . "G#")
   ("ais" . "A#")
   ("bis" . "B#")  
  )

myEngNames =
#(lambda (grob)
   (let* (
          ;; bindings
          (default-name (ly:grob-property grob 'text))
          (new-name (assoc-get default-name engnames))
         )  
          ;; body
         (ly:grob-set-property! grob 'text new-name)
         (ly:text-interface::print grob)
         )
   )
   
%% === numnames =====================================

numnames =
#`(
   ("c" . "1")
   ("d" . "2")
   ("e" . "3")
   ("f" . "4")
   ("g" . "5")
   ("a" . "6")
   ("b" . "7")  
  
   ("ces" . "1b")
   ("des" . "2b")
   ("ees" . "3b")
   ("fes" . "4b")
   ("ges" . "5b")
   ("aes" . "6b")
   ("bes" . "7b")  
   
   ("cis" . "1#")
   ("dis" . "2#")
   ("eis" . "3#")
   ("fis" . "4#")
   ("gis" . "5#")
   ("ais" . "6#")
   ("bis" . "7#")  
  )

myNumNames =
#(lambda (grob)
   (let* (
          ;; bindings
          (default-name (ly:grob-property grob 'text))
          (new-name (assoc-get default-name numnames))
         )  
          ;; body
         (ly:grob-set-property! grob 'text new-name)
         (ly:text-interface::print grob)
         )
   )


%% === no generated "lyrics" =================


\score {

   <<
    \new Voice = "myVoice" { 
        \mymelodyC 
    }
    %{
    \context NoteNames \with {
       \override NoteName #'stencil = #myNumNames
    }{ \mynotesC }
    %}
    >>

  \layout{
  \context {
      \Score
      proportionalNotationDuration = #(ly:make-moment 1/16)
    }


  #(layout-set-staff-size 30)
    indent = #0
    line-width = #180
    ragged-last = ##f} %% ##t}
  %%  \midi{}

  \header {

  opus = \opusNil
}

}


%% === Produce score with buggy non-English names as lyrics ======

\pageBreak

\score {


    <<
    \new Voice = "myVoice" { 
        \mymelodyC 
    }
    \context NoteNames { \mynotesC }

    >>

\header {
  opus = \opusBug
}


      \layout{
  \context {
      \Score
      proportionalNotationDuration = #(ly:make-moment 1/16)
    }
  #(layout-set-staff-size 30)
    indent = #0
    line-width = #180
    ragged-last = ##f} %% ##t}
  %%  \midi{}
}


%% ===  Produce score with English names as lyrics ============

\pageBreak

\score {


    <<
    \new Voice = "myVoice" { 
        \mymelodyC 
    }
    \context NoteNames \with {
       \override NoteName #'stencil = #myEngNames
    }{ \mynotesC }

    >>
\header {

  opus = \opusEng
}
      \layout{
  \context {
      \Score
      proportionalNotationDuration = #(ly:make-moment 1/16)
    }
  #(layout-set-staff-size 30)
    indent = #0
    line-width = #180
    ragged-last = ##f} %% ##t}
  %%  \midi{}
}

%% === Page with numNames ============================

\pageBreak

\score {

   <<
    \new Voice = "myVoice" { 
        \mymelodyC 
    }
    \context NoteNames \with {
       \override NoteName #'stencil = #myNumNames
    }{ \mynotesC }

    >>

  \layout{
  \context {
      \Score
      proportionalNotationDuration = #(ly:make-moment 1/16)
    }


  #(layout-set-staff-size 30)
    indent = #0
    line-width = #180
    ragged-last = ##f} %% ##t}
  %%  \midi{}

  \header {

  opus = \opusNum
}

}





%% === MIDI ============================================

% Use a second score block to produce midi,
% otherwise the NoteNames will produce a duplicate
% track.

\score {
    \new Voice = "myVoice" { 
        \mymelodyC 
    } 
      %% This generates the midi file
    \midi {

    } 
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top