Professional Documents
Culture Documents
Bao Cao Lab2 DSP Thang 08DT3
Bao Cao Lab2 DSP Thang 08DT3
Functions in
MATLAB and the
Groove Station
Lớp : 08DT3
Nhóm: 14B
1. Exercise 1: Fader
a. Hàm fade:
Matlab Code:
time = 0:0.01:1;
y = cos(time * pi * 25);
subplot(2,1,1);
plot(time, fade(y,0.2));
subplot(2,1,2);
plot(time, fade(y,0.8));
0.5
-0.5
-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0.5
-0.5
-1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Nhận xét: hàm fade có tác dụng làm tín hiệu sóng sin suy giảm theo thời gian.
2. Exercise 2: Repeater
a. Hàm repeat:
Mat lab code:
time=0:0.01:1;
y=cos(pi*25*time);
plot(repeat (fade(y,1),5))
0.8
0.6
0.4
0.2
-0.2
-0.4
-0.6
-0.8
-1
0 100 200 300 400 500 600 700
Nhận xét: Hàm repeat có tác dụng lặp lại tín hiệu N lần
c. Hàm tạo “khoảng lă ̣ng” repeater :
Mat lab code:
0.8
0.6
0.4
0.2
-0.2
-0.4
-0.6
-0.8
-1
0 200 400 600 800 1000 1200 1400
Nhận xét: Khi sử dụng hàm repeater thì có thêm khoảng lặng giữa các lần lặp lại
3. Exercise 3: Delay
a. Hàm delay:
Code matlab:
end
x1 = wavread('hatclosed')';
subplot(2,1,1);
plot(x1);
subplot(2,1,2);
plot(delay(x1,2,8000));
0.5
-0.5
-1
0 500 1000 1500 2000 2500 3000 3500 4000
0.5
-0.5
-1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
4
x 10
Nhận xét: Hàm delay có tác dụng làm trễ tín hiệu số một khoảng thời gian.
4. Exercise 4: Mixer
a. Hàm mixer.
Code matlab:
end
x1 = wavread('bleeep')';
x2 = wavread('bassdrum')';
subplot(3,1,1);
plot(x1);
subplot(3,1,2);
plot(x2);
x3=mixer(x1,x2);
subplot(3,1,3);
plot(x3);
1
0.5
-0.5
0 500 1000 1500 2000 2500 3000 3500 4000
1
-1
0 500 1000 1500 2000 2500 3000 3500 4000
1
-1
0 500 1000 1500 2000 2500 3000 3500 4000
Nhận xét: Hàm mixer là hàm để cộng 2 tín hiệu âm thanh với nhau
5. Exercise 5:
Code matlab:
x1 = wavread('snare')';
x2 = wavread('bassdrum')';
x3 = repeater(x1, 2);
x4= delay(mixer(x1,x2),0.3,8000);
x5=mixer(x4,x3);
x6=repeater(x5, 15)
x7=mixer(x6,xn);
Fs=8000;
sound(x7,8000);
plot(x7)
wavwrite(x7, 'pro.wav');
1
0.5
-0.5
-1
-1.5
0 0.5 1 1.5 2 2.5
5
x 10
Nhận xét: Dùng hàm repeat để lặp lại các đoạn âm thanh. Dùng hàm mixer để ghép các âm
thanh lại. Để tránh các âm thanh chồng lên nhau hỗn độn ta dùng hàm delay