Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Lilypond 如何缩写';用同一音符加上一个八度,括号为';在莉莉邦德?_Lilypond_Scheme_Guile_Music Notation - Fatal编程技术网

Lilypond 如何缩写';用同一音符加上一个八度,括号为';在莉莉邦德?

Lilypond 如何缩写';用同一音符加上一个八度,括号为';在莉莉邦德?,lilypond,scheme,guile,music-notation,Lilypond,Scheme,Guile,Music Notation,目前我编写的代码如下所示: \version "2.14.2" P = #parenthesize \relative c, { \clef bass <c \P c'> <e \P e'> <g \P g'>2 <c, \P c'>4 <d \P d'> <e \P e'>2 } \version "2.14.2" poct = ... \relative c, { \clef bass

目前我编写的代码如下所示:

\version "2.14.2"

P = #parenthesize

\relative c, {
  \clef bass 
    <c \P c'> <e \P e'> <g \P g'>2 <c, \P c'>4 <d \P d'> <e \P e'>2
}
\version "2.14.2"

poct = ...

\relative c, {
  \clef bass 
  \poct c \poct e \poct g2 \poct c,4 \poct d \poct e2
}
正如中所建议的,我已尝试使用,但我无法使其正常工作。我能得到的最接近的是

poct = #(define-music-function
     (parser location note)
     (ly:music?)
   #{
     << $note \transpose c c \parenthesize $note >>
   #})

好的,这是我为你们创建的一个函数,它允许你们重复单音高。唯一的问题是它不会使用
\relative
符号。这是因为,在相对记数法中,下面的音符序列显然比前面的高一个八度。不幸的是,我仍然找不到一种方法来拥有像
\function#3c'
这样输出
c'c
的函数。也就是说,下面是我的函数和一些示例:

\version "2.17.28"

times = #(define-music-function
     (parser location N note)
     (integer? ly:music?)
     (cond 
       ((>= N 2)
         #{ \repeat unfold $N { \absolute $note } #}
       )
       ((= N 1) 
         #{ \absolute $note #}
       )
     )
)

{
 a4 \times #3 b4
 R1
 \times #4 { c'8 d' }
 R1
 \times #1 { c''1 }
}
所以语法就是
\times#“重复次数”{…music…}
。如果只重复一个音符,则可以同时省略
{
}
\times#“重复次数”和“单个音符”

你可以在<代码>中间的相对< /代码>段落中使用这个函数,但是你应该输入函数的音高作为绝对音高。看看:

\version "2.17.28"

times = #(define-music-function
     (parser location N note)
     (integer? ly:music?)
     (cond 
       ((>= N 2)
         #{ \repeat unfold $N { \absolute $note } #}
       )
       ((= N 1) 
         #{ \absolute $note #}
       )
     )
)

\relative c'' {
  c4 d \times #4 e'' f g
}
请注意,以上所有音符都在同一个八度音阶中。音符
f
的倍频程位置也不受此函数的影响,它受该函数前面的音符的影响,即
d

当然,有一种方法可以为此编写更好的代码,但我无法使用任何
\relative
\transpose
命令来实现这一点


下面是一些尝试,以帮助您使用括号内的八度(与上面的函数相同,但有一些小改动):

\version“2.17.28”
timesP=#(定义音乐功能
(语法分析器位置N注释)
(integer?ly:音乐?)
(续)
((>=n2)
#{ 
>
#}
)
)
)
{
a4\timesP#3 b4
\时间P#8 c'16
\timesP#2 g4
\timesP#4{c'8 d'}%此处没有括号,因为有两个注释作为参数。。。
\timesP#1{c''1}%由于{}的原因,这里没有括号
}
\相对c“{
c4 d\timesP#4 e''f g
}
这里仍然有一些陷阱:当参数是没有
{}
编写的单个注释时,此函数将仅插入括号。上面的代码对此进行了很好的注释



我希望这能对你有所帮助。如果我在这里遇到八度音阶转换问题的解决方案,我会更新这个答案。

我刚从LilyPond的开发者之一David Kastrup那里得到了这个答案:


“八度音阶转换”之所以发生,是因为基本上\transpose c c与\absolute相同(因为LilyPond不适用于\relative转换音乐)

\绝对与\repeat unfold:\ repeat unfold知道如何处理相关音乐

版本2.14.2太旧了。无论如何,LilyPond跟踪器中目前存在一个问题,相应的代码可以在

