Skip to main content

Featured

Python programming 8 Music with mouse-drawn lines by PyGame

I revised my previous program "Small interactive music maker" and now melody is made from mouse-drawn lines. Actually, change is not big. Instead of my Fourier series function, two key functions are included as - draw lines with mouse by pygame - from line to fx Drawing lines from below.   https://www.dreamincode.net/forums/topic/401541-buttons-and-sliders-in-pygame/ This must be some pretty fun for kids!   ---------------------------------------------------------------------------------------------- blog 8 Some versions of pygame may have some bug. Need " pip install pygame==2.0.0.dev6 " import pygame, math, sys, time import pygame.midi # use pygame.midi (not Mido) from random import random, choice pygame.init() # initialize Pygame pygame.midi.init() # initialize Pygame MIDI port = pygame.midi.Output(0) # port open port.set_instrument(53, channel = 0) # Voice port.set_instrument(0, channel = 1) # piano port.set_instrument(33, channel = 2) # bass X = 900 ...

A song "Etude No.4" created by Fourier series uploaded to Youtube.

 Composed music: Etude (a trial piece) No. 4 uploaded to Youtube.


 

    https://www.youtube.com/watch?v=DfIxoH5QTnQ

Before composing this, my method of creating melody is just random movement of pitch up/down with some probabilities. Etude No. 1, 2, 3 are the products. (Etude No. 2. is on my Youtube)

Then I saw the Piano Roll of the melody and realized it was of course some kind of wave. Since any waves can be write as a Fourier series, I tested some music scores with Fast Fourier Transformation, and I started to use Fourier series for music composition. So this is my first song.

 See my Python Programming 3 Create melody with Fourier Series for details.

A MIDI file was saved by python. Then imported into DAW. I use BitWig Studio 3 now. But I only selected some instruments to MIDI tracks and exported Audio file. Actually any DAW is OK.

Though BitWig is pretty easy to use, compared to Digital Performer I used before, BitWig is not so good for my purpose (composing music by python), because it has some bug of importing MIDI files including pitchbend. I might be going to use other DAW.

https://answers.bitwig.com/questions/3604/pitch-bend-on-imported-midi-clips


Comments