项目作者: sunits

项目描述 :
Room impulse response simulator using python
高级语言: Python
项目地址: git://github.com/sunits/rir_simulator_python.git
创建时间: 2017-10-20T09:20:00Z
项目社区:https://github.com/sunits/rir_simulator_python

开源协议:MIT License

下载


Python RIR Simulator

Room impulse response simulator using python

Copyright 2003 Douglas R. Campbell

Copyright 2008-2016 Emmanuel Vincent

Copyright 2017 Sunit Sivasankaran

This software is a python version of the stripped-down version of the Roomsim toolbox version 3.3 by Douglas R. Campbell.
The matlab function for the stripped down version as well as RIR generation for moving sources can be found here:
Roomsimove, https://www.irisa.fr/metiss/members/evincent/Roomsimove.zip

If you find the code useful, please cite the following reference:
Room Impulse Response Generator, https://github.com/sunits/rir_simulator_python

One difference between the matlab version and this code is that
RT60 value is assumed to be same for all frequencies.

Tested for sampling rate of 16000 Hz.

Usage:

Generate random Room Impulse Responses

  1. import roomsimove_single
  2. # Create an interface. RIRs are not yet generated
  3. rir_if = roomsimove_single.RandomRIR(sampling_rate=16000)
  4. # Supports multiple sources. Each source is placed in a random position inside the same room.
  5. src = [np.random.rand(10000), np.random.rand(10000)]
  6. # Support multiple microphones. Position of each device is also random.
  7. # Minimum distance between each element (mics or sources) is 0.5 meters
  8. rev_sig = rir_if.reverberate(src, mic_cnt=2)
  9. # rev_sig contains a list of reverberate sources.
  10. # Each element in the list is of dimension [src_len x mic_cnt]

As standalone file:

  1. python roomsimove_single.py config_file source_pos_x source_pos_y source_pos_z output_file
  2. The help options will also give the details
  3. python roomsimove_single.py -h

As a module:

  1. using config_file
  2. -----------------
  3. import roomsimove_single
  4. sim_rir = roomsimove_single.RoomSim.init_from_config_file(config_file)
  5. source_pos = [1, 1, 1]
  6. rir = sim_rir.create_rir(source_pos)
  7. using default values of absorption coeffecients
  8. -----------------------------------------------
  9. import roomsimove_single
  10. room_dim = [4.2, 3.4, 5.2]
  11. room = roomsimove_single.Room(room_dim)
  12. mic_pos = [2, 2, 2]
  13. mic1 = roomsimove_single.Microphone(mic_pos, 1, \
  14. orientation=[0.0, 0.0, 0.0], direction='omnidirectional'):
  15. mic_pos = [2, 2, 1]
  16. mic2 = roomsimove_single.Microphone(mic_pos, 2, \
  17. orientation=[0.0, 0.0, 0.0], direction='cardioid'):
  18. mics = [mic1, mic2]
  19. sample_rate = 16000
  20. sim_rir = roomsimove_single.RoomSim(sample_rate, room, mics, RT60=0.3)
  21. source_pos = [1, 1, 1]
  22. rir = sim_rir.create_rir(source_pos)
  23. # Applying RIR to data
  24. import fftfilt
  25. import soundfile as sf
  26. # Assuming single channel data
  27. [data, fs] = sf.read(wav_file)
  28. reverb_data = fftfilt.fftfilt(rir,data)