Note
Go to the end to download the full example code.
Three sources – Generate synthetic microphone array data.¶
Generates a test data set for three sources.
The simulation generates the sound pressure at 64 microphones that are arrangend in the ‘array64’ geometry which is part of the package. The sound pressure signals are sampled at 51200 Hz for a duration of 1 second. The simulated signals are stored in a HDF5 file named ‘three_sources.h5’.
Source location (relative to array center) and levels:
Source |
Location |
Level |
---|---|---|
1 |
(-0.1,-0.1,0.3) |
1 Pa |
2 |
(0.15,0,0.3) |
0.7 Pa |
3 |
(0,0.1,0.3) |
0.5 Pa |
from pathlib import Path
import acoular as ac
sfreq = 51200
duration = 1
nsamples = duration * sfreq
micgeofile = Path(ac.__file__).parent / 'xml' / 'array_64.xml'
h5savefile = Path('three_sources.h5')
m = ac.MicGeom(from_file=micgeofile)
n1 = ac.WNoiseGenerator(sample_freq=sfreq, numsamples=nsamples, seed=1)
n2 = ac.WNoiseGenerator(sample_freq=sfreq, numsamples=nsamples, seed=2, rms=0.7)
n3 = ac.WNoiseGenerator(sample_freq=sfreq, numsamples=nsamples, seed=3, rms=0.5)
p1 = ac.PointSource(signal=n1, mics=m, loc=(-0.1, -0.1, 0.3))
p2 = ac.PointSource(signal=n2, mics=m, loc=(0.15, 0, 0.3))
p3 = ac.PointSource(signal=n3, mics=m, loc=(0, 0.1, 0.3))
p = ac.Mixer(source=p1, sources=[p2, p3])
wh5 = ac.WriteH5(source=p, name=h5savefile)
wh5.save()
See also
Basic Beamforming – Generate a map of three sources. for an example on how to load and analyze the generated data with Beamforming.
Total running time of the script: (0 minutes 0.540 seconds)