Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Elixir, MIDI and LiveView
Search
Thibaut Barrère
June 18, 2019
Programming
390
0
Share
Elixir, MIDI and LiveView
(Paris.Ex meetup)
Thibaut Barrère
June 18, 2019
More Decks by Thibaut Barrère
See All by Thibaut Barrère
Kiba ETL: feedback on OSS / open-core sustainability for a Ruby gem
thbar
0
130
Elixir, MIDI & LiveView (CodeElixir London 2019)
thbar
0
1.1k
Kiba ETL v2 - RubyKaigi 2018
thbar
4
2k
Elixir hot-reloading & MIDI events generation
thbar
1
530
De Rails à Phoenix - retour d'expérience sur une réécriture d'application SaaS
thbar
3
2.3k
Processing data with Ruby and Kiba ETL
thbar
0
240
Retour d'expérience sur le bootstrapping de WiseCash (produit SaaS)
thbar
0
880
Bootstrapping your SaaS product (with freelancing)
thbar
3
600
Prestations agiles avec Acunote et Freckle
thbar
3
580
Other Decks in Programming
See All in Programming
VueエンジニアがReactを触って感じた_設計の違い
koukimiura
0
180
PCOVから学ぶコードカバレッジ #phpcon_odawara
o0h
PRO
0
270
Vibe NLP for Applied NLP
inesmontani
PRO
0
430
Don't Prompt Harder, Structure Better
kitasuke
0
760
Cache-moi si tu peux : patterns et pièges du cache en production - Devoxx France 2026 - Conférence
slecache
0
240
レガシーPHP転生 〜父がドメインエキスパートだったのでDDD+Claude Codeでチート開発します〜
panda_program
0
940
mruby on C#: From VM Implementation to Game Scripting (RubyKaigi 2026)
hadashia
2
400
AIベース静的検査器の偽陽性率を抑える工夫3選
orgachem
PRO
3
270
煩雑なSkills管理をSoC(関心の分離)により解決する――関心を分離し、プロンプトを部品として育てるためのOSSを作った話 / Solving Complex Skills Management Through SoC (Separation of Concerns)
nrslib
4
940
事業会社でのセキュリティ長期インターンについて
masachikaura
0
250
「速くなった気がする」をデータで疑う
senleaf24
0
180
Oxlintとeslint-plugin-react-hooks 明日から始められそう?
t6adev
0
270
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.8k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
230
Product Roadmaps are Hard
iamctodd
PRO
55
12k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
210
Fireside Chat
paigeccino
42
3.9k
A designer walks into a library…
pauljervisheath
211
24k
Designing for humans not robots
tammielis
254
26k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Ethics towards AI in product and experience design
skipperchong
2
260
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
61
43k
Utilizing Notion as your number one productivity tool
mfonobong
4
290
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
100
Transcript
Elixir, MIDI & LiveView
@thibaut_barrere Consultant Ruby / Elixir / Ansible Kiba ETL /
Kiba Pro Remote 100% (Charente Maritime)
Elixir => Code-Centric Digital Audio Workstation? infiniwip (tm)
Previous episode https://github.com/thbar/demo-elixir-reloading-music Code.eval_file("music.exs")
MIDI
Note On {0x90 + channel, note, velocity} Note Off {0x80
+ channel, note, release_velocity}
Keyboard / Piano / Synthetizers photo by Clavia
MIDI controllers photo by Novation
Virtual Instruments (on computer)
Virtual Instruments (on iOS) photo by Korg
Lightning = Inter-Device Audio & MIDI (IDAM) photo by Apple
Elixir Code / DRY Refactoring Music Augmented Human (theory, scales)
Soft realtime
brew install portmidi
None
# Start a process for MIDI event queue {:ok, pid}
= PortMidi.open(:output, "Kontakt Virtual Input") note = 48 # C-4 velocity = 127 # Send "NOTE ON" PortMidi.write(pid, {0x90, note, velocity}) # Send "NOTE OFF" PortMidi.write(pid, {0x80, note})
None
Computer: Note 60 Human: WTF????
Translation def note_number_to_latin_name(midi_note, middle_c \\ @default_middle_c) do remap_note(midi_note, @latin_names, middle_c)
end defp remap_note(midi_note, names, middle_c) do offset = get_base_offset(middle_c) octave = div(midi_note + offset, 12) octave_note = rem(midi_note + offset, 12) octave_note = names |> Enum.at(octave_note) "#{octave_note}#{octave}" end defp get_base_offset("C4"), do: -12
DocTests ❤ ## Examples iex> MusicRef.note_number_to_latin_name(60) "Do4" iex> MusicRef.note_number_to_latin_name(78) "Fa#5"
Phoenix LiveView <div> <p> Time is <%= @time %> </p>
</div> HTML? ✔
Phoenix LiveView <svg> <%= for note <- notes do %>
<rect x="..." y="0" width="10" height="20" fill="<%= note.color %>"> <% end %> </svg> SVG? ✔
Phoenix LiveView <svg> <g> # white notes </g> <g> #
black notes </g> </svg>
None
None
def note_on({channel, note, velocity}, device, portmidi \\ PortMidi) do Phoenix.PubSub.broadcast(Widgets.PubSub,
"notes", {:note_on, note}) :ok = portmidi.write(device, {0x90 + channel, note, velocity}) end
None
Code & Demo