Experiments in making music with Elixir, for a forthcoming talk at the Indy Elixir meetup.
$ git clone email@example.com:stevegrossi/sweet_beats.git $ brew install sox $ mix run --no-halt
Each "track" is a looping worker process supervised by the main application:
worker(Melody, [Guitar, ~w(G . A . B . A . )]), worker(Rhythm, ["kick2.wav", ~w(X . X .)], id: 1),
There are currently two types of processes
This module is for generating musical tones. It takes two arguments, the first is an instrument module (e.g.
Guitar) which plays notes by implementing the
Instrument behaviour. The second argument is an array of notes. Specify sharps with
F#; flats with
Gb; and rests with
.. You can also optionally specify the octave with an integer, e.g.
This module is for playing audio file samples from the
/samples directory. Any file format that SoX supports should work. The worker process takes two arguments: the first is the name of the sample file, and the second is an array of beats.
. signifies a rest (play nothing), and any other character (I prefer
X) will play the sound file on that beat.
Improvements I’d Like to Make
- More and better
- A better API? At least one that allows composition.
- The ability to write and save compositions as text files rather than having to modify the
- Specifiable tempo per-track
- http://elixirsips.com/episodes/062_quickie_synth.html, a bit out of date, but this tutorial was the inspiration behind this project
- Samples from 99Sounds