summaryrefslogtreecommitdiff
path: root/premix.c
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2010-11-22 21:38:06 +0100
committerGravatar waker <wakeroid@gmail.com>2010-11-22 21:38:06 +0100
commit19a188df769b29df82c12e9b684f13000544fd5e (patch)
tree8f38cf4dbd227d8e287e2266bcb072a1c53de428 /premix.c
parenta839ce76b389e7bfa71e7eb17c6ce2a3e0243aab (diff)
added float clamp(-1,1) in premix
added plugin pointer to dsp instances code cleanup
Diffstat (limited to 'premix.c')
-rw-r--r--premix.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/premix.c b/premix.c
index 8c6f7e81..43a7ed8f 100644
--- a/premix.c
+++ b/premix.c
@@ -211,7 +211,14 @@ pcm_write_samples_float_to_16 (const ddb_waveformat_t * restrict inputfmt, const
if (channelmap[c] != -1) {
int16_t *out = (int16_t*)(output + (outputfmt->bps >> 3) * channelmap[c]);
float sample = *((float*)input);
- *out = (int16_t)ftoi (sample*0x7ff0);
+ // FIXME: sse optimize
+ if (sample > 1) {
+ sample = 1;
+ }
+ if (sample < -1) {
+ sample = -1;
+ }
+ *out = (int16_t)ftoi (sample*0x7fff);
}
input += 4;
}
@@ -229,7 +236,14 @@ pcm_write_samples_float_to_8 (const ddb_waveformat_t * restrict inputfmt, const
if (channelmap[c] != -1) {
int8_t *out = (int8_t*)(output + (outputfmt->bps >> 3) * channelmap[c]);
float sample = *((float*)input);
- *out = (int8_t)ftoi (sample*0x7e);
+ // FIXME: sse optimize
+ if (sample > 1) {
+ sample = 1;
+ }
+ if (sample < -1) {
+ sample = -1;
+ }
+ *out = (int8_t)ftoi (sample*0x7f);
}
input += 4;
}