ref: 38a965e3372e64c68870b4fa09d14d819deb9ffc
parent: 5e56bbdb87746397a19d2ba581fb6d859046413d
parent: c3e98d76d6794bdf6b683272ea857af58ef857ae
author: Paul Brossier <piem@piem.org>
date: Sat Sep 16 13:41:35 EDT 2017
Merge branch 'master' into coveralls
--- a/python/lib/aubio/cmd.py
+++ b/python/lib/aubio/cmd.py
@@ -20,6 +20,7 @@
action="store_true", dest="show_version")
subparsers = parser.add_subparsers(title='commands', dest='command',
+ parser_class= AubioArgumentParser,
metavar="")
parser_add_subcommand_help(subparsers)
@@ -32,6 +33,7 @@
parser_add_subcommand_mfcc(subparsers)
parser_add_subcommand_melbands(subparsers)
parser_add_subcommand_quiet(subparsers)
+ parser_add_subcommand_cut(subparsers)
return parser
@@ -46,16 +48,16 @@
subparser = subparsers.add_parser('onset',
help='estimate time of onsets (beginning of sound event)',
formatter_class = argparse.ArgumentDefaultsHelpFormatter)
- parser_add_input(subparser)
- parser_add_buf_hop_size(subparser)
+ subparser.add_input()
+ subparser.add_buf_hop_size()
helpstr = "onset novelty function"
helpstr += " <default|energy|hfc|complex|phase|specdiff|kl|mkl|specflux>"
- parser_add_method(subparser, helpstr=helpstr)
- parser_add_threshold(subparser)
- parser_add_silence(subparser)
- parser_add_minioi(subparser)
- parser_add_time_format(subparser)
- parser_add_verbose_help(subparser)
+ subparser.add_method(helpstr=helpstr)
+ subparser.add_threshold()
+ subparser.add_silence()
+ subparser.add_minioi()
+ subparser.add_time_format()
+ subparser.add_verbose_help()
subparser.set_defaults(process=process_onset)
def parser_add_subcommand_pitch(subparsers):
@@ -62,15 +64,15 @@
# pitch subcommand
subparser = subparsers.add_parser('pitch',
help='estimate fundamental frequency (monophonic)')
- parser_add_input(subparser)
- parser_add_buf_hop_size(subparser, buf_size=2048)
+ subparser.add_input()
+ subparser.add_buf_hop_size(buf_size=2048)
helpstr = "pitch detection method <default|yinfft|yin|mcomb|fcomb|schmitt>"
- parser_add_method(subparser, helpstr=helpstr)
- parser_add_threshold(subparser)
- parser_add_pitch_unit(subparser)
- parser_add_silence(subparser)
- parser_add_time_format(subparser)
- parser_add_verbose_help(subparser)
+ subparser.add_method(helpstr=helpstr)
+ subparser.add_threshold()
+ subparser.add_pitch_unit()
+ subparser.add_silence()
+ subparser.add_time_format()
+ subparser.add_verbose_help()
subparser.set_defaults(process=process_pitch)
def parser_add_subcommand_beat(subparsers):
@@ -77,10 +79,10 @@
# beat subcommand
subparser = subparsers.add_parser('beat',
help='estimate location of beats')
- parser_add_input(subparser)
- parser_add_buf_hop_size(subparser, buf_size=1024, hop_size=512)
- parser_add_time_format(subparser)
- parser_add_verbose_help(subparser)
+ subparser.add_input()
+ subparser.add_buf_hop_size(buf_size=1024, hop_size=512)
+ subparser.add_time_format()
+ subparser.add_verbose_help()
subparser.set_defaults(process=process_beat)
def parser_add_subcommand_tempo(subparsers):
@@ -87,10 +89,10 @@
# tempo subcommand
subparser = subparsers.add_parser('tempo',
help='estimate overall tempo in bpm')
- parser_add_input(subparser)
- parser_add_buf_hop_size(subparser, buf_size=1024, hop_size=512)
- parser_add_time_format(subparser)
- parser_add_verbose_help(subparser)
+ subparser.add_input()
+ subparser.add_buf_hop_size(buf_size=1024, hop_size=512)
+ subparser.add_time_format()
+ subparser.add_verbose_help()
subparser.set_defaults(process=process_tempo)
def parser_add_subcommand_notes(subparsers):
@@ -97,10 +99,10 @@
# notes subcommand
subparser = subparsers.add_parser('notes',
help='estimate midi-like notes (monophonic)')
- parser_add_input(subparser)
- parser_add_buf_hop_size(subparser)
- parser_add_time_format(subparser)
- parser_add_verbose_help(subparser)
+ subparser.add_input()
+ subparser.add_buf_hop_size()
+ subparser.add_time_format()
+ subparser.add_verbose_help()
subparser.set_defaults(process=process_notes)
def parser_add_subcommand_mfcc(subparsers):
@@ -107,10 +109,10 @@
# mfcc subcommand
subparser = subparsers.add_parser('mfcc',
help='extract Mel-Frequency Cepstrum Coefficients')
- parser_add_input(subparser)
- parser_add_buf_hop_size(subparser)
- parser_add_time_format(subparser)
- parser_add_verbose_help(subparser)
+ subparser.add_input()
+ subparser.add_buf_hop_size()
+ subparser.add_time_format()
+ subparser.add_verbose_help()
subparser.set_defaults(process=process_mfcc)
def parser_add_subcommand_melbands(subparsers):
@@ -117,10 +119,10 @@
# melbands subcommand
subparser = subparsers.add_parser('melbands',
help='extract energies in Mel-frequency bands')
- parser_add_input(subparser)
- parser_add_buf_hop_size(subparser)
- parser_add_time_format(subparser)
- parser_add_verbose_help(subparser)
+ subparser.add_input()
+ subparser.add_buf_hop_size()
+ subparser.add_time_format()
+ subparser.add_verbose_help()
subparser.set_defaults(process=process_melbands)
def parser_add_subcommand_quiet(subparsers):
@@ -127,88 +129,125 @@
# quiet subcommand
subparser = subparsers.add_parser('quiet',
help='extract timestamps of quiet and loud regions')
- parser_add_input(subparser)
- parser_add_hop_size(subparser)
- parser_add_silence(subparser)
- parser_add_time_format(subparser)
- parser_add_verbose_help(subparser)
+ subparser.add_input()
+ subparser.add_hop_size()
+ subparser.add_silence()
+ subparser.add_time_format()
+ subparser.add_verbose_help()
subparser.set_defaults(process=process_quiet)
-def parser_add_input(parser):
- parser.add_argument("source_uri", default=None, nargs='?',
- help="input sound file to analyse", metavar = "<source_uri>")
- parser.add_argument("-i", "--input", dest = "source_uri2",
- help="input sound file to analyse", metavar = "<source_uri>")
- parser.add_argument("-r", "--samplerate",
- metavar = "<freq>", type=int,
- action="store", dest="samplerate", default=0,
- help="samplerate at which the file should be represented")
+def parser_add_subcommand_cut(subparsers):
+ # quiet subcommand
+ subparser = subparsers.add_parser('cut',
+ help='slice at timestamps')
+ subparser.add_input()
+ helpstr = "onset novelty function"
+ helpstr += " <default|energy|hfc|complex|phase|specdiff|kl|mkl|specflux>"
+ subparser.add_method(helpstr=helpstr)
+ subparser.add_buf_hop_size()
+ subparser.add_silence()
+ subparser.add_threshold(default=0.3)
+ subparser.add_minioi()
+ subparser.add_slicer_options()
+ subparser.add_time_format()
+ subparser.add_verbose_help()
+ subparser.set_defaults(process=process_cut)
-def parser_add_verbose_help(parser):
- parser.add_argument("-v","--verbose",
- action="count", dest="verbose", default=1,
- help="make lots of noise [default]")
- parser.add_argument("-q","--quiet",
- action="store_const", dest="verbose", const=0,
- help="be quiet")
+class AubioArgumentParser(argparse.ArgumentParser):
-def parser_add_buf_hop_size(parser, buf_size=512, hop_size=256):
- parser_add_buf_size(parser, buf_size=buf_size)
- parser_add_hop_size(parser, hop_size=hop_size)
+ def add_input(self):
+ self.add_argument("source_uri", default=None, nargs='?',
+ help="input sound file to analyse", metavar = "<source_uri>")
+ self.add_argument("-i", "--input", dest = "source_uri2",
+ help="input sound file to analyse", metavar = "<source_uri>")
+ self.add_argument("-r", "--samplerate",
+ metavar = "<freq>", type=int,
+ action="store", dest="samplerate", default=0,
+ help="samplerate at which the file should be represented")
-def parser_add_buf_size(parser, buf_size=512):
- parser.add_argument("-B","--bufsize",
- action="store", dest="buf_size", default=buf_size,
- metavar = "<size>", type=int,
- help="buffer size [default=%d]" % buf_size)
+ def add_verbose_help(self):
+ self.add_argument("-v","--verbose",
+ action="count", dest="verbose", default=1,
+ help="make lots of noise [default]")
+ self.add_argument("-q","--quiet",
+ action="store_const", dest="verbose", const=0,
+ help="be quiet")
-def parser_add_hop_size(parser, hop_size=256):
- parser.add_argument("-H","--hopsize",
- metavar = "<size>", type=int,
- action="store", dest="hop_size", default=hop_size,
- help="overlap size [default=%d]" % hop_size)
+ def add_buf_hop_size(self, buf_size=512, hop_size=256):
+ self.add_buf_size(buf_size=buf_size)
+ self.add_hop_size(hop_size=hop_size)
-def parser_add_method(parser, method='default', helpstr='method'):
- parser.add_argument("-m","--method",
- metavar = "<method>", type=str,
- action="store", dest="method", default=method,
- help="%s [default=%s]" % (helpstr, method))
+ def add_buf_size(self, buf_size=512):
+ self.add_argument("-B","--bufsize",
+ action="store", dest="buf_size", default=buf_size,
+ metavar = "<size>", type=int,
+ help="buffer size [default=%d]" % buf_size)
-def parser_add_threshold(parser, default=None):
- parser.add_argument("-t","--threshold",
- metavar = "<threshold>", type=float,
- action="store", dest="threshold", default=default,
- help="threshold [default=%s]" % default)
+ def add_hop_size(self, hop_size=256):
+ self.add_argument("-H","--hopsize",
+ metavar = "<size>", type=int,
+ action="store", dest="hop_size", default=hop_size,
+ help="overlap size [default=%d]" % hop_size)
+
+ def add_method(self, method='default', helpstr='method'):
+ self.add_argument("-m","--method",
+ metavar = "<method>", type=str,
+ action="store", dest="method", default=method,
+ help="%s [default=%s]" % (helpstr, method))
-def parser_add_silence(parser):
- parser.add_argument("-s", "--silence",
- metavar = "<value>", type=float,
- action="store", dest="silence", default=-70,
- help="silence threshold")
+ def add_threshold(self, default=None):
+ self.add_argument("-t","--threshold",
+ metavar = "<threshold>", type=float,
+ action="store", dest="threshold", default=default,
+ help="threshold [default=%s]" % default)
-def parser_add_minioi(parser):
- parser.add_argument("-M", "--minioi",
- metavar = "<value>", type=str,
- action="store", dest="minioi", default="12ms",
- help="minimum Inter-Onset Interval")
+ def add_silence(self):
+ self.add_argument("-s", "--silence",
+ metavar = "<value>", type=float,
+ action="store", dest="silence", default=-70,
+ help="silence threshold")
-def parser_add_pitch_unit(parser, default="Hz"):
- help_str = "frequency unit, should be one of Hz, midi, bin, cent"
- help_str += " [default=%s]" % default
- parser.add_argument("-u", "--pitch-unit",
- metavar = "<value>", type=str,
- action="store", dest="pitch_unit", default=default,
- help=help_str)
+ def add_minioi(self, default="12ms"):
+ self.add_argument("-M", "--minioi",
+ metavar = "<value>", type=str,
+ action="store", dest="minioi", default=default,
+ help="minimum Inter-Onset Interval [default=%s]" % default)
-def parser_add_time_format(parser):
- helpstr = "select time values output format (samples, ms, seconds)"
- helpstr += " [default=seconds]"
- parser.add_argument("-T", "--time-format",
- metavar='format',
- dest="time_format",
- default=None,
- help=helpstr)
+ def add_pitch_unit(self, default="Hz"):
+ help_str = "frequency unit, should be one of Hz, midi, bin, cent"
+ help_str += " [default=%s]" % default
+ self.add_argument("-u", "--pitch-unit",
+ metavar = "<value>", type=str,
+ action="store", dest="pitch_unit", default=default,
+ help=help_str)
+ def add_time_format(self):
+ helpstr = "select time values output format (samples, ms, seconds)"
+ helpstr += " [default=seconds]"
+ self.add_argument("-T", "--time-format",
+ metavar='format',
+ dest="time_format",
+ default=None,
+ help=helpstr)
+
+ def add_slicer_options(self):
+ self.add_argument("-o","--output", type = str,
+ metavar = "<outputdir>",
+ action="store", dest="output_directory", default=None,
+ help="specify path where slices of the original file should be created")
+ self.add_argument("--cut-until-nsamples", type = int,
+ metavar = "<samples>",
+ action = "store", dest = "cut_until_nsamples", default = None,
+ help="how many extra samples should be added at the end of each slice")
+ self.add_argument("--cut-every-nslices", type = int,
+ metavar = "<samples>",
+ action = "store", dest = "cut_every_nslices", default = None,
+ help="how many slices should be groupped together at each cut")
+ self.add_argument("--cut-until-nslices", type = int,
+ metavar = "<slices>",
+ action = "store", dest = "cut_until_nslices", default = None,
+ help="how many extra slices should be added at the end of each slice")
+
# some utilities
def samples2seconds(n_frames, samplerate):
@@ -435,6 +474,28 @@
if fmt_out is not None:
fmt_out += self.time2string(frames_read, samplerate)
sys.stdout.write(fmt_out + '\n')
+
+class process_cut(process_onset):
+ def __init__(self, args):
+ super(process_cut, self).__init__(args)
+ self.slices = []
+ self.options = args
+
+ def __call__(self, block):
+ ret = super(process_cut, self).__call__(block)
+ if ret: self.slices.append(self.onset.get_last())
+ return ret
+
+ def flush(self, frames_read, samplerate):
+ from aubio.cut import _cut_slice
+ _cut_slice(self.options, self.slices)
+ duration = float (frames_read) / float(samplerate)
+ base_info = '%(source_file)s' % {'source_file': self.options.source_uri}
+ base_info += ' (total %(duration).2fs at %(samplerate)dHz)\n' % \
+ {'duration': duration, 'samplerate': samplerate}
+ info = "created %d slices from " % len(self.slices)
+ info += base_info
+ sys.stderr.write(info)
def main():
parser = aubio_parser()
--- a/python/lib/aubio/cut.py
+++ b/python/lib/aubio/cut.py
@@ -5,16 +5,11 @@
"""
import sys
-import argparse
+from aubio.cmd import AubioArgumentParser
-def parse_args():
- usage = "usage: %s [options] -i soundfile" % sys.argv[0]
- usage += "\n help: %s -h" % sys.argv[0]
- parser = argparse.ArgumentParser()
- parser.add_argument("source_file", default=None, nargs='?',
- help="input sound file to analyse", metavar = "<source_file>")
- parser.add_argument("-i", "--input", action = "store", dest = "source_file2",
- help="input sound file to analyse", metavar = "<source_file>")
+def aubio_cut_parser():
+ parser = AubioArgumentParser()
+ parser.add_input()
parser.add_argument("-O","--onset-method",
action="store", dest="onset_method", default='default',
metavar = "<onset_method>",
@@ -23,7 +18,7 @@
# cutting methods
parser.add_argument("-b","--beat",
action="store_true", dest="beat", default=False,
- help="use beat locations")
+ help="slice at beat locations")
"""
parser.add_argument("-S","--silencecut",
action="store_true", dest="silencecut", default=False,
@@ -34,33 +29,16 @@
help="silence threshold [default=-70]")
"""
# algorithm parameters
- parser.add_argument("-r", "--samplerate",
- metavar = "<freq>", type=int,
- action="store", dest="samplerate", default=0,
- help="samplerate at which the file should be represented")
- parser.add_argument("-B","--bufsize",
- action="store", dest="bufsize", default=512,
- metavar = "<size>", type=int,
- help="buffer size [default=512]")
- parser.add_argument("-H","--hopsize",
- metavar = "<size>", type=int,
- action="store", dest="hopsize", default=256,
- help="overlap size [default=256]")
- parser.add_argument("-t","--onset-threshold",
- metavar = "<value>", type=float,
+ parser.add_buf_hop_size()
+ parser.add_argument("-t","--threshold", "--onset-threshold",
+ metavar = "<threshold>", type=float,
action="store", dest="threshold", default=0.3,
help="onset peak picking threshold [default=0.3]")
parser.add_argument("-c","--cut",
action="store_true", dest="cut", default=False,
- help="cut input sound file at detected labels \
- best used with option -L")
+ help="cut input sound file at detected labels")
+ parser.add_minioi()
- # minioi
- parser.add_argument("-M","--minioi",
- metavar = "<value>", type=str,
- action="store", dest="minioi", default="12ms",
- help="minimum inter onset interval [default=12ms]")
-
"""
parser.add_argument("-D","--delay",
action = "store", dest = "delay", type = float,
@@ -81,9 +59,7 @@
metavar = "<value>",
action="store", dest="zerothres", default=0.008,
help="zero-crossing threshold for slicing [default=0.00008]")
- """
# plotting functions
- """
parser.add_argument("-p","--plot",
action="store_true", dest="plot", default=False,
help="draw plot")
@@ -109,51 +85,24 @@
action="store_true", dest="spectro", default=False,
help="add spectrogram to the plot")
"""
- parser.add_argument("-o","--output", type = str,
- metavar = "<outputdir>",
- action="store", dest="output_directory", default=None,
- help="specify path where slices of the original file should be created")
- parser.add_argument("--cut-until-nsamples", type = int,
- metavar = "<samples>",
- action = "store", dest = "cut_until_nsamples", default = None,
- help="how many extra samples should be added at the end of each slice")
- parser.add_argument("--cut-every-nslices", type = int,
- metavar = "<samples>",
- action = "store", dest = "cut_every_nslices", default = None,
- help="how many slices should be groupped together at each cut")
- parser.add_argument("--cut-until-nslices", type = int,
- metavar = "<slices>",
- action = "store", dest = "cut_until_nslices", default = None,
- help="how many extra slices should be added at the end of each slice")
+ parser.add_slicer_options()
+ parser.add_verbose_help()
+ return parser
- parser.add_argument("-v","--verbose",
- action="store_true", dest="verbose", default=True,
- help="make lots of noise [default]")
- parser.add_argument("-q","--quiet",
- action="store_false", dest="verbose", default=True,
- help="be quiet")
- args = parser.parse_args()
- if not args.source_file and not args.source_file2:
- sys.stderr.write("Error: no file name given\n")
- parser.print_help()
- sys.exit(1)
- elif args.source_file2 is not None:
- args.source_file = args.source_file2
- return args
-def main():
- options = parse_args()
-
- source_file = options.source_file
- hopsize = options.hopsize
- bufsize = options.bufsize
+def _cut_analyze(options):
+ hopsize = options.hop_size
+ bufsize = options.buf_size
samplerate = options.samplerate
- source_file = options.source_file
+ source_uri = options.source_uri
+ # analyze pass
from aubio import onset, tempo, source
- s = source(source_file, samplerate, hopsize)
- if samplerate == 0: samplerate = s.get_samplerate()
+ s = source(source_uri, samplerate, hopsize)
+ if samplerate == 0:
+ samplerate = s.get_samplerate()
+ options.samplerate = samplerate
if options.beat:
o = tempo(options.onset_method, bufsize, hopsize, samplerate=samplerate)
@@ -170,7 +119,6 @@
timestamps = []
total_frames = 0
- # analyze pass
while True:
samples, read = s()
if o(samples):
@@ -179,15 +127,12 @@
total_frames += read
if read < hopsize: break
del s
- # print some info
- nstamps = len(timestamps)
- duration = float (total_frames) / float(samplerate)
- info = 'found %(nstamps)d timestamps in %(source_file)s' % locals()
- info += ' (total %(duration).2fs at %(samplerate)dHz)\n' % locals()
- sys.stderr.write(info)
+ return timestamps, total_frames
+def _cut_slice(options, timestamps):
# cutting pass
- if options.cut and nstamps > 0:
+ nstamps = len(timestamps)
+ if nstamps > 0:
# generate output files
from aubio.slicing import slice_source_at_stamps
timestamps_end = None
@@ -202,12 +147,36 @@
if options.cut_until_nslices:
timestamps_end = [t for t in timestamps[1 + options.cut_until_nslices:]]
timestamps_end += [ 1e120 ] * (options.cut_until_nslices + 1)
- slice_source_at_stamps(source_file, timestamps, timestamps_end = timestamps_end,
+ slice_source_at_stamps(options.source_uri,
+ timestamps, timestamps_end = timestamps_end,
output_dir = options.output_directory,
- samplerate = samplerate)
+ samplerate = options.samplerate)
- # print some info
- duration = float (total_frames) / float(samplerate)
- info = 'created %(nstamps)d slices from %(source_file)s' % locals()
- info += ' (total %(duration).2fs at %(samplerate)dHz)\n' % locals()
+def main():
+ parser = aubio_cut_parser()
+ options = parser.parse_args()
+ if not options.source_uri and not options.source_uri2:
+ sys.stderr.write("Error: no file name given\n")
+ parser.print_help()
+ sys.exit(1)
+ elif options.source_uri2 is not None:
+ options.source_uri = options.source_uri2
+
+ # analysis
+ timestamps, total_frames = _cut_analyze(options)
+
+ # print some info
+ duration = float (total_frames) / float(options.samplerate)
+ base_info = '%(source_uri)s' % {'source_uri': options.source_uri}
+ base_info += ' (total %(duration).2fs at %(samplerate)dHz)\n' % \
+ {'duration': duration, 'samplerate': options.samplerate}
+
+ info = "found %d timestamps in " % len(timestamps)
+ info += base_info
+ sys.stderr.write(info)
+
+ if options.cut:
+ _cut_slice(options, timestamps)
+ info = "created %d slices from " % len(timestamps)
+ info += base_info
sys.stderr.write(info)
--- a/python/tests/test_filterbank.py
+++ b/python/tests/test_filterbank.py
@@ -1,9 +1,8 @@
#! /usr/bin/env python
-from unittest import main
-from numpy.testing import TestCase
-from numpy.testing import assert_equal, assert_almost_equal
import numpy as np
+from numpy.testing import TestCase, assert_equal, assert_almost_equal
+
from aubio import cvec, filterbank, float_type
from .utils import array_from_text_file
@@ -62,6 +61,13 @@
f.set_mel_coeffs_slaney(16000)
assert_almost_equal ( expected, f.get_coeffs() )
+ def test_mfcc_coeffs_get_coeffs(self):
+ f = filterbank(40, 512)
+ coeffs = f.get_coeffs()
+ self.assertIsInstance(coeffs, np.ndarray)
+ assert_equal (coeffs, 0)
+ assert_equal (np.shape(coeffs), (40, 512 / 2 + 1))
+
class aubio_filterbank_wrong_values(TestCase):
def test_negative_window(self):
@@ -81,4 +87,5 @@
f(cvec(256))
if __name__ == '__main__':
- main()
+ import nose2
+ nose2.main()
--- a/python/tests/test_filterbank_mel.py
+++ b/python/tests/test_filterbank_mel.py
@@ -1,11 +1,13 @@
#! /usr/bin/env python
-from unittest import main
-from numpy.testing import TestCase
-from numpy.testing import assert_equal, assert_almost_equal
-from numpy import array, shape
+import numpy as np
+from numpy.testing import TestCase, assert_equal, assert_almost_equal
+
from aubio import cvec, filterbank, float_type
+import warnings
+warnings.filterwarnings('ignore', category=UserWarning, append=True)
+
class aubio_filterbank_mel_test_case(TestCase):
def test_slaney(self):
@@ -12,33 +14,33 @@
f = filterbank(40, 512)
f.set_mel_coeffs_slaney(16000)
a = f.get_coeffs()
- assert_equal(shape (a), (40, 512/2 + 1) )
+ assert_equal(np.shape (a), (40, 512/2 + 1) )
def test_other_slaney(self):
f = filterbank(40, 512*2)
f.set_mel_coeffs_slaney(44100)
- _ = f.get_coeffs()
+ self.assertIsInstance(f.get_coeffs(), np.ndarray)
#print "sum is", sum(sum(a))
for win_s in [256, 512, 1024, 2048, 4096]:
f = filterbank(40, win_s)
f.set_mel_coeffs_slaney(32000)
- _ = f.get_coeffs()
#print "sum is", sum(sum(a))
+ self.assertIsInstance(f.get_coeffs(), np.ndarray)
def test_triangle_freqs_zeros(self):
f = filterbank(9, 1024)
freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000]
- freqs = array(freq_list, dtype = float_type)
+ freqs = np.array(freq_list, dtype = float_type)
f.set_triangle_bands(freqs, 48000)
- _ = f.get_coeffs().T
assert_equal ( f(cvec(1024)), 0)
+ self.assertIsInstance(f.get_coeffs(), np.ndarray)
def test_triangle_freqs_ones(self):
f = filterbank(9, 1024)
freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000]
- freqs = array(freq_list, dtype = float_type)
+ freqs = np.array(freq_list, dtype = float_type)
f.set_triangle_bands(freqs, 48000)
- _ = f.get_coeffs().T
+ self.assertIsInstance(f.get_coeffs(), np.ndarray)
spec = cvec(1024)
spec.norm[:] = 1
assert_almost_equal ( f(spec),
@@ -46,4 +48,5 @@
0.02133301, 0.02133301, 0.02133311, 0.02133334, 0.02133345])
if __name__ == '__main__':
- main()
+ import nose2
+ nose2.main()
--- a/src/io/source_avcodec.c
+++ b/src/io/source_avcodec.c
@@ -313,15 +313,15 @@
// TODO: use planar?
//av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_FLTP, 0);
#ifdef HAVE_AVRESAMPLE
- if ( ( err = avresample_open(avr) ) < 0) {
+ if ( ( err = avresample_open(avr) ) < 0)
#elif defined(HAVE_SWRESAMPLE)
- if ( ( err = swr_init(avr) ) < 0) {
+ if ( ( err = swr_init(avr) ) < 0)
#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
+ {
char errorstr[256];
av_strerror (err, errorstr, sizeof(errorstr));
- AUBIO_ERR("source_avcodec: Could not open AVAudioResampleContext for %s (%s)\n",
+ AUBIO_ERR("source_avcodec: Could not open resampling context for %s (%s)\n",
s->path, errorstr);
- //goto beach;
return;
}
s->avr = avr;