function outsig = space_echo(drysignal, impulse,predelay,wet,dry)

%%fast convolution 

fs = 44100

output_L = length(drysignal) + length(impulse)-1;  % This creates the length of the output signal

output_L2 = pow2(nextpow2(output_L)); % Move to the frequency domain - length to power 2 - then use this output for the fft

SIGNAL = fft(drysignal, output_L2); % Fast Fourier transform of the dry signal

IMPULSE_RESPONSE = fft(impulse, output_L2); % Fast Fourier transform of the impulse response

DELAY_SIGNAL = SIGNAL.*IMPULSE_RESPONSE; %Multiply both signals in the frequency domain (convolution)

delay_signal = real(ifft(DELAY_SIGNAL, output_L2)); % Inverse Fast Fourier transform of the product signal

delay_signal = delay_signal(1:output_L,1:2); % Take just the first N elements

outsig1 = delay_signal/max(abs(delay_signal)); % Normalise the output of the reverse reverb signal 
outsig1 = [outsig1, outsig1.*-1];

%% predelay 

predelay_in_samples = round((predelay./ 1000) .* fs); % calculates the 
% required samples given predelay in milliseconds

extra_samples = zeros(predelay_in_samples, size(drysignal,2)); % add the extra
% samples to the reverbed signal

signal_delayed = [extra_samples; outsig1]; % create a delayed version of the 
% signal

extr_samples_insig = zeros(length(signal_delayed) - length(drysignal), 2);
% calculate the extra samples to be added to the signal with no delay, so 
% to match its size to the delayed signal

signal_no_delay = [drysignal; extr_samples_insig]; % create a signal with no delay

%% mix
outsig = (signal_delayed.*wet) + (signal_no_delay.*dry); % add the two signals together
outsig = (outsig./max(max(outsig))).*.5; %normalises the output

end