sad

simple audio daemon
git clone git://git.2f30.org/sad
Log | Files | Refs | LICENSE

commit 205121fb07ff15343b15b6ebeffb250a8d64f5ee
parent 5e0e896f3a45a3351c55d36c60724db4804c3534
Author: sin <sin@2f30.org>
Date:   Fri,  2 Jan 2015 15:10:41 +0000

Add short to float conversions and vice-versa

Diffstat:
Mpcm.c | 18++++++++++++++++++
Msad.h | 2++
2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/pcm.c b/pcm.c @@ -24,3 +24,21 @@ s16stereotomono(short *in, short *out, size_t nsamples) for (i = 0; i < nsamples; i++) out[i] = in[i * 2] / 2 + in[i * 2 + 1] / 2; } + +void +s16tofloat(short *in, float *out, size_t nsamples) +{ + size_t i; + + for (i = 0; i < nsamples; i++) + out[i] = in[i] / 32768.f; +} + +void +floattos16(float *in, short *out, size_t nsamples) +{ + size_t i; + + for (i = 0; i < nsamples; i++) + out[i] = in[i] * 32768.f; +} diff --git a/sad.h b/sad.h @@ -151,3 +151,5 @@ void removesubscriber(int); /* pcm.c */ void s16monotostereo(short *, short *, size_t); void s16stereotomono(short *, short *, size_t); +void s16tofloat(short *, float *, size_t); +void floattos16(float *, short *, size_t);