I am interested in writing accept-worthy code which is specific to this question.
In the interim, here's some resources.
This demonstrates generation of C code, and uses basic audio filtering as a toy example. create-standalone-executables
You might be able to use
OpenReadon a /dev object, andReadcustom frames (length, delimiter etc.; perhaps Dolby has some custom format). ref/Read.html, ref/OpenRead.html. There are of courseOpenWriteandWrite.This might help with reading data from a stream How to wait for new input from file InputStream
Keep in mind you can use
Streams[]to list all open (I and O) streams while debuggingIt might be worth looking at guide/StreamMethods, though this would probably not be at all useful to begin with.
Along the same lines, tutorial/StreamMethods shows how to do some basic stream processing, but not necessarily concurrent and linked IO.
I'd be curious to see if it's possible to get MMA to handle data quick enough and consistently enough. I also don't know the best way to handle buffer over/underflows
You can monitor memory usage with
MemoryInUse[], ref/MemoryInUse.html. It may be worth popping up a new front end each time you test stuff so you can monitor the memory of just the streams and processing, seeCreateNotebook.If you decide to interface MMA with an external program,
LinkCreatemay be useful. I I've linked MMA with Java, and I've done direct sample generation audio with Java, though both projects were separate. ref/LinkCreateI'll just note that I can't find anyone using
AudioCapture["Memory"]anywhere, but it may be useful.There is an example in ref/AudioStream to
Display the power spectrum of a signal while it is playing:
I modified it slightly and it worked to plot my microphone input just fine:
ClearAll[astream,spectrum] astream = AudioStream[First@$AudioInputDevices]; spectrum[audio_] := Periodogram[audio, 2000, PlotRange -> {{40, 20000}, {-80, 10}}, ScalingFunctions -> {"Log", "dB"}, Frame -> True, Axes -> False] Dynamic[spectrum[astream["CurrentAudio"]]] AudioPlay@astream;astream@"Status"="Recording"; (*later*) AudioStop@astream; You might try to get input from the proper device, try to output to the proper device, and then try to shunt data between them.
I'm interested to hear what you make of/from this.