I have a live stream of notes and note velocities using SoundNote and SoundVolume. My problem is that I have no idea how to export the MIDI data in real time to an external synthesizer. Would I just use something like this, for example?

Dynamic[Export["file.mid", Sound[SoundNote[0]]] ]

I haven't tried this yet because even if I did have a dynamic MIDI file, how would I get the third party software, like GarageBand or Logic to recognize the MIDI input stream?

Another way to phrase this question would be: how do I make Mathematica into a live-playing software synth and not just produce a static MIDI composition?

  • $\begingroup$ So wait, would the options IntervalUpdate-> 0 not do ? $\endgroup$
    – user753
    Mar 17, 2012 at 4:16
  • $\begingroup$ @RichardBrown Mathematica was just not designed for real-time processing. Real time audio processing requires a reliable < 10 ms latency (i.e. delay introduced between input and output). $\endgroup$
    – Szabolcs
    Mar 18, 2012 at 11:20

2 Answers 2


Here is a letter I got regarding this question from premier service technical support:

Thank you for taking the time to send this in. Unfortunately, I do not believe this functionality currently exists in Mathematica and I have forwarded the suggestion that it be included in a future release of Mathematica to the developers in charge of this area.

I can imagine that this might be possible just JLink or MathLink. Essentially it would require writing a Java or C program that served as an interface with Mathematica."

  • $\begingroup$ Well, Mathematica is not excellent at timing anyway, so it might not have been the best tool for this. For music you need very very precise timing. I can sense a delay as little as 20 ms between hitting a key and hearing a sound, even though I have no musical training. I don't believe Mathematica could have handled such tight timing requirements. $\endgroup$
    – Szabolcs
    Feb 20, 2012 at 21:42
  • $\begingroup$ Well, I'm trying to process live video into sound and mathematica easily handles the video part, I know there is jitter/max-msp, but I don't own those programs and they are quite expensive (even compared to Mathematica since I'm on the student version). It might be possible to do the processing with puredata, but mathematica is really quite an easy language and I'm not the most experienced programmer. But you are right, latency might be an issue... $\endgroup$ Feb 20, 2012 at 22:34
  • $\begingroup$ OK, update: So after revisiting the cycling74 website to review max/msp costs, I noticed that they have a free program called "Soundflower" And it turns out that this is the audio equivalent to what I was trying to do with midi, while this doesn't solve all my programming problems, it solves enough where I should (hopefully) now be able to build and test a prototype! $\endgroup$ Feb 20, 2012 at 22:48
  • 1
    $\begingroup$ I'm sorry to disappoint, but I really do think that for real time work Mathematica will not be usable, primarily because of the latency. But for non real time processing it could be great. Also note that Mathematica's representation of MIDI is not completely general. It's good for very simple experiments, but for more complex things it's inadequate. That's why it cannot import MIDI, only export. (I played a little bit with MIDI files in Mathematica and I almost ended up with my own representation) Do check out puredata as well as processing.org for a video -> midi application. $\endgroup$
    – Szabolcs
    Feb 20, 2012 at 23:29
  • $\begingroup$ I was not aware of "processing.org" I'll look into it. Thank You! $\endgroup$ Feb 20, 2012 at 23:42

The basic idea is to install a virtual MIDI device software on your Mac and change the system default MIDI output to that virtual device. Mathematica will play into it, and the device can at the same time function as a MIDI input for Logic/GarageBand.


It would be easier if you could change the device Mathematica outputs to, but I don't see an option for that.

  • $\begingroup$ Thanks, I've been able to do everything EXCEPT configure the system default midi so that mathematica defaults out to the virtual device. It seems in all the documentation that I've been reading that there is no universal default midi device and that the midi input-output is program specific. On Logic it was very easy for me to make the change, but there does not seem to be anyway for mathematica to change. I'm wondering if Mathematica is synthesizing the tones 100% within itself and that there is no "midi" until it is converted and exported, in which case, what to do? $\endgroup$ Feb 20, 2012 at 3:27
  • $\begingroup$ @JMarkInman On Windows at least Mathematica uses Java to play (synthesize) MIDI. It does not use the system MIDI output. $\endgroup$
    – Szabolcs
    Feb 20, 2012 at 9:55
  • $\begingroup$ Yes, I suspect this might be true with a Mac as well, then. I'm not sure what to do... $\endgroup$ Feb 20, 2012 at 18:02
  • 1
    $\begingroup$ On my Mac I can see MIDI events - somewhat sporadically - using the ControllerInformation[], which shows the various MIDI interfaces currently connected. However, even if this can be made to work, it's probably input only... hard to tell from the documentation. $\endgroup$
    – cormullion
    Feb 20, 2012 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.