I have been reading papers related to adding echos into digital audio signals recently. I guess I understood the logic behind, yet I guess I am still having lack of DSP knowledge to figure out everything.
In order to add a single echo delay $\Delta$ into audio signal $S$ using convolution operator, echo kernel $k(n)$ is defined as:
$$ k(n)= \delta [n] + \alpha \cdot \delta [n-\Delta]$$
where $\delta [n]$ is Kronecker Delta Function, and $ 0 < \alpha \ll 1.$
Echoed sound signal $S'$ calculated using convolution operator "$*$" as:
$$S'=S \ * k(n)$$
I have no problems until this part. My question is based on this publication, [Ko, Nishimura, Suzuki - 2005]. It is based on echo data hiding for audio watermarking (steganography), but a very good source to understand sound echos. Authors say that multiple echos provide better quality for HAS than single echos (see Fig. 1.)
A pseudorandom sequence is generated to spread multiple echos in time. I generate it in MATLAB with the following code:
rand('seed', key); % set seed of random sequence a = rand(length, 1); prseq = (a > 0.5)*2-1; % convert into -1 and +1
In next step, time-spread echo kernel is defined using PN Sequence as: (see Fig. 2.)
$$ k(n)= \delta [n] + \alpha \cdot P[n-\Delta], 0 < \alpha \ll 1 $$
Schemetic explanation is made in Fig. 3. below:
I tried this tecnique in MATLAB and I actually have two questions:
- Audio signal is being corrupted when the number of echos increases no matter how small $\alpha$ value is chosen. In the same article length of PN Sequence is chosen as $1023$, and delay = 1 ms which is about 44 samples in 44.1 kHz audio signal. So how is it possible to provide "a real room" echos as it is said in the article? Do I miss anything?
I am adding my summarized MATLAB codes:
delta = 44; alpha = 0.02; % Single echo kernel for n=1:delta+1 k_single(n) = kdelta(n-1) + alpha*kdelta(n-delta-1); end % Time-spread echo kernel without using kronecker delta: kernel = [1 zeros(1,delta-1) alpha*prseq']; echoed = conv(audio_data, kernel); function [ out ] = kdelta( x ) out = double((x==0)); end
single_echo = signal + alpha*[zeros(1,delta) signal(1:length(signal)-delta)];
- I was adding echos in an audio signal by shifting and adding as I mentioned above "alternatively". I figured out that it would take so much time to use it for multiple echos, so I thought I had to use convolution. But
conv(x,y)function in matlab changing data size up to
length(x)+length(y)-1according to definition of convolution. Is it a good idea to just to crop it like
echoed(1:length(audio_data))to keep the length fixed? What is best option to accomplish multiple echoing as fast as possible and using less memory?
Excuse me for such a long question. I wanted to explain my problem in details, so it made my question longer.
Thanks in advance.