MCPcopy
hub / github.com/LCAV/pyroomacoustics / add_source

Method add_source

pyroomacoustics/room.py:2055–2102  ·  view source on GitHub ↗

Adds a sound source given by its position in the room. Optionally a source signal and a delay can be provided. Parameters ----------- position: ndarray, shape: (2,) or (3,) The location of the source in the room signal: ndarray, shape: (n

(self, position, signal=None, delay=0, directivity=None)

Source from the content-addressed store, hash-verified

2053 return self.add(mic_array)
2054
2055 def add_source(self, position, signal=None, delay=0, directivity=None):
2056 """
2057 Adds a sound source given by its position in the room. Optionally
2058 a source signal and a delay can be provided.
2059
2060 Parameters
2061 -----------
2062 position: ndarray, shape: (2,) or (3,)
2063 The location of the source in the room
2064 signal: ndarray, shape: (n_samples,), optional
2065 The signal played by the source
2066 delay: float, optional
2067 A time delay until the source signal starts
2068 in the simulation
2069
2070 Returns
2071 -------
2072 :py:obj:`~pyroomacoustics.room.Room`
2073 The room is returned for further tweaking.
2074 """
2075
2076 if self.dim != 3 and directivity is not None:
2077 raise NotImplementedError("Directivity is only supported for 3D rooms.")
2078
2079 if isinstance(position, SoundSource):
2080 if directivity is not None:
2081 if isinstance(directivity, CardioidFamily) or isinstance(
2082 directivity, MeasuredDirectivity
2083 ):
2084 return self.add(SoundSource(position, directivity=directivity))
2085 else:
2086 return self.add(position)
2087 else:
2088 if directivity is not None:
2089 if isinstance(directivity, CardioidFamily) or isinstance(
2090 directivity, MeasuredDirectivity
2091 ):
2092 return self.add(
2093 SoundSource(
2094 position,
2095 signal=signal,
2096 delay=delay,
2097 directivity=directivity,
2098 )
2099 )
2100
2101 else:
2102 return self.add(SoundSource(position, signal=signal, delay=delay))
2103
2104 def add_soundsource(self, sndsrc, directivity=None):
2105 """

Callers 15

random_room_ismFunction · 0.95
test_square_roomMethod · 0.95
test_issue_22Function · 0.80
compute_rirFunction · 0.80
wrapper_ismFunction · 0.80
wrapper_random_ismFunction · 0.80
get_rt60Function · 0.80
test_room_mix.pyFile · 0.80

Calls 2

addMethod · 0.95
SoundSourceClass · 0.85

Tested by 15

random_room_ismFunction · 0.76
test_square_roomMethod · 0.76
test_issue_22Function · 0.64
compute_rirFunction · 0.64
wrapper_ismFunction · 0.64
wrapper_random_ismFunction · 0.64
get_rt60Function · 0.64
test_rir_hpfFunction · 0.64
test_hpfFunction · 0.64
test_issue_313Function · 0.64