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'
def _weighting(filter_type, first, last): third_oct_bands = third(12.5, 20000.0) low = np.where(third_oct_bands == first)[0] high = np.where(third_oct_bands == last)[0] if filter_type == "a": freq_weightings = THIRD_OCTAVE_A_WEIGHTING elif filter_type == "c": freq_weightings = THIRD_OCTAVE_C_WEIGHTING return freq_weightings[low:high + 1]
def _weighting(filter_type, first, last): third_oct_bands = third(12.5, 20000.0) low = np.where(third_oct_bands == first)[0] high = np.where(third_oct_bands == last)[0] if filter_type == "a": freq_weightings = THIRD_OCTAVE_A_WEIGHTING elif filter_type == "c": freq_weightings = THIRD_OCTAVE_C_WEIGHTING return freq_weightings[low: high+1]
def _weighting(filter_type, first, last): third_oct_bands = third(12.5, 20000.0).tolist() low = third_oct_bands.index(first) high = third_oct_bands.index(last) if filter_type == "a": freq_weightings = THIRD_OCTAVE_A_WEIGHTING elif filter_type == "c": freq_weightings = THIRD_OCTAVE_C_WEIGHTING return freq_weightings[low:high + 1]
(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', np.array([0.27998887, 0.15885362, 0.07971810, 0.03710582, 0.02143263, 0.00962214, 0.02179504, 0.01961945])), (data_path() + 'living_room_1.wav', third(100, 5000), 't30', np.array([0.28442960, 0.34634621, 0.25757467, 0.31086982, 0.26658673, 0.37620645, 0.34203975, 0.26774014, 0.21206741, 0.24635442, 0.21050635, 0.23151149, 0.19184106, 0.23050360, 0.25227970, 0.20164536, 0.18413574, 0.21605655])), (data_path() + 'living_room_1.wav', third(100, 5000), 't20', np.array([0.20768170, 0.39155525, 0.18814558, 0.17202362, 0.14049935, 0.20770758, 0.32284992, 0.22108431, 0.10189647, 0.10997154, 0.08072728, 0.12806066, 0.07219205, 0.07380865, 0.08706586, 0.12925068, 0.13712873, 0.17112382])), (data_path() + 'living_room_1.wav', third(100, 5000), 't10', np.array([0.21147617, 0.10531143, 0.13209715,
def test_third(third_real): generated = third(12.5, 20000) real = third_real assert_array_equal(generated, real)
def test_third(): generated = third(12.5, 20000) real = third_real assert_array_equal(generated, real)
def set_default_locators_and_formatters(self, axis): axis.set_major_locator(NullLocator()) axis.set_major_formatter(ScalarFormatter()) axis.set_minor_locator(FixedLocator(third(12.5, 20000))) axis.set_minor_formatter(ScalarFormatter())
@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 ])), (data_path() + 'living_room_1.wav', third(100, 5000), 't20', np.array([ 0.202, 0.383, 0.189, 0.173, 0.141, 0.208, 0.323, 0.221, 0.102, 0.110, 0.081, 0.128, 0.072, 0.074, 0.087, 0.129, 0.137, 0.171 ])), (data_path() + 'living_room_1.wav', third(100, 5000), 't10', np.array([ 0.110, 0.104, 0.132, 0.166, 0.135, 0.040, 0.119, 0.223, 0.025, 0.023, 0.047, 0.050, 0.010, 0.017, 0.039, 0.084, 0.154, 0.093 ])), (data_path() + 'living_room_1.wav', third(100, 5000), 'edt',
import acoustics.descriptors as acd print "reference SPL:", acd.REFERENCE_PRESSURE print "equivalent SPL:",acd.equivalent_sound_pressure_level(sigy) print "peak SPL:", acd.peak_sound_pressure(sigy) """ IEC 61672 """ import acoustics.standards as acs print "third octave center frequency vector:", acs.iec_61672_1_2013.NOMINAL_OCTAVE_CENTER_FREQUENCIES print "reference frequency:", acs.iec_61672_1_2013.REFERENCE_FREQUENCY print "slow time constant:", acs.iec_61672_1_2013.SLOW """ third octave band """ import acoustics.bands as acb print "some thrid octave frequency:", acb.third(100, 500) print "third octave to octave:",acb.third2oct([10,10,10,10,10,10]) """ third octave analysis """ import acoustics.signal as ass a,AX = ass.third_octaves(sigy, fs) a,AZ1 = ass.third_octaves(sigz1, fs) a,AZ2 = ass.third_octaves(sigz2, fs) """ show graphics using pylab """ import pylab as plt plt.hold(True)