From 122b08b2ca917b4362a3bbea0fa8f6c537d444c8 Mon Sep 17 00:00:00 2001 From: oparviai Date: Sat, 1 Sep 2012 07:43:14 +0000 Subject: [PATCH] Fixed 8bit file processing --- source/SoundStretch/WavFile.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/SoundStretch/WavFile.cpp b/source/SoundStretch/WavFile.cpp index 7bc482a..180a5e6 100644 --- a/source/SoundStretch/WavFile.cpp +++ b/source/SoundStretch/WavFile.cpp @@ -394,11 +394,11 @@ int WavInFile::read(float *buffer, int maxElems) { case 1: { - char *temp2 = temp; + unsigned char *temp2 = (unsigned char*)temp; double conv = 1.0 / 128.0; for (int i = 0; i < numElems; i ++) { - buffer[i] = (float)(temp2[i] * conv); + buffer[i] = (float)(temp2[i] * conv - 1.0); } break; } @@ -886,10 +886,10 @@ void WavOutFile::write(const float *buffer, int numElems) { case 1: { - char *temp2 = (char *)temp; + unsigned char *temp2 = (unsigned char *)temp; for (int i = 0; i < numElems; i ++) { - temp2[i] = (char)saturate(buffer[i] * 128.0f, -128.0f, 127.0f); + temp2[i] = (unsigned char)saturate(buffer[i] * 128.0f + 128.0f, 0.0f, 255.0f); } break; }