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)
| 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 | """ |