Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to reduce Audio Latency by MATLAB DSP System Toolbox ?

Status
Not open for further replies.

charanbandi

Junior Member level 1
Joined
Jun 20, 2012
Messages
18
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,407
I have been working on my ANC project. For this I have two microphone inputs and one loud speaker output, but initially I am using single microphone and dspStreamingPassthrough to pass microphone input to loud speaker. Here is my code


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{
% Initialization
numIterations = 500;
% Construct sources (for all inputs)
src1 = dsp.AudioRecorder('DeviceName','Mikrofon (USB-Audiogerät)','NumChannels',1);
% Construct sinks (for all outputs)
sink1_1 = dsp.SpectrumAnalyzer('SampleRate',44100, ...
  'PlotAsTwoSidedSpectrum',false, ...
  'ShowLegend',true);
sink1_2 = dsp.TimeScope('BufferLength',44100, ...
  'SampleRate',44100, ...
  'TimeSpan',1, ...
  'ShowLegend',true, ...
  'ShowGrid',true, ...
  'YLimits',[-0.5 0.5]);
sink1_3 = dsp.AudioPlayer('BufferSizeSource','Property','BufferSize',1024,...
'QueueDuration',0,'OutputNumUnderrunSamples',true);
sink1_3.DeviceName = 'Lautsprecher (USB-Audiogerät)';
% Stream processing loop
clear dspStreamingPassthrough;
for i = 1:numIterations
  % Sources
  in1 = step(src1);
    % User Algorithm
    out1 = dspStreamingPassthrough(in1);
    % Sinks
    step(sink1_3,out1);
    step(sink1_1,out1);
    step(sink1_2,out1);
    nUnderrun=step(sink1_3,out1);
end
% Clean up
release(src1);
release(sink1_1);
release(sink1_2);
}



I am using Windows DirectSound Audio driver ( I cannot use ASIO driver as I cannot access individual audio devices names. ! ) Now I have the audio latency of 1.2 seconds i.e if I say ''hello'' in microphone now, after 1.2 seconds speaker is saying ''hello''(this is absolutely with out any audio input data processing just 'dspStreamingPassthrough'). How to reduce this incredible delay ?

For my project of 1 meter length pipe(air duct), I should be able to process the data in 1.7 msec or less !! I have tried with lowest 'BufferSize' and lowest 'QueueDuration' possible !!

What other parameters can influence to speed up this process? Is it possible with MATLAB or not ?

PS: -sorry for whole code. -I am using a cheap quality Sound card (7 euros)
 
Last edited by a moderator:

There may be settings for 'hardware passthrough' or 'software passthrough'. This may be in your system preferences for audio devices. (Or else I may have seen this option in Audacity, a popular free digital audio program.)

I suppose software passthrough goes through an extra routine, converting audio input to digital, then back to audio output.

The longest delay I'm used to hearing through a computer is a couple tenths of a second.

I guess the above paragraphs do not apply to your equipment.

There is your sampling rate of 44.1 kHz. What if you choose fewer samples per second? That should result in quicker processing, and a shorter wait time.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top