8000 follow the coding style PEP 8 - white spaces, blank lines, etc · sfstoolbox/sfs-python@8fd0392 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8fd0392

Browse files
committed
follow the coding style PEP 8 - white spaces, blank lines, etc
1 parent 5078c23 commit 8fd0392

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

examples/time_domain_nfchoa.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,37 +36,36 @@
3636
delay, weight, sos, phaseshift = sfs.time.drivingfunction.nfchoa_25d_plane(x0, R, npw, max_order=max_order, normalize=True)
3737
t = 0
3838

39-
4039
# Driving signals
4140
d, fs, t_offset = sfs.time.drivingfunction.nfchoa_driving_signals(delay, weight, sos, phaseshift, signal, max_order=max_order)
4241

4342
plt.figure()
4443
plt.imshow(sfs.util.db(d), interpolation='None', cmap='Blues')
4544
plt.axis('tight')
4645
plt.colorbar()
47-
plt.clim([-120,0])
46+
plt.clim([-120, 0])
4847

4948
plt.figure()
5049
plt.imshow(np.real(d), interpolation='None', cmap='coolwarm')
5150
plt.axis('tight')
5251
plt.colorbar()
53-
plt.clim([-0.1,0.1])
52+
plt.clim([-0.1, 0.1])
5453

5554

5655
# Synthesized sound field
5756
a0 = np.ones(len(x0))
5857
p = sfs.time.soundfield.p_array(x0, (d, fs, t_offset), a0, t, grid)
5958

60-
plt.figure(figsize=(3,3))
59+
plt.figure(figsize=(3, 3))
6160
sfs.plot.level(p, grid, cmap='Blues')
6261
sfs.plot.loudspeaker_2d(x0, n0)
6362
#sfs.plot.virtualsource_2d(xs, type='point')
64-
sfs.plot.virtualsource_2d([0,0], ns=npw, type='plane')
63+
sfs.plot.virtualsource_2d([0, 0], ns=npw, type='plane')
6564
plt.savefig('pw_level.png')
6665

67-
plt.figure(figsize=(3,3))
66+
plt.figure(figsize=(3, 3))
6867
sfs.plot.soundfield(p, grid, cmap='coolwarm')
6968
sfs.plot.loudspeaker_2d(x0, n0)
7069
#sfs.plot.virtualsource_2d(xs, type='point')
71-
sfs.plot.virtualsource_2d([0,0], ns=npw, type='plane')
70+
sfs.plot.virtualsource_2d([0, 0], ns=npw, type='plane')
7271
plt.savefig('pw_soundfield.png')

