Ignore:
Timestamp:
Mar 22, 2013, 6:15:46 PM (11 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
dc798e1
Parents:
6ff6d18 (diff), 18a378e (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 'device' into develop

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/source_sndfile.c

    r6ff6d18 r5d16185  
    2727
    2828#include "aubio_priv.h"
     29#include "fvec.h"
     30#include "fmat.h"
    2931#include "source_sndfile.h"
    30 #include "fvec.h"
    3132
    3233#include "temporal/resampler.h"
     
    159160    data[j] = 0;
    160161    for (i = 0; i < input_channels; i++) {
    161       data[j] += (smpl_t)s->scratch_data[input_channels*j+i];
     162      data[j] += s->scratch_data[input_channels*j+i];
    162163    }
    163164    data[j] /= (smpl_t)input_channels;
     
    171172
    172173  *read = (int)FLOOR(s->ratio * read_samples / input_channels + .5);
     174
     175  if (*read < s->hop_size) {
     176    for (j = *read; j < s->hop_size; j++) {
     177      data[j] = 0;
     178    }
     179  }
     180
     181}
     182
     183void aubio_source_sndfile_do_multi(aubio_source_sndfile_t * s, fmat_t * read_data, uint_t * read){
     184  uint_t i,j, input_channels = s->input_channels;
     185  /* do actual reading */
     186  sf_count_t read_samples = sf_read_float (s->handle, s->scratch_data, s->scratch_size);
     187
     188  smpl_t **data;
     189
     190#ifdef HAVE_SAMPLERATE
     191  if (s->ratio != 1) {
     192    AUBIO_ERR("source_sndfile: no multi channel resampling yet");
     193    return;
     194    //data = s->input_data->data;
     195  } else
     196#endif /* HAVE_SAMPLERATE */
     197  {
     198    data = read_data->data;
     199  }
     200
     201  /* de-interleaving data */
     202  for (j = 0; j < read_samples / input_channels; j++) {
     203    for (i = 0; i < input_channels; i++) {
     204      data[i][j] = (smpl_t)s->scratch_data[input_channels*j+i];
     205    }
     206  }
     207
     208#ifdef HAVE_SAMPLERATE
     209  if (s->resampler) {
     210    //aubio_resampler_do(s->resampler, s->input_data, read_data);
     211  }
     212#endif /* HAVE_SAMPLERATE */
     213
     214  *read = (int)FLOOR(s->ratio * read_samples / input_channels + .5);
     215
     216  if (*read < s->hop_size) {
     217    for (i = 0; i < input_channels; i++) {
     218      for (j = *read; j < s->hop_size; j++) {
     219        data[i][j] = 0.;
     220      }
     221    }
     222  }
     223
    173224}
    174225
    175226uint_t aubio_source_sndfile_get_samplerate(aubio_source_sndfile_t * s) {
    176227  return s->samplerate;
     228}
     229
     230uint_t aubio_source_sndfile_get_channels(aubio_source_sndfile_t * s) {
     231  return s->input_channels;
     232}
     233
     234uint_t aubio_source_sndfile_seek (aubio_source_sndfile_t * s, uint_t pos) {
     235  uint_t resampled_pos = (uint_t)ROUND(pos * s->input_samplerate * 1. / s->samplerate);
     236  return sf_seek (s->handle, resampled_pos, SEEK_SET);
    177237}
    178238
Note: See TracChangeset for help on using the changeset viewer.