简体   繁体   English

如何使用 music21 显示空的五线谱?

[英]How can I display an empty staff using music21?

I am trying to produce a quick reworking of some educational materials on music showing how it may be able to create the associated media assets (images, audio files) from "code" in a Jupyter notebook using the Python music21 package.我正在尝试快速修改一些关于音乐的教育材料,展示它如何能够使用 Python music21 package 从 Jupyter 笔记本中的“代码”创建相关的媒体资产(图像、音频文件)。

It seems the simplest steps are the hardest.似乎最简单的步骤是最难的。 For example, how do I create an empty staff:例如,我如何创建一个空员工:

在此处输入图像描述

or a staff populated by notes but without a clef at the start?还是由音符组成但一开始没有谱号的五线谱?

在此处输入图像描述

If I do something like:如果我做类似的事情:

from music21 import *

s = stream.Stream()
s.append(note.Note('G4', type='whole'))
s.append(note.Note('A4', type='whole'))
s.append(note.Note('B4', type='whole'))
s.append(note.Note('C5', type='whole'))
s.show()

I get the following?我得到以下?

在此处输入图像描述

Try creating a stream.Measure object, so that barlines before the notes don't appear.尝试创建一个 stream.Measure object,这样便不会出现音符前的小节线。

Music21 puts barlines and clefs, etc., in by default. Music21 默认放入小节线和谱号等。 You can manually put in a time signature of 4/1 and a treble clef and set them with ".style.hideObjectOnPrint" (or just ".hideObjectOnPrint" on older m21 versions).您可以手动输入 4/1 的拍号和高音谱号,并使用“.style.hideObjectOnPrint”(或在旧的 m21 版本上仅使用“.hideObjectOnPrint”)设置它们。 You will probably need to also set.rightBarline = bar.Barline('none') or something like that for the end.最后,您可能还需要 set.rightBarline = bar.Barline('none') 或类似的东西。

It is possible, but I haven't ever fully tried all the parts of it.这是可能的,但我还没有完全尝试过它的所有部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM