[英]How to make MIDI file from notes with Flute instrument in Python (music21 library)
我有一些筆記,我想要的是用長笛樂器創建 MIDI 文件。 但結果是輸出 MIDI 文件播放鋼琴而不是長笛。 我試過其他樂器,但總是一樣的,鋼琴。 到底是怎么回事?
(...)
new_note = note.Note(pattern)
new_note.offset = offset
new_note.storedInstrument = instrument.Piano()
output_notes.append(new_note)
(...)
midi_stream = stream.Stream(output_notes)
midi_stream.write('midi', fp='output.midi')
根據 文檔,唯一具有storedInstrument
屬性的類是note.Unpitched
。
和:
Unpitched
對象當前不執行任何操作,不應使用。
無論如何, music21/midi/translate.py
的testMidiProgramChangeA
/ B
函數展示了這是如何完成的:只需將樂器對象添加到應該使用它的Note
之前的Stream
:
output_notes.append(instrument.Flute())
new_note = ...
output_notes.append(new_note)
...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.