Suggestions for playing music from real-time data generated in Julia

A little project I have in mind requires making data in real time (well, maybe 100 times a second at most) that is used to output music in real time. Details are scant because I haven’t really done anything yet, I’m trying to see what my options are and would love suggestions from the more experienced. So far I envision two vague approaches:

  1. Computing a MIDI stream that an existing software synthesizer can use to make music. I like the idea of this because of functionality (especially audio effects like reverb) I honestly have no idea how to implement from scratch. However, I haven’t been able to find any way to stream MIDI from a Julia script to a software synthesizer. JuliaMusic has some options for playing MIDI files, but I don’t know if that’s at all applicable for MIDI data I’m making on the fly.
    I found pyfluidsynth, a Python binding for FluidSynth, and it made me wonder if I need a Julia binding for a synthesizer to do this with Julia.

  2. Computing a waveform from periodic pitch and volume data, and streaming samples of it regularly. I pulled this off with PyAudio’s callback mode a few years ago. I’m not stoked about this option because, again, I would rather use existing software instead of reinventing the wheel. Still, if I must, I need a way to play WAV-like audio data. So far I’ve found PortAudio.jl (but Pkg.add isn’t working for it, not sure why). If the 1st approach is unfeasible, I’m open to suggestions for this one.

It looks like

https://github.com/JuliaMusic/MIDI.jl

has all the building blocks to emit a stream of MIDI chunks — I would suggest asking how to connect to a midi server in an issue.

1 Like

I’m unsure about how to ask this because I don’t know what a MIDI server is. I do see an open issue that seems related: #8 Allow midi events to be written directly to a midi device.

It’s a sink that can receive MIDI events and convert them to an audio signal. You may be able to use a network connection via RTP-MIDI too, but I am not familiar with the details (all my MIDI knowledge comes from having musician friends who ask me for computer setup help occasionally, which I provide along these lines).

1 Like

I don’t see this package in the general registry, so it likely hasn’t been registered. You can use Pkg to just add the GitHub repo directly though ] add https://github.com/JuliaAudio/PortAudio.jl