Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Elixir, MIDI and LiveView
Search
Thibaut Barrère
June 18, 2019
Programming
420
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Elixir, MIDI and LiveView
(Paris.Ex meetup)
Thibaut Barrère
June 18, 2019
Transcript
27 slides
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
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
160
Elixir, MIDI & LiveView (CodeElixir London 2019)
thbar
0
1.2k
Kiba ETL v2 - RubyKaigi 2018
thbar
4
2k
Elixir hot-reloading & MIDI events generation
thbar
1
580
De Rails à Phoenix - retour d'expérience sur une réécriture d'application SaaS
thbar
3
2.4k
Processing data with Ruby and Kiba ETL
thbar
0
260
Retour d'expérience sur le bootstrapping de WiseCash (produit SaaS)
thbar
0
930
Bootstrapping your SaaS product (with freelancing)
thbar
3
630
Prestations agiles avec Acunote et Freckle
thbar
3
640
Other Decks in Programming
See All in Programming
DroidKnights 2026 Android A2UI Jetpack Compose 기반의 안전한 AI UI 렌더링 - 박제창
itsmedreamwalker
1
260
AIが実装を担う時代の「技術設計」と「チームマネジメント」
kamina_zzz
2
450
そのデザイントークン、Flutterでも同じ見た目になりますか?
nakamizu
0
480
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
150
はじめてのKubernetesコントリビューション
nasa9084
0
320
エラーチャンネルのボールを拾い続けて鍛えるエンジニアの地力 / phpcon-niigata2026
meihei3
1
500
あなたはMCPの機能を、まだ知らない。
4geru
1
740
React Native経験者が Flutterを30⽇間触って驚いたこと
3saito
0
210
なぜ私たちは「現時点では」KMPの導入を見送ったのか
chigichan24
1
630
正解の無い問題を 「できるだけ上手く」解く ヒューリスティックで感性を磨こう。〜現実課題をプログラミングで解きあうコミュニティについて〜
allegrogiken
0
110
Growing PicoRuby's Ecosystem on ESP32
yuuu
2
150
imagewebp()の向こう側: WebPはなぜ JPEG・PNGより軽いのか
yuzneri
0
150
Featured
See All Featured
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.9k
Between Models and Reality
mayunak
4
610
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
The agentic SEO stack - context over prompts
schlessera
0
1k
Scaling GitHub
holman
464
140k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
360
Balancing Empowerment & Direction
lara
6
1.4k
Large-scale JavaScript Application Architecture
addyosmani
516
110k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
Paper Plane
katiecoart
PRO
6
55k