0% found this document useful (0 votes)
58 views4 pages

Generating Audio Signal and Performing Different Operations On Recorded Signal

The document discusses recording an audio signal in MATLAB and performing various operations on the recorded signal, including resampling, quantization, Fourier transform, convolution, and auto-correlation. The original audio signal is recorded at 8 kHz with 8-bit samples and 1 channel. It is then resampled to 10 kHz and quantized to 4 bits. Fourier transform shows the signal's vertical symmetry. Convolution is performed by shifting the signal right by 10,000 samples and convolving with the original. Auto-correlation of the convolved signal demonstrates its similarity. MATLAB code implementing these operations is also included.

Uploaded by

Shahab Javed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views4 pages

Generating Audio Signal and Performing Different Operations On Recorded Signal

The document discusses recording an audio signal in MATLAB and performing various operations on the recorded signal, including resampling, quantization, Fourier transform, convolution, and auto-correlation. The original audio signal is recorded at 8 kHz with 8-bit samples and 1 channel. It is then resampled to 10 kHz and quantized to 4 bits. Fourier transform shows the signal's vertical symmetry. Convolution is performed by shifting the signal right by 10,000 samples and convolving with the original. Auto-correlation of the convolved signal demonstrates its similarity. MATLAB code implementing these operations is also included.

Uploaded by

Shahab Javed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

JUNE 13, 2019

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

We convolved the shifted signal d with


original signal b and we obtain this signal
with double the length of b (length of b +
Fig. 4 length of d).he convolution sum of the
signals is shown by Fig.7.
Now we have to move on Fourier transform
of audio signal which shows the symmetry
in audio signal. We can use either Fourier
transform or discrete time Fourier

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

Last operation is auto correlation of convolved


signal. From this operation we will
demonstrate the similarity of the signal. We
use xcorr (x, y) built-in command of MATLAB. It
shows the cross correlation of x with y but Fourier transform shows the vertical
same command can be used for auto symmetry of audio signal. The value of the
correlation such that xcorr (e), here e is voice will be taken into account when the
convolution of signal b and signal d. voice frequency domain correspond to the
highest amplitude.
MATLAB CODE:
%record the signal
a=audiorecorder(8000,8,1)
record(a,5);

%plot of voice signal


b=getaudiodata(a);
t=0:length(b)-1;
figure(1);plot(t,b);
title('voice signal plot');
%play the voice signal
sound(b);

%sampling of voice signal


Fig. 8
Fs=8000;
[P,Q]=rat(10000/Fs);
CONCLUSION: This report presented the d=resample(b,P,Q);
different operations on recorded signal. By figure(2);
default, an audiorecorder uses a sample rate stem((0:length(d)-1)/(P/Q*Fs),d);
title('sampling');xlabel('time');y
of 8000Hz, a depth of 8 bits per sample and
label('amplidute');
a single audio channel. These settings
minimize the required amount of data %quantization of voice signal
storage. For higher quality recordings we Fs=8000;
n=0:1:Fs*5-1;
can increase the sample rate or bit depth. bits=4;
y=b;
For quantization we use the 4 bits, for use Ns=length(b);
of higher bits quantizer gives the more Xq=zeros(1,length(b));
precise signal due to increase to index=zeros(1,length(b));

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');

%signal to quantization noise


ratio (SQNR)
error=b-Xq';
SQNR=10*log10(sum(b.^2)/(sum(error
.^2)));
figure(5);plot(error);
axis([0 40000 -1 1]);
title('error signal');
xlabel('frequency');ylabel('amplid
ute');

%fft of recorded signal


figure(6);plot(abs(fft(b)));
title('fft of voice signal');
xlabel('frequency');ylabel('amplid
ute');

%sifting voice signal by 10k;


shift=10000;
d = zeros(size(b));
d(shift+1:end) = b(1:end-shift);
figure(7);plot(d);
title('shifted signal of voice by
10000 sample');
xlabel('frequency');ylabel('amplid
ute');

%convolution of shifted and voice


signal
e=conv(d,b);
figure(8);plot(e);
axis([0 8*10^4 -100 100]);
title('convolution of shifted
signal with voice signal');

Page | 4

You might also like