Changes in / [0770148:22d7902]


Ignore:
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • python/lib/gen_external.py

    r0770148 r22d7902  
    4747    'audio_unit',
    4848    'spectral_whitening',
     49    'timestretch', # TODO fix parsing of uint_t *read in _do
    4950]
    5051
  • src/aubio.h

    r0770148 r22d7902  
    222222#include "tempo/beattracking.h"
    223223#include "effects/pitchshift.h"
     224#include "effects/timestretch.h"
    224225#include "utils/scale.h"
    225226#include "utils/hist.h"
  • src/effects/pitchshift.h

    r0770148 r22d7902  
    4646
    4747*/
    48 void aubio_pitchshift_do (aubio_pitchshift_t * o, const fvec_t * in, fvec_t * out);
     48void aubio_pitchshift_do (aubio_pitchshift_t * o, const fvec_t * in,
     49        fvec_t * out);
    4950
    5051/** deletion of the pitch shifting object
     
    8283  \param pitchscale new pitch scale of the pitch shifting object
    8384
     85  pitchscale is a frequency ratio. It should be in the range [0.25, 4].
     86
    8487  \return 0 if successfull, non-zero otherwise
    8588
    8689*/
    87 uint_t aubio_pitchshift_set_pitchscale (aubio_pitchshift_t * o, smpl_t pitchscale);
     90uint_t aubio_pitchshift_set_pitchscale (aubio_pitchshift_t * o,
     91        smpl_t pitchscale);
    8892
    8993/** get the pitchscale of the pitch shifting object
     
    99103
    100104  \param o pitch shifting object as returned by new_aubio_pitchshift()
    101   \param transpose new pitch transposition of the pitch shifting object, expressed
    102   in semitones (should be in the range [-24;+24])
     105  \param transpose new pitch transposition of the pitch shifting object,
     106  expressed in semitones (should be in the range [-24;+24])
    103107
    104108  \return 0 if successfull, non-zero otherwise
    105109
    106110*/
    107 uint_t aubio_pitchshift_set_transpose (aubio_pitchshift_t * o, smpl_t transpose);
     111uint_t aubio_pitchshift_set_transpose (aubio_pitchshift_t * o,
     112        smpl_t transpose);
    108113
    109114/** get the transposition of the pitch shifting object, in semitones
  • src/effects/pitchshift_rubberband.c

    r0770148 r22d7902  
    2626#include "effects/pitchshift.h"
    2727
    28 #include "rubberband/rubberband-c.h"
     28#include <rubberband/rubberband-c.h>
    2929
    3030/** generic pitch shifting structure */
     
    7979  fvec_t *zeros = new_fvec(p->hopsize);
    8080  while (available <= (int)latency) {
    81     rubberband_process(p->rb, (const float* const*)&(zeros->data), p->hopsize, 0);
     81    rubberband_process(p->rb,
     82        (const float* const*)&(zeros->data), p->hopsize, 0);
    8283    available = rubberband_available(p->rb);
    8384  }
     
    113114    return AUBIO_OK;
    114115  } else {
    115     AUBIO_ERR("pitchshift: could not set pitchscale to %.2f\n", pitchscale);
     116    AUBIO_ERR("pitchshift: could not set pitchscale to '%f',"
     117        " should be in the range [0.25, 4.].\n", pitchscale);
    116118    return AUBIO_FAIL;
    117119  }
     
    131133    return aubio_pitchshift_set_pitchscale(p, pitchscale);
    132134  } else {
    133     AUBIO_ERR("pitchshift: could not set transpose to %.2f\n", transpose);
     135    AUBIO_ERR("pitchshift: could not set transpose to '%f',"
     136        " should be in the range [-24; 24.].\n", transpose);
    134137    return AUBIO_FAIL;
    135138  }
     
    150153    rubberband_retrieve(p->rb, (float* const*)&(out->data), p->hopsize);
    151154  } else {
    152     AUBIO_WRN("pitchshift: catching up with zeros, only %d available, needed: %d, "
    153         "current pitchscale: %f\n",
     155    AUBIO_WRN("pitchshift: catching up with zeros"
     156        ", only %d available, needed: %d, current pitchscale: %f\n",
    154157        rubberband_available(p->rb), p->hopsize, p->pitchscale);
    155158    fvec_zeros(out);
  • src/effects/rubberband_utils.c

    r0770148 r22d7902  
    55#ifdef HAVE_RUBBERBAND
    66
    7 #include "rubberband/rubberband-c.h"
     7#include <rubberband/rubberband-c.h>
    88
    99// check rubberband is 1.8.1, warn if 1.3
     
    1414#define RubberBandOptionDetectorSoft 0x00000000
    1515#endif
     16
     17#include <stdio.h>
     18#include <stdlib.h>
     19#include <string.h>
     20#include <assert.h>
     21
     22char_t** aubio_split_str(const char_t* str, const char_t sep) {
     23  char_t** result = 0;
     24  uint_t count = 0;
     25  char_t input[PATH_MAX];
     26  char_t* in_ptr = input;
     27  char_t* last_sep = 0;
     28  char_t delim[2]; delim[0] = sep; delim[1] = 0;
     29
     30  strncpy(input, str, PATH_MAX);
     31  input[PATH_MAX - 1] = '\0';
     32
     33  // count number of elements
     34  while (*in_ptr) {
     35    if (sep == *in_ptr) {
     36      count++;
     37      last_sep = in_ptr;
     38    }
     39    in_ptr++;
     40  }
     41  // add space for trailing token.
     42  count += last_sep < (input + strlen(input) - 1);
     43  count++;
     44
     45  result = AUBIO_ARRAY(char_t*, count);
     46  if (result) {
     47    uint_t idx  = 0;
     48    char_t* params = strtok(input, delim);
     49    while (params) {
     50      // make sure we don't got in the wild
     51      assert(idx < count);
     52      *(result + idx++) = strdup(params);
     53      params = strtok(0, delim);
     54    }
     55    assert(idx == count - 1);
     56    // add null string at the end
     57    *(result + idx) = 0;
     58  }
     59  return result;
     60}
    1661
    1762RubberBandOptions aubio_get_rubberband_opts(const char_t *mode)
     
    4489    // nothing to do
    4590  } else {
    46     // failed parsing option string
    47     return -1;
     91    // attempt to parse a list of options, separated with ','
     92    char_t **params = aubio_split_str(mode, ':');
     93    uint_t i = 0;
     94    if (!params || !params[0]) {
     95      // memory failure occurred or empty string was passed
     96      AUBIO_ERR("rubberband_utils: failed parsing options\n");
     97      rboptions = -1;
     98    }
     99    while (*(params + i) != NULL) {
     100      if ( strcmp(params[i], "ProcessOffline" ) == 0 )        {
     101             rboptions = RubberBandOptionProcessOffline;
     102        // TODO: add wrapper to rb study(smpl_t *input, uint_t write)
     103        AUBIO_ERR("rubberband_utils: RubberBandOptionProcessOffline is not available\n");
     104        rboptions = -1;
     105      }
     106      else if ( strcmp(params[i], "ProcessRealTime" ) == 0 )       rboptions |= RubberBandOptionProcessRealTime;
     107      else if ( strcmp(params[i], "StretchElastic" ) == 0 )        rboptions |= RubberBandOptionStretchElastic;
     108      else if ( strcmp(params[i], "StretchPrecise" ) == 0 )        rboptions |= RubberBandOptionStretchPrecise;
     109      else if ( strcmp(params[i], "TransientsCrisp" ) == 0 )       rboptions |= RubberBandOptionTransientsCrisp;
     110      else if ( strcmp(params[i], "TransientsMixed" ) == 0 )       rboptions |= RubberBandOptionTransientsMixed;
     111      else if ( strcmp(params[i], "TransientsSmooth" ) == 0 )      rboptions |= RubberBandOptionTransientsSmooth;
     112      else if ( strcmp(params[i], "DetectorCompound" ) == 0 )      rboptions |= RubberBandOptionDetectorCompound;
     113      else if ( strcmp(params[i], "DetectorPercussive" ) == 0 )    rboptions |= RubberBandOptionDetectorPercussive;
     114      else if ( strcmp(params[i], "DetectorSoft" ) == 0 )          rboptions |= RubberBandOptionDetectorSoft;
     115      else if ( strcmp(params[i], "PhaseLaminar" ) == 0 )          rboptions |= RubberBandOptionPhaseLaminar;
     116      else if ( strcmp(params[i], "PhaseIndependent" ) == 0 )      rboptions |= RubberBandOptionPhaseIndependent;
     117      else if ( strcmp(params[i], "ThreadingAuto" ) == 0 )         rboptions |= RubberBandOptionThreadingAuto;
     118      else if ( strcmp(params[i], "ThreadingNever" ) == 0 )        rboptions |= RubberBandOptionThreadingNever;
     119      else if ( strcmp(params[i], "ThreadingAlways" ) == 0 )       rboptions |= RubberBandOptionThreadingAlways;
     120      else if ( strcmp(params[i], "WindowStandard" ) == 0 )        rboptions |= RubberBandOptionWindowStandard;
     121      else if ( strcmp(params[i], "WindowShort" ) == 0 )           rboptions |= RubberBandOptionWindowShort;
     122      else if ( strcmp(params[i], "WindowLong" ) == 0 )            rboptions |= RubberBandOptionWindowLong;
     123      else if ( strcmp(params[i], "SmoothingOff" ) == 0 )          rboptions |= RubberBandOptionSmoothingOff;
     124      else if ( strcmp(params[i], "SmoothingOn" ) == 0 )           rboptions |= RubberBandOptionSmoothingOn;
     125      else if ( strcmp(params[i], "FormantShifted" ) == 0 )        rboptions |= RubberBandOptionFormantShifted;
     126      else if ( strcmp(params[i], "FormantPreserved" ) == 0 )      rboptions |= RubberBandOptionFormantPreserved;
     127      else if ( strcmp(params[i], "PitchHighSpeed" ) == 0 )        rboptions |= RubberBandOptionPitchHighSpeed;
     128      else if ( strcmp(params[i], "PitchHighQuality" ) == 0 )      rboptions |= RubberBandOptionPitchHighQuality;
     129      else if ( strcmp(params[i], "PitchHighConsistency" ) == 0 )  rboptions |= RubberBandOptionPitchHighConsistency;
     130      else if ( strcmp(params[i], "ChannelsApart" ) == 0 )         rboptions |= RubberBandOptionChannelsApart;
     131      else if ( strcmp(params[i], "ChannelsTogether" ) == 0 )      rboptions |= RubberBandOptionChannelsTogether;
     132      else {
     133        AUBIO_ERR("rubberband_utils: did not understand option '%s', should be one of: "
     134          "StretchElastic|StretchPrecise, TransientsCrisp|TransientsMixed|TransientsSmooth, "
     135          "DetectorCompound|DetectorPercussive|DetectorSoft, PhaseLaminar|PhaseIndependent, "
     136          "ThreadingAuto|ThreadingNever|ThreadingAlways, WindowStandard|WindowLong|WindowShort, "
     137          "SmoothingOn|SmoothingOff, FormantShifted|FormantPreserved, "
     138          "PitchHighSpeed|PitchHighQuality|PitchHighConsistency, ChannelsApart|ChannelsTogether\n"
     139          , params[i]);
     140        rboptions = -1;
     141      }
     142      AUBIO_FREE(params[i]);
     143      i++;
     144    }
     145    AUBIO_FREE(params);
    48146  }
    49   // other options to include
    50   //p->rboptions |= RubberBandOptionWindowStandard;
    51   //p->rboptions |= RubberBandOptionSmoothingOff;
    52   //p->rboptions |= RubberBandOptionFormantShifted;
    53   //p->rboptions |= RubberBandOptionPitchHighConsistency;
    54147  return rboptions;
    55148}
  • tests/src/effects/test-pitchshift.c

    r0770148 r22d7902  
    7676  del_fvec(out);
    7777beach_fvec:
     78  aubio_cleanup();
    7879#else
    7980  err = 0;
Note: See TracChangeset for help on using the changeset viewer.