History

Merge branch 'master' into fix/setbiquad

Paul Brossier committed 7 years ago

Commit 841ceed2 parents 11c46c8 e3fde2111 files · +37 −20Browse files

Showing the changes to python (8 of 11 files). Show all

Unified · Split

8 files
  1. python/demos/demo_wav2midi.py +1 −1
  2. python/ext/aubio-docstrings.h +1 −1
  3. python/ext/py-fft.c +1 −1
  4. python/ext/py-sink.c +1 −1
  5. python/lib/gen_external.py +5 −4
  6. python/tests/test_hztomel.py +14 −5
  7. python/tests/test_phasevoc.py +2 −2
  8. python/tests/utils.py +4 −0
python/demos/demo_wav2midi.py+1−1
@@ -63,7 +63,7 @@ while True: · 62 unmodified lines
63 delta = frames2tick(total_frames) - last_time63 delta = frames2tick(total_frames) - last_time
64 if new_note[2] > 0:64 if new_note[2] > 0:
65 track.append(Message('note_off', note=int(new_note[2]),65 track.append(Message('note_off', note=int(new_note[2]),
66 velocity=127, time=0)66 velocity=127, time=delta)
67 )67 )
68 track.append(Message('note_on',68 track.append(Message('note_on',
69 note=int(new_note[0]),69 note=int(new_note[0]),
python/ext/aubio-docstrings.h+1−1
@@ -1,7 +1,7 @@
1#define PYAUBIO_dct_doc \1#define PYAUBIO_dct_doc \
2 "dct(size=1024)\n"\2 "dct(size=1024)\n"\
3 "\n"\3 "\n"\
4 "Compute Discrete Fourier Transorms of Type-II.\n"\4 "Compute Discrete Fourier Transforms of Type-II.\n"\
5 "\n"\5 "\n"\
6 "Parameters\n"\6 "Parameters\n"\
7 "----------\n"\7 "----------\n"\
python/ext/py-fft.c+1−1
@@ -3,7 +3,7 @@ · 2 unmodified lines
3static char Py_fft_doc[] = ""3static char Py_fft_doc[] = ""
4"fft(size=1024)\n"4"fft(size=1024)\n"
5"\n"5"\n"
6"Compute Fast Fourier Transorms.\n"6"Compute Fast Fourier Transforms.\n"
7"\n"7"\n"
8"Parameters\n"8"Parameters\n"
9"----------\n"9"----------\n"
python/ext/py-sink.c+1−1
@@ -81,7 +81,7 @@ static char Py_sink_close_doc[] = "" · 80 unmodified lines
81"Close this sink now.\n"81"Close this sink now.\n"
82"\n"82"\n"
83"By default, the sink will be closed before being deleted.\n"83"By default, the sink will be closed before being deleted.\n"
84"Explicitely closing a sink can be useful to control the number\n"84"Explicitly closing a sink can be useful to control the number\n"
85"of files simultaneously opened.\n"85"of files simultaneously opened.\n"
86"";86"";
87 87
python/lib/gen_external.py+5−4
@@ -120,23 +120,24 @@ def get_cpp_output(header=header, usedouble=False): · 119 unmodified lines
120 print("Running command: {:s}".format(" ".join(cpp_cmd)))120 print("Running command: {:s}".format(" ".join(cpp_cmd)))
121 proc = subprocess.Popen(cpp_cmd,121 proc = subprocess.Popen(cpp_cmd,
122 stderr=subprocess.PIPE,122 stderr=subprocess.PIPE,
123 stdout=subprocess.PIPE)123 stdout=subprocess.PIPE,
124 universal_newlines=True)
124 assert proc, 'Proc was none'125 assert proc, 'Proc was none'
125 cpp_output = proc.stdout.read()126 cpp_output = proc.stdout.read()
126 err_output = proc.stderr.read()127 err_output = proc.stderr.read()
127 if err_output:128 if err_output:
128 print("Warning: preprocessor produced errors or warnings:\n%s" \129 print("Warning: preprocessor produced errors or warnings:\n%s" \
129 % err_output.decode('utf8'))130 % err_output)
130 if not cpp_output:131 if not cpp_output:
131 raise_msg = "preprocessor output is empty! Running command " \132 raise_msg = "preprocessor output is empty! Running command " \
132 + "\"%s\" failed" % " ".join(cpp_cmd)133 + "\"%s\" failed" % " ".join(cpp_cmd)
133 if err_output:134 if err_output:
134 raise_msg += " with stderr: \"%s\"" % err_output.decode('utf8')135 raise_msg += " with stderr: \"%s\"" % err_output
135 else:136 else:
136 raise_msg += " with no stdout or stderr"137 raise_msg += " with no stdout or stderr"
137 raise Exception(raise_msg)138 raise Exception(raise_msg)
138 if not isinstance(cpp_output, list):139 if not isinstance(cpp_output, list):
139 cpp_output = [l.strip() for l in cpp_output.decode('utf8').split('\n')]140 cpp_output = [l.strip() for l in cpp_output.split('\n')]
140 141
141 return cpp_output142 return cpp_output
142 143
python/tests/test_hztomel.py+14−5
@@ -4,23 +4,28 @@ from unittest import main · 3 unmodified lines
4from numpy.testing import TestCase4from numpy.testing import TestCase
5from numpy.testing import assert_equal, assert_almost_equal5from numpy.testing import assert_equal, assert_almost_equal
6from _tools import assert_warns6from _tools import assert_warns
7from utils import is32bit
7import numpy as np8import numpy as np
8import aubio9import aubio
9 10
10from aubio import hztomel, meltohz11from aubio import hztomel, meltohz
11from aubio import hztomel_htk, meltohz_htk12from aubio import hztomel_htk, meltohz_htk
12 13
13
14class aubio_hztomel_test_case(TestCase):14class aubio_hztomel_test_case(TestCase):
15 15
16 def test_hztomel(self):16 def test_hztomel(self):
17 assert_equal(hztomel(0.), 0.)17 assert_equal(hztomel(0.), 0.)
18 assert_almost_equal(hztomel(400. / 3.), 2., decimal=5)18 assert_almost_equal(hztomel(400. / 3.), 2., decimal=5)
19 assert_almost_equal(hztomel(1000. / 3), 5.)19 assert_almost_equal(hztomel(1000. / 3), 5.)
20 assert_equal(hztomel(200.), 3.)20 # on 32bit, some of these tests fails unless compiling with -ffloat-store
21 try:
22 assert_equal(hztomel(200.), 3.)
23 except AssertionError:
24 if not is32bit(): raise
25 assert_almost_equal(hztomel(200.), 3., decimal=5)
21 assert_almost_equal(hztomel(1000.), 15)26 assert_almost_equal(hztomel(1000.), 15)
22 assert_almost_equal(hztomel(6400), 42)27 assert_almost_equal(hztomel(6400), 42, decimal=5)
23 assert_almost_equal(hztomel(40960), 69)28 assert_almost_equal(hztomel(40960), 69, decimal=5)
24 29
25 for m in np.linspace(0, 1000, 100):30 for m in np.linspace(0, 1000, 100):
26 assert_almost_equal(hztomel(meltohz(m)) - m, 0, decimal=3)31 assert_almost_equal(hztomel(meltohz(m)) - m, 0, decimal=3)
@@ -28,7 +33,11 @@ class aubio_hztomel_test_case(TestCase): · 1 unmodified line
28 def test_meltohz(self):33 def test_meltohz(self):
29 assert_equal(meltohz(0.), 0.)34 assert_equal(meltohz(0.), 0.)
30 assert_almost_equal(meltohz(2), 400. / 3., decimal=4)35 assert_almost_equal(meltohz(2), 400. / 3., decimal=4)
31 assert_equal(meltohz(3.), 200.)36 try:
37 assert_equal(meltohz(3.), 200.)
38 except AssertionError:
39 if not is32bit(): raise
40 assert_almost_equal(meltohz(3.), 200., decimal=5)
32 assert_almost_equal(meltohz(5), 1000. / 3., decimal=4)41 assert_almost_equal(meltohz(5), 1000. / 3., decimal=4)
33 assert_almost_equal(meltohz(15), 1000., decimal=4)42 assert_almost_equal(meltohz(15), 1000., decimal=4)
34 assert_almost_equal(meltohz(42), 6400., decimal=2)43 assert_almost_equal(meltohz(42), 6400., decimal=2)
python/tests/test_phasevoc.py+2−2
@@ -1,7 +1,7 @@
1#! /usr/bin/env python1#! /usr/bin/env python
2 2
3from numpy.testing import TestCase, assert_equal, assert_array_less3from numpy.testing import TestCase, assert_equal, assert_array_less
4from _tools import parametrize4from _tools import parametrize, skipTest
5from aubio import fvec, cvec, pvoc, float_type5from aubio import fvec, cvec, pvoc, float_type
6import numpy as np6import numpy as np
7 7
@@ -51,7 +51,7 @@ class Test_aubio_pvoc_test_case(object): · 43 unmodified lines
51 assert_equal (s.phas[s.phas > 0], +np.pi)51 assert_equal (s.phas[s.phas > 0], +np.pi)
52 assert_equal (s.phas[s.phas < 0], -np.pi)52 assert_equal (s.phas[s.phas < 0], -np.pi)
53 assert_equal (np.abs(s.phas[np.abs(s.phas) != np.pi]), 0)53 assert_equal (np.abs(s.phas[np.abs(s.phas) != np.pi]), 0)
54 self.skipTest('pvoc(fvec(%d)).phas != +0, ' % win_s \54 skipTest('pvoc(fvec(%d)).phas != +0, ' % win_s \
55 + 'This is expected when using fftw3 on powerpc.')55 + 'This is expected when using fftw3 on powerpc.')
56 assert_equal ( r, 0.)56 assert_equal ( r, 0.)
57 57
python/tests/utils.py+4−0
@@ -3,11 +3,15 @@ · 2 unmodified lines
3import os3import os
4import re4import re
5import glob5import glob
6import struct
6import numpy as np7import numpy as np
7from tempfile import mkstemp8from tempfile import mkstemp
8 9
9DEFAULT_SOUND = '22050Hz_5s_brownnoise.wav'10DEFAULT_SOUND = '22050Hz_5s_brownnoise.wav'
10 11
12def is32bit():
13 return struct.calcsize("P") * 8 == 32
14
11def array_from_text_file(filename, dtype = 'float'):15def array_from_text_file(filename, dtype = 'float'):
12 realpathname = os.path.join(os.path.dirname(__file__), filename)16 realpathname = os.path.join(os.path.dirname(__file__), filename)
13 return np.loadtxt(realpathname, dtype = dtype)17 return np.loadtxt(realpathname, dtype = dtype)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t