Music by Python Tips

This page is for summary of memos to implement audio progarm by python.

For making sound from MIDI input to audio output on Raspberry Pi, I run following command on Raspberry Pi :

$ qjackctl &
$ qsynth &

In detail, Raspberry Pi Tips - Fluidsynth


Generate audio files

Generate sine, sawtooth and square wave by numpy and scipy libraries.


python-rtmidi

Search "Synth" output port and play midi file


Mido

  • Environment: Rpi 3B, python 3.5.3 / 3.7.0
  • pip install mido python-rtmidi

MIDI note-on and note-off by Mido

Load MIDI file and check the length of music

Ref:


Pygame

  • Environment: Rpi 3B, python 3.5.3 / 3.7.0
  • pip install pygame

List output ports

GUI keyboard - display piano and send MIDI message

Midi keyboard

Pretty_midi

  • Environment: Rpi 3B, python 3.5.3 (I could not install pretty-midi to virtual env of python3.7.0 )
git clone https://github.com/craffel/pretty-midi
cd pretty-midi
python3 setup.py install

Make MIDI file of noteon and noteoff of "G4"

Load MIDI file

Ref: