Changeset b2f41be for src/effects/rubberband_utils.c
- Timestamp:
- Dec 7, 2018, 6:03:19 PM (6 years ago)
- Branches:
- feature/cnn, feature/crepe, feature/timestretch, fix/ffmpeg5, master
- Children:
- ff87a67
- Parents:
- 97a5ac08
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/effects/rubberband_utils.c
r97a5ac08 rb2f41be 20 20 #include <assert.h> 21 21 22 char ** aubio_split_str(char_t* input, const char_t sep) {22 char_t** aubio_split_str(const char_t* str, const char_t sep) { 23 23 char_t** result = 0; 24 24 uint_t count = 0; 25 char_t input[PATH_MAX]; 25 26 char_t* in_ptr = input; 26 27 char_t* last_sep = 0; 27 28 char_t delim[2]; delim[0] = sep; delim[1] = 0; 29 30 strncpy(input, str, PATH_MAX); 31 input[PATH_MAX - 1] = '\0'; 28 32 29 33 // count number of elements … … 37 41 // add space for trailing token. 38 42 count += last_sep < (input + strlen(input) - 1); 39 // add one more for terminating null string40 43 count++; 41 44 42 result = malloc(sizeof(char*) *count);45 result = AUBIO_ARRAY(char_t*, count); 43 46 if (result) { 44 size_t idx = 0;45 char * params = strtok(input, delim);47 uint_t idx = 0; 48 char_t* params = strtok(input, delim); 46 49 while (params) { 47 50 // make sure we don't got in the wild … … 87 90 } else { 88 91 // attempt to parse a list of options, separated with ',' 89 char *modecopy = strndup(mode, PATH_MAX); 90 char **params = aubio_split_str(modecopy, ':'); 91 uint_t i; 92 if (!params) { 93 return -1; 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; 94 98 } 95 for (i = 0; *(params + i); i++) {99 while (*(params + i) != NULL) { 96 100 if ( strcmp(params[i], "ProcessOffline" ) == 0 ) { 97 101 rboptions = RubberBandOptionProcessOffline; 98 AUBIO_WRN("rubberband_utils: RubberBandOptionProcessOffline is not available in aubio yet\n"); 99 // TODO: add wrapper to function study(smpl_t *input, uint_t write) 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; 100 105 } 101 106 else if ( strcmp(params[i], "ProcessRealTime" ) == 0 ) rboptions |= RubberBandOptionProcessRealTime; … … 133 138 "PitchHighSpeed|PitchHighQuality|PitchHighConsistency, ChannelsApart|ChannelsTogether\n" 134 139 , params[i]); 135 r eturn-1;140 rboptions = -1; 136 141 } 137 free(params[i]); 142 AUBIO_FREE(params[i]); 143 i++; 138 144 } 139 free(params); 140 free(modecopy); 145 AUBIO_FREE(params); 141 146 } 142 147 return rboptions;
Note: See TracChangeset
for help on using the changeset viewer.