ref: 4bc10e20d16aaaefc7d6b4942a666facddd8e090
parent: 357f81e2b95e86c7378fba81335b56a78ccee7b6
parent: cefa29d8bedf7cd205b18f793a487f9e6e1cd3d3
author: Paul Brossier <piem@piem.org>
date: Tue Oct 30 08:57:10 EDT 2018
Merge branch 'master' into feature/earlynoteoff
--- /dev/null
+++ b/.circleci/config.yml
@@ -1,0 +1,104 @@
+apt-run: &apt-install
+ name: Install apt packages
+ command: |
+ sudo apt-get update
+ sudo apt-get -y install make sox pkg-config libavcodec-dev libavformat-dev libavresample-dev libavutil-dev libsndfile1-dev libsamplerate-dev
+
+pip-install: &pip-install
+ name: Install pip dependencies
+ command: |
+ pip install --user -r requirements.txt
+
+build-wheel: &build-wheel
+ name: Build python wheel
+ command: |
+ pip wheel -v -v -v --wheel-dir=dist .
+
+install-wheel: &install-wheel
+ name: Install python wheel
+ command: |
+ pip install --user dist/aubio*.whl
+
+test-nose2: &test-nose2
+ name: Test python wheel
+ command: |
+ make create_test_sounds
+ PATH=/home/circleci/.local/bin:$PATH nose2 -v
+
+test-nose2-nosounds: &test-nose2-nosounds
+ name: Test python wheel
+ command: |
+ PATH=/home/circleci/.local/bin:$PATH nose2 -v
+
+uninstall-wheel: &uninstall-wheel
+ name: Uninstall python wheel
+ command: |
+ pip show -f aubio
+ pip uninstall --verbose --yes aubio
+
+version: 2
+jobs:
+ build-27:
+ docker:
+ - image: circleci/python:2.7
+ steps:
+ - checkout
+ - run: *apt-install
+ - run: *pip-install
+ - run: *build-wheel
+ - run: *install-wheel
+ - run: *test-nose2
+ - run: *uninstall-wheel
+ - store_artifacts:
+ path: dist/
+
+ build-36:
+ docker:
+ - image: circleci/python:3.6
+ steps:
+ - checkout
+ - run: *apt-install
+ - run: *pip-install
+ - run: *build-wheel
+ - run: *install-wheel
+ - run: *test-nose2
+ - run: *uninstall-wheel
+ - store_artifacts:
+ path: dist/
+
+ build-37:
+ docker:
+ - image: circleci/python:3.7
+ steps:
+ - checkout
+ - run: *apt-install
+ - run: *pip-install
+ - run: *build-wheel
+ - run: *install-wheel
+ - run: *test-nose2
+ - run: *uninstall-wheel
+ - store_artifacts:
+ path: dist/
+
+ build-37-nodeps:
+ docker:
+ - image: circleci/python:3.7
+ steps:
+ - checkout
+ - run: *pip-install
+ - run: *build-wheel
+ - run: *install-wheel
+ - run: *test-nose2-nosounds
+ - run: *uninstall-wheel
+ - store_artifacts:
+ path: dist/
+
+workflows:
+ version: 2
+
+ test-wheel:
+ jobs:
+ - build-27
+ - build-36
+ - build-37
+ - build-37-nodeps
--- /dev/null
+++ b/azure-pipelines.yml
@@ -1,0 +1,38 @@
+# configuration file for azure continuous integration
+jobs:
+
+- job: linux
+ pool:
+ vmImage: 'Ubuntu 16.04'
+ steps:
+ - script: |
+ make
+ displayName: 'make'
+ env:
+ CFLAGS: -Werror
+
+- job: windows
+ pool:
+ vmIMage: 'VS2017-Win2016'
+ steps:
+ - script: |
+ make
+ displayName: 'make'
+ env:
+ # fail on error
+ CFLAGS: /WX
+
+- job: macos
+ pool:
+ vmIMage: macOS-10.13
+ steps:
+ - script: |
+ brew update
+ brew install pkg-config gnupg
+ brew install sox ffmpeg libsndfile lcov
+ displayName: 'brew install'
+ - script: |
+ make
+ displayName: 'make'
+ env:
+ CFLAGS: -Werror
--- a/circle.yml
+++ /dev/null
@@ -1,9 +1,0 @@
-dependencies:
- pre:
- - sudo apt-get update; sudo apt-get install make sox pkg-config libavcodec-dev libavformat-dev libavresample-dev libavutil-dev libsndfile1-dev libsamplerate-dev
-
-test:
- pre:
- - make create_test_sounds
- override:
- - nose2 -v
--- a/doc/about.rst
+++ b/doc/about.rst
@@ -59,7 +59,7 @@
License
-------
-aubio is a `free <http://www.debian.org/intro/free>`_ and `open source
+aubio is a `free <https://www.debian.org/intro/free>`_ and `open source
<http://www.opensource.org/docs/definition.php>`_ software; **you** can
redistribute it and/or modify it under the terms of the `GNU
<https://www.gnu.org/>`_ `General Public License
--- a/doc/aubiomfcc.txt
+++ b/doc/aubiomfcc.txt
@@ -51,7 +51,7 @@
according to Malcolm Slaney's Auditory Toolbox, available at the following
url:
- http://cobweb.ecn.purdue.edu/~malcolm/interval/1998-010/ (see file mfcc.m)
+ https://engineering.purdue.edu/~malcolm/interval/1998-010/ (see file mfcc.m)
SEE ALSO
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -45,7 +45,7 @@
# General information about the project.
project = u'aubio'
-copyright = u'2016, Paul Brossier'
+copyright = u'2018, Paul Brossier'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
--- a/doc/python_module.rst
+++ b/doc/python_module.rst
@@ -79,4 +79,3 @@
.. _python demos folder: https://github.com/aubio/aubio/blob/master/python/demos
.. _demo_filter.py: https://github.com/aubio/aubio/blob/master/python/demos/demo_filter.py
.. _python tests: https://github.com/aubio/aubio/blob/master/python/tests
-
--- a/examples/parse_args.h
+++ b/examples/parse_args.h
@@ -65,8 +65,8 @@
// internal stuff
extern int blocks;
-extern fvec_t *ibuf;
-extern fvec_t *obuf;
+extern fvec_t *input_buffer;
+extern fvec_t *output_buffer;
const char *prog_name;
@@ -211,11 +211,11 @@
{NULL, 0, NULL, 0}
};
#endif /* HAVE_GETOPT_H */
- prog_name = argv[0];
+ // better safe than sorry
if (argc < 1) {
usage (stderr, 1);
- return -1;
}
+ prog_name = argv[0];
#ifdef HAVE_GETOPT_H
do {
next_option = getopt_long (argc, argv, options, long_options, NULL);
--- a/examples/utils.c
+++ b/examples/utils.c
@@ -63,8 +63,8 @@
// internal memory stuff
aubio_source_t *this_source = NULL;
aubio_sink_t *this_sink = NULL;
-fvec_t *ibuf;
-fvec_t *obuf;
+fvec_t *input_buffer;
+fvec_t *output_buffer;
smpl_t miditap_note = 69.;
smpl_t miditap_velo = 65.;
@@ -126,15 +126,15 @@
source_uri = "jack";
#endif /* HAVE_JACK */
}
- ibuf = new_fvec (hop_size);
- obuf = new_fvec (hop_size);
+ input_buffer = new_fvec (hop_size);
+ output_buffer = new_fvec (hop_size);
}
void examples_common_del (void)
{
- del_fvec (ibuf);
- del_fvec (obuf);
+ del_fvec (input_buffer);
+ del_fvec (output_buffer);
aubio_cleanup ();
fflush(stderr);
fflush(stdout);
@@ -166,14 +166,14 @@
blocks = 0;
do {
- aubio_source_do (this_source, ibuf, &read);
- process_func (ibuf, obuf);
+ aubio_source_do (this_source, input_buffer, &read);
+ process_func (input_buffer, output_buffer);
// print to console if verbose or no output given
if (verbose || sink_uri == NULL) {
print();
}
if (this_sink) {
- aubio_sink_do (this_sink, obuf, hop_size);
+ aubio_sink_do (this_sink, output_buffer, hop_size);
}
blocks++;
total_read += read;
--- a/python/demos/demo_bpm_extract.py
+++ b/python/demos/demo_bpm_extract.py
@@ -22,7 +22,7 @@
elif params.mode in ['default']:
pass
else:
- print("unknown mode {:s}".format(params.mode))
+ raise ValueError("unknown mode {:s}".format(params.mode))
# manual settings
if 'samplerate' in params:
samplerate = params.samplerate
@@ -69,9 +69,9 @@
parser = argparse.ArgumentParser()
parser.add_argument('-m', '--mode',
help="mode [default|fast|super-fast]",
- dest="mode")
+ dest="mode", default='default')
parser.add_argument('sources',
- nargs='*',
+ nargs='+',
help="input_files")
args = parser.parse_args()
for f in args.sources:
--- a/python/ext/aubiomodule.c
+++ b/python/ext/aubiomodule.c
@@ -117,7 +117,9 @@
smpl_t input, samplerate, fftsize;
smpl_t output;
- if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR , &input, &samplerate, &fftsize)) {
+ if (!PyArg_ParseTuple (args,
+ "" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR,
+ &input, &samplerate, &fftsize)) {
return NULL;
}
@@ -132,7 +134,9 @@
smpl_t input, samplerate, fftsize;
smpl_t output;
- if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR , &input, &samplerate, &fftsize)) {
+ if (!PyArg_ParseTuple (args,
+ "" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR,
+ &input, &samplerate, &fftsize)) {
return NULL;
}
@@ -147,7 +151,9 @@
smpl_t input, samplerate, fftsize;
smpl_t output;
- if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR, &input, &samplerate, &fftsize)) {
+ if (!PyArg_ParseTuple (args,
+ "" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR,
+ &input, &samplerate, &fftsize)) {
return NULL;
}
@@ -162,7 +168,9 @@
smpl_t input, samplerate, fftsize;
smpl_t output;
- if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR, &input, &samplerate, &fftsize)) {
+ if (!PyArg_ParseTuple (args,
+ "" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR,
+ &input, &samplerate, &fftsize)) {
return NULL;
}
--- a/python/ext/py-filterbank.c
+++ b/python/ext/py-filterbank.c
@@ -94,7 +94,7 @@
if (self->vec.length != self->win_s / 2 + 1) {
PyErr_Format(PyExc_ValueError,
- "input cvec has length %d, but fft expects length %d",
+ "input cvec has length %d, but filterbank expects length %d",
self->vec.length, self->win_s / 2 + 1);
return NULL;
}
@@ -139,7 +139,7 @@
&(self->freqs), samplerate);
if (err > 0) {
PyErr_SetString (PyExc_ValueError,
- "error when setting filter to A-weighting");
+ "error when running set_triangle_bands");
return NULL;
}
Py_RETURN_NONE;
@@ -158,7 +158,7 @@
err = aubio_filterbank_set_mel_coeffs_slaney (self->o, samplerate);
if (err > 0) {
PyErr_SetString (PyExc_ValueError,
- "error when setting filter to A-weighting");
+ "error when running set_mel_coeffs_slaney");
return NULL;
}
Py_RETURN_NONE;
--- a/python/lib/aubio/cmd.py
+++ b/python/lib/aubio/cmd.py
@@ -255,6 +255,9 @@
metavar = "<slices>",
action = "store", dest = "cut_until_nslices", default = None,
help="how many extra slices should be added at the end of each slice")
+ self.add_argument("--create-first",
+ action = "store_true", dest = "create_first", default = False,
+ help="always include first slice")
# some utilities
@@ -511,7 +514,24 @@
def main():
parser = aubio_parser()
- args = parser.parse_args()
+ if sys.version_info[0] != 3:
+ # on py2, create a dummy ArgumentParser to workaround the
+ # optional subcommand issue. See https://bugs.python.org/issue9253
+ # This ensures that:
+ # - version string is shown when only '-V' is passed
+ # - help is printed if '-V' is passed with any other argument
+ # - any other argument get forwarded to the real parser
+ parser_root = argparse.ArgumentParser(add_help=False)
+ parser_root.add_argument('-V', '--version', help="show version",
+ action="store_true", dest="show_version")
+ args, extras = parser_root.parse_known_args()
+ if args.show_version == False: # no -V, forward to parser
+ args = parser.parse_args(extras, namespace=args)
+ elif len(extras) != 0: # -V with other arguments, print help
+ parser.print_help()
+ sys.exit(1)
+ else: # in py3, we can simply use parser directly
+ args = parser.parse_args()
if 'show_version' in args and args.show_version:
sys.stdout.write('aubio version ' + aubio.version + '\n')
sys.exit(0)
--- a/python/lib/aubio/cut.py
+++ b/python/lib/aubio/cut.py
@@ -101,7 +101,7 @@
s = source(source_uri, samplerate, hopsize)
if samplerate == 0:
- samplerate = s.get_samplerate()
+ samplerate = s.samplerate
options.samplerate = samplerate
if options.beat:
@@ -150,7 +150,8 @@
slice_source_at_stamps(options.source_uri,
timestamps, timestamps_end = timestamps_end,
output_dir = options.output_directory,
- samplerate = options.samplerate)
+ samplerate = options.samplerate,
+ create_first = options.create_first)
def main():
parser = aubio_cut_parser()
--- a/python/lib/aubio/midiconv.py
+++ b/python/lib/aubio/midiconv.py
@@ -1,9 +1,11 @@
# -*- coding: utf-8 -*-
""" utilities to convert midi note number to and from note names """
-__all__ = ['note2midi', 'midi2note', 'freq2note']
+__all__ = ['note2midi', 'midi2note', 'freq2note', 'note2freq']
import sys
+from ._aubio import freqtomidi, miditofreq
+
py3 = sys.version_info[0] == 3
if py3:
str_instances = str
@@ -24,10 +26,11 @@
}
_valid_octaves = range(-1, 10)
if not isinstance(note, str_instances):
- raise TypeError("a string is required, got %s (%s)" % (note, str(type(note))))
+ msg = "a string is required, got {:s} ({:s})"
+ raise TypeError(msg.format(str(type(note)), repr(note)))
if len(note) not in range(2, 5):
- raise ValueError("string of 2 to 4 characters expected, got %d (%s)" \
- % (len(note), note))
+ msg = "string of 2 to 4 characters expected, got {:d} ({:s})"
+ raise ValueError(msg.format(len(note), note))
notename, modifier, octave = [None]*3
if len(note) == 4:
@@ -51,7 +54,8 @@
if octave not in _valid_octaves:
raise ValueError("%s is not a valid octave" % octave)
- midi = 12 + octave * 12 + _valid_notenames[notename] + _valid_modifiers[modifier]
+ midi = 12 + octave * 12 + _valid_notenames[notename] \
+ + _valid_modifiers[modifier]
if midi > 127:
raise ValueError("%s is outside of the range C-2 to G8" % note)
return midi
@@ -61,11 +65,36 @@
if not isinstance(midi, int_instances):
raise TypeError("an integer is required, got %s" % midi)
if midi not in range(0, 128):
- raise ValueError("an integer between 0 and 127 is excepted, got %d" % midi)
- _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
+ msg = "an integer between 0 and 127 is excepted, got {:d}"
+ raise ValueError(msg.format(midi))
+ _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#',
+ 'A', 'A#', 'B']
return _valid_notenames[midi % 12] + str(int(midi / 12) - 1)
def freq2note(freq):
" convert frequency in Hz to nearest note name, e.g. [0, 22050.] -> [C-1, G9] "
- from aubio import freqtomidi
- return midi2note(int(freqtomidi(freq)))
+ nearest_note = int(freqtomidi(freq) + .5)
+ return midi2note(nearest_note)
+
+def note2freq(note):
+ """Convert note name to corresponding frequency, in Hz.
+
+ Parameters
+ ----------
+ note : str
+ input note name
+
+ Returns
+ -------
+ freq : float [0, 23000[
+ frequency, in Hz
+
+ Example
+ -------
+ >>> aubio.note2freq('A4')
+ 440
+ >>> aubio.note2freq('A3')
+ 220.1
+ """
+ midi = note2midi(note)
+ return miditofreq(midi)
--- a/python/lib/aubio/slicing.py
+++ b/python/lib/aubio/slicing.py
@@ -6,19 +6,22 @@
_max_timestamp = 1e120
def slice_source_at_stamps(source_file, timestamps, timestamps_end=None,
- output_dir=None, samplerate=0, hopsize=256):
+ output_dir=None, samplerate=0, hopsize=256,
+ create_first=False):
""" slice a sound file at given timestamps """
if timestamps is None or len(timestamps) == 0:
raise ValueError("no timestamps given")
- if timestamps[0] != 0:
+ if timestamps[0] != 0 and create_first:
timestamps = [0] + timestamps
if timestamps_end is not None:
timestamps_end = [timestamps[1] - 1] + timestamps_end
if timestamps_end is not None:
- if len(timestamps_end) != len(timestamps):
+ if len(timestamps_end) == len(timestamps) - 1:
+ timestamps_end = timestamps_end + [_max_timestamp]
+ elif len(timestamps_end) != len(timestamps):
raise ValueError("len(timestamps_end) != len(timestamps)")
else:
timestamps_end = [t - 1 for t in timestamps[1:]] + [_max_timestamp]
@@ -48,7 +51,7 @@
# get hopsize new samples from source
vec, read = _source.do_multi()
# if the total number of frames read will exceed the next region start
- if len(regions) and total_frames + read >= regions[0][0]:
+ while len(regions) and total_frames + read >= regions[0][0]:
#print "getting", regions[0], "at", total_frames
# get next region
start_stamp, end_stamp = regions.pop(0)
@@ -75,7 +78,7 @@
if remaining > start:
# write remaining samples from current region
_sink.do_multi(vec[:, start:remaining], remaining - start)
- #print "closing region", "remaining", remaining
+ #print("closing region", "remaining", remaining)
# close this file
_sink.close()
elif read > start:
@@ -82,5 +85,8 @@
# write all the samples
_sink.do_multi(vec[:, start:read], read - start)
total_frames += read
+ # remove old slices
+ slices = list(filter(lambda s: s['end_stamp'] > total_frames,
+ slices))
if read < hopsize:
break
--- a/python/tests/test_aubio_cmd.py
+++ b/python/tests/test_aubio_cmd.py
@@ -19,13 +19,16 @@
class aubio_cmd_utils(TestCase):
def test_samples2seconds(self):
- self.assertEqual(aubio.cmd.samples2seconds(3200, 32000), "0.100000\t")
+ self.assertEqual(aubio.cmd.samples2seconds(3200, 32000),
+ "0.100000\t")
def test_samples2milliseconds(self):
- self.assertEqual(aubio.cmd.samples2milliseconds(3200, 32000), "100.000000\t")
+ self.assertEqual(aubio.cmd.samples2milliseconds(3200, 32000),
+ "100.000000\t")
def test_samples2samples(self):
- self.assertEqual(aubio.cmd.samples2samples(3200, 32000), "3200\t")
+ self.assertEqual(aubio.cmd.samples2samples(3200, 32000),
+ "3200\t")
if __name__ == '__main__':
main()
--- a/python/tests/test_note2midi.py
+++ b/python/tests/test_note2midi.py
@@ -3,7 +3,7 @@
from __future__ import unicode_literals
-from aubio import note2midi, freq2note
+from aubio import note2midi, freq2note, note2freq, float_type
from nose2.tools import params
import unittest
@@ -111,9 +111,26 @@
class freq2note_simple_test(unittest.TestCase):
- def test_freq2note(self):
+ def test_freq2note_above(self):
" make sure freq2note(441) == A4 "
self.assertEqual("A4", freq2note(441))
+
+ def test_freq2note_under(self):
+ " make sure freq2note(439) == A4 "
+ self.assertEqual("A4", freq2note(439))
+
+class note2freq_simple_test(unittest.TestCase):
+
+ def test_note2freq(self):
+ " make sure note2freq('A3') == 220"
+ self.assertEqual(220, note2freq("A3"))
+
+ def test_note2freq_under(self):
+ " make sure note2freq(A4) == 440"
+ if float_type == 'float32':
+ self.assertEqual(440, note2freq("A4"))
+ else:
+ self.assertLess(abs(note2freq("A4")-440), 1.e-12)
if __name__ == '__main__':
import nose2
--- a/python/tests/test_slicing.py
+++ b/python/tests/test_slicing.py
@@ -23,19 +23,27 @@
def test_slice_start_only_no_zero(self):
regions_start = [i*1000 for i in range(1, n_slices)]
- slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir)
+ slice_source_at_stamps(self.source_file, regions_start,
+ output_dir = self.output_dir, create_first=True)
def test_slice_start_beyond_end(self):
regions_start = [i*1000 for i in range(1, n_slices)]
regions_start += [count_samples_in_file(self.source_file) + 1000]
- slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir)
+ slice_source_at_stamps(self.source_file, regions_start,
+ output_dir = self.output_dir, create_first=True)
def test_slice_start_every_blocksize(self):
hopsize = 200
- regions_start = [i*hopsize for i in range(1, n_slices)]
+ regions_start = [i*hopsize for i in range(0, n_slices)]
slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir,
hopsize = 200)
+ def test_slice_start_every_half_blocksize(self):
+ hopsize = 200
+ regions_start = [i*hopsize//2 for i in range(0, n_slices)]
+ slice_source_at_stamps(self.source_file, regions_start,
+ output_dir = self.output_dir, hopsize = 200)
+
def tearDown(self):
original_samples = count_samples_in_file(self.source_file)
written_samples = count_samples_in_directory(self.output_dir)
@@ -91,6 +99,19 @@
assert_equal(written_samples, expected_samples,
"number of samples written different from number of original samples")
+ def test_slice_start_and_ends_with_missing_end(self):
+ regions_start = [i*1000 for i in range(n_slices)]
+ regions_ends = [r-1 for r in regions_start[1:]]
+ slice_source_at_stamps(self.source_file, regions_start, regions_ends,
+ output_dir = self.output_dir)
+ written_samples = count_samples_in_directory(self.output_dir)
+ original_samples = count_samples_in_file(self.source_file)
+ total_files = count_files_in_directory(self.output_dir)
+ assert_equal(n_slices, total_files,
+ "number of slices created different from expected")
+ assert_equal(written_samples, original_samples,
+ "number of samples written different from number of original samples")
+
def tearDown(self):
shutil.rmtree(self.output_dir)
@@ -133,7 +154,7 @@
regions_start = [i*1000 for i in range(1, n_slices)]
regions_end = None
slice_source_at_stamps (self.source_file, regions_start, regions_end,
- output_dir = self.output_dir)
+ output_dir = self.output_dir, create_first=True)
total_files = count_files_in_directory(self.output_dir)
assert_equal(n_slices, total_files,
"number of slices created different from expected")
--- a/src/io/source_avcodec.c
+++ b/src/io/source_avcodec.c
@@ -34,7 +34,7 @@
// determine whether we use libavformat from ffmpeg or from libav
#define FFMPEG_LIBAVFORMAT (LIBAVFORMAT_VERSION_MICRO > 99 )
-// max_analyze_duration2 was used from ffmpeg libavformat 55.43.100 through 57.2.100
+// max_analyze_duration2 was used from ffmpeg libavformat 55.43.100 -> 57.2.100
#define FFMPEG_LIBAVFORMAT_MAX_DUR2 FFMPEG_LIBAVFORMAT && ( \
(LIBAVFORMAT_VERSION_MAJOR == 55 && LIBAVFORMAT_VERSION_MINOR >= 43) \
|| (LIBAVFORMAT_VERSION_MAJOR == 56) \
@@ -92,9 +92,12 @@
uint_t multi;
};
-// hack to create or re-create the context the first time _do or _do_multi is called
-void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s, uint_t multi);
-void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s, uint_t * read_samples);
+// create or re-create the context when _do or _do_multi is called
+void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s,
+ uint_t multi);
+// actually read a frame
+void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s,
+ uint_t * read_samples);
uint_t aubio_source_avcodec_has_network_url(aubio_source_avcodec_t *s);
@@ -111,7 +114,8 @@
}
-aubio_source_avcodec_t * new_aubio_source_avcodec(const char_t * path, uint_t samplerate, uint_t hop_size) {
+aubio_source_avcodec_t * new_aubio_source_avcodec(const char_t * path,
+ uint_t samplerate, uint_t hop_size) {
aubio_source_avcodec_t * s = AUBIO_NEW(aubio_source_avcodec_t);
AVFormatContext *avFormatCtx = s->avFormatCtx;
AVCodecContext *avCodecCtx = s->avCodecCtx;
@@ -128,11 +132,13 @@
goto beach;
}
if ((sint_t)samplerate < 0) {
- AUBIO_ERR("source_avcodec: Can not open %s with samplerate %d\n", path, samplerate);
+ AUBIO_ERR("source_avcodec: Can not open %s with samplerate %d\n",
+ path, samplerate);
goto beach;
}
if ((sint_t)hop_size <= 0) {
- AUBIO_ERR("source_avcodec: Can not open %s with hop_size %d\n", path, hop_size);
+ AUBIO_ERR("source_avcodec: Can not open %s with hop_size %d\n",
+ path, hop_size);
goto beach;
}
@@ -172,8 +178,8 @@
if ( (err = avformat_find_stream_info(avFormatCtx, NULL)) < 0 ) {
char errorstr[256];
av_strerror (err, errorstr, sizeof(errorstr));
- AUBIO_ERR("source_avcodec: Could not find stream information " "for %s (%s)\n", s->path,
- errorstr);
+ AUBIO_ERR("source_avcodec: Could not find stream information "
+ "for %s (%s)\n", s->path, errorstr);
goto beach;
}
@@ -213,8 +219,9 @@
/* Allocate a codec context for the decoder */
avCodecCtx = avcodec_alloc_context3(codec);
if (!avCodecCtx) {
- AUBIO_ERR("source_avcodec: Failed to allocate the %s codec context for path %s\n",
- av_get_media_type_string(AVMEDIA_TYPE_AUDIO), s->path);
+ AUBIO_ERR("source_avcodec: Failed to allocate the %s codec context "
+ "for path %s\n", av_get_media_type_string(AVMEDIA_TYPE_AUDIO),
+ s->path);
goto beach;
}
#else
@@ -229,8 +236,9 @@
#if FF_API_LAVF_AVCTX
/* Copy codec parameters from input stream to output codec context */
if ((err = avcodec_parameters_to_context(avCodecCtx, codecpar)) < 0) {
- AUBIO_ERR("source_avcodec: Failed to copy %s codec parameters to decoder context for %s\n",
- av_get_media_type_string(AVMEDIA_TYPE_AUDIO), s->path);
+ AUBIO_ERR("source_avcodec: Failed to copy %s codec parameters to "
+ "decoder context for %s\n",
+ av_get_media_type_string(AVMEDIA_TYPE_AUDIO), s->path);
goto beach;
}
#endif
@@ -238,7 +246,8 @@
if ( ( err = avcodec_open2(avCodecCtx, codec, NULL) ) < 0) {
char errorstr[256];
av_strerror (err, errorstr, sizeof(errorstr));
- AUBIO_ERR("source_avcodec: Could not load codec for %s (%s)\n", s->path, errorstr);
+ AUBIO_ERR("source_avcodec: Could not load codec for %s (%s)\n", s->path,
+ errorstr);
goto beach;
}
@@ -265,7 +274,8 @@
}
/* allocate output for avr */
- s->output = (smpl_t *)av_malloc(AUBIO_AVCODEC_MAX_BUFFER_SIZE * sizeof(smpl_t));
+ s->output = (smpl_t *)av_malloc(AUBIO_AVCODEC_MAX_BUFFER_SIZE
+ * sizeof(smpl_t));
s->read_samples = 0;
s->read_index = 0;
@@ -293,7 +303,9 @@
return NULL;
}
-void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s, uint_t multi) {
+void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s,
+ uint_t multi)
+{
// create or reset resampler to/from mono/multi-channel
if ( (multi != s->multi) || (s->avr == NULL) ) {
int err;
@@ -308,15 +320,15 @@
SwrContext *oldavr = s->avr;
#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
- av_opt_set_int(avr, "in_channel_layout", input_layout, 0);
- av_opt_set_int(avr, "out_channel_layout", output_layout, 0);
- av_opt_set_int(avr, "in_sample_rate", s->input_samplerate, 0);
- av_opt_set_int(avr, "out_sample_rate", s->samplerate, 0);
+ av_opt_set_int(avr, "in_channel_layout", input_layout, 0);
+ av_opt_set_int(avr, "out_channel_layout", output_layout, 0);
+ av_opt_set_int(avr, "in_sample_rate", s->input_samplerate, 0);
+ av_opt_set_int(avr, "out_sample_rate", s->samplerate, 0);
av_opt_set_int(avr, "in_sample_fmt", s->avCodecCtx->sample_fmt, 0);
#if HAVE_AUBIO_DOUBLE
- av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_DBL, 0);
+ av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_DBL, 0);
#else
- av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_FLT, 0);
+ av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_FLT, 0);
#endif
// TODO: use planar?
//av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_FLTP, 0);
@@ -328,8 +340,8 @@
{
char errorstr[256];
av_strerror (err, errorstr, sizeof(errorstr));
- AUBIO_ERR("source_avcodec: Could not open resampling context for %s (%s)\n",
- s->path, errorstr);
+ AUBIO_ERR("source_avcodec: Could not open resampling context"
+ " for %s (%s)\n", s->path, errorstr);
return;
}
s->avr = avr;
@@ -346,7 +358,9 @@
}
}
-void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s, uint_t * read_samples) {
+void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s,
+ uint_t * read_samples)
+{
AVFormatContext *avFormatCtx = s->avFormatCtx;
AVCodecContext *avCodecCtx = s->avCodecCtx;
AVFrame *avFrame = s->avFrame;
@@ -387,7 +401,8 @@
if (err != 0) {
char errorstr[256];
av_strerror (err, errorstr, sizeof(errorstr));
- AUBIO_ERR("source_avcodec: could not read frame in %s (%s)\n", s->path, errorstr);
+ AUBIO_ERR("source_avcodec: could not read frame in %s (%s)\n",
+ s->path, errorstr);
s->eof = 1;
goto beach;
}
@@ -405,10 +420,12 @@
}
if (ret < 0) {
if (ret == AVERROR(EAGAIN)) {
- //AUBIO_WRN("source_avcodec: output is not available right now - user must try to send new input\n");
+ //AUBIO_WRN("source_avcodec: output is not available right now - "
+ // "user must try to send new input\n");
goto beach;
} else if (ret == AVERROR_EOF) {
- AUBIO_WRN("source_avcodec: the decoder has been fully flushed, and there will be no more output frames\n");
+ AUBIO_WRN("source_avcodec: the decoder has been fully flushed, "
+ "and there will be no more output frames\n");
} else {
AUBIO_ERR("source_avcodec: decoding errors on %s\n", s->path);
goto beach;
@@ -423,7 +440,8 @@
}
#endif
if (got_frame == 0) {
- AUBIO_WRN("source_avcodec: did not get a frame when reading %s\n", s->path);
+ AUBIO_WRN("source_avcodec: did not get a frame when reading %s\n",
+ s->path);
goto beach;
}
@@ -430,10 +448,12 @@
#if LIBAVUTIL_VERSION_MAJOR > 52
if (avFrame->channels != (sint_t)s->input_channels) {
AUBIO_WRN ("source_avcodec: trying to read from %d channel(s),"
- "but configured for %d; is '%s' corrupt?\n", avFrame->channels,
- s->input_channels, s->path);
+ "but configured for %d; is '%s' corrupt?\n",
+ avFrame->channels, s->input_channels, s->path);
goto beach;
}
+#else
+#warning "avutil < 53 is deprecated, crashes might occur on corrupt files"
#endif
#ifdef HAVE_AVRESAMPLE
@@ -454,7 +474,8 @@
(const uint8_t **)avFrame->data, in_samples);
#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
if (out_samples <= 0) {
- AUBIO_WRN("source_avcodec: no sample found while converting frame (%s)\n", s->path);
+ AUBIO_WRN("source_avcodec: no sample found while converting frame (%s)\n",
+ s->path);
goto beach;
}
@@ -472,7 +493,8 @@
av_packet_unref(&avPacket);
}
-void aubio_source_avcodec_do(aubio_source_avcodec_t * s, fvec_t * read_data, uint_t * read){
+void aubio_source_avcodec_do(aubio_source_avcodec_t * s, fvec_t * read_data,
+ uint_t * read) {
uint_t i;
uint_t end = 0;
uint_t total_wrote = 0;
@@ -504,7 +526,8 @@
*read = total_wrote;
}
-void aubio_source_avcodec_do_multi(aubio_source_avcodec_t * s, fmat_t * read_data, uint_t * read){
+void aubio_source_avcodec_do_multi(aubio_source_avcodec_t * s,
+ fmat_t * read_data, uint_t * read) {
uint_t i,j;
uint_t end = 0;
uint_t total_wrote = 0;
@@ -550,7 +573,8 @@
}
uint_t aubio_source_avcodec_seek (aubio_source_avcodec_t * s, uint_t pos) {
- int64_t resampled_pos = (uint_t)ROUND(pos * (s->input_samplerate * 1. / s->samplerate));
+ int64_t resampled_pos =
+ (uint_t)ROUND(pos * (s->input_samplerate * 1. / s->samplerate));
int64_t min_ts = MAX(resampled_pos - 2000, 0);
int64_t max_ts = MIN(resampled_pos + 2000, INT64_MAX);
int seek_flags = AVSEEK_FLAG_FRAME | AVSEEK_FLAG_ANY;
@@ -558,7 +582,8 @@
if (s->avFormatCtx != NULL && s->avr != NULL) {
ret = AUBIO_OK;
} else {
- AUBIO_ERR("source_avcodec: failed seeking in %s (file not opened?)", s->path);
+ AUBIO_ERR("source_avcodec: failed seeking in %s (file not opened?)",
+ s->path);
return ret;
}
if ((sint_t)pos < 0) {
@@ -569,7 +594,8 @@
ret = avformat_seek_file(s->avFormatCtx, s->selected_stream,
min_ts, resampled_pos, max_ts, seek_flags);
if (ret < 0) {
- AUBIO_ERR("source_avcodec: failed seeking to %d in file %s", pos, s->path);
+ AUBIO_ERR("source_avcodec: failed seeking to %d in file %s",
+ pos, s->path);
}
// reset read status
s->eof = 0;
--- a/src/mathutils.c
+++ b/src/mathutils.c
@@ -522,7 +522,7 @@
if (freq < 2. || freq > 100000.) return 0.; // avoid nans and infs
/* log(freq/A-2)/log(2) */
midi = freq / 6.875;
- midi = LOG (midi) / 0.69314718055995;
+ midi = LOG (midi) / 0.6931471805599453;
midi *= 12;
midi -= 3;
return midi;
@@ -534,7 +534,7 @@
smpl_t freq;
if (midi > 140.) return 0.; // avoid infs
freq = (midi + 3.) / 12.;
- freq = EXP (freq * 0.69314718055995);
+ freq = EXP (freq * 0.6931471805599453);
freq *= 6.875;
return freq;
}
--- a/src/spectral/filterbank_mel.h
+++ b/src/spectral/filterbank_mel.h
@@ -58,8 +58,9 @@
\param samplerate audio sampling rate
The filter coefficients are built according to Malcolm Slaney's Auditory
- Toolbox, available at http://engineering.purdue.edu/~malcolm/interval/1998-010/
- (see file mfcc.m).
+ Toolbox, available online at the following address (see file mfcc.m):
+
+ https://engineering.purdue.edu/~malcolm/interval/1998-010/
*/
uint_t aubio_filterbank_set_mel_coeffs_slaney (aubio_filterbank_t * fb,
--- a/src/spectral/mfcc.h
+++ b/src/spectral/mfcc.h
@@ -26,9 +26,10 @@
This object computes MFCC coefficients on an input cvec_t.
The implementation follows the specifications established by Malcolm Slaney
- in its Auditory Toolbox, available online (see file mfcc.m).
+ in its Auditory Toolbox, available online at the following address (see
+ file mfcc.m):
- http://engineering.ecn.purdue.edu/~malcolm/interval/1998-010/
+ https://engineering.purdue.edu/~malcolm/interval/1998-010/
\example spectral/test-mfcc.c
--- a/src/spectral/phasevoc.c
+++ b/src/spectral/phasevoc.c
@@ -212,3 +212,13 @@
for (i = 0; i < pv->end; i++)
synthold[i] += synth[i + pv->hop_s] * pv->scale;
}
+
+uint_t aubio_pvoc_get_win(aubio_pvoc_t* pv)
+{
+ return pv->win_s;
+}
+
+uint_t aubio_pvoc_get_hop(aubio_pvoc_t* pv)
+{
+ return pv->hop_s;
+}
--- a/src/spectral/phasevoc.h
+++ b/src/spectral/phasevoc.h
@@ -88,6 +88,7 @@
*/
uint_t aubio_pvoc_get_win(aubio_pvoc_t* pv);
+
/** get hop size
\param pv phase vocoder to get the hop size from
--- a/src/synth/wavetable.c
+++ b/src/synth/wavetable.c
@@ -164,7 +164,7 @@
//aubio_wavetable_set_freq (s, 0.);
aubio_wavetable_set_amp (s, 0.);
//s->last_pos = 0;
- return aubio_wavetable_set_playing (s, 1);
+ return aubio_wavetable_set_playing (s, 0);
}
uint_t aubio_wavetable_set_freq ( aubio_wavetable_t * s, smpl_t freq )
--- a/src/synth/wavetable.h
+++ b/src/synth/wavetable.h
@@ -51,16 +51,6 @@
*/
aubio_wavetable_t * new_aubio_wavetable(uint_t samplerate, uint_t hop_size);
-/** load source in wavetable
-
- \param o wavetable, created by new_aubio_wavetable()
- \param uri the uri of the source to load
-
- \return 0 if successful, non-zero otherwise
-
-*/
-uint_t aubio_wavetable_load( aubio_wavetable_t * o, const char_t * uri );
-
/** process wavetable function
\param o wavetable, created by new_aubio_wavetable()
--- a/wscript
+++ b/wscript
@@ -605,5 +605,6 @@
ctx.excl += ' **/.travis.yml'
ctx.excl += ' **/.landscape.yml'
ctx.excl += ' **/.appveyor.yml'
- ctx.excl += ' **/circle.yml'
+ ctx.excl += ' **/.circleci/*'
+ ctx.excl += ' **/azure-pipelines.yml'
ctx.excl += ' **/.coveragerc'