Can I make real time audio processing with Mathematica in the same way I can do with images using Dynamic[CurrentImage[]]
.
I know that is possible to use SystemDialogInput["RecordSound"]
function, but you can't make real time dynamics on it.
For example, I would like create one notebook that could make an alert when sound's beyond some level.
It's possible?
-
$\begingroup$ I don't think so... Let's pray ;) $\endgroup$– RojoCommented Oct 26, 2012 at 0:27
-
$\begingroup$ On Linux this is not possible. I add my prayers :) $\endgroup$– image_doctorCommented Oct 26, 2012 at 11:14
-
$\begingroup$ In my case I use a Mac. It's strange that it's so easy to do it with a cam, but not with a microphone. $\endgroup$– MurtaCommented Oct 26, 2012 at 11:29
-
$\begingroup$ Also see here for interacting with chuck. $\endgroup$– SzabolcsCommented Mar 19, 2015 at 21:57
-
1$\begingroup$ The best I have seen for real time work with MMA was this: a live stream of Conrad Wolfram doing face recognition to block it in real time. twitter.com/conradwolfram/status/573416811728904192 . Since he did it live on stage in front of an audience I would have though some audio processing would be possible providing the bandwidth was low enough. I should note that the frame rate and resolution were typical webcam quality - ie low. $\endgroup$– Gordon CoaleCommented Mar 20, 2015 at 9:41
3 Answers
Generally, Mathematica is just not good at real-time anything. It was not designed for this. Audio processing has very strict requirements on latency. The delay between input and output must be tiny, on the order of milliseconds, otherwise the delay will be noticeable.
Mathematica is simply not meant for this and doesn't have precise timing facilities. I'm fairly confident that the practical answer to this is no, it's not possible.
For non-real time audio processing or things like algorithmic music, I see many uses. But it's not a tool for real-time work.
-
1$\begingroup$ Thank you very much! I'm aware of the latency, but this is not really an issue. I would use it to create something like "soundscapes". So, it's not very important that the timing is very accurate. More important is a vast variety of possibilities to manipulate sound in order to create new and interesting approaches in performing. But based on you answer, I assume that it's still no the best software to do something like this. Thanks... $\endgroup$– PhilippCommented Mar 19, 2015 at 22:08
-
2$\begingroup$ @Philipp There are many interesting possibilities for uses in music, just not when it must be real-time ... it might be possible to hack something together for simple uses, but I wouldn't feel comfortable with it ... I definitely wouldn't trust it enough to use during a live performance with an audience. Well, at least not without very very extensively testing it first. $\endgroup$– SzabolcsCommented Mar 19, 2015 at 22:38
-
-
1
Advise if this is best relegated to comment status.
There are server-based real-time analytics of life science experiments using the Wolfram Language provided by these guys http://emeraldcloudlab.com.
Note the Mathematica 9 logo in their materials, indicates webMathematica rather than a private Wolfram Cloud.
I'll agree that real-time acoustic analysis may be difficult in Mma at present. There are very interesting ~10fps image processing examples I'm aware of but can't provide details of, other than this is a friendly upper limit to aim for.
Disclaimer: no connections to emeraldcloud.com
You can do this now. If you provide AudioStream a function from a list of times (in seconds) to a list of audio samples, it will call that function repeatedly and pipe the result directly to your sound card.
This plays an infinite 300 Hz sine tone:
stream = AudioStream[t |-> Sin[300 2π t]]
AudioPlay[stream];
The AudioStream reference page has several examples of real-time interactivity using Dynamic[], including buttons to start and stop the audio stream, and real-time spectrum analyzers.