コード例 #1
0
ファイル: rir_generate_2d.py プロジェクト: yaozengwei/setk
from libs.scheduler import run_command
from libs.utils import get_logger, write_wav
from libs.opts import StrToFloatTupleAction, StrToBoolAction, str2tuple
from libs.sampler import UniformSampler

try:
    import pyrirgen
    pyrirgen_available = True
except ImportError:
    pyrirgen_available = False

try:
    import gpuRIR as pygpurir
    gpu_rir_available = True
    pygpurir.activateMixedPrecision(False)
    pygpurir.activateLUT(True)
except ImportError:
    gpu_rir_available = False

if shutil.which("rir-simulate"):
    cpp_rir_available = True
else:
    cpp_rir_available = False

plt.switch_backend("agg")

default_dpi = 200
default_fmt = "jpg"

logger = get_logger(__name__)
コード例 #2
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" Example for simulating the recording of a moving source with a microphone array.
You need to have a 'source_signal.wav' audio file to use it as source signal and it will generate
the file 'filtered_signal.wav' with the stereo recording simulation.
"""
import numpy as np
import matplotlib.pyplot as plt
from scipy.io import wavfile

import gpuRIR
gpuRIR.activateMixedPrecision(False)

fs, source_signal = wavfile.read('source_signal.wav')

room_sz = [3, 4, 2.5]  # Size of the room [m]
traj_pts = 64  # Number of trajectory points
pos_traj = np.tile(np.array([0.0, 3.0, 1.0]), (traj_pts, 1))
pos_traj[:,
         0] = np.linspace(0.1, 2.9,
                          traj_pts)  # Positions of the trajectory points [m]
nb_rcv = 2  # Number of receivers
pos_rcv = np.array([[1.4, 1, 1.5], [1.6, 1,
                                    1.5]])  # Position of the receivers [m]
orV_rcv = np.array([[-1, 0, 0], [1, 0, 0]])
mic_pattern = "card"  # Receiver polar pattern
T60 = 0.6  # Time for the RIR to reach 60dB of attenuation [s]
att_diff = 15.0  # Attenuation when start using the diffuse reverberation model [dB]
att_max = 60.0  # Attenuation at the end of the simulation [dB]

beta = gpuRIR.beta_SabineEstimation(room_sz, T60)  # Reflection coefficients