mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-02-06 16:47:59 +08:00
Support for various sample formats (#11)
* wip : support for various sample formats * finalize support for various sample formats * adding more tests * update python bindings * add "string" header
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
cdef extern from "ggwave.h" nogil:
|
||||
|
||||
ctypedef enum ggwave_SampleFormat:
|
||||
GGWAVE_SAMPLE_FORMAT_UNDEFINED,
|
||||
GGWAVE_SAMPLE_FORMAT_U8,
|
||||
GGWAVE_SAMPLE_FORMAT_I8,
|
||||
GGWAVE_SAMPLE_FORMAT_U16,
|
||||
GGWAVE_SAMPLE_FORMAT_I16,
|
||||
GGWAVE_SAMPLE_FORMAT_F32
|
||||
|
||||
@@ -16,12 +20,12 @@ cdef extern from "ggwave.h" nogil:
|
||||
int sampleRateIn
|
||||
int sampleRateOut
|
||||
int samplesPerFrame
|
||||
ggwave_SampleFormat formatIn
|
||||
ggwave_SampleFormat formatOut
|
||||
ggwave_SampleFormat sampleFormatIn
|
||||
ggwave_SampleFormat sampleFormatOut
|
||||
|
||||
ctypedef int ggwave_Instance
|
||||
|
||||
ggwave_Parameters ggwave_defaultParameters();
|
||||
ggwave_Parameters ggwave_getDefaultParameters();
|
||||
|
||||
ggwave_Instance ggwave_init(const ggwave_Parameters parameters);
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ import struct
|
||||
|
||||
cimport cggwave
|
||||
|
||||
def defaultParameters():
|
||||
return cggwave.ggwave_defaultParameters()
|
||||
def getDefaultParameters():
|
||||
return cggwave.ggwave_getDefaultParameters()
|
||||
|
||||
def init(parameters = None):
|
||||
if (parameters is None):
|
||||
parameters = defaultParameters()
|
||||
parameters = getDefaultParameters()
|
||||
|
||||
return cggwave.ggwave_init(parameters)
|
||||
|
||||
@@ -33,7 +33,7 @@ def encode(payload, txProtocolId = 1, volume = 10, instance = None):
|
||||
own = False
|
||||
if (instance is None):
|
||||
own = True
|
||||
instance = init(defaultParameters())
|
||||
instance = init(getDefaultParameters())
|
||||
|
||||
n = cggwave.ggwave_encode(instance, cdata, len(data_bytes), txProtocolId, volume, coutput)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user