Generating Audio Signal and Performing Different Operations On Recorded Signal
Generating Audio Signal and Performing Different Operations On Recorded Signal
ABSTRACT: This report will go to original recorded audio signal. The original
introduce how to record the signal on voice signal is shown in fig.1.
MATLAB and performing different
operation with the use of audio signal. This
report disscuss the working to play the
audio signal, resampling the recorded
siganl, quantization of audio signal, fourier
transform, convoution with right shifted
audio signal and auto-correlation of
convolved signal.
INTRODUCTION: There are lot of
methods to generating the voice signal in
MATLAB. One can use the external
recorded file and load it in MATLAB but
we use the simple, yet versatile method to Fig.1
generate the voice signal in MATLAB. A
OPERATIONS:
simple command for recording voice signal
that we used a=audiorecorder (Fs, nbits, The first operation is to sampling the audio
channels). An audio recorder object using signal. We use the resample rate of
the sampling frequency Fs in Hz, the 10000Hz which means 10000 samples in
sampling size of nbits and the number of one second this resampling will change the
channels. Fs can be any sampling rate sound of original voice. To confirmation
supported by the audio hardware. Common simply use sound command to hearing the
sampling frequency are 8000, 11025, voice of resampling. Fig.2 shows the
22050 and 44000. The value of nbits must resampled audio signal at 10000 sample per
be 8 or 16. For mono or stereo, channels second.
must be 1 or 2.
We use the sampling frequency Fs 8000Hz,
8 number of bits per sample and channel 1
and speaking text is “SHAHAB JAVED
007”.
Now the thing is: how much the seconds of
recorded signal is? To solve this issue we
use the built-in command record (a, 5). It
record the audio signal for 5 seconds. It can
be for greater than 5 seconds audio but it Fig. 2
depend on the need how much the length of For quantization we use assume the 4 bits
signal you want. We will get the audio data quantizer. The levels of quantization are
from b=getaudiadata(a), The all data will be 24 and the quantization step will be 𝛿
stored in variable b. We will perform the all (delta):
operations on variable b which is our
Page 1
𝑥 max −𝑥𝑚𝑖𝑛 transform. We will be calculate Fourier
𝛿=
2𝑛 − 1 transform by simply use of fft in MATLAB
and plot the absolute of the fft. Fig.5 shows
Step size is 0.1250. We round the
Fourier transform of audio signal with
maximum and minimum values at 1 and -1.
vertical symmetry in signal.
Fig.3 Fig.5
For getting x max and x min. Fig.3 shows Next operation is convolution: performing
the quantization of recorded audio signal. by right shifted audio signal convolve with
The exact quantization signal will be in original audio signal. To perform this
stairs case, so can see this stair quantization operation we have to shift right the signal
signal by zooming the axes or we can use by 10000 samples. The plot of shifted
the axis command to see the quantized signal in shown in Fig.6.
signal. Fig.4 shows the stairs quantization
of recorded audio signal. The range of
frequency is chosen from 0Hz to 500Hz and
amplitude taken from -0.8 to 0.8. The graph
will be shown in Fig.4.
Fig. 6
Page | 2
quantization levels. The signal to
quantization signal ratio is 7.9183 dB and
error between original signal and quantized
signal is:
Fig. 7
Page | 3
X_max=round(max(b)); xlabel('frequency');ylabel('amplid
X_min=round(min(b)); ute');
del=(X_max-X_min)/2.^bits;
A_max=X_max-del/2; %auto-correlation of convolution
A_min=X_min+del/2; signal
for i=A_min:del:A_max f=xcorr(e);
for j=1:Ns figure(9);plot(f);
if(((i-del/2)<b(j)) && title('auto-correlation of
(b(j)<(i+del/2))) convolution signal');
Xq(j)=i; xlabel('frequency');ylabel('amplid
index(j)=round((b(j)- ute');
A_min)/del);
end
end
end
figure(3);plot(n,Xq);
title('quantization (4 bits
quantizer)');
xlabel('frequency');ylabel('amplid
ute');
figure(4);plot(n,Xq);
axis([0 0.05*10^4 -0.8 0.8]);
title('stair quantization');
xlabel('frequency');ylabel('amplid
ute');
Page | 4