Comments (7)
Hi @maelp , I'll answer in order.
- That's a perfectly valid thing to want! I think it should be possible to do this without too much effort. I will try to write an example in the next few days.
- Wether one wants to use 2D or 3D is entirely dependent on the situation I guess. The situation in research in acoustical signal processing is that many people validate their algorithms in 2D room environments. Now I think this has more to do with ease of implementation than accuracy. You can imagine that a 2D room is like a room without floor or ceiling (an infinite elevator shaft). If you are interested in realistic rendering, I would use a 3D room. Then again, the image source model is not the most life-like simulator to use.
- I have not used the simulator from Eric Lehmann, but if I recall correctly, it uses a more sophisticated method to improve the rendering of the tail of the RIR, but has the drawback of only handling shoebox rooms and requires Matlab.
from pyroomacoustics.
Closed by mistake. I'll close the issue when the example is added :)
from pyroomacoustics.
from pyroomacoustics.
Finally, I could do this quickly. I have added room_simulation.py
in the examples folder. I hope this helps.
'''
A simple example of using pyroomacoustics to simulate
sound propagation in a shoebox room and record the result
to a wav file.
'''
import numpy as np
import pyroomacoustics as pra
import matplotlib.pyplot as plt
from scipy.io import wavfile
fs, audio_anechoic = wavfile.read('examples/samples/guitar_16k.wav')
# room dimension
room_dim = [5, 4, 6]
# Create the shoebox
shoebox = pra.ShoeBox(
room_dim,
absorption=0.2,
fs=fs,
max_order=15,
)
# source and mic locations
shoebox.add_source([2, 3.1, 2], signal=audio_anechoic)
shoebox.add_microphone_array(
pra.MicrophoneArray(
np.array([[2, 1.5, 2]]).T,
shoebox.fs)
)
# run ism
shoebox.simulate()
audio_reverb = shoebox.mic_array.to_wav('examples/samples/guitar_16k_reverb.wav', norm=True, bitdepth=np.int16)
from pyroomacoustics.
Thanks @fakufaku, would this be correct to simulate the reverb:
- create the room
- create a source which emits a single sample with amplitude 1.0
- get the
audio_reverb
- convolve wav with it
from pyroomacoustics.
Dear @maelp , as I understand, you are interested to look at the room impulse response of the room. There is a simpler way to do this. When you run the shoebox.simulate()
line above, all room impulse responses will be computed and stored in shoebox.rir
. Then, the impulse response between the m
-th microphone and the s
-th source can be accessed at shoebox.rir[m][s]
.
In case you are only interested in getting the impulse response (as opposed to simulate the propagation of a particular sound sample), you can omit the source signal specification and call shoebox.compute_rir()
instead of simulate()
. Here is the modified example.
'''
A simple example of using pyroomacoustics to compute
the room impulse response between one source and one microphone.
'''
import numpy as np
import pyroomacoustics as pra
import matplotlib.pyplot as plt
# room dimension
room_dim = [5, 4, 6]
# Create the shoebox
shoebox = pra.ShoeBox(
room_dim,
absorption=0.2,
fs=fs,
max_order=15,
)
# source and mic locations
shoebox.add_source([2, 3.1, 2])
shoebox.add_microphone_array(
pra.MicrophoneArray(
np.array([[2, 1.5, 2]]).T,
shoebox.fs)
)
# run ism
shoebox.compute_rir()
# this plots the RIR between the 1st source and the 1st microphone
rir_time = np.arange(len(shoebox.rir[0][0])) / shoebox.fs
plt.plot(rir_time, shoebox.rir[0][0])
from pyroomacoustics.
Thanks !
from pyroomacoustics.
Related Issues (20)
- Adding a diffuser
- problem in pip HOT 4
- Has Gaussian-Laplace IVA (IVA-GL) been also implemented in this library? HOT 1
- Bug in auxiva? Script did not show any error, but got nan in the result of source matrix HOT 2
- Compute RIR up to a K (earliest or strongest) reflection (or max time)
- ValueError: operands could not be broadcast together with shapes (2709,96) (2500,1) (2709,96)
- Waves in the signal after convolving the signal with the RIR HOT 3
- Question regarding materials HOT 1
- scipy.signal.hann is deprecated in SciPy 1.13.0
- How to simulation energy decrease? HOT 8
- why conj in ILRMA HOT 4
- Error in pyroomacoustics/pyroomacoustics /beamforming.py HOT 1
- Differences With Other Libraries HOT 1
- Help me understand energy scaling HOT 4
- libroom.rir_builder error: "The rir array is too small for the maximum time recorded" HOT 13
- Plot of Microphones HOT 1
- directivity argument of Room.add_microphone_array HOT 1
- About directional source signal
- Potential bug when generating RT60 using v0.7.5 HOT 6
- CMU-ARCTIC’s accent tags are different from those shown on the official website
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyroomacoustics.