Esempio n. 1
0
    def testInit(self):
        hrtf = CipicHRTF(filename=os.path.join(TEST_DATA_DIR, 'hrtf',
                                               'cipic_hrir.mat'),
                         samplingRate=44100.0)
        impulse = hrtf.getImpulseResponse(azimut=50.0, elevation=75.0)
        self.assertTrue(np.array_equal(hrtf.impulses.shape, [25, 50, 2, 200]))
        self.assertTrue(np.array_equal(impulse.shape, [2, 200]))

        hrtf = CipicHRTF(filename=os.path.join(TEST_DATA_DIR, 'hrtf',
                                               'cipic_hrir.mat'),
                         samplingRate=16000.0)
        impulse = hrtf.getImpulseResponse(azimut=50.0, elevation=75.0)
        self.assertTrue(np.array_equal(hrtf.impulses.shape, [25, 50, 2, 72]))
        self.assertTrue(np.array_equal(impulse.shape, [2, 72]))
Esempio n. 2
0
    def testGetImpulseResponse(self):

        hrtf = CipicHRTF(filename=os.path.join(TEST_DATA_DIR, 'hrtf',
                                               'cipic_hrir.mat'),
                         samplingRate=44100.0)

        for elevation, azimut in [(0.0, 0.0), (0.0, -90.0), (0.0, 90.0),
                                  (-120.0, 0.0)]:

            impulse = hrtf.getImpulseResponse(azimut, elevation)
            self.assertTrue(np.array_equal(impulse.shape, [2, 200]))

            fig = plt.figure()
            plt.title('azimut = %f, elevation = %f' % (azimut, elevation))
            plt.plot(impulse[0], color='b', label='Left channel')
            plt.plot(impulse[1], color='g', label='Right channel')
            plt.legend()
            plt.show(block=False)
            time.sleep(1.0)
            plt.close(fig)