Detect when I save a code file
def init(args) do
{:ok, watcher_pid} = FileSystem.start_link(args)
FileSystem.subscribe(watcher_pid)
def handle_info({:file_event, watcher_pid, {path, events}}, state) do do
IO.puts "The file at #{path} has changed!"
{:noreply, state}
end
Slide 5
Slide 5 text
Re-evaluate it at runtime (hot reloading)
def handle_info({:file_event, watcher_pid, {path, events}}, state) do do
Code.eval_file(path)
{:noreply, state}
end
Slide 6
Slide 6 text
AHA MOMENT
GenServer reloading keeps the state across reloads.
=> We can keep the "current music position/tick"
between reloads.
defmodule Artist do
use GenServer
def handle_info(:tick, state) do
Process.send_after(self(), :tick, @tick_period)
Slide 7
Slide 7 text
MIDI
Slide 8
Slide 8 text
Note On
{0x90 + channel, note, velocity}
Note Off
{0x80 + channel, note, release_velocity}
Slide 9
Slide 9 text
Keyboard / Piano / Synthetizers
photo by Clavia
Slide 10
Slide 10 text
MIDI controllers
photo by Novation
Slide 11
Slide 11 text
Virtual Instruments (on computer)
Slide 12
Slide 12 text
Virtual Instruments (on iOS)
photo by Korg
Slide 13
Slide 13 text
Lightning = Inter-Device Audio & MIDI (IDAM)
photo by Apple
Slide 14
Slide 14 text
Elixir
Code / DRY
Refactoring Music
Augmented Human (theory, scales)
Soft realtime