- Timestamp:
- Sep 21, 2014, 2:02:26 AM (10 years ago)
- 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:
- 11b49d7
- Parents:
- a79ec76
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/ext/py-source.c
ra79ec76 r24931d5 77 77 uint_t samplerate = 0; 78 78 uint_t hop_size = 0; 79 static char *kwlist[] = { "uri", "samplerate", "hop_size", NULL }; 80 81 if (!PyArg_ParseTupleAndKeywords (args, kwds, "|sII", kwlist, 82 &uri, &samplerate, &hop_size)) { 79 uint_t channels = 0; 80 static char *kwlist[] = { "uri", "samplerate", "hop_size", "channels", NULL }; 81 82 if (!PyArg_ParseTupleAndKeywords (args, kwds, "|sIII", kwlist, 83 &uri, &samplerate, &hop_size, &channels)) { 83 84 return NULL; 84 85 } … … 113 114 } 114 115 116 self->channels = 1; 117 if ((sint_t)channels >= 0) { 118 self->channels = channels; 119 } else if ((sint_t)channels < 0) { 120 PyErr_SetString (PyExc_ValueError, 121 "can not use negative value for channels"); 122 return NULL; 123 } 124 115 125 return (PyObject *) self; 116 126 } … … 121 131 self->o = new_aubio_source ( self->uri, self->samplerate, self->hop_size ); 122 132 if (self->o == NULL) { 123 PyErr_SetString (PyExc_StandardError, "error creating object"); 133 char_t errstr[30 + strlen(self->uri)]; 134 sprintf(errstr, "error creating source with %s", self->uri); 135 PyErr_SetString (PyExc_StandardError, errstr); 124 136 return -1; 125 137 } 126 138 self->samplerate = aubio_source_get_samplerate ( self->o ); 127 self->channels = aubio_source_get_channels ( self->o ); 139 if (self->channels == 0) { 140 self->channels = aubio_source_get_channels ( self->o ); 141 } 128 142 129 143 return 0;
Note: See TracChangeset
for help on using the changeset viewer.