Issue with real time audio application using fast convolution

5 vues (au cours des 30 derniers jours)
Javi García
Javi García le 22 Mai 2017
Hi,
I'm trying to do a fast convolution of two signals, one audio signal and one Head Related Impulse Response (HRIR).
I've already changed the frame length of the dsp.AudioFileReader to 19000 (being my sample rate 44100 Hz), which is the one that works longer, meaning that my processing algorithm works but just for less than one second, being my audio signal 4 seconds long. If I change the frame length to another value, higher or lower, I get unexpected results. The result you should expect is to hear the audio signal like if the sound were coming from the right side of your head.
This is my code:
frameLength = 19000; %16384
path = 'anechoic_distcm_80_el_0_az_90.wav';
% Sound source reader object
fileReader1 = dsp.AudioFileReader('bongos_st.wav','SamplesPerFrame',frameLength);
% HRIR reader object
fileReader2 = dsp.AudioFileReader(path,'SamplesPerFrame',frameLength);
%fileInfo1 = audioinfo('bongos_st.wav')
% Total samples: 212419
% Duration: 4.8168 seg
%fileInfo2 = audioinfo(path)
% Total samples: 4800
% Duration: 0.1 seg
% Writer object, Fs = Sound source Fs
deviceWriter = audioDeviceWriter('SampleRate',fileReader1.SampleRate,...
'BitDepth','16-bit integer',...
'SupportVariableSizeInput',false,... % Default
'BufferSize',4096); % Default
% Audio stream loop
totalUnderrun = 0;
while ~isDone(fileReader1) % while reading sound
bongos_st = fileReader1();
az90 = fileReader2();
processedSignal = fconv(bongos_st,az90);
numUnderrun = deviceWriter(processedSignal); % Output
totalUnderrun = totalUnderrun + numUnderrun;
end
fprintf('Total samples underrun: %d. \n',totalUnderrun);
fprintf('Total seconds underrun: %d. \n',...
double(totalUnderrun)/double(deviceWriter.SampleRate));
% Release the objects
release(fileReader1);
release(fileReader2);
release(deviceWriter);
I also don't get any underrun sample in any iteration, and I checked my fconv.m function outside this code and it works perfectly. Here's a .rar with both .wav file I use in the code, in case you want to test it.
Hope you can help me in some way!
Thanks in advance,
Javi.

Réponses (0)

Catégories

En savoir plus sur Audio Processing Algorithm Design dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by