- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经编写了一个python脚本来处理带有music21的midi文件并再次编写一个midi文件。如果独奏钢琴在某种意义上是“简单的”,即没有在一个声音中同时演奏多个音高/音符,则此方法有效。
https://github.com/githubuser1983/algorithmic_python_music/blob/main/12RootOf2.py
上面的相关部分是:
def parseMidi(fp,part=0):
import os
from music21 import converter
print(fp)
score = converter.parse(fp,quantizePost=True)
print(list(score.elements[0].notesAndRests))
#print([e.partAbbreviation for e in score.elements][0])
from music21 import chord
durs = []
ll0 = []
vols = []
isPauses = []
for p in score.elements[part].notesAndRests:
#print(p)
if type(p)==chord.Chord:
pitches = median([e.pitch.midi-21 for e in p]) # todo: think about chords
vol = median([e.volume.velocity for e in p])
dur = float(p.duration.quarterLength)
#print(pitches)
ll0.append(pitches)
isPause = False
elif (p.name=="rest"):
pitches = 89
vol = 1
dur = float(p.duration.quarterLength)
ll0.append(pitches)
isPause = True
else:
pitches = p.pitch.midi-21
vol = p.volume.velocity
dur = float(p.duration.quarterLength)
ll0.append(pitches)
isPause = False
durs.append(dur/(12*4.0))
vols.append(vol*1.0/127.0)
isPauses.append(isPause)
#print(p.name,p.octave,p.duration.quarterLength)
#print(dir(score))
#print(ll0)
#print(durs)
return ll0,durs,vols,isPauses
另一种选择是读取musicxml而不是midi。我需要算法工作,是每个声音的音符列表=(音高,持续时间,音量,isPause)。
最佳答案
目前,在music21,stream.Voice
对象更像是一个显示概念而不是一个逻辑概念。声音和和弦都是同时发生的,这就是 MIDI 文件的全部内容。 (实际上,本周将发布的第 7 版中的 pending changes 除了制作小节外,还可以从 MIDI 文件中生成更少的声音和更多的和弦。如果混响或录制的演奏有小的重叠,您可能会获得雕刻师永远不会在乐谱中打印的“声音”。)
在你的情况下,我可能只需要一个 .flat
的Part
对象摆脱声音(最终在 v.7 中测量),然后运行 chordify()
如果你想确保没有重叠。否则,如果您根本不需要和弦,您仍然可以获取 chordify() 的输出并找到每个和弦的根音。几种可能性都取决于您的来源是什么样的。
关于parsing - 如何在 Music21 中为独奏钢琴读取 midi/musicxml 文件,其中一个声音中可以同时有多个音符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68881287/
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
我一直在查看 musicXML 规范,据我所知,对和弦符号的支持不会节省和弦的持续时间。这是 G6/D ( from here) 的示例: G
我经常使用 MusicXML 文件,并尝试编译一个小节列表,其中许多片段都有关键更改。我需要一些使用 python 的帮助来首先确定 在哪里标 checkout 现在XML文件中,然后从中提取数字上
我是编程和 Python 的新手,但我目前的很多研究都涉及从 musicxml 文件中提取数据。我有一段音乐,想提取一首曲子中不构成调号一部分的临时记号的数量。我不知道该怎么做,有人可以帮忙吗?这是我
我正在编写一个程序,可以读取完整的 MusicXML 文件,对其进行编辑,然后写出一个新文件。我正在使用 xml.Decode 将数据读入 MusicXML 文件的结构中,但是当我运行它时似乎什么也没
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 3 年前。
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 2年前关闭。 Improve thi
我正在使用 java swing 开发一个桌面应用程序,它应该能够显示在框架中的 MusicXML 文件中定义的视觉内容(音符、谱号、小节)。我发现的所有 .xml 解析器只允许我创建树。我也无法使用
我一直在尝试加载一个 MusicXML 文件,对其进行编辑(删除几个部分),并创建一个 PDF 表格文档 + midi/mp3,所有这些都使用 Python。 我首先查看了 music21,它可以正确
我正在使用 Python 批量编辑许多当前看起来像这样的 musicXML 文件: ... -5 -9
我已经编写了一个python脚本来处理带有music21的midi文件并再次编写一个midi文件。如果独奏钢琴在某种意义上是“简单的”,即没有在一个声音中同时演奏多个音高/音符,则此方法有效。 htt
LibMusicXML:有没有人有在 IOS 项目中使用这个库的例子?想用它来查看 musicXML 格式的乐谱。 有关添加 C++ 库以及如何在 IOS 中使用此库显示 musicXML 的建议将不
我正在尝试 music21 库,为涉及流派分类和分类的机器学习项目做准备。我和以下一些可用的教程 here 。我正在使用MuseScore作为我的MusicXML程序,我正在尝试从 iPython 运
我是一名优秀的程序员,十分优秀!