pythonプログラミング で楽譜作成!| music21 ~基本操作③

pythonプログラミング で楽譜作成!| music21 ~基本操作③

今回は、前回の続きで基本操作③を紹介します。(前回↓)

音符を装飾する

articulationクラスを用いる事で、noteに装飾を加えることができます。

スタッカート、アクセントなど

#------------------------------------------------------------
#articulationクラス
#------------------------------------------------------------
#スタッカートの定義
stac = articulations.Articulation()
stac.placement = 'above'
stac = articulations.Staccato()

#アクセントの定義
acc = articulations.Articulation()
acc.placement='below'
acc = articulations.Accent()

print('スタッカート↓')
n1 = note.Note('C5')
n1.articulations.append(stac)
n1.show()

print('スタッカート&アクセント↓')
n2 = note.Note('C5')
n2.articulations.append(stac)
n2.articulations.append(acc)
n2.show()

・スタッカート:articulations.Staccato()

・テヌート:articulations.Tenuto()

・アクセント(横向きアクセント):articulations.Accent()

・強アクセント(縦向きアクセント、山型アクセント):articulations.StrongAccent()

↓詳しくは以下に記載されています。

フェルマータ

#フェルマータはexpressionsを用いる
p1 = stream.Stream()
n3 = note.Note('C5')
n3.expressions.append(expressions.Fermata())
p1.append(n3)
p1.show()

↓詳しくは以下に記載されています。

N連符(3連符、5連符など)

quarterLengthを調整する(3連符ならば「1/3」、5連符ならば「1/5」)

3連符

n1 = note.Note('C4')
n2 = note.Note('E4')
n3 = note.Note('G4')

n1.quarterLength = 1/3
n2.quarterLength = 1/3
n3.quarterLength = 1/3

st1 = stream.Stream()
st1.append([n1,n2,n3])
    
st1.show()

5連符

n1 = note.Note('C4')
n2 = note.Note('E4')
n3 = note.Note('G4')
n4 = note.Note('C5')
n5 = note.Note('E5')

n1.quarterLength = 1/5
n2.quarterLength = 1/5
n3.quarterLength = 1/5
n4.quarterLength = 1/5
n5.quarterLength = 1/5

st1 = stream.Stream()

st1.append([n1,n2,n3,n4,n5])
    
st1.show()

次のステップへ

簡易的に楽譜を表記するための「TinyNotation」についてご紹介します。

本日のAmazonおすすめ_Top10

2024-04-25 07:07:24時点