Changes in / [357f81e:4bc10e2]


Ignore:
Files:
2 added
1 deleted
25 edited

Legend:

Unmodified
Added
Removed
  • doc/about.rst

    r357f81e r4bc10e2  
    6060-------
    6161
    62 aubio is a `free <http://www.debian.org/intro/free>`_ and `open source
     62aubio is a `free <https://www.debian.org/intro/free>`_ and `open source
    6363<http://www.opensource.org/docs/definition.php>`_ software; **you** can
    6464redistribute it and/or modify it under the terms of the `GNU
  • doc/aubiomfcc.txt

    r357f81e r4bc10e2  
    5252  url:
    5353
    54   http://cobweb.ecn.purdue.edu/~malcolm/interval/1998-010/ (see file mfcc.m)
     54  https://engineering.purdue.edu/~malcolm/interval/1998-010/ (see file mfcc.m)
    5555
    5656SEE ALSO
  • doc/conf.py

    r357f81e r4bc10e2  
    4646# General information about the project.
    4747project = u'aubio'
    48 copyright = u'2016, Paul Brossier'
     48copyright = u'2018, Paul Brossier'
    4949
    5050# The version info for the project you're documenting, acts as replacement for
  • doc/python_module.rst

    r357f81e r4bc10e2  
    8080.. _demo_filter.py: https://github.com/aubio/aubio/blob/master/python/demos/demo_filter.py
    8181.. _python tests: https://github.com/aubio/aubio/blob/master/python/tests
    82 
  • examples/parse_args.h

    r357f81e r4bc10e2  
    6666extern int blocks;
    6767
    68 extern fvec_t *ibuf;
    69 extern fvec_t *obuf;
     68extern fvec_t *input_buffer;
     69extern fvec_t *output_buffer;
    7070
    7171const char *prog_name;
     
    212212  };
    213213#endif /* HAVE_GETOPT_H */
    214   prog_name = argv[0];
     214  // better safe than sorry
    215215  if (argc < 1) {
    216216    usage (stderr, 1);
    217     return -1;
    218   }
     217  }
     218  prog_name = argv[0];
    219219#ifdef HAVE_GETOPT_H
    220220  do {
  • examples/utils.c

    r357f81e r4bc10e2  
    6464aubio_source_t *this_source = NULL;
    6565aubio_sink_t *this_sink = NULL;
    66 fvec_t *ibuf;
    67 fvec_t *obuf;
     66fvec_t *input_buffer;
     67fvec_t *output_buffer;
    6868
    6969smpl_t miditap_note = 69.;
     
    127127#endif /* HAVE_JACK */
    128128  }
    129   ibuf = new_fvec (hop_size);
    130   obuf = new_fvec (hop_size);
     129  input_buffer = new_fvec (hop_size);
     130  output_buffer = new_fvec (hop_size);
    131131
    132132}
     
    134134void examples_common_del (void)
    135135{
    136   del_fvec (ibuf);
    137   del_fvec (obuf);
     136  del_fvec (input_buffer);
     137  del_fvec (output_buffer);
    138138  aubio_cleanup ();
    139139  fflush(stderr);
     
    167167
    168168    do {
    169       aubio_source_do (this_source, ibuf, &read);
    170       process_func (ibuf, obuf);
     169      aubio_source_do (this_source, input_buffer, &read);
     170      process_func (input_buffer, output_buffer);
    171171      // print to console if verbose or no output given
    172172      if (verbose || sink_uri == NULL) {
     
    174174      }
    175175      if (this_sink) {
    176         aubio_sink_do (this_sink, obuf, hop_size);
     176        aubio_sink_do (this_sink, output_buffer, hop_size);
    177177      }
    178178      blocks++;
  • python/demos/demo_bpm_extract.py

    r357f81e r4bc10e2  
    2323            pass
    2424        else:
    25             print("unknown mode {:s}".format(params.mode))
     25            raise ValueError("unknown mode {:s}".format(params.mode))
    2626    # manual settings
    2727    if 'samplerate' in params:
     
    7070    parser.add_argument('-m', '--mode',
    7171            help="mode [default|fast|super-fast]",
    72             dest="mode")
     72            dest="mode", default='default')
    7373    parser.add_argument('sources',
    74             nargs='*',
     74            nargs='+',
    7575            help="input_files")
    7676    args = parser.parse_args()
  • python/ext/aubiomodule.c

    r357f81e r4bc10e2  
    118118  smpl_t output;
    119119
    120   if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR , &input, &samplerate, &fftsize)) {
     120  if (!PyArg_ParseTuple (args,
     121        "" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR,
     122        &input, &samplerate, &fftsize)) {
    121123    return NULL;
    122124  }
     
    133135  smpl_t output;
    134136
    135   if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR , &input, &samplerate, &fftsize)) {
     137  if (!PyArg_ParseTuple (args,
     138        "" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR,
     139        &input, &samplerate, &fftsize)) {
    136140    return NULL;
    137141  }
     
    148152  smpl_t output;
    149153
    150   if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR, &input, &samplerate, &fftsize)) {
     154  if (!PyArg_ParseTuple (args,
     155        "" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR,
     156        &input, &samplerate, &fftsize)) {
    151157    return NULL;
    152158  }
     
    163169  smpl_t output;
    164170
    165   if (!PyArg_ParseTuple (args, "|" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR, &input, &samplerate, &fftsize)) {
     171  if (!PyArg_ParseTuple (args,
     172        "" AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR AUBIO_NPY_SMPL_CHR,
     173        &input, &samplerate, &fftsize)) {
    166174    return NULL;
    167175  }
  • python/ext/py-filterbank.c

    r357f81e r4bc10e2  
    9595  if (self->vec.length != self->win_s / 2 + 1) {
    9696    PyErr_Format(PyExc_ValueError,
    97                  "input cvec has length %d, but fft expects length %d",
     97                 "input cvec has length %d, but filterbank expects length %d",
    9898                 self->vec.length, self->win_s / 2 + 1);
    9999    return NULL;
     
    140140  if (err > 0) {
    141141    PyErr_SetString (PyExc_ValueError,
    142         "error when setting filter to A-weighting");
     142        "error when running set_triangle_bands");
    143143    return NULL;
    144144  }
     
    159159  if (err > 0) {
    160160    PyErr_SetString (PyExc_ValueError,
    161         "error when setting filter to A-weighting");
     161        "error when running set_mel_coeffs_slaney");
    162162    return NULL;
    163163  }
  • python/lib/aubio/cmd.py

    r357f81e r4bc10e2  
    256256                action = "store", dest = "cut_until_nslices", default = None,
    257257                help="how many extra slices should be added at the end of each slice")
     258        self.add_argument("--create-first",
     259                action = "store_true", dest = "create_first", default = False,
     260                help="always include first slice")
    258261
    259262# some utilities
     
    512515def main():
    513516    parser = aubio_parser()
    514     args = parser.parse_args()
     517    if sys.version_info[0] != 3:
     518        # on py2, create a dummy ArgumentParser to workaround the
     519        # optional subcommand issue. See https://bugs.python.org/issue9253
     520        # This ensures that:
     521        #  - version string is shown when only '-V' is passed
     522        #  - help is printed if  '-V' is passed with any other argument
     523        #  - any other argument get forwarded to the real parser
     524        parser_root = argparse.ArgumentParser(add_help=False)
     525        parser_root.add_argument('-V', '--version', help="show version",
     526                action="store_true", dest="show_version")
     527        args, extras = parser_root.parse_known_args()
     528        if args.show_version == False: # no -V, forward to parser
     529            args = parser.parse_args(extras, namespace=args)
     530        elif len(extras) != 0: # -V with other arguments, print help
     531            parser.print_help()
     532            sys.exit(1)
     533    else: # in py3, we can simply use parser directly
     534        args = parser.parse_args()
    515535    if 'show_version' in args and args.show_version:
    516536        sys.stdout.write('aubio version ' + aubio.version + '\n')
  • python/lib/aubio/cut.py

    r357f81e r4bc10e2  
    102102    s = source(source_uri, samplerate, hopsize)
    103103    if samplerate == 0:
    104         samplerate = s.get_samplerate()
     104        samplerate = s.samplerate
    105105        options.samplerate = samplerate
    106106
     
    151151                timestamps, timestamps_end = timestamps_end,
    152152                output_dir = options.output_directory,
    153                 samplerate = options.samplerate)
     153                samplerate = options.samplerate,
     154                create_first = options.create_first)
    154155
    155156def main():
  • python/lib/aubio/midiconv.py

    r357f81e r4bc10e2  
    22""" utilities to convert midi note number to and from note names """
    33
    4 __all__ = ['note2midi', 'midi2note', 'freq2note']
     4__all__ = ['note2midi', 'midi2note', 'freq2note', 'note2freq']
    55
    66import sys
     7from ._aubio import freqtomidi, miditofreq
     8
    79py3 = sys.version_info[0] == 3
    810if py3:
     
    2527    _valid_octaves = range(-1, 10)
    2628    if not isinstance(note, str_instances):
    27         raise TypeError("a string is required, got %s (%s)" % (note, str(type(note))))
     29        msg = "a string is required, got {:s} ({:s})"
     30        raise TypeError(msg.format(str(type(note)), repr(note)))
    2831    if len(note) not in range(2, 5):
    29         raise ValueError("string of 2 to 4 characters expected, got %d (%s)" \
    30                          % (len(note), note))
     32        msg = "string of 2 to 4 characters expected, got {:d} ({:s})"
     33        raise ValueError(msg.format(len(note), note))
    3134    notename, modifier, octave = [None]*3
    3235
     
    5255        raise ValueError("%s is not a valid octave" % octave)
    5356
    54     midi = 12 + octave * 12 + _valid_notenames[notename] + _valid_modifiers[modifier]
     57    midi = 12 + octave * 12 + _valid_notenames[notename] \
     58            + _valid_modifiers[modifier]
    5559    if midi > 127:
    5660        raise ValueError("%s is outside of the range C-2 to G8" % note)
     
    6266        raise TypeError("an integer is required, got %s" % midi)
    6367    if midi not in range(0, 128):
    64         raise ValueError("an integer between 0 and 127 is excepted, got %d" % midi)
    65     _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
     68        msg = "an integer between 0 and 127 is excepted, got {:d}"
     69        raise ValueError(msg.format(midi))
     70    _valid_notenames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#',
     71            'A', 'A#', 'B']
    6672    return _valid_notenames[midi % 12] + str(int(midi / 12) - 1)
    6773
    6874def freq2note(freq):
    6975    " convert frequency in Hz to nearest note name, e.g. [0, 22050.] -> [C-1, G9] "
    70     from aubio import freqtomidi
    71     return midi2note(int(freqtomidi(freq)))
     76    nearest_note = int(freqtomidi(freq) + .5)
     77    return midi2note(nearest_note)
     78
     79def note2freq(note):
     80    """Convert note name to corresponding frequency, in Hz.
     81
     82    Parameters
     83    ----------
     84    note : str
     85        input note name
     86
     87    Returns
     88    -------
     89    freq : float [0, 23000[
     90        frequency, in Hz
     91
     92    Example
     93    -------
     94    >>> aubio.note2freq('A4')
     95    440
     96    >>> aubio.note2freq('A3')
     97    220.1
     98    """
     99    midi = note2midi(note)
     100    return miditofreq(midi)
  • python/lib/aubio/slicing.py

    r357f81e r4bc10e2  
    77
    88def slice_source_at_stamps(source_file, timestamps, timestamps_end=None,
    9                            output_dir=None, samplerate=0, hopsize=256):
     9                           output_dir=None, samplerate=0, hopsize=256,
     10                           create_first=False):
    1011    """ slice a sound file at given timestamps """
    1112
     
    1314        raise ValueError("no timestamps given")
    1415
    15     if timestamps[0] != 0:
     16    if timestamps[0] != 0 and create_first:
    1617        timestamps = [0] + timestamps
    1718        if timestamps_end is not None:
     
    1920
    2021    if timestamps_end is not None:
    21         if len(timestamps_end) != len(timestamps):
     22        if len(timestamps_end) == len(timestamps) - 1:
     23            timestamps_end = timestamps_end + [_max_timestamp]
     24        elif len(timestamps_end) != len(timestamps):
    2225            raise ValueError("len(timestamps_end) != len(timestamps)")
    2326    else:
     
    4952        vec, read = _source.do_multi()
    5053        # if the total number of frames read will exceed the next region start
    51         if len(regions) and total_frames + read >= regions[0][0]:
     54        while len(regions) and total_frames + read >= regions[0][0]:
    5255            #print "getting", regions[0], "at", total_frames
    5356            # get next region
     
    7679                    # write remaining samples from current region
    7780                    _sink.do_multi(vec[:, start:remaining], remaining - start)
    78                     #print "closing region", "remaining", remaining
     81                    #print("closing region", "remaining", remaining)
    7982                    # close this file
    8083                    _sink.close()
     
    8386                _sink.do_multi(vec[:, start:read], read - start)
    8487        total_frames += read
     88        # remove old slices
     89        slices = list(filter(lambda s: s['end_stamp'] > total_frames,
     90            slices))
    8591        if read < hopsize:
    8692            break
  • python/tests/test_aubio_cmd.py

    r357f81e r4bc10e2  
    2020
    2121    def test_samples2seconds(self):
    22         self.assertEqual(aubio.cmd.samples2seconds(3200, 32000), "0.100000\t")
     22        self.assertEqual(aubio.cmd.samples2seconds(3200, 32000),
     23                "0.100000\t")
    2324
    2425    def test_samples2milliseconds(self):
    25         self.assertEqual(aubio.cmd.samples2milliseconds(3200, 32000), "100.000000\t")
     26        self.assertEqual(aubio.cmd.samples2milliseconds(3200, 32000),
     27                "100.000000\t")
    2628
    2729    def test_samples2samples(self):
    28         self.assertEqual(aubio.cmd.samples2samples(3200, 32000), "3200\t")
     30        self.assertEqual(aubio.cmd.samples2samples(3200, 32000),
     31                "3200\t")
    2932
    3033if __name__ == '__main__':
  • python/tests/test_note2midi.py

    r357f81e r4bc10e2  
    44from __future__ import unicode_literals
    55
    6 from aubio import note2midi, freq2note
     6from aubio import note2midi, freq2note, note2freq, float_type
    77from nose2.tools import params
    88import unittest
     
    112112class freq2note_simple_test(unittest.TestCase):
    113113
    114     def test_freq2note(self):
     114    def test_freq2note_above(self):
    115115        " make sure freq2note(441) == A4 "
    116116        self.assertEqual("A4", freq2note(441))
     117
     118    def test_freq2note_under(self):
     119        " make sure freq2note(439) == A4 "
     120        self.assertEqual("A4", freq2note(439))
     121
     122class note2freq_simple_test(unittest.TestCase):
     123
     124    def test_note2freq(self):
     125        " make sure note2freq('A3') == 220"
     126        self.assertEqual(220, note2freq("A3"))
     127
     128    def test_note2freq_under(self):
     129        " make sure note2freq(A4) == 440"
     130        if float_type == 'float32':
     131            self.assertEqual(440, note2freq("A4"))
     132        else:
     133            self.assertLess(abs(note2freq("A4")-440), 1.e-12)
    117134
    118135if __name__ == '__main__':
  • python/tests/test_slicing.py

    r357f81e r4bc10e2  
    2424    def test_slice_start_only_no_zero(self):
    2525        regions_start = [i*1000 for i in range(1, n_slices)]
    26         slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir)
     26        slice_source_at_stamps(self.source_file, regions_start,
     27                output_dir = self.output_dir, create_first=True)
    2728
    2829    def test_slice_start_beyond_end(self):
    2930        regions_start = [i*1000 for i in range(1, n_slices)]
    3031        regions_start += [count_samples_in_file(self.source_file) + 1000]
    31         slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir)
     32        slice_source_at_stamps(self.source_file, regions_start,
     33                output_dir = self.output_dir, create_first=True)
    3234
    3335    def test_slice_start_every_blocksize(self):
    3436        hopsize = 200
    35         regions_start = [i*hopsize for i in range(1, n_slices)]
     37        regions_start = [i*hopsize for i in range(0, n_slices)]
    3638        slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir,
    3739                hopsize = 200)
     40
     41    def test_slice_start_every_half_blocksize(self):
     42        hopsize = 200
     43        regions_start = [i*hopsize//2 for i in range(0, n_slices)]
     44        slice_source_at_stamps(self.source_file, regions_start,
     45                output_dir = self.output_dir, hopsize = 200)
    3846
    3947    def tearDown(self):
     
    92100            "number of samples written different from number of original samples")
    93101
     102    def test_slice_start_and_ends_with_missing_end(self):
     103        regions_start = [i*1000 for i in range(n_slices)]
     104        regions_ends = [r-1 for r in regions_start[1:]]
     105        slice_source_at_stamps(self.source_file, regions_start, regions_ends,
     106                output_dir = self.output_dir)
     107        written_samples = count_samples_in_directory(self.output_dir)
     108        original_samples = count_samples_in_file(self.source_file)
     109        total_files = count_files_in_directory(self.output_dir)
     110        assert_equal(n_slices, total_files,
     111            "number of slices created different from expected")
     112        assert_equal(written_samples, original_samples,
     113            "number of samples written different from number of original samples")
     114
    94115    def tearDown(self):
    95116        shutil.rmtree(self.output_dir)
     
    134155        regions_end = None
    135156        slice_source_at_stamps (self.source_file, regions_start, regions_end,
    136                 output_dir = self.output_dir)
     157                output_dir = self.output_dir, create_first=True)
    137158        total_files = count_files_in_directory(self.output_dir)
    138159        assert_equal(n_slices, total_files,
  • src/io/source_avcodec.c

    r357f81e r4bc10e2  
    3535// determine whether we use libavformat from ffmpeg or from libav
    3636#define FFMPEG_LIBAVFORMAT (LIBAVFORMAT_VERSION_MICRO > 99 )
    37 // max_analyze_duration2 was used from ffmpeg libavformat 55.43.100 through 57.2.100
     37// max_analyze_duration2 was used from ffmpeg libavformat 55.43.100 -> 57.2.100
    3838#define FFMPEG_LIBAVFORMAT_MAX_DUR2 FFMPEG_LIBAVFORMAT && ( \
    3939      (LIBAVFORMAT_VERSION_MAJOR == 55 && LIBAVFORMAT_VERSION_MINOR >= 43) \
     
    9393};
    9494
    95 // hack to create or re-create the context the first time _do or _do_multi is called
    96 void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s, uint_t multi);
    97 void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s, uint_t * read_samples);
     95// create or re-create the context when _do or _do_multi is called
     96void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s,
     97    uint_t multi);
     98// actually read a frame
     99void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s,
     100    uint_t * read_samples);
    98101
    99102uint_t aubio_source_avcodec_has_network_url(aubio_source_avcodec_t *s);
     
    112115
    113116
    114 aubio_source_avcodec_t * new_aubio_source_avcodec(const char_t * path, uint_t samplerate, uint_t hop_size) {
     117aubio_source_avcodec_t * new_aubio_source_avcodec(const char_t * path,
     118    uint_t samplerate, uint_t hop_size) {
    115119  aubio_source_avcodec_t * s = AUBIO_NEW(aubio_source_avcodec_t);
    116120  AVFormatContext *avFormatCtx = s->avFormatCtx;
     
    129133  }
    130134  if ((sint_t)samplerate < 0) {
    131     AUBIO_ERR("source_avcodec: Can not open %s with samplerate %d\n", path, samplerate);
     135    AUBIO_ERR("source_avcodec: Can not open %s with samplerate %d\n",
     136        path, samplerate);
    132137    goto beach;
    133138  }
    134139  if ((sint_t)hop_size <= 0) {
    135     AUBIO_ERR("source_avcodec: Can not open %s with hop_size %d\n", path, hop_size);
     140    AUBIO_ERR("source_avcodec: Can not open %s with hop_size %d\n",
     141        path, hop_size);
    136142    goto beach;
    137143  }
     
    173179    char errorstr[256];
    174180    av_strerror (err, errorstr, sizeof(errorstr));
    175     AUBIO_ERR("source_avcodec: Could not find stream information " "for %s (%s)\n", s->path,
    176         errorstr);
     181    AUBIO_ERR("source_avcodec: Could not find stream information "
     182        "for %s (%s)\n", s->path, errorstr);
    177183    goto beach;
    178184  }
     
    214220  avCodecCtx = avcodec_alloc_context3(codec);
    215221  if (!avCodecCtx) {
    216     AUBIO_ERR("source_avcodec: Failed to allocate the %s codec context for path %s\n",
    217         av_get_media_type_string(AVMEDIA_TYPE_AUDIO), s->path);
     222    AUBIO_ERR("source_avcodec: Failed to allocate the %s codec context "
     223        "for path %s\n", av_get_media_type_string(AVMEDIA_TYPE_AUDIO),
     224        s->path);
    218225    goto beach;
    219226  }
     
    230237  /* Copy codec parameters from input stream to output codec context */
    231238  if ((err = avcodec_parameters_to_context(avCodecCtx, codecpar)) < 0) {
    232     AUBIO_ERR("source_avcodec: Failed to copy %s codec parameters to decoder context for %s\n",
    233        av_get_media_type_string(AVMEDIA_TYPE_AUDIO), s->path);
     239    AUBIO_ERR("source_avcodec: Failed to copy %s codec parameters to "
     240        "decoder context for %s\n",
     241        av_get_media_type_string(AVMEDIA_TYPE_AUDIO), s->path);
    234242    goto beach;
    235243  }
     
    239247    char errorstr[256];
    240248    av_strerror (err, errorstr, sizeof(errorstr));
    241     AUBIO_ERR("source_avcodec: Could not load codec for %s (%s)\n", s->path, errorstr);
     249    AUBIO_ERR("source_avcodec: Could not load codec for %s (%s)\n", s->path,
     250        errorstr);
    242251    goto beach;
    243252  }
     
    266275
    267276  /* allocate output for avr */
    268   s->output = (smpl_t *)av_malloc(AUBIO_AVCODEC_MAX_BUFFER_SIZE * sizeof(smpl_t));
     277  s->output = (smpl_t *)av_malloc(AUBIO_AVCODEC_MAX_BUFFER_SIZE
     278      * sizeof(smpl_t));
    269279
    270280  s->read_samples = 0;
     
    294304}
    295305
    296 void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s, uint_t multi) {
     306void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s,
     307    uint_t multi)
     308{
    297309  // create or reset resampler to/from mono/multi-channel
    298310  if ( (multi != s->multi) || (s->avr == NULL) ) {
     
    309321#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
    310322
    311     av_opt_set_int(avr, "in_channel_layout",  input_layout,           0);
    312     av_opt_set_int(avr, "out_channel_layout", output_layout,          0);
    313     av_opt_set_int(avr, "in_sample_rate",     s->input_samplerate,    0);
    314     av_opt_set_int(avr, "out_sample_rate",    s->samplerate,          0);
     323    av_opt_set_int(avr, "in_channel_layout",  input_layout,              0);
     324    av_opt_set_int(avr, "out_channel_layout", output_layout,             0);
     325    av_opt_set_int(avr, "in_sample_rate",     s->input_samplerate,       0);
     326    av_opt_set_int(avr, "out_sample_rate",    s->samplerate,             0);
    315327    av_opt_set_int(avr, "in_sample_fmt",      s->avCodecCtx->sample_fmt, 0);
    316328#if HAVE_AUBIO_DOUBLE
    317     av_opt_set_int(avr, "out_sample_fmt",     AV_SAMPLE_FMT_DBL,      0);
    318 #else
    319     av_opt_set_int(avr, "out_sample_fmt",     AV_SAMPLE_FMT_FLT,      0);
     329    av_opt_set_int(avr, "out_sample_fmt",     AV_SAMPLE_FMT_DBL,         0);
     330#else
     331    av_opt_set_int(avr, "out_sample_fmt",     AV_SAMPLE_FMT_FLT,         0);
    320332#endif
    321333    // TODO: use planar?
     
    329341      char errorstr[256];
    330342      av_strerror (err, errorstr, sizeof(errorstr));
    331       AUBIO_ERR("source_avcodec: Could not open resampling context for %s (%s)\n",
    332           s->path, errorstr);
     343      AUBIO_ERR("source_avcodec: Could not open resampling context"
     344         " for %s (%s)\n", s->path, errorstr);
    333345      return;
    334346    }
     
    347359}
    348360
    349 void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s, uint_t * read_samples) {
     361void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s,
     362    uint_t * read_samples)
     363{
    350364  AVFormatContext *avFormatCtx = s->avFormatCtx;
    351365  AVCodecContext *avCodecCtx = s->avCodecCtx;
     
    388402      char errorstr[256];
    389403      av_strerror (err, errorstr, sizeof(errorstr));
    390       AUBIO_ERR("source_avcodec: could not read frame in %s (%s)\n", s->path, errorstr);
     404      AUBIO_ERR("source_avcodec: could not read frame in %s (%s)\n",
     405          s->path, errorstr);
    391406      s->eof = 1;
    392407      goto beach;
     
    406421  if (ret < 0) {
    407422    if (ret == AVERROR(EAGAIN)) {
    408       //AUBIO_WRN("source_avcodec: output is not available right now - user must try to send new input\n");
     423      //AUBIO_WRN("source_avcodec: output is not available right now - "
     424      //    "user must try to send new input\n");
    409425      goto beach;
    410426    } else if (ret == AVERROR_EOF) {
    411       AUBIO_WRN("source_avcodec: the decoder has been fully flushed, and there will be no more output frames\n");
     427      AUBIO_WRN("source_avcodec: the decoder has been fully flushed, "
     428          "and there will be no more output frames\n");
    412429    } else {
    413430      AUBIO_ERR("source_avcodec: decoding errors on %s\n", s->path);
     
    424441#endif
    425442  if (got_frame == 0) {
    426     AUBIO_WRN("source_avcodec: did not get a frame when reading %s\n", s->path);
     443    AUBIO_WRN("source_avcodec: did not get a frame when reading %s\n",
     444        s->path);
    427445    goto beach;
    428446  }
     
    431449  if (avFrame->channels != (sint_t)s->input_channels) {
    432450    AUBIO_WRN ("source_avcodec: trying to read from %d channel(s),"
    433         "but configured for %d; is '%s' corrupt?\n", avFrame->channels,
    434         s->input_channels, s->path);
    435     goto beach;
    436   }
     451        "but configured for %d; is '%s' corrupt?\n",
     452        avFrame->channels, s->input_channels, s->path);
     453    goto beach;
     454  }
     455#else
     456#warning "avutil < 53 is deprecated, crashes might occur on corrupt files"
    437457#endif
    438458
     
    455475#endif /* HAVE_AVRESAMPLE || HAVE_SWRESAMPLE */
    456476  if (out_samples <= 0) {
    457     AUBIO_WRN("source_avcodec: no sample found while converting frame (%s)\n", s->path);
     477    AUBIO_WRN("source_avcodec: no sample found while converting frame (%s)\n",
     478        s->path);
    458479    goto beach;
    459480  }
     
    473494}
    474495
    475 void aubio_source_avcodec_do(aubio_source_avcodec_t * s, fvec_t * read_data, uint_t * read){
     496void aubio_source_avcodec_do(aubio_source_avcodec_t * s, fvec_t * read_data,
     497    uint_t * read) {
    476498  uint_t i;
    477499  uint_t end = 0;
     
    505527}
    506528
    507 void aubio_source_avcodec_do_multi(aubio_source_avcodec_t * s, fmat_t * read_data, uint_t * read){
     529void aubio_source_avcodec_do_multi(aubio_source_avcodec_t * s,
     530    fmat_t * read_data, uint_t * read) {
    508531  uint_t i,j;
    509532  uint_t end = 0;
     
    551574
    552575uint_t aubio_source_avcodec_seek (aubio_source_avcodec_t * s, uint_t pos) {
    553   int64_t resampled_pos = (uint_t)ROUND(pos * (s->input_samplerate * 1. / s->samplerate));
     576  int64_t resampled_pos =
     577    (uint_t)ROUND(pos * (s->input_samplerate * 1. / s->samplerate));
    554578  int64_t min_ts = MAX(resampled_pos - 2000, 0);
    555579  int64_t max_ts = MIN(resampled_pos + 2000, INT64_MAX);
     
    559583    ret = AUBIO_OK;
    560584  } else {
    561     AUBIO_ERR("source_avcodec: failed seeking in %s (file not opened?)", s->path);
     585    AUBIO_ERR("source_avcodec: failed seeking in %s (file not opened?)",
     586        s->path);
    562587    return ret;
    563588  }
     
    570595      min_ts, resampled_pos, max_ts, seek_flags);
    571596  if (ret < 0) {
    572     AUBIO_ERR("source_avcodec: failed seeking to %d in file %s", pos, s->path);
     597    AUBIO_ERR("source_avcodec: failed seeking to %d in file %s",
     598        pos, s->path);
    573599  }
    574600  // reset read status
  • src/mathutils.c

    r357f81e r4bc10e2  
    523523  /* log(freq/A-2)/log(2) */
    524524  midi = freq / 6.875;
    525   midi = LOG (midi) / 0.69314718055995;
     525  midi = LOG (midi) / 0.6931471805599453;
    526526  midi *= 12;
    527527  midi -= 3;
     
    535535  if (midi > 140.) return 0.; // avoid infs
    536536  freq = (midi + 3.) / 12.;
    537   freq = EXP (freq * 0.69314718055995);
     537  freq = EXP (freq * 0.6931471805599453);
    538538  freq *= 6.875;
    539539  return freq;
  • src/spectral/filterbank_mel.h

    r357f81e r4bc10e2  
    5959
    6060  The filter coefficients are built according to Malcolm Slaney's Auditory
    61   Toolbox, available at http://engineering.purdue.edu/~malcolm/interval/1998-010/
    62   (see file mfcc.m).
     61  Toolbox, available online at the following address (see file mfcc.m):
     62
     63  https://engineering.purdue.edu/~malcolm/interval/1998-010/
    6364
    6465*/
  • src/spectral/mfcc.h

    r357f81e r4bc10e2  
    2727
    2828  The implementation follows the specifications established by Malcolm Slaney
    29   in its Auditory Toolbox, available online (see file mfcc.m).
     29  in its Auditory Toolbox, available online at the following address (see
     30  file mfcc.m):
    3031
    31   http://engineering.ecn.purdue.edu/~malcolm/interval/1998-010/
     32  https://engineering.purdue.edu/~malcolm/interval/1998-010/
    3233
    3334  \example spectral/test-mfcc.c
  • src/spectral/phasevoc.c

    r357f81e r4bc10e2  
    213213    synthold[i] += synth[i + pv->hop_s] * pv->scale;
    214214}
     215
     216uint_t aubio_pvoc_get_win(aubio_pvoc_t* pv)
     217{
     218  return pv->win_s;
     219}
     220
     221uint_t aubio_pvoc_get_hop(aubio_pvoc_t* pv)
     222{
     223  return pv->hop_s;
     224}
  • src/spectral/phasevoc.h

    r357f81e r4bc10e2  
    8989*/
    9090uint_t aubio_pvoc_get_win(aubio_pvoc_t* pv);
     91
    9192/** get hop size
    9293
  • src/synth/wavetable.c

    r357f81e r4bc10e2  
    165165  aubio_wavetable_set_amp (s, 0.);
    166166  //s->last_pos = 0;
    167   return aubio_wavetable_set_playing (s, 1);
     167  return aubio_wavetable_set_playing (s, 0);
    168168}
    169169
  • src/synth/wavetable.h

    r357f81e r4bc10e2  
    5151*/
    5252aubio_wavetable_t * new_aubio_wavetable(uint_t samplerate, uint_t hop_size);
    53 
    54 /** load source in wavetable
    55 
    56   \param o wavetable, created by new_aubio_wavetable()
    57   \param uri the uri of the source to load
    58 
    59   \return 0 if successful, non-zero otherwise
    60 
    61 */
    62 uint_t aubio_wavetable_load( aubio_wavetable_t * o, const char_t * uri );
    6353
    6454/** process wavetable function
  • wscript

    r357f81e r4bc10e2  
    606606    ctx.excl += ' **/.landscape.yml'
    607607    ctx.excl += ' **/.appveyor.yml'
    608     ctx.excl += ' **/circle.yml'
     608    ctx.excl += ' **/.circleci/*'
     609    ctx.excl += ' **/azure-pipelines.yml'
    609610    ctx.excl += ' **/.coveragerc'
Note: See TracChangeset for help on using the changeset viewer.