Experiments in making music with Elixir, for a forthcoming talk at the Indy Elixir meetup.
$ git clone git@github.com:stevegrossi/sweet_beats.git
$ brew install sox
$ mix run --no-halt
Learn more about the SoX library (docs)
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 #, e.g. F#; flats with b, e.g. Gb; and rests with .. You can also optionally specify the octave with an integer, e.g. G#2
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.
- More and better
Instruments! - 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
Supervisor.Spec. - 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