在那里,我们确实进入了方案编程。尽管{{}可能无法正常工作,但即使在2.14中,相应的defmacro public也可能工作

根据该定义,您的双重定义将变成:

double=#(定义音乐功能 (解析器位置注释) (李:音乐?) (作相对的注释) #{ $note$note #}))

然后将在绝对和相对模式下工作。如果2.14#{#}与make relative不兼容,那么编写(make sequential music(list(ly:music deep copy note)(ly:music deep copy note))应该作为方案替换


一旦您意识到原来的问题只是一个简单的代码替换,那么就更容易理解了,因此\relative{\double c'}变成了\relative{c'c'}使用不同的八度音阶。make relative宏将仅对单个音符执行\relative操作,然后将结果粘贴到音乐表达式中。

根据您问题中的代码和另一个答复中引用的David Kastrup的答案,我构建了以下代码,将音符转换为同一音符的和弦,高出一个八度,而不是括号:

#(define (octavate-pitch pitch octaves)
   (ly:make-pitch
    (+ (ly:pitch-octave pitch) octaves)
    (ly:pitch-notename pitch)
    (ly:pitch-alteration pitch)))

#(define (articulation-is-of-type? art type)
   (string=? (ly:music-property art 'articulation-type) type))

#(define (copy-articulation? art)
   (cond ((music-is-of-type? art 'tie-event)
          #t)
         ((and (music-is-of-type? art 'articulation-event)
               (articulation-is-of-type? art "fermata"))
          #f)
         ; TODO add more cases
         (else
          #f)))

#(define (octNote note)
   (if (null? (ly:music-property note 'pitch))
       note
       (make-relative (note) note
                      (let ((note2 (ly:music-deep-copy note))
                            (pitch (ly:music-property note 'pitch)))
                        (set! (ly:music-property note2 'pitch)
                              (octavate-pitch pitch 1))
                        (set! (ly:music-property note2 'articulations)
                              (filter copy-articulation? (ly:music-property note2 'articulations)))
                        (make-event-chord (list note note2))))))

oct = #(define-music-function
           (parser location music)
           (ly:music?)
         (music-map octNote music))
它可以应用于单个音符或完整的音乐表达:

\relative c' \oct {
  c d e f |
  g2 g |
}
它也以相反的顺序工作,
\oct\relative c'{…}

要将添加的注释插入括号,请将
octNote
中最后一次引用的
note2
替换为
(插入括号的note2)
——我只喜欢非插入括号的版本供自己使用。(在这种情况下,您可能应该将函数重命名为
octPNote
octP
,以避免混淆。我曾短暂尝试将
octPNote
编写为调用
octPNote
并对结果进行后期处理以插入第二个注释的函数,但没有成功。)


您几乎肯定还需要扩展
复制连接?
谓词–ties和fermate只是我遇到的两种连接。(它默认不复制未知的发音,因此如果谓词不完整,您将在复制的注释上看到它缺少发音。)

为什么要否决?这是一个编程问题,领域是Lilypond/Scheme语言的组合。那次否决票太荒谬了。这个问题研究得很好,写得很好,充满了小例子,关于编程(而不是作曲/记谱音乐)的LilyPond问题确实属于StackOverflow。还有一个评论,关于你关于
\transpose c
的问题。嗯,在我的2.17.28版本中,它实际上什么也没做(正如我所预料的)。但是如果你使用
\transposeC'
,那么它会把所有的东西都调高一个八度(从c到c')。尝试
\relative c'{a4\transpose c a r2 | a4\transpose c'a r2}
,它应该首先呈现两个相同的音符a(由于
\transpose c c
不起任何作用,所以不进行转置),然后呈现另外两个音符
#(define (octavate-pitch pitch octaves)
   (ly:make-pitch
    (+ (ly:pitch-octave pitch) octaves)
    (ly:pitch-notename pitch)
    (ly:pitch-alteration pitch)))

#(define (articulation-is-of-type? art type)
   (string=? (ly:music-property art 'articulation-type) type))

#(define (copy-articulation? art)
   (cond ((music-is-of-type? art 'tie-event)
          #t)
         ((and (music-is-of-type? art 'articulation-event)
               (articulation-is-of-type? art "fermata"))
          #f)
         ; TODO add more cases
         (else
          #f)))

#(define (octNote note)
   (if (null? (ly:music-property note 'pitch))
       note
       (make-relative (note) note
                      (let ((note2 (ly:music-deep-copy note))
                            (pitch (ly:music-property note 'pitch)))
                        (set! (ly:music-property note2 'pitch)
                              (octavate-pitch pitch 1))
                        (set! (ly:music-property note2 'articulations)
                              (filter copy-articulation? (ly:music-property note2 'articulations)))
                        (make-event-chord (list note note2))))))

oct = #(define-music-function
           (parser location music)
           (ly:music?)
         (music-map octNote music))
\relative c' \oct {
  c d e f |
  g2 g |
}