Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
    
So wait, would the options IntervalUpdate-> 0 not do ? –  user753 Mar 17 '12 at 4:16
    
@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). –  Szabolcs Mar 18 '12 at 11:20

2 Answers 2

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.

http://www.johanlooijenga.com/tools/5-apps/12-virtual-ports.html

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

share|improve this answer
    
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? –  J Mark Inman Feb 20 '12 at 3:27
    
@JMarkInman On Windows at least Mathematica uses Java to play (synthesize) MIDI. It does not use the system MIDI output. –  Szabolcs Feb 20 '12 at 9:55
    
Yes, I suspect this might be true with a Mac as well, then. I'm not sure what to do... –  J Mark Inman Feb 20 '12 at 18:02
1  
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. –  cormullion Feb 20 '12 at 19:50

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."

share|improve this answer
    
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. –  Szabolcs Feb 20 '12 at 21:42
    
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... –  J Mark Inman Feb 20 '12 at 22:34
    
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! –  J Mark Inman Feb 20 '12 at 22:48
1  
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. –  Szabolcs Feb 20 '12 at 23:29
    
I was not aware of "processing.org" I'll look into it. Thank You! –  J Mark Inman Feb 20 '12 at 23:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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