Changeset 38a965e


Ignore:
Timestamp:
Sep 16, 2017, 5:41:35 PM (3 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master
Children:
a729232
Parents:
5e56bbd (diff), c3e98d7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into coveralls

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • python/lib/aubio/cmd.py

    r5e56bbd r38a965e  
    2121
    2222    subparsers = parser.add_subparsers(title='commands', dest='command',
     23            parser_class= AubioArgumentParser,
    2324            metavar="")
    2425
     
    3334    parser_add_subcommand_melbands(subparsers)
    3435    parser_add_subcommand_quiet(subparsers)
     36    parser_add_subcommand_cut(subparsers)
    3537
    3638    return parser
     
    4749            help='estimate time of onsets (beginning of sound event)',
    4850            formatter_class = argparse.ArgumentDefaultsHelpFormatter)
    49     parser_add_input(subparser)
    50     parser_add_buf_hop_size(subparser)
     51    subparser.add_input()
     52    subparser.add_buf_hop_size()
    5153    helpstr = "onset novelty function"
    5254    helpstr += " <default|energy|hfc|complex|phase|specdiff|kl|mkl|specflux>"
    53     parser_add_method(subparser, helpstr=helpstr)
    54     parser_add_threshold(subparser)
    55     parser_add_silence(subparser)
    56     parser_add_minioi(subparser)
    57     parser_add_time_format(subparser)
    58     parser_add_verbose_help(subparser)
     55    subparser.add_method(helpstr=helpstr)
     56    subparser.add_threshold()
     57    subparser.add_silence()
     58    subparser.add_minioi()
     59    subparser.add_time_format()
     60    subparser.add_verbose_help()
    5961    subparser.set_defaults(process=process_onset)
    6062
     
    6365    subparser = subparsers.add_parser('pitch',
    6466            help='estimate fundamental frequency (monophonic)')
    65     parser_add_input(subparser)
    66     parser_add_buf_hop_size(subparser, buf_size=2048)
     67    subparser.add_input()
     68    subparser.add_buf_hop_size(buf_size=2048)
    6769    helpstr = "pitch detection method <default|yinfft|yin|mcomb|fcomb|schmitt>"
    68     parser_add_method(subparser, helpstr=helpstr)
    69     parser_add_threshold(subparser)
    70     parser_add_pitch_unit(subparser)
    71     parser_add_silence(subparser)
    72     parser_add_time_format(subparser)
    73     parser_add_verbose_help(subparser)
     70    subparser.add_method(helpstr=helpstr)
     71    subparser.add_threshold()
     72    subparser.add_pitch_unit()
     73    subparser.add_silence()
     74    subparser.add_time_format()
     75    subparser.add_verbose_help()
    7476    subparser.set_defaults(process=process_pitch)
    7577
     
    7880    subparser = subparsers.add_parser('beat',
    7981            help='estimate location of beats')
    80     parser_add_input(subparser)
    81     parser_add_buf_hop_size(subparser, buf_size=1024, hop_size=512)
    82     parser_add_time_format(subparser)
    83     parser_add_verbose_help(subparser)
     82    subparser.add_input()
     83    subparser.add_buf_hop_size(buf_size=1024, hop_size=512)
     84    subparser.add_time_format()
     85    subparser.add_verbose_help()
    8486    subparser.set_defaults(process=process_beat)
    8587
     
    8890    subparser = subparsers.add_parser('tempo',
    8991            help='estimate overall tempo in bpm')
    90     parser_add_input(subparser)
    91     parser_add_buf_hop_size(subparser, buf_size=1024, hop_size=512)
    92     parser_add_time_format(subparser)
    93     parser_add_verbose_help(subparser)
     92    subparser.add_input()
     93    subparser.add_buf_hop_size(buf_size=1024, hop_size=512)
     94    subparser.add_time_format()
     95    subparser.add_verbose_help()
    9496    subparser.set_defaults(process=process_tempo)
    9597
     
    98100    subparser = subparsers.add_parser('notes',
    99101            help='estimate midi-like notes (monophonic)')
    100     parser_add_input(subparser)
    101     parser_add_buf_hop_size(subparser)
    102     parser_add_time_format(subparser)
    103     parser_add_verbose_help(subparser)
     102    subparser.add_input()
     103    subparser.add_buf_hop_size()
     104    subparser.add_time_format()
     105    subparser.add_verbose_help()
    104106    subparser.set_defaults(process=process_notes)
    105107
     
    108110    subparser = subparsers.add_parser('mfcc',
    109111            help='extract Mel-Frequency Cepstrum Coefficients')
    110     parser_add_input(subparser)
    111     parser_add_buf_hop_size(subparser)
    112     parser_add_time_format(subparser)
    113     parser_add_verbose_help(subparser)
     112    subparser.add_input()
     113    subparser.add_buf_hop_size()
     114    subparser.add_time_format()
     115    subparser.add_verbose_help()
    114116    subparser.set_defaults(process=process_mfcc)
    115117
     
    118120    subparser = subparsers.add_parser('melbands',
    119121            help='extract energies in Mel-frequency bands')
    120     parser_add_input(subparser)
    121     parser_add_buf_hop_size(subparser)
    122     parser_add_time_format(subparser)
    123     parser_add_verbose_help(subparser)
     122    subparser.add_input()
     123    subparser.add_buf_hop_size()
     124    subparser.add_time_format()
     125    subparser.add_verbose_help()
    124126    subparser.set_defaults(process=process_melbands)
    125127
     
    128130    subparser = subparsers.add_parser('quiet',
    129131            help='extract timestamps of quiet and loud regions')
    130     parser_add_input(subparser)
    131     parser_add_hop_size(subparser)
    132     parser_add_silence(subparser)
    133     parser_add_time_format(subparser)
    134     parser_add_verbose_help(subparser)
     132    subparser.add_input()
     133    subparser.add_hop_size()
     134    subparser.add_silence()
     135    subparser.add_time_format()
     136    subparser.add_verbose_help()
    135137    subparser.set_defaults(process=process_quiet)
    136138
    137 def parser_add_input(parser):
    138     parser.add_argument("source_uri", default=None, nargs='?',
    139             help="input sound file to analyse", metavar = "<source_uri>")
    140     parser.add_argument("-i", "--input", dest = "source_uri2",
    141             help="input sound file to analyse", metavar = "<source_uri>")
    142     parser.add_argument("-r", "--samplerate",
    143             metavar = "<freq>", type=int,
    144             action="store", dest="samplerate", default=0,
    145             help="samplerate at which the file should be represented")
    146 
    147 def parser_add_verbose_help(parser):
    148     parser.add_argument("-v","--verbose",
    149             action="count", dest="verbose", default=1,
    150             help="make lots of noise [default]")
    151     parser.add_argument("-q","--quiet",
    152             action="store_const", dest="verbose", const=0,
    153             help="be quiet")
    154 
    155 def parser_add_buf_hop_size(parser, buf_size=512, hop_size=256):
    156     parser_add_buf_size(parser, buf_size=buf_size)
    157     parser_add_hop_size(parser, hop_size=hop_size)
    158 
    159 def parser_add_buf_size(parser, buf_size=512):
    160     parser.add_argument("-B","--bufsize",
    161             action="store", dest="buf_size", default=buf_size,
    162             metavar = "<size>", type=int,
    163             help="buffer size [default=%d]" % buf_size)
    164 
    165 def parser_add_hop_size(parser, hop_size=256):
    166     parser.add_argument("-H","--hopsize",
    167             metavar = "<size>", type=int,
    168             action="store", dest="hop_size", default=hop_size,
    169             help="overlap size [default=%d]" % hop_size)
    170 
    171 def parser_add_method(parser, method='default', helpstr='method'):
    172     parser.add_argument("-m","--method",
    173             metavar = "<method>", type=str,
    174             action="store", dest="method", default=method,
    175             help="%s [default=%s]" % (helpstr, method))
    176 
    177 def parser_add_threshold(parser, default=None):
    178     parser.add_argument("-t","--threshold",
    179             metavar = "<threshold>", type=float,
    180             action="store", dest="threshold", default=default,
    181             help="threshold [default=%s]" % default)
    182 
    183 def parser_add_silence(parser):
    184     parser.add_argument("-s", "--silence",
    185             metavar = "<value>", type=float,
    186             action="store", dest="silence", default=-70,
    187             help="silence threshold")
    188 
    189 def parser_add_minioi(parser):
    190     parser.add_argument("-M", "--minioi",
    191             metavar = "<value>", type=str,
    192             action="store", dest="minioi", default="12ms",
    193             help="minimum Inter-Onset Interval")
    194 
    195 def parser_add_pitch_unit(parser, default="Hz"):
    196     help_str = "frequency unit, should be one of Hz, midi, bin, cent"
    197     help_str += " [default=%s]" % default
    198     parser.add_argument("-u", "--pitch-unit",
    199             metavar = "<value>", type=str,
    200             action="store", dest="pitch_unit", default=default,
    201             help=help_str)
    202 
    203 def parser_add_time_format(parser):
    204     helpstr = "select time values output format (samples, ms, seconds)"
    205     helpstr += " [default=seconds]"
    206     parser.add_argument("-T", "--time-format",
    207              metavar='format',
    208              dest="time_format",
    209              default=None,
    210              help=helpstr)
     139def parser_add_subcommand_cut(subparsers):
     140    # quiet subcommand
     141    subparser = subparsers.add_parser('cut',
     142            help='slice at timestamps')
     143    subparser.add_input()
     144    helpstr = "onset novelty function"
     145    helpstr += " <default|energy|hfc|complex|phase|specdiff|kl|mkl|specflux>"
     146    subparser.add_method(helpstr=helpstr)
     147    subparser.add_buf_hop_size()
     148    subparser.add_silence()
     149    subparser.add_threshold(default=0.3)
     150    subparser.add_minioi()
     151    subparser.add_slicer_options()
     152    subparser.add_time_format()
     153    subparser.add_verbose_help()
     154    subparser.set_defaults(process=process_cut)
     155
     156class AubioArgumentParser(argparse.ArgumentParser):
     157
     158    def add_input(self):
     159        self.add_argument("source_uri", default=None, nargs='?',
     160                help="input sound file to analyse", metavar = "<source_uri>")
     161        self.add_argument("-i", "--input", dest = "source_uri2",
     162                help="input sound file to analyse", metavar = "<source_uri>")
     163        self.add_argument("-r", "--samplerate",
     164                metavar = "<freq>", type=int,
     165                action="store", dest="samplerate", default=0,
     166                help="samplerate at which the file should be represented")
     167
     168    def add_verbose_help(self):
     169        self.add_argument("-v","--verbose",
     170                action="count", dest="verbose", default=1,
     171                help="make lots of noise [default]")
     172        self.add_argument("-q","--quiet",
     173                action="store_const", dest="verbose", const=0,
     174                help="be quiet")
     175
     176    def add_buf_hop_size(self, buf_size=512, hop_size=256):
     177        self.add_buf_size(buf_size=buf_size)
     178        self.add_hop_size(hop_size=hop_size)
     179
     180    def add_buf_size(self, buf_size=512):
     181        self.add_argument("-B","--bufsize",
     182                action="store", dest="buf_size", default=buf_size,
     183                metavar = "<size>", type=int,
     184                help="buffer size [default=%d]" % buf_size)
     185
     186    def add_hop_size(self, hop_size=256):
     187        self.add_argument("-H","--hopsize",
     188                metavar = "<size>", type=int,
     189                action="store", dest="hop_size", default=hop_size,
     190                help="overlap size [default=%d]" % hop_size)
     191
     192    def add_method(self, method='default', helpstr='method'):
     193        self.add_argument("-m","--method",
     194                metavar = "<method>", type=str,
     195                action="store", dest="method", default=method,
     196                help="%s [default=%s]" % (helpstr, method))
     197
     198    def add_threshold(self, default=None):
     199        self.add_argument("-t","--threshold",
     200                metavar = "<threshold>", type=float,
     201                action="store", dest="threshold", default=default,
     202                help="threshold [default=%s]" % default)
     203
     204    def add_silence(self):
     205        self.add_argument("-s", "--silence",
     206                metavar = "<value>", type=float,
     207                action="store", dest="silence", default=-70,
     208                help="silence threshold")
     209
     210    def add_minioi(self, default="12ms"):
     211        self.add_argument("-M", "--minioi",
     212                metavar = "<value>", type=str,
     213                action="store", dest="minioi", default=default,
     214                help="minimum Inter-Onset Interval [default=%s]" % default)
     215
     216    def add_pitch_unit(self, default="Hz"):
     217        help_str = "frequency unit, should be one of Hz, midi, bin, cent"
     218        help_str += " [default=%s]" % default
     219        self.add_argument("-u", "--pitch-unit",
     220                metavar = "<value>", type=str,
     221                action="store", dest="pitch_unit", default=default,
     222                help=help_str)
     223
     224    def add_time_format(self):
     225        helpstr = "select time values output format (samples, ms, seconds)"
     226        helpstr += " [default=seconds]"
     227        self.add_argument("-T", "--time-format",
     228                 metavar='format',
     229                 dest="time_format",
     230                 default=None,
     231                 help=helpstr)
     232
     233    def add_slicer_options(self):
     234        self.add_argument("-o","--output", type = str,
     235                metavar = "<outputdir>",
     236                action="store", dest="output_directory", default=None,
     237                help="specify path where slices of the original file should be created")
     238        self.add_argument("--cut-until-nsamples", type = int,
     239                metavar = "<samples>",
     240                action = "store", dest = "cut_until_nsamples", default = None,
     241                help="how many extra samples should be added at the end of each slice")
     242        self.add_argument("--cut-every-nslices", type = int,
     243                metavar = "<samples>",
     244                action = "store", dest = "cut_every_nslices", default = None,
     245                help="how many slices should be groupped together at each cut")
     246        self.add_argument("--cut-until-nslices", type = int,
     247                metavar = "<slices>",
     248                action = "store", dest = "cut_until_nslices", default = None,
     249                help="how many extra slices should be added at the end of each slice")
    211250
    212251# some utilities
     
    436475            fmt_out += self.time2string(frames_read, samplerate)
    437476            sys.stdout.write(fmt_out + '\n')
     477
     478class process_cut(process_onset):
     479    def __init__(self, args):
     480        super(process_cut, self).__init__(args)
     481        self.slices = []
     482        self.options = args
     483
     484    def __call__(self, block):
     485        ret = super(process_cut, self).__call__(block)
     486        if ret: self.slices.append(self.onset.get_last())
     487        return ret
     488
     489    def flush(self, frames_read, samplerate):
     490        from aubio.cut import _cut_slice
     491        _cut_slice(self.options, self.slices)
     492        duration = float (frames_read) / float(samplerate)
     493        base_info = '%(source_file)s' % {'source_file': self.options.source_uri}
     494        base_info += ' (total %(duration).2fs at %(samplerate)dHz)\n' % \
     495                {'duration': duration, 'samplerate': samplerate}
     496        info = "created %d slices from " % len(self.slices)
     497        info += base_info
     498        sys.stderr.write(info)
    438499
    439500def main():
  • python/lib/aubio/cut.py

    r5e56bbd r38a965e  
    66
    77import sys
    8 import argparse
     8from aubio.cmd import AubioArgumentParser
    99
    10 def parse_args():
    11     usage = "usage: %s [options] -i soundfile" % sys.argv[0]
    12     usage += "\n help: %s -h" % sys.argv[0]
    13     parser = argparse.ArgumentParser()
    14     parser.add_argument("source_file", default=None, nargs='?',
    15             help="input sound file to analyse", metavar = "<source_file>")
    16     parser.add_argument("-i", "--input", action = "store", dest = "source_file2",
    17             help="input sound file to analyse", metavar = "<source_file>")
     10def aubio_cut_parser():
     11    parser = AubioArgumentParser()
     12    parser.add_input()
    1813    parser.add_argument("-O","--onset-method",
    1914            action="store", dest="onset_method", default='default',
     
    2419    parser.add_argument("-b","--beat",
    2520            action="store_true", dest="beat", default=False,
    26             help="use beat locations")
     21            help="slice at beat locations")
    2722    """
    2823    parser.add_argument("-S","--silencecut",
     
    3530            """
    3631    # algorithm parameters
    37     parser.add_argument("-r", "--samplerate",
    38             metavar = "<freq>", type=int,
    39             action="store", dest="samplerate", default=0,
    40             help="samplerate at which the file should be represented")
    41     parser.add_argument("-B","--bufsize",
    42             action="store", dest="bufsize", default=512,
    43             metavar = "<size>", type=int,
    44             help="buffer size [default=512]")
    45     parser.add_argument("-H","--hopsize",
    46             metavar = "<size>", type=int,
    47             action="store", dest="hopsize", default=256,
    48             help="overlap size [default=256]")
    49     parser.add_argument("-t","--onset-threshold",
    50             metavar = "<value>", type=float,
     32    parser.add_buf_hop_size()
     33    parser.add_argument("-t","--threshold", "--onset-threshold",
     34            metavar = "<threshold>", type=float,
    5135            action="store", dest="threshold", default=0.3,
    5236            help="onset peak picking threshold [default=0.3]")
    5337    parser.add_argument("-c","--cut",
    5438            action="store_true", dest="cut", default=False,
    55             help="cut input sound file at detected labels \
    56                     best used with option -L")
    57 
    58     # minioi
    59     parser.add_argument("-M","--minioi",
    60             metavar = "<value>", type=str,
    61             action="store", dest="minioi", default="12ms",
    62             help="minimum inter onset interval [default=12ms]")
     39            help="cut input sound file at detected labels")
     40    parser.add_minioi()
    6341
    6442    """
     
    8260            action="store", dest="zerothres", default=0.008,
    8361            help="zero-crossing threshold for slicing [default=0.00008]")
    84             """
    8562    # plotting functions
    86     """
    8763    parser.add_argument("-p","--plot",
    8864            action="store_true", dest="plot", default=False,
     
    11086            help="add spectrogram to the plot")
    11187    """
    112     parser.add_argument("-o","--output", type = str,
    113             metavar = "<outputdir>",
    114             action="store", dest="output_directory", default=None,
    115             help="specify path where slices of the original file should be created")
    116     parser.add_argument("--cut-until-nsamples", type = int,
    117             metavar = "<samples>",
    118             action = "store", dest = "cut_until_nsamples", default = None,
    119             help="how many extra samples should be added at the end of each slice")
    120     parser.add_argument("--cut-every-nslices", type = int,
    121             metavar = "<samples>",
    122             action = "store", dest = "cut_every_nslices", default = None,
    123             help="how many slices should be groupped together at each cut")
    124     parser.add_argument("--cut-until-nslices", type = int,
    125             metavar = "<slices>",
    126             action = "store", dest = "cut_until_nslices", default = None,
    127             help="how many extra slices should be added at the end of each slice")
     88    parser.add_slicer_options()
     89    parser.add_verbose_help()
     90    return parser
    12891
    129     parser.add_argument("-v","--verbose",
    130             action="store_true", dest="verbose", default=True,
    131             help="make lots of noise [default]")
    132     parser.add_argument("-q","--quiet",
    133             action="store_false", dest="verbose", default=True,
    134             help="be quiet")
    135     args = parser.parse_args()
    136     if not args.source_file and not args.source_file2:
    137         sys.stderr.write("Error: no file name given\n")
    138         parser.print_help()
    139         sys.exit(1)
    140     elif args.source_file2 is not None:
    141         args.source_file = args.source_file2
    142     return args
    14392
    144 def main():
    145     options = parse_args()
     93def _cut_analyze(options):
     94    hopsize = options.hop_size
     95    bufsize = options.buf_size
     96    samplerate = options.samplerate
     97    source_uri = options.source_uri
    14698
    147     source_file = options.source_file
    148     hopsize = options.hopsize
    149     bufsize = options.bufsize
    150     samplerate = options.samplerate
    151     source_file = options.source_file
    152 
     99    # analyze pass
    153100    from aubio import onset, tempo, source
    154101
    155     s = source(source_file, samplerate, hopsize)
    156     if samplerate == 0: samplerate = s.get_samplerate()
     102    s = source(source_uri, samplerate, hopsize)
     103    if samplerate == 0:
     104        samplerate = s.get_samplerate()
     105        options.samplerate = samplerate
    157106
    158107    if options.beat:
     
    171120    timestamps = []
    172121    total_frames = 0
    173     # analyze pass
    174122    while True:
    175123        samples, read = s()
     
    180128        if read < hopsize: break
    181129    del s
    182     # print some info
     130    return timestamps, total_frames
     131
     132def _cut_slice(options, timestamps):
     133    # cutting pass
    183134    nstamps = len(timestamps)
    184     duration = float (total_frames) / float(samplerate)
    185     info = 'found %(nstamps)d timestamps in %(source_file)s' % locals()
    186     info += ' (total %(duration).2fs at %(samplerate)dHz)\n' % locals()
    187     sys.stderr.write(info)
    188 
    189     # cutting pass
    190     if options.cut and nstamps > 0:
     135    if nstamps > 0:
    191136        # generate output files
    192137        from aubio.slicing import slice_source_at_stamps
     
    203148            timestamps_end = [t for t in timestamps[1 + options.cut_until_nslices:]]
    204149            timestamps_end += [ 1e120 ] * (options.cut_until_nslices + 1)
    205         slice_source_at_stamps(source_file, timestamps, timestamps_end = timestamps_end,
     150        slice_source_at_stamps(options.source_uri,
     151                timestamps, timestamps_end = timestamps_end,
    206152                output_dir = options.output_directory,
    207                 samplerate = samplerate)
     153                samplerate = options.samplerate)
    208154
    209         # print some info
    210         duration = float (total_frames) / float(samplerate)
    211         info = 'created %(nstamps)d slices from %(source_file)s' % locals()
    212         info += ' (total %(duration).2fs at %(samplerate)dHz)\n' % locals()
     155def main():
     156    parser = aubio_cut_parser()
     157    options = parser.parse_args()
     158    if not options.source_uri and not options.source_uri2:
     159        sys.stderr.write("Error: no file name given\n")
     160        parser.print_help()
     161        sys.exit(1)
     162    elif options.source_uri2 is not None:
     163        options.source_uri = options.source_uri2
     164
     165    # analysis
     166    timestamps, total_frames = _cut_analyze(options)
     167
     168    # print some info
     169    duration = float (total_frames) / float(options.samplerate)
     170    base_info = '%(source_uri)s' % {'source_uri': options.source_uri}
     171    base_info += ' (total %(duration).2fs at %(samplerate)dHz)\n' % \
     172            {'duration': duration, 'samplerate': options.samplerate}
     173
     174    info = "found %d timestamps in " % len(timestamps)
     175    info += base_info
     176    sys.stderr.write(info)
     177
     178    if options.cut:
     179        _cut_slice(options, timestamps)
     180        info = "created %d slices from " % len(timestamps)
     181        info += base_info
    213182        sys.stderr.write(info)
  • python/tests/test_filterbank.py

    r5e56bbd r38a965e  
    11#! /usr/bin/env python
    22
    3 from unittest import main
    4 from numpy.testing import TestCase
    5 from numpy.testing import assert_equal, assert_almost_equal
    63import numpy as np
     4from numpy.testing import TestCase, assert_equal, assert_almost_equal
     5
    76from aubio import cvec, filterbank, float_type
    87from .utils import array_from_text_file
     
    6362        assert_almost_equal ( expected, f.get_coeffs() )
    6463
     64    def test_mfcc_coeffs_get_coeffs(self):
     65        f = filterbank(40, 512)
     66        coeffs = f.get_coeffs()
     67        self.assertIsInstance(coeffs, np.ndarray)
     68        assert_equal (coeffs, 0)
     69        assert_equal (np.shape(coeffs), (40, 512 / 2 + 1))
     70
    6571class aubio_filterbank_wrong_values(TestCase):
    6672
     
    8288
    8389if __name__ == '__main__':
    84     main()
     90    import nose2
     91    nose2.main()
  • python/tests/test_filterbank_mel.py

    r5e56bbd r38a965e  
    11#! /usr/bin/env python
    22
    3 from unittest import main
    4 from numpy.testing import TestCase
    5 from numpy.testing import assert_equal, assert_almost_equal
    6 from numpy import array, shape
     3import numpy as np
     4from numpy.testing import TestCase, assert_equal, assert_almost_equal
     5
    76from aubio import cvec, filterbank, float_type
     7
     8import warnings
     9warnings.filterwarnings('ignore', category=UserWarning, append=True)
    810
    911class aubio_filterbank_mel_test_case(TestCase):
     
    1315        f.set_mel_coeffs_slaney(16000)
    1416        a = f.get_coeffs()
    15         assert_equal(shape (a), (40, 512/2 + 1) )
     17        assert_equal(np.shape (a), (40, 512/2 + 1) )
    1618
    1719    def test_other_slaney(self):
    1820        f = filterbank(40, 512*2)
    1921        f.set_mel_coeffs_slaney(44100)
    20         _ = f.get_coeffs()
     22        self.assertIsInstance(f.get_coeffs(), np.ndarray)
    2123        #print "sum is", sum(sum(a))
    2224        for win_s in [256, 512, 1024, 2048, 4096]:
    2325            f = filterbank(40, win_s)
    2426            f.set_mel_coeffs_slaney(32000)
    25             _ = f.get_coeffs()
    2627            #print "sum is", sum(sum(a))
     28            self.assertIsInstance(f.get_coeffs(), np.ndarray)
    2729
    2830    def test_triangle_freqs_zeros(self):
    2931        f = filterbank(9, 1024)
    3032        freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000]
    31         freqs = array(freq_list, dtype = float_type)
     33        freqs = np.array(freq_list, dtype = float_type)
    3234        f.set_triangle_bands(freqs, 48000)
    33         _ = f.get_coeffs().T
    3435        assert_equal ( f(cvec(1024)), 0)
     36        self.assertIsInstance(f.get_coeffs(), np.ndarray)
    3537
    3638    def test_triangle_freqs_ones(self):
    3739        f = filterbank(9, 1024)
    3840        freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000]
    39         freqs = array(freq_list, dtype = float_type)
     41        freqs = np.array(freq_list, dtype = float_type)
    4042        f.set_triangle_bands(freqs, 48000)
    41         _ = f.get_coeffs().T
     43        self.assertIsInstance(f.get_coeffs(), np.ndarray)
    4244        spec = cvec(1024)
    4345        spec.norm[:] = 1
     
    4749
    4850if __name__ == '__main__':
    49     main()
     51    import nose2
     52    nose2.main()
  • src/io/source_avcodec.c

    r5e56bbd r38a965e  
    314314    //av_opt_set_int(avr, "out_sample_fmt",     AV_SAMPLE_FMT_FLTP,      0);
    315315#ifdef HAVE_AVRESAMPLE
    316     if ( ( err = avresample_open(avr) ) < 0) {
    317 #elif defined(HAVE_SWRESAMPLE)
    318     if ( ( err = swr_init(avr) ) < 0) {
     316    if ( ( err = avresample_open(avr) ) < 0)
     317#elif defined(HAVE_SWRESAMPLE)
     318    if ( ( err = swr_init(avr) ) < 0)
    319319#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
     320    {
    320321      char errorstr[256];
    321322      av_strerror (err, errorstr, sizeof(errorstr));
    322       AUBIO_ERR("source_avcodec: Could not open AVAudioResampleContext for %s (%s)\n",
     323      AUBIO_ERR("source_avcodec: Could not open resampling context for %s (%s)\n",
    323324          s->path, errorstr);
    324       //goto beach;
    325325      return;
    326326    }
Note: See TracChangeset for help on using the changeset viewer.