有没有办法使用像列表这样的midi文件,其中每个元素都是一个音符-并单独播放它们?

时间:2019-04-06 22:31:22

标签: python midi

我正在尝试使用Python逐个注释地播放钢琴MIDI文件。有没有一种方法可以将MIDI文件表示为音符列表?我可以在计算机的声音输出中播放每个声音吗?

理想情况下,它看起来像这样:

song = '/pathto/file.mid'

play(song[0])   #would play the first note of file.mid

play(song[n])   #would play the note n of file.mid

1 个答案:

答案 0 :(得分:1)

似乎您正在寻找名为winsound的模块

这会产生蜂鸣声:

import winsound
winsound.Beep(1500, 1000)

winsound.Beep中的第一个参数是频率,然后第二个是频率 声音应该以毫秒为单位。

在这里查看钢琴上音符的频率: http://www.sengpielaudio.com/calculator-notenames.htm

希望这会有所帮助!

相关问题