Generate music sound effects using mathematics.
well, this project is not written the best way of it. I mean It works, but using this is a bit difficult.
there are some functions in this project. working with each other to craft you a music.
the file audio4.py shows you an example how to use it.
it simply gets a midi file as input and generates a music based on notes the file provides.
but I will make a better wiki for this later! I promise!
functions.pyfor generating basic audio functions.notes.pyfor generating notes.midi_conversions.pyfor converting note number to frequency.instruments.pyfor describing each instrument.music.pyfor generating music.write.pyfor writing generated audio into a wave fileread_midi.pyfor reading notes data from.midfilesaudio*.pyfor test.
any note we hear is consisted of a sine function with a main frequency summed up with it's harmonics- each with it's own amplitude.
adding up sine functions, we create a new function for each instrument which is it's basic sound. see harmonics function in functions.py.
but this is not enough by itself to make a nice sound.
amplitude of a sound changes dampingly over time. this is also a unique property of an instrument.
see instrument* and push_instrument* functions in instruments.py.
different notes have different frequencies. harmonics change respecting to main frequency. see notes.py to learn more.
combining notes by synthesizing them, we create a music. each note has a duration and a note number. look up music.py to see how it works.
so now we can generate sounds but we need notes! the funcion read_midi in file read_midi.py gets a midi file as input and extracts notes out of it to use.
now we are ready to generate a music from zero!
look up audio*.py to see how a list of notes by time and some more details can make a nice music!
finally we should save generated audio wave into a .wav (wave) file. the function write_to_file in write.py does it. and when done, it's done!
-
different tracks in midi file, each have their own instrument. add a support for this
-
get timing info from midi file
-
write better instruments.
-
make documentation for code. maybe rewrite this README file too.
-
make a wiki for developers so it will be easier to develope.