gisogrimm / tascar

toolbox for acoustic scene creation and rendering
http://www.tascar.org/
GNU General Public License v2.0
25 stars 10 forks source link

Difference between rir_generator and Tascar RIR #28

Closed ahmadikalkhorani closed 6 months ago

ahmadikalkhorani commented 7 months ago

Hello,

I have a question regarding a simple microphone array simulation. In this setup, I'm simulating a basic room with an omnidirectional microphone. The Room Impulse Response (RIR) obtained using TASCar appears to be different from the one generated with rir_generator.

Here's the XML code snippet for reference:

<?xml version="1.0"?>
<session attribution="test" loop="false" duration="4.0" playonload="true">
    <scene name="mix" guiscale="8" ismorder="1" c="343">
        <source name="spk1">
            <position>
                0 3.81 1.919 1.423
            </position>
            <orientation>
                0 0 0 0
            </orientation>
            <sound type="omni">
                <plugins>
                    <sndfile name="test.wav" loop="0" levelmode="calib" level="80" resample="true" />
                </plugins>
            </sound>
        </source>
        <facegroup name="Naked Room" reflectivity="1" damping="0" scattering="0" shoebox="7.875 5.839 3.088">
            <position>
                0 3.9375 2.9195 1.544
            </position>
        </facegroup>
        <reverb name="reverb" type="simplefdn" t60="0.413" volumetric="7.875 5.839 3.088">
            <position>
                0 3.9375 2.9195 1.544
            </position>
        </reverb>
        <receiver type="micarray" name="out">
            <position>
                0 3.974 2.979 1.418
            </position>
            <mic delay="freefield" position="0 0 0">
            </mic>
        </receiver>
    </scene>
</session>

image

Could you help identify why the observed RIR differs from the expected value?

Thank you for your assistance.

gisogrimm commented 6 months ago

To identify the differences, more information on the reference rir_generator is needed. By looking at the generated impulse responses it looks like:

ahmadikalkhorani commented 6 months ago

Thanks for the response, here is the code I used to generate RIR using rir_generator:


import rir_generator 
import numpy as np
import matplotlib.pyplot as plt
import soundfile as sf

T60 = 0.413  # seconds
room_dim = [7.875, 5.839, 3.088]  # meters

fs = 8000 # Hz

room_sz = room_dim  # Size of the room [m]
pos_src = np.array([
    [3.810, 1.919, 1.423],
    ]) # Positions of the sources ([m]
pos_rcv = np.array([
    [3.974, 2.979, 1.418],
    ])   # Position of the receivers [m]

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]

rir_generator_RIRs = rir_generator.generate(
            c=343,
            fs=fs,
            r=np.ascontiguousarray(pos_rcv),
            s=np.ascontiguousarray(pos_src[0]),
            L=np.ascontiguousarray(room_dim),
            reverberation_time=T60,
            mtype=rir_generator.mtype.omnidirectional,
        )
gisogrimm commented 6 months ago

Following the documentation of rir_generator and its original implementation, it is based on: J.B. Allen and D.A. Berkley, "Image method for efficiently simulating small-room acoustics," Journal Acoustic Society of America, 65(4), April 1979, p 943. In TASCAR we use a different method of generating room impulse responses. Both are just approximations; if you try 10 different room acoustic modeling tools you will get 10 different room impulse responses. TASCAR is designed for low-delay interactive simulation of acoustic environments with (rough) physical modeling of early reflections and plausible room acoustic simulation. If you strive for prediction of room acosutic parameters based on geometric models, you should use tools specifically developed for that purpose.