summaryrefslogtreecommitdiff
path: root/pysoundtouch/src/pysoundtouch.h
blob: e9790af25955bdf99dabdbf256f03da04b99d494 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * python interface to soundtouch (the open-source audio processing library)
 * Pitch, tempo, and rate shifting
 */

#ifndef __PY_SOUNDTOUCH_H__
#define __PY_SOUNDTOUCH_H__

#define __cplusplus

#include <Python.h>
#include <SoundTouch.h>

#define BUFFER_SIZE 44100

// Definition of the soundtouch object
typedef struct {
  PyObject_HEAD
  int channels; // 1 or 2
  soundtouch::SoundTouch* soundtouch;
  union {
    char chars[BUFFER_SIZE];
    short shorts[BUFFER_SIZE/2];
  } buffer;
} py_soundtouch; /* Soundtouch */

#define PY_SOUNDTOUCH(x) ((py_soundtouch *) x)

extern PyTypeObject py_soundtouch_t;

// Deallocate the SoundTouch object
static void py_soundtouch_dealloc(PyObject* self, PyObject* args);

// Adjust attributes of samples that have been entered
static PyObject* py_soundtouch_set_rate(PyObject* self, PyObject* args);
static PyObject* py_soundtouch_set_tempo(PyObject* self, PyObject* args);
static PyObject* py_soundtouch_set_pitch(PyObject* self, PyObject* args);
static PyObject* py_soundtouch_set_pitch_shift(PyObject* self, PyObject* args);

// Move all waiting samples to the output
static PyObject* py_soundtouch_flush(PyObject* self, PyObject* args);

// Clear the buffer of samples
static PyObject* py_soundtouch_clear(PyObject* self, PyObject* args);

// Add new samples to be processed
static PyObject* py_soundtouch_put_samples(PyObject* self, PyObject* args);

// Extract processed samples from the output
static PyObject* py_soundtouch_get_samples(PyObject* self, PyObject* args);

// Return how many samples are available for output
static PyObject* py_soundtouch_ready_count(PyObject* self, PyObject* args);

// Return how many samples will be available given the current data
static PyObject* py_soundtouch_waiting_count(PyObject* self, PyObject* args);

// Get additional attributes from the SoundTouch object
static PyObject* py_soundtouch_getattr(PyObject* self, char* name);

#endif