Latency issue when using DSP System Toolbox for Real-Time audio processing

4 次查看(过去 30 天)
Trying to make a real-time audio processor which performs pitch detection and pitch shifting, but setting up the basic audio in - audio out is causing trouble as the latency is massive. The basic code is as follows;
Fs = 44100;
nbits = 16;
buffSize = 516;
if (audiodevinfo(1,0,Fs,nbits,2) == 1)
fprintf('Audio input device found\n');
else
fprintf('No audio input device found\n')
return
end
Speaker = dsp.AudioPlayer('SampleRate',Fs);
WavWriter = dsp.AudioFileWriter('myspeech.wav','FileFormat', 'WAV');
Microphone = dsp.AudioRecorder('SampleRate',Fs, ...
'NumChannels',2, ...
'BufferSize',buffSize, ...
'QueueDuration',0.0, ...
'SamplesPerFrame', buffSize);
tic;
while(toc<5)
audioIn = step(Microphone);
step(Speaker, audioIn);
step(WavWriter,audioIn);
end
fprintf('Recording complete\n')
end
release(Microphone);
release(Speaker);
release(WavWriter);
It records and plays fine, but the latency is over 1 second long. I'm guessing, the cause is most likely due to the warning I get; "Warning: The BufferSize property is not relevant in this configuration of the System object." I'm also guessing that the QueueDuration property is "not relevant" too, and its resetting to its default which is a delay of 1.0 (I think). I'm working with Matlab 2011 (which doesn't support ASIO btw, so I'm using the directsound ins/outs).
Any help with this issue or suggestions for a different approach would be hugely appreciated. Thanks a mil. Mark

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by