Changeset bde49c4a
- Timestamp:
- Mar 12, 2017, 2:19:46 PM (8 years ago)
- Branches:
- sampler
- Children:
- 4ac4ebc
- Parents:
- 41b985f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/effects/rubberband_utils.c
r41b985f rbde49c4a 15 15 #define RubberBandOptionDetectorSoft 0x00000000 16 16 #endif 17 18 #include <stdio.h> 19 #include <stdlib.h> 20 #include <string.h> 21 #include <assert.h> 22 23 char** aubio_split_str(char_t* input, const char_t sep) { 24 char_t** result = 0; 25 uint_t count = 0; 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 // count number of elements 31 while (*in_ptr) { 32 if (sep == *in_ptr) { 33 count++; 34 last_sep = in_ptr; 35 } 36 in_ptr++; 37 } 38 // add space for trailing token. 39 count += last_sep < (input + strlen(input) - 1); 40 // add one more for terminating null string 41 count++; 42 43 result = malloc(sizeof(char*) * count); 44 if (result) { 45 size_t idx = 0; 46 char* params = strtok(input, delim); 47 while (params) { 48 // make sure we don't got in the wild 49 assert(idx < count); 50 *(result + idx++) = strdup(params); 51 params = strtok(0, delim); 52 } 53 assert(idx == count - 1); 54 // add null string at the end 55 *(result + idx) = 0; 56 } 57 return result; 58 } 17 59 18 60 RubberBandOptions aubio_get_rubberband_opts(const char_t *mode) … … 45 87 // nothing to do 46 88 } else { 47 // failed parsing option string 48 return -1; 89 // attempt to parse a list of options, separated with ',' 90 char *modecopy = strndup(mode, PATH_MAX); 91 char **params = aubio_split_str(modecopy, ','); 92 uint_t i; 93 if (!params) { 94 return -1; 95 } 96 for (i = 0; *(params + i); i++) { 97 if ( strcmp(params[i], "ProcessOffline" ) == 0 ) { 98 rboptions = RubberBandOptionProcessOffline; 99 AUBIO_WRN("rubberband_utils: RubberBandOptionProcessOffline is not available in aubio yet\n"); 100 // TODO: add wrapper to function study(smpl_t *input, uint_t write) 101 } 102 else if ( strcmp(params[i], "ProcessRealTime" ) == 0 ) rboptions |= RubberBandOptionProcessRealTime; 103 else if ( strcmp(params[i], "StretchElastic" ) == 0 ) rboptions |= RubberBandOptionStretchElastic; 104 else if ( strcmp(params[i], "StretchPrecise" ) == 0 ) rboptions |= RubberBandOptionStretchPrecise; 105 else if ( strcmp(params[i], "TransientsCrisp" ) == 0 ) rboptions |= RubberBandOptionTransientsCrisp; 106 else if ( strcmp(params[i], "TransientsMixed" ) == 0 ) rboptions |= RubberBandOptionTransientsMixed; 107 else if ( strcmp(params[i], "TransientsSmooth" ) == 0 ) rboptions |= RubberBandOptionTransientsSmooth; 108 else if ( strcmp(params[i], "DetectorCompound" ) == 0 ) rboptions |= RubberBandOptionDetectorCompound; 109 else if ( strcmp(params[i], "DetectorPercussive" ) == 0 ) rboptions |= RubberBandOptionDetectorPercussive; 110 else if ( strcmp(params[i], "DetectorSoft" ) == 0 ) rboptions |= RubberBandOptionDetectorSoft; 111 else if ( strcmp(params[i], "PhaseLaminar" ) == 0 ) rboptions |= RubberBandOptionPhaseLaminar; 112 else if ( strcmp(params[i], "PhaseIndependent" ) == 0 ) rboptions |= RubberBandOptionPhaseIndependent; 113 else if ( strcmp(params[i], "ThreadingAuto" ) == 0 ) rboptions |= RubberBandOptionThreadingAuto; 114 else if ( strcmp(params[i], "ThreadingNever" ) == 0 ) rboptions |= RubberBandOptionThreadingNever; 115 else if ( strcmp(params[i], "ThreadingAlways" ) == 0 ) rboptions |= RubberBandOptionThreadingAlways; 116 else if ( strcmp(params[i], "WindowStandard" ) == 0 ) rboptions |= RubberBandOptionWindowStandard; 117 else if ( strcmp(params[i], "WindowShort" ) == 0 ) rboptions |= RubberBandOptionWindowShort; 118 else if ( strcmp(params[i], "WindowLong" ) == 0 ) rboptions |= RubberBandOptionWindowLong; 119 else if ( strcmp(params[i], "SmoothingOff" ) == 0 ) rboptions |= RubberBandOptionSmoothingOff; 120 else if ( strcmp(params[i], "SmoothingOn" ) == 0 ) rboptions |= RubberBandOptionSmoothingOn; 121 else if ( strcmp(params[i], "FormantShifted" ) == 0 ) rboptions |= RubberBandOptionFormantShifted; 122 else if ( strcmp(params[i], "FormantPreserved" ) == 0 ) rboptions |= RubberBandOptionFormantPreserved; 123 else if ( strcmp(params[i], "PitchHighSpeed" ) == 0 ) rboptions |= RubberBandOptionPitchHighSpeed; 124 else if ( strcmp(params[i], "PitchHighQuality" ) == 0 ) rboptions |= RubberBandOptionPitchHighQuality; 125 else if ( strcmp(params[i], "PitchHighConsistency" ) == 0 ) rboptions |= RubberBandOptionPitchHighConsistency; 126 else if ( strcmp(params[i], "ChannelsApart" ) == 0 ) rboptions |= RubberBandOptionChannelsApart; 127 else if ( strcmp(params[i], "ChannelsTogether" ) == 0 ) rboptions |= RubberBandOptionChannelsTogether; 128 else { 129 AUBIO_WRN("rubberband_utils: did not understand option '%s', should be one of: " 130 "StretchElastic|StretchPrecise, TransientsCrisp|TransientsMixed|TransientsSmooth, " 131 "DetectorCompound|DetectorPercussive|DetectorSoft, PhaseLaminar|PhaseIndependent, " 132 "ThreadingAuto|ThreadingNever|ThreadingAlways, WindowStandard|WindowLong|WindowShort, " 133 "SmoothingOn|SmoothingOff, FormantShifted|FormantPreserved, " 134 "PitchHighSpeed|PitchHighQuality|PitchHighConsistency, ChannelsApart|ChannelsTogether\n" 135 , params[i]); 136 } 137 free(params[i]); 138 } 139 free(params); 140 free(modecopy); 49 141 } 50 // other options to include51 //p->rboptions |= RubberBandOptionWindowStandard;52 //p->rboptions |= RubberBandOptionSmoothingOff;53 //p->rboptions |= RubberBandOptionFormantShifted;54 //p->rboptions |= RubberBandOptionPitchHighConsistency;55 142 return rboptions; 56 143 }
Note: See TracChangeset
for help on using the changeset viewer.