thejohncotton
I’ve been having a lot of discussions around using MIDI on a nerves device and wanted to start a thread to discuss some of it in the open so that it is easier to help others in the same discussion.
I have midi 1.0 working in nerves with Circuits.UART and some diy hardware. I need to publish a public repo with the UART Framing (will be sharing soon).
Some of the more interesting discussions and my current interest are around working with USB midi.
GitHub - haubie/midiex: Cross platform Midi library in Elixir. Powered by midir, a Rust midi library and Rustler. · GitHub looks like it could be really close to what we would want in terms of portability but I’m having issues getting it to run on my nerves system (raspberry pi4 but slightly modified)
I’ve got some debugging to do on that test but wanted to consider other options too. Particularly anything lightweight.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
octetta
I’m just starting to look at “official” MIDI on Linux because like you, I’ve just always rolled my own UART implementation and avoided USB altogether.
That being said, without having looked at midiex (which looks pretty nice on via my desktop+Elixir), I wonder if there are missing pieces in your Nerves system that it’s looking for…
It appears ALSA and MIDI depend on kernel modules that aren’t part of a basic Nerves system, notably
snd_usbmidi_lib.Can you get to the iex shell on your Nerves system and type:
cmd "lsmod"…and see if that module is loaded?
Also, try running “dmesg” to see if your USB MIDI module is detected when it’s plugged in.
Oh, and another question… what USB/MIDI interface are you using?
octetta
As I fumble with ALSA and MIDI, this doc is useful, at least on my Raspbian system where
aconnectandaseqdumpwork.Since I’ve yet to build a Nerves system from scratch, I do wonder where the options to include this ALSA stuff lives. The basic audio stuff is loaded on the Nerves fleet distro on the boxes I’ve set up for Lars…
entone
It hasn’t seen any development in a long time, but the Firmata protocol is based on MIDI so maybe can get some insight here GitHub - entone/firmata: Firmata protocol in Elixir · GitHub
It does support USB MIDI. EDIT… yeah this is just using UART, so probably not what you’re looking for.
entone
The Firmata protocol doc is here, protocol/protocol.md at master · firmata/protocol · GitHub
fhunleth
In addition to the other options, there’s the Sonic Pi MIDI library at GitHub - sonic-pi-net/sp_midi: MIDI functionality for Sonic Pi for use as Erlang module · GitHub. It looks self-contained and lightweight, but would need a little modification to build with
mixand be easier to use with an Elixir/Nerves project.octetta
Just pulling this code now… it looks like it wraps
RtMidi, which in turn (under Linux at least) links with ALSA and/or JACK libraries.For simple and non-portable stuff, I think this is possible with much less code using ALSA directly, but I bet it’ll still depend on a Linux build with ALSA MIDI stuff included.
ChatGPT gave me a very simple snip of code to enumerate the visible MIDI ports which I built and ran on my Raspbian RPi3 device to show my Arturia Beatstep pads:
Code courtesy ChatGPT (build via
gcc listmidi.c -o listmidi -lasound… you might need tosudo apt install libasound2-devto build) :On my unmodified “Lars fleet RPi3”, this binary isn’t able to find the symbol
snd_seq_openso I suspect buildroot/??? left pieces of ALSA out.One of these days I should actually build a system from scratch instead of hoping someone else will do it for me,
octetta
I’m questioning my sanity regarding USB/MIDI devices on Linux.
However I have evidence (old Python scripts) that indicate at one time my Arturia BeatStep USB/MIDI device showed up as both a serial device (under a
/dev/ttyUSB#scheme) and under/dev/midi#.The world seems to be changing under my feet and I have no knowledge of
udevand friends, so could it be possible that the/dev/ttyUSB#device could still be available with some fiddling of configuration?I’ll wander off and do my own research, but thought I’d mention it here, since dealing with these devices as UART drags a lot less baggage than ALSA and / or libusb (which I’ve already spent way more time on than I thought I would, LOL).
octetta
There’s evidence that
udevcan map USB MIDI devices to serial ports… just need to see if it’s more work than ALSA or libusb. Stay tuned…thejohncotton
Interestingly enough my problem with getting the rustler deps to load was related to this thread:
@octetta It did end up being an issue related to buildroot but also an operator error. (I’ll push up some code this afternoon after work to show the specifics)
@fhunleth when I included the extra alsa packages and blew my system away and rebuilt it I was able to get the midiex dependency to work on the firmware. I’ll run some more tests and confirm it actually works later but this is pretty cool.
Would you want some of these extra deps included in the official system? I’m going to publish my fork for audio/midi but could also just contribute back if you think it would be useful.
octetta
@thejohncotton I really like that more of ALSA stuff is possible… and I’ll probably pursue something in the vein of an Erlang port driver for MIDI stuff. I have a half-baked POC port driver for audio sampling and playback that I hope to share soon (targeting the Nerves meetup in November).