SFS Toolbox
Theory Matlab Python
  • Installation
    • Requirements
    • Installation
  • Examples
    • Sound Field Synthesis
      • Circular loudspeaker arrays
        • Wave Field Synthesis (WFS)
        • Near-Field Compensated Higher Order Ambisonics (NFC-HOA)
      • Linear loudspeaker array
        • Wave Field Synthesis (WFS)
    • Modal Room Acoustics
      • Sound Field for One Frequency
      • Frequency Response at One Point
    • Mirror Image Sources and the Sound Field in a Rectangular Room
      • 2D Mirror Image Sources
      • Monochromatic Sound Field
      • Spatio-temporal Impulse Response
    • Animations of a Pulsating Sphere
      • Particle Displacement
      • Particle Velocity
      • Sound Pressure
    • Example Python Scripts
  • API Documentation
    • sfs.fd
      • sfs.fd.source
      • sfs.fd.wfs
      • sfs.fd.nfchoa
      • sfs.fd.sdm
      • sfs.fd.esa
    • sfs.td
      • sfs.td.source
      • sfs.td.wfs
      • sfs.td.nfchoa
    • sfs.array
    • sfs.tapering
    • sfs.plot2d
    • sfs.plot3d
    • sfs.util
  • References
  • Contributing
    • Development Installation
    • Building the Documentation
    • Running the Tests
    • Creating a New Release
  • Version History
SFS Toolbox
  • »
  • Examples »
  • Modal Room Acoustics
  • Edit on GitHub

This page was generated from /home/docs/checkouts/readthedocs.org/user_builds/sfs-python/checkouts/0.6.2/doc/examples/modal-room-acoustics.ipynb. Interactive online version: Binder badge

Modal Room Acoustics¶

[1]:
import numpy as np
import matplotlib.pyplot as plt
import sfs
/home/docs/checkouts/readthedocs.org/user_builds/sfs-python/conda/0.6.2/lib/python3.9/site-packages/traitlets/traitlets.py:3030: FutureWarning: --rc={'figure.dpi': 96} for dict-traits is deprecated in traitlets 5.0. You can pass --rc <key=value> ... multiple times to add items to a dict.
  warn(
[2]:
%matplotlib inline
/home/docs/checkouts/readthedocs.org/user_builds/sfs-python/conda/0.6.2/lib/python3.9/site-packages/traitlets/traitlets.py:3030: FutureWarning: --rc={'figure.dpi': 96} for dict-traits is deprecated in traitlets 5.0. You can pass --rc <key=value> ... multiple times to add items to a dict.
  warn(
[3]:
x0 = 1, 3, 1.80  # source position
L = 6, 6, 3  # dimensions of room
deltan = 0.01  # absorption factor of walls
N = 20  # maximum order of modes

You can experiment with different combinations of modes:

[4]:
#N = [[1], 0, 0]

Sound Field for One Frequency¶

[5]:
f = 500  # frequency
omega = 2 * np.pi * f  # angular frequency
[6]:
grid = sfs.util.xyz_grid([0, L[0]], [0, L[1]], L[2] / 2, spacing=.1)
[7]:
p = sfs.fd.source.point_modal(omega, x0, grid, L, N=N, deltan=deltan)

For now, we apply an arbitrary scaling factor to make the plot look good

TODO: proper normalization

[8]:
p *= 0.05
[9]:
sfs.plot2d.amplitude(p, grid);
[9]:
<matplotlib.image.AxesImage at 0x7fc1a4c03a00>
../_images/examples_modal-room-acoustics_12_1.svg

Frequency Response at One Point¶

[10]:
f = np.linspace(20, 200, 180)  # frequency
omega = 2 * np.pi * f  # angular frequency

receiver = 1, 1, 1.8

p = [sfs.fd.source.point_modal(om, x0, receiver, L, N=N, deltan=deltan)
     for om in omega]

plt.plot(f, sfs.util.db(p))
plt.xlabel('frequency / Hz')
plt.ylabel('level / dB')
plt.grid()
../_images/examples_modal-room-acoustics_14_0.svg
Next Previous

© Copyright 2019, SFS Toolbox Developers. Revision 51d8493b.

Built with Sphinx using a theme provided by Read the Docs.