|
8 | 8 | import matplotlib.pyplot as plt |
9 | 9 | import numpy as np |
10 | 10 | import sfs |
11 | | - from scipy.signal import unit_impulse |
| 11 | + from scipy.signal import unit_impulse, firwin |
12 | 12 |
|
13 | 13 | # Plane wave |
14 | 14 | npw = sfs.util.direction_vector(np.radians(-45)) |
|
26 | 26 |
|
27 | 27 | # Impulsive excitation |
28 | 28 | fs = 44100 |
29 | | - signal = unit_impulse(512), fs |
| 29 | + # either with: signal = unit_impulse(512), fs |
| 30 | + # or with: bandlimited Dirac, i.e. a linear-phase lowpass FIR |
| 31 | + Nlp = 2**10 + 1 |
| 32 | + tlp = (Nlp/2) / fs |
| 33 | + signal = firwin(numtaps=Nlp, |
| 34 | + cutoff=16000, |
| 35 | + window=('kaiser', 4), |
| 36 | + pass_zero='lowpass', |
| 37 | + scale=True, fs=fs), fs |
30 | 38 |
|
31 | 39 | # Circular loudspeaker array |
32 | 40 | N = 32 # number of loudspeakers |
33 | 41 | R = 1.5 # radius |
34 | 42 | array = sfs.array.circular(N, R) |
35 | 43 |
|
36 | | - grid = sfs.util.xyz_grid([-2, 2], [-2, 2], 0, spacing=0.02) |
| 44 | + grid = sfs.util.xyz_grid([-2, 2], [-2, 2], 0, spacing=0.01) |
37 | 45 |
|
38 | 46 | def plot(d, selection, secondary_source, t=0): |
39 | 47 | p = sfs.td.synthesize(d, selection, array, secondary_source, grid=grid, |
40 | 48 | observation_time=t) |
41 | | - sfs.plot2d.level(p, grid) |
| 49 | + sfs.plot2d.level(p, grid, cmap='Blues') |
42 | 50 | sfs.plot2d.loudspeakers(array.x, array.n, |
43 | 51 | selection * array.a, size=0.15) |
44 | 52 |
|
@@ -108,7 +116,8 @@ def plane_25d(x0, n0, n=[0, 1, 0], xref=[0, 0, 0], c=None): |
108 | 116 | delays, weights, selection, secondary_source = \ |
109 | 117 | sfs.td.wfs.plane_25d(array.x, array.n, npw) |
110 | 118 | d = sfs.td.wfs.driving_signals(delays, weights, signal) |
111 | | - plot(d, selection, secondary_source) |
| 119 | + # note that WFS prefilter is not included |
| 120 | + plot(d, selection, secondary_source, t=tlp) |
112 | 121 |
|
113 | 122 | """ |
114 | 123 | if c is None: |
@@ -187,8 +196,10 @@ def point_25d(x0, n0, xs, xref=[0, 0, 0], c=None): |
187 | 196 |
|
188 | 197 | delays, weights, selection, secondary_source = \ |
189 | 198 | sfs.td.wfs.point_25d(array.x, array.n, xs) |
| 199 | + weights *= 4*np.pi*rs # normalize |
190 | 200 | d = sfs.td.wfs.driving_signals(delays, weights, signal) |
191 | | - plot(d, selection, secondary_source, t=ts) |
| 201 | + # note that WFS prefilter is not included |
| 202 | + plot(d, selection, secondary_source, t=ts+tlp) |
192 | 203 |
|
193 | 204 | """ |
194 | 205 | if c is None: |
@@ -281,8 +292,10 @@ def point_25d_legacy(x0, n0, xs, xref=[0, 0, 0], c=None): |
281 | 292 |
|
282 | 293 | delays, weights, selection, secondary_source = \ |
283 | 294 | sfs.td.wfs.point_25d(array.x, array.n, xs) |
| 295 | + weights *= 4*np.pi*rs # normalize |
284 | 296 | d = sfs.td.wfs.driving_signals(delays, weights, signal) |
285 | | - plot(d, selection, secondary_source, t=ts) |
| 297 | + # note that WFS prefilter is not included |
| 298 | + plot(d, selection, secondary_source, t=ts+tlp) |
286 | 299 |
|
287 | 300 | """ |
288 | 301 | if c is None: |
@@ -363,8 +376,10 @@ def focused_25d(x0, n0, xs, ns, xref=[0, 0, 0], c=None): |
363 | 376 |
|
364 | 377 | delays, weights, selection, secondary_source = \ |
365 | 378 | sfs.td.wfs.focused_25d(array.x, array.n, xf, nf) |
| 379 | + weights *= 4*np.pi*rs # normalize |
366 | 380 | d = sfs.td.wfs.driving_signals(delays, weights, signal) |
367 | | - plot(d, selection, secondary_source, t=tf) |
| 381 | + # note that WFS prefilter is not included |
| 382 | + plot(d, selection, secondary_source, t=tf+tlp) |
368 | 383 |
|
369 | 384 | """ |
370 | 385 | if c is None: |
|
0 commit comments