From 919566c02e2440a0b31bb3bc7ad2a2ba3129456f Mon Sep 17 00:00:00 2001 From: gerstrong Date: Sun, 2 Aug 2009 12:52:09 +0000 Subject: [PATCH] improved classic PC Speaker Sounds. Thx a lot to Napalm. Credits to him! git-svn-id: https://clonekeenplus.svn.sourceforge.net/svnroot/clonekeenplus/cgenius/trunk@203 4df4b0f3-56ce-47cb-b001-ed939b7d65a6 --- src/sdl/sound/CSoundSlot.cpp | 41 +++++++++++++----------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/src/sdl/sound/CSoundSlot.cpp b/src/sdl/sound/CSoundSlot.cpp index 1886a64b4..2d52026f1 100644 --- a/src/sdl/sound/CSoundSlot.cpp +++ b/src/sdl/sound/CSoundSlot.cpp @@ -9,10 +9,10 @@ #define MAX_SOUNDS 50 #define MAX_STACK_SPACE 1024 -#define SOUND_FREQ_DIVISOR 1363634 // The past original one #include #include +#include #include "CSoundSlot.h" #include "../../CLogFile.h" #include "../../fileio.h" @@ -52,7 +52,6 @@ bool CSoundSlot::loadSound(const std::string& fname, const std::string& searchna int curheader = 0x10; int i,j; int offset, priority, garbage, nr_of_sounds; - int sndbyte; char name[12]; for(i=0;i<12;i++) @@ -86,35 +85,24 @@ bool CSoundSlot::loadSound(const std::string& fname, const std::string& searchna return false; sound_found: ; - // use stacking method for reading sound - unsigned int tempstack[MAX_STACK_SPACE]; - m_soundlength = 0; fseek(fp, offset, SEEK_SET); - for(i=0;i waveform; + do + { + sample = fgeti(fp); + waveform.push_back( (sample != 0x0000 && sample != 0xFFFF) ? (0x1234DD/sample) : sample ); + }while (sample != 0xffff); + + m_soundlength = waveform.size(); + + // copy the data to the real m_sounddata block and reduce fragmentation! m_sounddata = new unsigned int[m_soundlength]; - memcpy(m_sounddata, tempstack, m_soundlength*sizeof(unsigned int)); + memcpy(m_sounddata, waveform.data(), m_soundlength*sizeof(unsigned int)); g_pLogFile->ftextOut("loadSound : loaded sound %s of %d bytes.
", searchname.c_str(), m_soundlength); m_hqsound.enabled = false; @@ -124,3 +112,4 @@ bool CSoundSlot::loadSound(const std::string& fname, const std::string& searchna } } +