Ignore:
Timestamp:
Mar 12, 2017, 11:26:24 AM (7 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
sampler
Children:
bde49c4a
Parents:
71f2e5f (diff), 67b6618 (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 'origin/master' into sampler

Conflicts:

.travis.yml
Makefile
examples/aubionotes.c
examples/parse_args.h
python/demos/demo_timestretch_online.py
python/lib/moresetuptools.py
python/tests/test_source.py
setup.py
src/io/source.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/source_sndfile.c

    r71f2e5f r41b985f  
    1919*/
    2020
    21 
    22 #include "config.h"
     21#include "aubio_priv.h"
    2322
    2423#ifdef HAVE_SNDFILE
     
    2625#include <sndfile.h>
    2726
    28 #include "aubio_priv.h"
    2927#include "fvec.h"
    3028#include "fmat.h"
     
    3331#include "temporal/resampler.h"
    3432
    35 #define MAX_CHANNELS 6
    3633#define MAX_SIZE 4096
    37 #define MAX_SAMPLES MAX_CHANNELS * MAX_SIZE
     34#define MAX_SAMPLES AUBIO_MAX_CHANNELS * MAX_SIZE
    3835
    3936#if !HAVE_AUBIO_DOUBLE
     
    141138    if (s->ratio > 1) {
    142139      // we would need to add a ring buffer for these
    143       if ( (uint_t)(s->input_hop_size * s->ratio + .5)  != s->hop_size ) {
     140      if ( (uint_t)FLOOR(s->input_hop_size * s->ratio + .5)  != s->hop_size ) {
    144141        AUBIO_ERR("source_sndfile: can not upsample %s from %d to %d\n", s->path,
    145142            s->input_samplerate, s->samplerate);
     
    298295uint_t aubio_source_sndfile_seek (aubio_source_sndfile_t * s, uint_t pos) {
    299296  uint_t resampled_pos = (uint_t)ROUND(pos / s->ratio);
    300   sf_count_t sf_ret = sf_seek (s->handle, resampled_pos, SEEK_SET);
     297  sf_count_t sf_ret;
     298  if (s->handle == NULL) {
     299    AUBIO_ERR("source_sndfile: failed seeking in %s (file not opened?)\n",
     300        s->path);
     301    return AUBIO_FAIL;
     302  }
     303  if ((sint_t)pos < 0) {
     304    AUBIO_ERR("source_sndfile: could not seek %s at %d (seeking position"
     305       " should be >= 0)\n", s->path, pos);
     306    return AUBIO_FAIL;
     307  }
     308  sf_ret = sf_seek (s->handle, resampled_pos, SEEK_SET);
    301309  if (sf_ret == -1) {
    302310    AUBIO_ERR("source_sndfile: Failed seeking %s at %d: %s\n", s->path, pos, sf_strerror (NULL));
     
    313321uint_t aubio_source_sndfile_close (aubio_source_sndfile_t *s) {
    314322  if (!s->handle) {
    315     return AUBIO_FAIL;
     323    return AUBIO_OK;
    316324  }
    317325  if(sf_close(s->handle)) {
Note: See TracChangeset for help on using the changeset viewer.