Changeset b81a642 for python/ext


Ignore:
Timestamp:
Nov 28, 2016, 6:26:18 PM (7 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, sampler, yinfft+
Children:
2f89ef4
Parents:
fa6373c
Message:

python/ext/py-sink.c: always set samplerate and channels in init

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/ext/py-sink.c

    rfa6373c rb81a642  
    8787
    8888  self->samplerate = Py_aubio_default_samplerate;
    89   if ((sint_t)samplerate > 0) {
     89  if (samplerate != 0) {
    9090    self->samplerate = samplerate;
    91   } else if ((sint_t)samplerate < 0) {
    92     PyErr_SetString (PyExc_ValueError,
    93         "can not use negative value for samplerate");
    94     return NULL;
    9591  }
    9692
    9793  self->channels = 1;
    98   if ((sint_t)channels > 0) {
     94  if (channels != 0) {
    9995    self->channels = channels;
    100   } else if ((sint_t)channels < 0) {
    101     PyErr_SetString (PyExc_ValueError,
    102         "can not use negative or null value for channels");
    103     return NULL;
    10496  }
    10597
     
    110102Py_sink_init (Py_sink * self, PyObject * args, PyObject * kwds)
    111103{
    112   if (self->channels == 1) {
    113     self->o = new_aubio_sink ( self->uri, self->samplerate );
    114   } else {
    115     self->o = new_aubio_sink ( self->uri, 0 );
    116     aubio_sink_preset_channels ( self->o, self->channels );
    117     aubio_sink_preset_samplerate ( self->o, self->samplerate );
    118   }
     104  self->o = new_aubio_sink ( self->uri, 0 );
    119105  if (self->o == NULL) {
    120     PyErr_SetString (PyExc_RuntimeError, "error creating sink with this uri");
     106    // error string was set in new_aubio_sink
    121107    return -1;
    122108  }
     109  if (aubio_sink_preset_channels(self->o, self->channels) != 0) {
     110    // error string was set in aubio_sink_preset_channels
     111    return -1;
     112  }
     113  if (aubio_sink_preset_samplerate(self->o, self->samplerate) != 0) {
     114    // error string was set in aubio_sink_preset_samplerate
     115    return -1;
     116  }
     117
    123118  self->samplerate = aubio_sink_get_samplerate ( self->o );
    124119  self->channels = aubio_sink_get_channels ( self->o );
Note: See TracChangeset for help on using the changeset viewer.