sfs/time/drivingfunction.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -281,28 +281,28 @@ def nfchoa_25d_plane(x0, r0, npw, max_order=None, c=None, fs=44100, normalize=Tr
281281
weight : float
282282
Overall weight (common to all secondary sources)
283283
sos : dictionary
284-
Second-order section filters
284+
Second-order section filters
285285
phaseshift : float
286286
Phase shift
287-
287+
288288
References
289289
----------
290290
S. Spors, V. Kuscher, J. Ahrens (2011) - "Efficient realization of
291291
model-based rendering for 2.5-dimensional near-field compensated higher
292292
order Ambisonics", WASPAA, p. 61-64
293-
293+
294294
See Eq.(10)
295295
"""
296296
if max_order is None:
297-
max_order =_max_order_circular_harmonics(len(x0), max_order)
297+
max_order = _max_order_circular_harmonics(len(x0), max_order)
298298
if c is None:
299299
c = defs.c
300300

301301
x0 = util.asarray_of_rows(x0)
302302
npw = util.asarray_1d(npw)
303303
phipw, _, _ = util.cart2sph(*npw)
304304
phi0, _, _ = util.cart2sph(*x0.T)
305-
305+
306306
delay = -r0/c
307307
weight = 2
308308
sos = {}
@@ -347,21 +347,20 @@ def nfchoa_25d_point(x0, r0, xs, max_order=None, c=None, fs=44100, normalize=Tru
347347
weight : float
348348
Overall weight (common to all secondary sources)
349349
sos : dictionary
350-
Second-order section filters
350+
Second-order section filters
351351
phaseshift : float
352352
Phase shift
353353
354-
355354
References
356355
----------
357356
S. Spors, V. Kuscher, J. Ahrens (2011) - "Efficient realization of
358357
model-based rendering for 2.5-dimensional near-field compensated higher
359358
order Ambisonics", WASPAA, p. 61-64
360-
359+
361360
See Eq.(11)
362361
"""
363362
if max_order is None:
364-
max_order =_max_order_circular_harmonics(len(x0), max_order)
363+
max_order = _max_order_circular_harmonics(len(x0), max_order)
365364
if c is None:
366365
c = defs.c
367366

@@ -385,7 +384,7 @@ def nfchoa_25d_point(x0, r0, xs, max_order=None, c=None, fs=44100, normalize=Tru
385384
k = _normalize_digital_filter_gain(s0, sinf, z0, zinf, fs=fs)
386385
else:
387386
k = 1
388-
sos[m] = sig.zpk2sos(z0,zinf,k,pairing='nearest')
387+
sos[m] = sig.zpk2sos(z0, zinf, k, pairing='nearest')
389388
# TODO: normalize the SOS filters individually?
390389
phaseshift = phi0 - phi
391390
return delay, weight, sos, phaseshift
@@ -401,7 +400,7 @@ def nfchoa_driving_signals(delay, weight, sos, phaseshift, signal, max_order=Non
401400
weight : float
402401
Overall weight (common to all secondary sources)
403402
sos : dictionary
404-
Second-order section filters
403+
Second-order section filters
405404
phaseshift : (C,) array_like
406405
Phase shift
407406
signal : (N,) array_like
@@ -418,30 +417,32 @@ def nfchoa_driving_signals(delay, weight, sos, phaseshift, signal, max_order=Non
418417
419418
"""
420419
if max_order is None:
421-
max_order =_max_order_circular_harmonics(len(phaseshift), max_order)
420+
max_order = _max_order_circular_harmonics(len(phaseshift), max_order)
422421

423422
delay = util.asarray_1d(delay)
424423
weight = util.asarray_1d(weight)
425424
# TODO : check FOS/SOS structure
426425

427426
N = len(phaseshift)
428427
L = len(signal)
429-
d = np.zeros((L,N),dtype='complex128')
428+
d = np.zeros((L, N), dtype='complex128')
430429

431430
modal_response = sig.sosfilt(sos[0], signal)
432431
for l in range(N):
433-
d[:,l] += modal_response
432+
d[:, l] += modal_response
434433
for m in range(1, max_order+1):
435434
modal_response = sig.sosfilt(sos[np.abs(m)], signal)
436435
for l in range(N):
437-
d[:,l] += modal_response * 2 * np.cos(m*phaseshift[l])
436+
d[:, l] += modal_response * 2 * np.cos(m*phaseshift[l])
438437
t_offset = delay[0]
439438
return np.real(d) * weight, fs, t_offset
440-
439+
440+
441441
def _max_order_circular_harmonics(N, max_order):
442442
"""Compute order of 2D HOA."""
443443
return (N-1) // 2 if max_order is None else max_order
444444

445+
445446
def _normalize_digital_filter_gain(s0, sinf, z0, zinf, fs=44100):
446447
"""Match the digital filter gain at the Nyquist freuqneycy"""
447448

@@ -453,5 +454,4 @@ def _normalize_digital_filter_gain(s0, sinf, z0, zinf, fs=44100):
453454
omega = 1j*np.pi*fs
454455
k *= np.prod((omega-s0)/(omega-sinf))
455456
k *= np.prod((-1-zinf)/(-1-z0))
456-
return np.abs(k)
457-
457+
return np.abs(k)

0 commit comments

Comments
 (0)
0