def test_wrong_size(self): """ test that creation fails with a non power-of-two size """ # supports for non 2** fft sizes only when compiled with fftw3 size = 13 try: with self.assertRaises(RuntimeError): aubio.dct(size) except AssertionError: self.skipTest('creating aubio.dct with size %d did not fail' % size)
def test_some_ones(self): """ test that dct(somevector) is computed correctly """ a_dct = aubio.dct(16) a_in = np.ones(16).astype(aubio.float_type) a_in[1] = 0 a_in[3] = np.pi a_expected = aubio.fvec(precomputed_some_ones) assert_almost_equal(a_dct(a_in), a_expected, decimal=6)
def test_reconstruction(self): """ test that some_ones vector can be recontructed """ a_dct = aubio.dct(16) a_in = np.ones(16).astype(aubio.float_type) a_in[1] = 0 a_in[3] = np.pi a_dct_in = a_dct(a_in) a_dct_reconstructed = a_dct.rdo(a_dct_in) assert_almost_equal(a_dct_reconstructed, a_in, decimal=6)
def test_arange(self): """ test that dct(arange(8)) is computed correctly >>> from scipy.fftpack import dct >>> a_in = np.arange(8).astype(aubio.float_type) >>> precomputed = dct(a_in, norm='ortho') """ N = len(precomputed_arange) a_dct = aubio.dct(8) a_in = np.arange(8).astype(aubio.float_type) a_expected = aubio.fvec(precomputed_arange) assert_almost_equal(a_dct(a_in), a_expected, decimal=5)
def test_negative_size(self): """ test that creation fails with a negative size """ with self.assertRaises(ValueError): aubio.dct(-1)
def test_init(self): """ test that aubio.dct() is created with expected size """ a_dct = aubio.dct() self.assertEqual(a_dct.size, 1024)
active = 0 visualizers = [Colors()] @window.event def on_draw(dt): window.clear() visualizers[active].quad.draw(visualizers[active].method) @window.event def on_key_press(symbol, modifiers): print(symbol, modifiers) g = dct(16) def bands(data): bands = g(data) return np.absolute(bands) def audio_input_callback(indata, frames, time, status): data = indata.transpose()[0] visualizers[active].input(data, bands(data)) audio_input_stream = sd.InputStream(channels=1, callback=audio_input_callback, dtype='float32',