Changeset 25a19c2


Ignore:
Timestamp:
Sep 21, 2016, 5:36:50 PM (7 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/cnn, feature/crepe, feature/pitchshift, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch
Children:
3ffedf22
Parents:
6e6849d
Message:

src/effects/pitchshift.h: split implementations in two files, move option parsing to rubberband_utils.c

Location:
src/effects
Files:
2 added
1 moved

Legend:

Unmodified
Added
Removed
  • src/effects/pitchshift_rubberband.c

    r6e6849d r25a19c2  
    2020
    2121#include "config.h"
     22
     23#ifdef HAVE_RUBBERBAND
     24
    2225#include "aubio_priv.h"
    2326#include "fvec.h"
    2427#include "effects/pitchshift.h"
    2528
    26 #ifdef HAVE_RUBBERBAND
    27 
    2829#include "rubberband/rubberband-c.h"
    29 
    30 // check rubberband is 1.8.1, warn if 1.3
    31 #if !((RUBBERBAND_API_MAJOR_VERSION >= 2) && \
    32     (RUBBERBAND_API_MINOR_VERSION >= 5))
    33 #warning RubberBandOptionDetectorSoft not available, \
    34  please upgrade rubberband to version 1.8.1 or higher
    35 #define RubberBandOptionDetectorSoft 0x00000000
    36 #endif
    3730
    3831/** generic pitch shifting structure */
     
    4639  RubberBandOptions rboptions;
    4740};
     41
     42extern RubberBandOptions aubio_get_rubberband_opts(const char_t *mode);
    4843
    4944aubio_pitchshift_t *
     
    6257  }
    6358
    64   p->rboptions = RubberBandOptionProcessRealTime;
    65 
    66   if ( strcmp(mode,"crispness:0") == 0 ) {
    67     p->rboptions |= RubberBandOptionTransientsSmooth;
    68     p->rboptions |= RubberBandOptionWindowLong;
    69     p->rboptions |= RubberBandOptionPhaseIndependent;
    70   } else if ( strcmp(mode, "crispness:1") == 0 ) {
    71     p->rboptions |= RubberBandOptionDetectorSoft;
    72     p->rboptions |= RubberBandOptionTransientsSmooth;
    73     p->rboptions |= RubberBandOptionWindowLong;
    74     p->rboptions |= RubberBandOptionPhaseIndependent;
    75   } else if ( strcmp(mode, "crispness:2") == 0 ) {
    76     p->rboptions |= RubberBandOptionTransientsSmooth;
    77     p->rboptions |= RubberBandOptionPhaseIndependent;
    78   } else if ( strcmp(mode, "crispness:3") == 0 ) {
    79     p->rboptions |= RubberBandOptionTransientsSmooth;
    80   } else if ( strcmp(mode, "crispness:4") == 0 ) {
    81     // same as "default"
    82   } else if ( strcmp(mode, "crispness:5") == 0 ) {
    83     p->rboptions |= RubberBandOptionTransientsCrisp;
    84   } else if ( strcmp(mode, "crispness:6") == 0 ) {
    85     p->rboptions |= RubberBandOptionTransientsCrisp;
    86     p->rboptions |= RubberBandOptionWindowShort;
    87     p->rboptions |= RubberBandOptionPhaseIndependent;
    88   } else if ( strcmp(mode, "default") == 0 ) {
    89     // nothing to do
    90   } else {
    91     AUBIO_ERR("pitchshift: unknown pitch shifting method %s\n", mode);
     59  p->rboptions = aubio_get_rubberband_opts(mode);
     60  if (p->rboptions < 0) {
     61    AUBIO_ERR("timestretch: unknown pitch shifting method %s\n", mode);
    9262    goto beach;
    9363  }
    9464  //AUBIO_MSG("pitchshift: using pitch shifting method %s\n", mode);
    9565
    96   //p->rboptions |= RubberBandOptionTransientsCrisp;
    97   //p->rboptions |= RubberBandOptionWindowStandard;
    98   //p->rboptions |= RubberBandOptionSmoothingOff;
    99   //p->rboptions |= RubberBandOptionFormantShifted;
    100   //p->rboptions |= RubberBandOptionPitchHighConsistency;
    10166  p->rb = rubberband_new(samplerate, 1, p->rboptions, 1., p->pitchscale);
    10267  rubberband_set_max_process_size(p->rb, p->hopsize);
     
    187152}
    188153
    189 #else
    190 
    191 // TODO fallback pitch shifting implementation
    192 
    193 struct _aubio_pitchshift_t
    194 {
    195   void *dummy;
    196 };
    197 
    198 void aubio_pitchshift_do (aubio_pitchshift_t * o UNUSED, const fvec_t * in UNUSED,
    199     fvec_t * out UNUSED) {
    200 }
    201 
    202 void del_aubio_pitchshift (aubio_pitchshift_t * o UNUSED) {
    203 }
    204 
    205 aubio_pitchshift_t *new_aubio_pitchshift (const char_t * method UNUSED,
    206     smpl_t pitchscale UNUSED, uint_t hop_size UNUSED, uint_t samplerate UNUSED)
    207 {
    208   AUBIO_ERR ("aubio was not compiled with rubberband\n");
    209   return NULL;
    210 }
    211 
    212 uint_t aubio_pitchshift_set_pitchscale (aubio_pitchshift_t * o UNUSED, smpl_t pitchscale UNUSED)
    213 {
    214   return AUBIO_FAIL;
    215 }
    216 
    217 smpl_t aubio_pitchshift_get_pitchscale (aubio_pitchshift_t * o UNUSED)
    218 {
    219   return 1.;
    220 }
    221 
    222 uint_t aubio_pitchshift_set_transpose (aubio_pitchshift_t * o UNUSED, smpl_t transpose UNUSED) {
    223   return AUBIO_FAIL;
    224 }
    225 
    226 smpl_t aubio_pitchshift_get_transpose (aubio_pitchshift_t * o UNUSED) {
    227   return 0.;
    228 }
    229 
    230 uint_t aubio_pitchshift_get_latency (aubio_pitchshift_t * o UNUSED) {
    231   return 0.;
    232 }
    233 
    234 // end of dummy implementation
    235 
    236 #endif /* HAVE_RUBBERBAND */
     154#endif
Note: See TracChangeset for help on using the changeset viewer.