def setup_module(imaging):
    imaging.octaves = octave(16, 16000)
    imaging.thirds = third(63, 8000)
    imaging.tl_oct = np.array([3, 4, 5, 12, 15, 24, 28, 23, 35, 45, 55])
    imaging.tl_third = np.array([0,   0,  0,  1,  1,  2,  3,  5,  8, 13, 21,
                                 32, 41, 47, 46, 44, 58, 77, 61, 75, 56, 54])
    imaging.title = 'Title'
    imaging.label = 'Label'
def setup_module(imaging):
    imaging.octaves = octave(16, 16000)
    imaging.thirds = third(63, 8000)
    imaging.tl_oct = np.array([3, 4, 5, 12, 15, 24, 28, 23, 35, 45, 55])
    imaging.tl_third = np.array([
        0, 0, 0, 1, 1, 2, 3, 5, 8, 13, 21, 32, 41, 47, 46, 44, 58, 77, 61, 75,
        56, 54
    ])
    imaging.title = 'Title'
    imaging.label = 'Label'
Exemple #3
0
def rt60(wav, img):

    plt.cla()  # Clear axis
    plt.clf()  # Clear figure
    plt.close()  # Close a figure window
    filePath = wav
    octave_bands = band.octave(100, 8000)
    sample_rate, data = wavfile.read(filePath)
    plt.ylabel('Freqency (hz)')
    plt.xlabel('Time(sec)')

    spectrum, freqs, t, im = plt.specgram(
        data,
        Fs=sample_rate,
        NFFT=1024,
        cmap=plt.get_cmap('twilight_shifted_r'))
    t60 = room.t60_impulse(filePath, octave_bands, 't30')

    plt.savefig(img)
    np.set_printoptions(
        formatter={'float_kind': lambda x: "{0:0.3f}".format(x)})

    return np.round(t60, 3)
def test_nrc_1d():
    alpha = np.array([0.1, 0.25, 0.5, 0.9])
    calculated = nrc(alpha)
    real = 0.4375
    assert_almost_equal(calculated, real)


def test_nrc_2d():
    alphas = np.array([[0.1, 0.2, 0.3, 0.4], [0.4, 0.5, 0.6, 0.7]])
    calculated = nrc(alphas)
    real = np.array([0.25, 0.55])
    assert_array_almost_equal(calculated, real)


