SBAU443 November 2023
The driver for the AC-MB can be controlled with Matlab, allowing for some automated testing. The following code demonstrates capturing audio from the AC-MB with Matlab. This example requires the Audio Toolbox™.
if ismac % macOS driver
deviceReader = audioDeviceReader( 'Device', 'TI USB Audio 2.0',…
'SampleRate', 48000, …
'NumChannels', 8 ,…
'BitDepth', '32-bit float',…
'OutputDataType','double');
elseif ispc % windows driver
devoiceReader = audioDeviceReader( 'Driver','ASIO', 'Device', 'Texas Instruments USB Audio ...',…
'SampleRate', 48000, …
'NumChannels', 8 ,…
'BitDepth', '32-bit float',…
'OutputDataType','double’);
end
setup(deviceReader);% Setup the device reader
% Play out a file through PC and capture in the EVM
info = audioinfo( infile_name );% Read audiophile infile_name
fileReader = dsp.AudioFileReader( infile_name );% Create fileReader object
fileInfo = audioinfo(infile_name);% Copy info from infile_name
fileWriter = dsp.AudioFileWriter( outfile_name, 'SampleRate', deviceReader.SampleRate, 'DataType', 'int32’);% Create fileWriter object
audioOut = audioDeviceWriter('SampleRate', fileInfo.SampleRate);% Setup audio playback
setup( audioOut, zeros(deviceReader.SamplesPerFrame, fileInfo.NumChannels) );
while ~isDone(fileReader)% For each block played out, record the block from EVM
audioToPlay = fileReader();% Read a chunk of audio from infile_name
audioOut(audioToPlay);% Play a chance of audio
[audioRead, numOverrun] = deviceReader();% Grab a chunk of audio from EVM
fileWriter(audioRead);% Write the chunk of audio from EVM to a file
end
release(audioOut);% Close all objects
release(fileReader);
release(fileWriter);
release(deviceReader);