Beispiel #1
0
static PyObject* cAction_fade(PyObject* self, PyObject* args)
{
    PyObject *objInSound;
    float volume = 1.0f;
    float from = 0.0f;
    float to = 1.0f;
    
    if (!PyArg_ParseTuple(args, "O|f|f|f", &objInSound, &volume, &from, &to))
        return NULL;
    
    PyArrayObject *inSound = get_pyarray(objInSound);
    if (inSound == NULL)
        return NULL;
    
    uint nSamples = inSound->dimensions[0];
    uint nChannels = inSound->dimensions[1];
    float *inSamples = (Float32 *)NA_OFFSETDATA(inSound);
    
    // Limit:
    for (uint j = 0; j < nChannels; j++)
    {
        for (uint i = 0; i < nSamples; i++)
        {
            float frac = ((float)(nSamples - i) / (float) nSamples) * (to - from) + from;
            float f = inSamples[nChannels * i + j];
            inSamples[nChannels * i + j] = limiter(frac * f * volume);
        }
    }
    
    // Do we need to make a copy before returning, or can we return the modified original?
    return PyArray_Return(inSound);
}
Beispiel #2
0
static PyObject* cAction_limit(PyObject* self, PyObject* args)
{
    PyObject *objInSound;
    if (!PyArg_ParseTuple(args, "O", &objInSound))
        return NULL;
    
    PyArrayObject *inSound = get_pyarray(objInSound);
    if (inSound == NULL)
        return NULL;
    
    uint nSamples = inSound->dimensions[0];
    uint nChannels = inSound->dimensions[1];
    float *inSamples = (Float32 *)NA_OFFSETDATA(inSound);
    
    // Limit:
    for (uint j = 0; j < nChannels; j++)
    {
        for (uint i = 0; i < nSamples; i++)
        {
            float f = inSamples[nChannels*i  + j];
            inSamples[nChannels*i + j] = limiter(f);
        }
    }
    
    // Do we need to make a copy before returning, or can we return the modified original?
    return PyArray_Return(inSound);
}
Beispiel #3
0
//line23
static PyObject *
real_printArray(PyObject *self, PyObject *args)
{
  PyObject *firstPtr;
  PyArrayObject *secPtr;
  Int32 *data;

  if(!PyArg_ParseTuple(args, "O", &firstPtr))
  {  
    printf("bad input");
    fflush(stdout);
  }

  secPtr = NA_InputArray( firstPtr, tInt32, C_ARRAY); //HERE!

  data=(Int32 *) NA_OFFSETDATA(secPtr);
  printArray(data);
  return (PyObject *)Py_BuildValue("");
}