Latency issue when using DSP System Toolbox for Real-Time audio processing
5 次查看(过去 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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File 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!