How do I play sound in a notebook (preferably Pluto)?

I want to build a synthesizer in Julia, and I want to play the output inside the notebook, like this example for Jupyter+Python: IPython Cookbook - 11.7. Creating a sound synthesizer in the Notebook
I have searched how to play sound in Julia, and all of the libraries are either unmaintained (AudioIO.jl) or segfaults (PortAudio.jl)


There’s also JuliaMusic - eg things like - as well as JuliaAudio. (The difference between music and audio is a question for another day… :smiley:)


The problem with Mplay is that its only a MIDI player, it doesn’t generate and play sounds by itself. And JuliaAudio doesn’t have any package that works with Julia 1.4.1 (JACKAudio.jl is deprecated, and PortAudio.jl does not officially support Julia 1.0 and above, and if I try to use it anyway, it segfaults).

And all of them plays the audio directly, it isn’t like Python notebooks where there is a play button in the notebook and the audio is playing through the browser

1 Like

Yes, it’s not all there at present, unfortunately.

But I noticed this on Twitter, so something is possible…

1 Like

The thing is that in that linked twitter thread, Julia controls Pure Data that actually generates and plays the sound, so again its not Julia that plays the sound, unlike Matlab play() and sound() functions.

To work around this I write the array into a file, then I run sox that reads from the file and plays the sound. Its a little bit round about, but it works perfectly both in REPL and Pluto

1 Like

If any of you find a Julia package that has basic types for waveforms and it does not play audio when you use it in Pluto, let me know! We can make this work pretty easily – I just need to add the audio MIME type.


This would be very nice, especially if it could be served online.