機械知能ワタナベ(2)
Machine Intelligence Watanabe-2
データの前処理
from music21 import *
# Midiファイルを読み込み
inputMidi = converter.parse('./data/NorwegianWood.mid')
# 2番目の楽器を使用
parseMidi = inputMidi.parts[1].recurse()
# 音階(Midi番号)と拍数を配列に格納
notes = []
for element in parseMidi:
if isinstance(element, note.Note):
notes.append([int(element.pitch.ps),float(round(element.quarterLength,6))])
# 辞書型に格納
notesDict={}
for i in range(len(notes)):
notesDict[i]=notes[i]
print(notesDict)
エンコード(Encode)

最終更新