How do I write a functional code for direct convolution?

6 views (last 30 days)
I am really struggling with the digital signal theory class I have to take in my audio grad program. One of my assignments is to write a program in MATLAB that has inputs for two signals (an impulse response and a dry signal), convolution method, segment length, and the filename of the convolved output signal. Convolution methods are can be either direct or fast, and the segment length input is used for block method convolution. We're supposed to get the code to run with just fast and direct before we input block method. I'm trying to just focus on one part of a time.
I'm currently building my direct convolution code, and will add in the fast convolution and block method later (hence why there are fewer inputs).
This is what I have right now. I just keep getting "Busy." I know this is code isn't optimized for speed, but I just want to know if it should work theoretically? It still hasn't written the wavfile...
function directconvolver(IRfilename,SIGfilename,filename)
IRfilename=wavread(IRfilename); %reads impulse responce file into MATLAB
SIGfilename=wavread(SIGfilename); %reads dry signal into MATLAB
OUTlength=length(IRfilename)+length(SIGfilename)-1; %finds length of convolved signal
directConv=zeros(OUTlength,1); %creates vector of zeros for OUTlength
idx=1:length(SIGfilename);%creates index for input signal
for m=1:OUTlength; %for a period of time
directConv(idx)=directConv(idx)+IRfilename(m)*SIGfilename;
idx=idx+1;
end
wavwrite(directConv,44100,filename);
plot(filename)
end

Answers (0)

Categories

Find more on Audio Processing Algorithm Design in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!