Synthesize musical notes (with piano sounds) in Python

后端 未结 2 410
被撕碎了的回忆
被撕碎了的回忆 2020-12-28 18:34

I would like to have a python implementation of a musical instrument library (for instance, a piano object) that I can use to convert a list of notes and a duration into sou

2条回答
  •  再見小時候
    2020-12-28 18:54

    A student of mine has just started using mingus to do just this so here's quick guide on how to get going on linux (ubuntu):

    Install fluidsynth and mingus if you don't have them already:

    $ sudo apt-get install fluidsynth

    $ sudo easy_install mingus

    Now you should be able to open python and type:

    >>> from mingus.midi import fluidsynth   
    >>> fluidsynth.init('/usr/share/sounds/sf2/FluidR3_GM.sf2',"alsa")
    

    This imports the necessary stuff from mingus and initialises fluidsynth to play through alsa (not jack which is the default). Then:

    >>> fluidsynth.play_Note(64,0,100)
    

    ...and you should hear a note played on the piano (arguments are: note number, channel number and velocity).

    For more information go here:

    https://code.google.com/p/mingus/wiki/tutorialFluidsynth

提交回复
热议问题