-
Notifications
You must be signed in to change notification settings - Fork 196
/
2008-01-31-acous.diary
115 lines (93 loc) · 3.71 KB
/
2008-01-31-acous.diary
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
% 2008-01-31 E6820 acoustics lecture matlab demos
% First, simple traveling wave simulation
help travel1.m
% y = travel1(l,d,r,x,v) Visualize reflected travelling wave in waveguide
% l is the length of each waveguide in samples.
% d is the number of output samples to produce (default 10000).
% r is the refelection FIR at the far end (default [-1])
% x is optional initial input waveform ([1] by default)
% v if present and zero suppresses plotting.
% 2001-02-01 [email protected]. Based on pluck1a.m
y = travel1(20,200,[-1],hanning(5)'); % 5 pt pulse, fixed end, 20 pt len
% Maybe have some 'dispersion' in reflection
y = travel1(20,200,[-.25 -.5 -.25],[1]);
% Waves travelling in both directions...
y = travel1(20,200,[-1],[1 0 0 0 0 0 0 0 0 0 1]);
% Animations of sinusoidal standing waves
help sintwavemov
% m = sintwavemov(k,w,z,l,n) Build a movie of sin travelling wave interference
% For a pair of opposite-moving sinusoidal travelling waves of
% temporal frequency w and spatial frequency k where the ratio
% of forward to backward waves at *l* is z (complex), make n
% plots of l points of the wave, both forward, backward, sum and
% difference. Record each plot in a movie, returned in m.
% 2001-02-02 [email protected] e6820 acous
% 20 steps for one cycle physically, 40 time steps per cycle, open end
subplot(211)
m = sintwavemov(2*pi/20,2*pi/40,-1,33,40);
movie(m,10)
% You can see waves traveling each way
% - the sum (blue) is the pressure (zero at end)
% - the diff (red) is the volume velocity u(x,t)
% Vowel simulation by simple pole pairs
% e.g. ah = 500 1500 2500
wc = pi/4000; % so f*wc is normalized angular frq of pole
r = 0.97;
r2 = r*r;
aah = conv(conv([1 -2*r*cos(500*wc) r2],[1 -2*r*cos(1500*wc) r2]), [1 -2*r*cos(2500*wc) r2]);
freqz(1,aah,512,8000)
pt = (rem(1:8000,80)==0);
vah = filter(1,aah,pt);
soundsc(vah)
% 'ee' has formants at 250 Hz, 2300 Hz (say)
aee = conv([1 -2*r*cos(250*wc) r2],[1 -2*r*cos(2300*wc) r2]);
freqz(1,aee,512,8000)
vee = filter(1,aee,pt);
soundsc(vee)
soundsc(vah)
% oo around 330, 900
aoo = conv([1 -2*r*cos(wc*330) r2],[1 -2*r*cos(wc*900) r2]);
freqz(1,aoo,512,8000)
voo = filter(1,aoo,pt);
soundsc(voo)
soundsc([vah,voo/8,vee])
% Sounds OK... oo is louder because formants both low-frequency
% Plucked string simulation
help pluck1a
% y = pluck1a(l,d,r,x,v) Plucked string synthesis via pair of waveguide 'rails'
% l is the length of each waveguide in samples.
% d is the number of output samples to produce (default 10000).
% r is the refelection FIR at the far end (default [-.25 -.5 -.25] if empty)
% x is optional initial shape to plucked string (triangular by default)
% if x is a scalar value, it is taken as the pluck point as a
% proportion of the string length (default 0.5).
% v if present and nonzero plots waves & string at each sample time.
% 2001-02-01 [email protected]. Based on Julius Smith's 1992 CMJ paper.
x = pluck1a(40,10000);
soundsc(x)
subplot(211)
specgram(x,512,8000)
% Odd harmonics only - plucked in the middle
% Frequency-dependent decay reflects gain of reflection...
freqz([.25 .5 .25],1,512,8000)
% Pure loss still decays, but no coloration
x0 = pluck1a(40,10000,[0 -.97 0]);
soundsc(x0)
subplot(211)
specgram(x0,512,8000)
plot(x0(1:300))
subplot(212)
plot(x(1:300))
% output is actually 'loss' at bridge - high-pass for disperse filt
% Pluck point affects initial excitation, hence harmonics
x2 = pluck1a(40,10000, [], 0.2);
subplot(211)
specgram(x,512,8000)
subplot(212)
specgram(x2,512,8000)
soundsc(x2)
soundsc(x)
% Visualization of string behavior
x1 = pluck1a(40,10000, [], 0.5,1);
% Notice how resultant wave (red) is fixed at ends, but 'unfolds' each way