예제 #1
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" Measure the runtime of the library against the number of RIRs.
It may need several minutes.
"""

import numpy as np
import matplotlib.pyplot as plt
import time

import gpuRIR

gpuRIR.activateMixedPrecision(False)
gpuRIR.activateLUT(False)

nb_src_vec = np.concatenate([2**np.arange(12),
                             [4095]])  # Number of RIRs to measure
nb_test_per_point = 10  # Number of simulations per T60 to average the runtime

nb_rcv = 1  # Number of receivers
room_sz = np.array([3, 4, 2.5])  # Room size [m]
T60 = 0.7  # Reverberation time [s]
att_diff = 13.0  # Attenuation when start using the diffuse reverberation model [dB]
att_max = 50.0  # Attenuation at the end of the simulation [dB]
fs = 16000  # Sampling frequency [Hz]

pos_rcv = np.random.rand(nb_rcv, 3) * room_sz

time_max = 100  # Stop the measurements after find an average time greter than this time [s]
times = np.zeros((len(nb_src_vec), 1))
for i in range(len(nb_src_vec)):
예제 #2
0
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__)
예제 #3
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" Example for computing the RIR between several sources and receivers in GPU.
"""

import numpy as np
import numpy.matlib
import matplotlib.pyplot as plt
from math import ceil

import gpuRIR
gpuRIR.activateMixedPrecision(False)
gpuRIR.activateLUT(True)

room_sz = [3, 3, 2.5]  # Size of the room [m]
nb_src = 2  # Number of sources
pos_src = np.array([[1, 2.9, 0.5], [1, 2,
                                    0.5]])  # Positions of the sources ([m]
nb_rcv = 3  # Number of receivers
pos_rcv = np.array([[0.5, 1, 0.5], [1, 1, 0.5],
                    [1.5, 1, 0.5]])  # Position of the receivers [m]
orV_rcv = np.matlib.repmat(
    np.array([0, 1, 0]), nb_rcv,
    1)  # Vectors pointing in the same direction than the receivers
mic_pattern = "card"  # Receiver polar pattern
abs_weights = [0.9] * 5 + [0.5]  # Absortion coefficient ratios of the walls
T60 = 1.0  # 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]
fs = 16000.0  # Sampling frequency [Hz]