@pytest.mark.parametrize("file_name, bands, rt, expected", [
    (data_path() + 'ir_sportscentre_omni.wav', octave(125, 4000), 't30',
     np.array([7.24027654, 8.47019681, 6.79466752,
               6.51780663, 4.79692643, 4.08912686])),
    (data_path() + 'ir_sportscentre_omni.wav', octave(125, 4000), 'edt',
     np.array([4.71644743, 5.94075422, 6.00702329,
               5.94062563, 5.03778274, 3.73465316])),
    (data_path() + 'living_room_1.wav', octave(63, 8000), 't30',
     np.array([0.27658574, 0.36466480, 0.30282462, 0.25946725, 0.22710926,
               0.21056449, 0.20445301, 0.18080435])),
    (data_path() + 'living_room_1.wav', octave(63, 8000), 't20',
     np.array([0.30418539, 0.36486166, 0.15138373, 0.15594470, 0.10192937,
               0.07587109, 0.14564938, 0.15231023])),
    (data_path() + 'living_room_1.wav', octave(63, 8000), 't10',
     np.array([0.18067203, 0.06121885, 0.10898306, 0.02377203, 0.03865264,
               0.02303814, 0.10484486, 0.07141563])),
    (data_path() + 'living_room_1.wav', octave(63, 8000), 'edt',
def test_octave(octave_real):
    generated = octave(16, 16000)
    real = octave_real
    assert_array_equal(generated, real)
def test_octave():
    generated = octave(16, 16000)
    real = octave_real
    assert_array_equal(generated, real)
 def set_default_locators_and_formatters(self, axis):
     axis.set_major_locator(FixedLocator(octave(16, 16000)))
     axis.set_major_formatter(ScalarFormatter())
     axis.set_minor_locator(NullLocator())
     axis.set_minor_formatter(NullFormatter())
Exemple #8
0
def test_nrc_1d():
    alpha = np.array([0.1, 0.25, 0.5, 0.9])
    calculated = nrc(alpha)
    real = 0.4375
    assert_almost_equal(calculated, real)


def test_nrc_2d():
    alphas = np.array([[0.1, 0.2, 0.3, 0.4], [0.4, 0.5, 0.6, 0.7]])
    calculated = nrc(alphas)
    real = np.array([0.25, 0.55])
    assert_array_almost_equal(calculated, real)


@pytest.mark.parametrize("file_name, bands, rt, expected", [
    (data_path() + 'ir_sportscentre_omni.wav', octave(125, 4000), 't30',
     np.array([7.388, 8.472, 6.795, 6.518, 4.797, 4.089])),
    (data_path() + 'ir_sportscentre_omni.wav', octave(125, 4000), 'edt',
     np.array([4.667, 5.942, 6.007, 5.941, 5.038, 3.735])),
    (data_path() + 'living_room_1.wav', octave(63, 8000), 't30',
     np.array([0.274, 0.365, 0.303, 0.259, 0.227, 0.211, 0.204, 0.181])),
    (data_path() + 'living_room_1.wav', octave(63, 8000), 't20',
     np.array([0.300, 0.365, 0.151, 0.156, 0.102, 0.076, 0.146, 0.152])),
    (data_path() + 'living_room_1.wav', octave(63, 8000), 't10',
     np.array([0.185, 0.061, 0.109, 0.024, 0.039, 0.023, 0.105, 0.071])),
    (data_path() + 'living_room_1.wav', octave(63, 8000), 'edt',
     np.array([0.267, 0.159, 0.080, 0.037, 0.021, 0.010, 0.022, 0.020])),
    (data_path() + 'living_room_1.wav', third(100, 5000), 't30',
     np.array([
         0.318, 0.340, 0.259, 0.311, 0.267, 0.376, 0.342, 0.268, 0.212, 0.246,
         0.211, 0.232, 0.192, 0.231, 0.252, 0.202, 0.184, 0.216
Exemple #9
0
 def set_default_locators_and_formatters(self, axis):
     axis.set_major_locator(FixedLocator(octave(16, 16000)))
     axis.set_major_formatter(ScalarFormatter())
     axis.set_minor_locator(NullLocator())
     axis.set_minor_formatter(NullFormatter())
def test_nrc_1d():
    alpha = np.array([0.1, 0.25, 0.5, 0.9])
    calculated = nrc(alpha)
    real = 0.4375
    assert_almost_equal(calculated, real)


def test_nrc_2d():
    alphas = np.array([[0.1, 0.2, 0.3, 0.4], [0.4, 0.5, 0.6, 0.7]])
    calculated = nrc(alphas)
    real = np.array([0.25, 0.55])
    assert_array_almost_equal(calculated, real)


@pytest.mark.parametrize("file_name, bands, rt, expected", [
    (data_path() + 'ir_sportscentre_omni.wav', octave(125, 4000), 't30',
     np.array([7.388, 8.472, 6.795, 6.518, 4.797, 4.089])),
    (data_path() + 'ir_sportscentre_omni.wav', octave(125, 4000), 'edt',
     np.array([4.667, 5.942, 6.007, 5.941, 5.038, 3.735])),
    (data_path() + 'living_room_1.wav', octave(63, 8000), 't30',
     np.array([0.274, 0.365, 0.303, 0.259, 0.227, 0.211, 0.204, 0.181])),
    (data_path() + 'living_room_1.wav', octave(63, 8000), 't20',
     np.array([0.300, 0.365, 0.151, 0.156, 0.102, 0.076, 0.146, 0.152])),
    (data_path() + 'living_room_1.wav', octave(63, 8000), 't10',
     np.array([0.185, 0.061, 0.109, 0.024, 0.039, 0.023, 0.105, 0.071])),
    (data_path() + 'living_room_1.wav', octave(63, 8000), 'edt',
     np.array([0.267, 0.159, 0.080, 0.037, 0.021, 0.010, 0.022, 0.020])),
    (data_path() + 'living_room_1.wav', third(100, 5000), 't30',
     np.array([0.318, 0.340, 0.259, 0.311, 0.267, 0.376,
               0.342, 0.268, 0.212, 0.246, 0.211, 0.232,
               0.192, 0.231, 0.252, 0.202, 0.184, 0.216])),
def test_nrc_1d():
    alpha = np.array([0.1, 0.25, 0.5, 0.9])
    calculated = nrc(alpha)
    real = 0.4375
    assert_almost_equal(calculated, real)


def test_nrc_2d():
    alphas = np.array([[0.1, 0.2, 0.3, 0.4], [0.4, 0.5, 0.6, 0.7]])
    calculated = nrc(alphas)
    real = np.array([0.25, 0.55])
    assert_array_almost_equal(calculated, real)


@pytest.mark.parametrize("file_name, bands, rt, expected", [
    (data_path() + 'ir_sportscentre_omni.wav', octave(125, 4000), 't30',
     np.array([7.388, 8.472, 6.795, 6.518, 4.797, 4.089])),
    (data_path() + 'ir_sportscentre_omni.wav', octave(125, 4000), 'edt',
     np.array([4.667, 5.942, 6.007, 5.941, 5.038, 3.735])),
    (data_path() + 'living_room_1.wav', octave(63, 8000), 't30',
     np.array([0.274, 0.365, 0.303, 0.259, 0.227, 0.211, 0.204, 0.181])),
    (data_path() + 'living_room_1.wav', octave(63, 8000), 't20',
     np.array([0.300, 0.365, 0.151, 0.156, 0.102, 0.076, 0.146, 0.152])),
    (data_path() + 'living_room_1.wav', octave(63, 8000), 't10',
     np.array([0.185, 0.061, 0.109, 0.024, 0.039, 0.023, 0.105, 0.071])),
    (data_path() + 'living_room_1.wav', octave(63, 8000), 'edt',
     np.array([0.267, 0.159, 0.080, 0.037, 0.021, 0.010, 0.022, 0.020])),
    (data_path() + 'living_room_1.wav', third(100, 5000), 't30',
     np.array([
         0.318, 0.340, 0.259, 0.311, 0.267, 0.376, 0.342, 0.268, 0.212, 0.246, 0.211, 0.232, 0.192, 0.231, 0.252, 0.202,
         0.184, 0.216