I struggle with a basic feedback delay network

27 Views Asked by At

Im working on a basic fdn reverb in Matlab. I managed to do a feedforward which was really easy but I kinda struggle with a feedback. Below you can see my code and tell me if it is even right. The sound of the clap is kinda more metallic then delayi/reverbi if you know what I mean.

Im not looking for someone who does this work for me, just some sugguestings. But if you already have this programmed I wouldnt mind a link or something just to compare.

Its kinda hard to explain my reasoning for why I came with that specific for loop. Im not a big programmer it was kinda just intuitive to do it like that. Of course i needed to initialize the first first element of the array delayedAudio to the first element of my input y so I can even have something to feedback...

Good day!

% Read the audio file
[y, Fs] = audioread('808clp.wav');

% Define delay parameters
delayTime = 0.03; % in seconds
feedbackGain = 0.6; % adjust to control feedback level
wetGain = 1; % adjust to control wet signal level

% Convert delay time to samples
delaySamples = round(delayTime * Fs);

% Create an empty array to store delayed audio
delayedAudio = zeros(size(y));
delayedAudio(1,:) = y(1,:);
% Apply delay effect
for i = delaySamples+1:length(y)
    delayedAudio(i,:) = y(i,:) + feedbackGain * delayedAudio(i-delaySamples,:);
end

% Mix original and delayed audio
outputAudio = y + wetGain * delayedAudio;

% Write the output audio to a new file
audiowrite('output_audio_with_delay.wav', outputAudio, Fs);

% Play the output audio
sound(outputAudio, Fs);

0

There are 0 best solutions below