Dual channel capture with high-end sound card?

1 view (last 30 days)
Dan Basel
Dan Basel on 15 Feb 2011
Edited: Walter Roberson on 3 Apr 2014
I have a project where I am trying to implement a dual channel capture to work at low frequencies (say input frequency of ~20 KHz). This is to build a software radio system where I can digitize the downconverted I/Q channels from a higher frequency radio.
I thought using a high quality, independently sampled, 2 channel sound card may do the trick -- say the EMU 1212M sound card as seen here:
They claim up to 192KHz sampling rate, which would mean that the 20 KHz frequency sampled at Nyquist (40 KHz) would be fine - correct?
Anyway - the question is -- is this possible to do with Matlab? What kind of drivers/software/etc. should I make sure that is available?
Any other thoughts about getting a low-cost digitizer?
Thanks and best regards,

Answers (4)

Daniel Shub
Daniel Shub on 16 Feb 2011
You cannot use the standard MATLAB sound commands (e.g., audiorecorder) since these force you to record the entire signal before you can access the signal. Specifying short signal sequences, doe snot work since there is a delay between stopping one audiorecorder and starting the next. You can treat the soundcard like an DAQ device with the real time DAQ toolbox (Windows only). This lets you stream data "directly" from the soundcard. It won't take advatage of any low level drivers (e.g., ASIO) the soundcard comes with. Latency could be an issue (both startup latency (knowing when time 0 is) and latency between the signal occurring and being available in MATLAB. This approach may work. A high end soundcard won't give you much benefit in terms of latency with this approach (although bit and sample rate differences will still be preserved), so you should be able to try it out. If the latency is too great, then you need to go with something based on portaudio (e.g., the ASIO pawavplay). These still require a minimum buffer size of ~256 samples at 44.1kHz and have a latency of ~6ms (I have seen claims of smaller latencies, but I do not by it). Startup latency is still a problem.

Walter Roberson
Walter Roberson on 15 Feb 2011
Well, the news isn't as good as you might hope. The EMU documentation is short on description of the interface, but if you read the right sample dialog example you will see that the driver being expected is an ASIO driver. I admit I had not heard of ASIO before, but it is apparently well known for high end cards.
Checking around the Mathworks site, I find that there is no direct Mathworks support for ASIO interfaces. However, if you were using the Simulink To Audio or From Audio blockset, then the library that is used for that can be recompiled to use ASIO; instructions here
There is also an open-source tool, pa-waveplay, that someone has build for 32 bit Windows as a file exchange contribution here that can deal with ASIO devices.

Walter Roberson
Walter Roberson on 15 Feb 2011
I would be concerned about potential latency issues. I'm not saying there is a problem for sure, but it is not uncommon for the only way to sustain those kinds of rates is to buffer the data up well. I wouldn't imagine that the Simulink Block Set is tremendously more efficient than the Instrument Control Toolbox, but the maximum they can handle with the ICT on MS Windows is 5000 interrupts per second (and few people have reported being able to sustain 2000 interrupts per second in practice.)
Your problem requires 40 KHz, and some number of bits per sample (the 1202m is normally 16 bits per sample) or the equivalent of 64,000 bits per second. How quickly do you need to be able to react to any one sample of input, or are the samples packetized and you construct complete packets in response?

Darel on 13 Nov 2013
Edited: Walter Roberson on 3 Apr 2014
ASIO support is now built into DSP System Toolbox. To select ASIO, go to MATLAB preferences and from there to the DSP tab. Select ASIO as your Audio Hardware API. You can use dsp.AudioRecorder for audio input and dsp.AudioPlayer for audio output. The same support is built into To Audio Device and From Audio Device blocks as well, no need to rebuild PortAudio. There is no problem with going to 192kHz, and you can set the frame size to trade off latency with throughput. All of these capabilities are meant to be used with streaming signals "in the loop". Whether or not MATLAB can keep up will just depend on how much processing you need to do, how powerful your machine is and whether you are able to tolerate latency in order to increase frame size sufficiently support your throughput needs. (Larger frame size reduces overhead and hence increases your throughput, but increases your latency too.)
Daniel Shub
Daniel Shub on 17 Nov 2013
Edited: Walter Roberson on 3 Apr 2014
When ASIO support was first added in R2012a, Tucker Mcclure added a useful answer to a question that I had previously answered.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by