mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-22 12:35:11 +00:00
SAA1099: fix SAASound on MSVC
This commit is contained in:
parent
4679501f75
commit
aac3b719be
11 changed files with 51 additions and 50 deletions
1
extern/SAASound/MODIFIED.md
vendored
1
extern/SAASound/MODIFIED.md
vendored
|
@ -3,3 +3,4 @@
|
|||
this is a modified version of SAASound for Furnace.
|
||||
|
||||
it fixes some warnings and doesn't use its CMakeLists because I need to static-link it and disable config file support.
|
||||
it also replaces long with int, to fix a discrepancy between MSVC and GCC/Clang.
|
4
extern/SAASound/src/SAAEnv.cpp
vendored
4
extern/SAASound/src/SAAEnv.cpp
vendored
|
@ -266,7 +266,7 @@ inline void CSAAEnv::Tick(void)
|
|||
else // (m_nPhasePosition < 16)
|
||||
{
|
||||
// still within the same phase;
|
||||
// but, importantly, we are no longer at the start of the phase ...
|
||||
// but, importantly, we are no inter at the start of the phase ...
|
||||
// so new data cannot be acted on immediately, and must
|
||||
// be buffered
|
||||
m_bEnvelopeEnded = false;
|
||||
|
@ -365,7 +365,7 @@ inline void CSAAEnv::SetNewEnvData(int nData)
|
|||
m_bEnvelopeEnded = false;
|
||||
// is this right?
|
||||
// YES. See test case EnvExt_34c (setting data multiple times
|
||||
// when at a point (3) resets the waveform so you're no longer
|
||||
// when at a point (3) resets the waveform so you're no inter
|
||||
// at a point (3).
|
||||
}
|
||||
else
|
||||
|
|
4
extern/SAASound/src/SAAFreq.cpp
vendored
4
extern/SAASound/src/SAAFreq.cpp
vendored
|
@ -173,7 +173,7 @@ void CSAAFreq::_SetClockRate(int nClockRate)
|
|||
// initialise the frequency table based on the SAA clockrate
|
||||
// Each item in m_FreqTable corresponds to the frequency calculated by
|
||||
// the standard formula (15625 << octave) / (511 - offset)
|
||||
// then multiplied by 8192 (and represented as a long integer value).
|
||||
// then multiplied by 8192 (and represented as a int integer value).
|
||||
// We are therefore using 12 bits (i.e. 2^12 = 4096) as fractional part.
|
||||
// The reason we multiply by 8192, not 4096, is that we use this as a counter
|
||||
// to toggle the oscillator state, so we need to count half-waves (i.e. twice
|
||||
|
@ -188,7 +188,7 @@ void CSAAFreq::_SetClockRate(int nClockRate)
|
|||
int ix = 0;
|
||||
for (int nOctave = 0; nOctave < 8; nOctave++)
|
||||
for (int nOffset = 0; nOffset < 256; nOffset++)
|
||||
m_FreqTable[ix++] = (unsigned long)((8192.0 * 15625.0 * double(1 << nOctave) * (double(nClockRate) / 8000000.0)) / (511.0 - double(nOffset)));
|
||||
m_FreqTable[ix++] = (unsigned int)((8192.0 * 15625.0 * double(1 << nOctave) * (double(nClockRate) / 8000000.0)) / (511.0 - double(nOffset)));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
16
extern/SAASound/src/SAAFreq.h
vendored
16
extern/SAASound/src/SAAFreq.h
vendored
|
@ -17,18 +17,18 @@ private:
|
|||
// 'load in' the data for the static frequency lookup table
|
||||
// precomputed for a fixed clockrate
|
||||
// See: tools/freqdat.py
|
||||
const static unsigned long m_FreqTable[2048];
|
||||
const static unsigned int m_FreqTable[2048];
|
||||
#else
|
||||
// we'll calculate the frequency lookup table at runtime.
|
||||
unsigned long m_FreqTable[2048];
|
||||
unsigned long m_nClockRate;
|
||||
unsigned int m_FreqTable[2048];
|
||||
unsigned int m_nClockRate;
|
||||
#endif
|
||||
|
||||
unsigned long m_nCounter;
|
||||
unsigned long m_nAdd;
|
||||
unsigned long m_nCounter_low;
|
||||
uint64_t m_nCounter;
|
||||
uint64_t m_nAdd;
|
||||
unsigned int m_nCounter_low;
|
||||
unsigned int m_nOversample;
|
||||
unsigned long m_nCounterLimit_low;
|
||||
unsigned int m_nCounterLimit_low;
|
||||
int m_nLevel;
|
||||
|
||||
int m_nCurrentOffset;
|
||||
|
@ -39,7 +39,7 @@ private:
|
|||
bool m_bNewData;
|
||||
bool m_bSync;
|
||||
|
||||
unsigned long m_nSampleRate;
|
||||
uint64_t m_nSampleRate;
|
||||
CSAANoise * const m_pcConnectedNoiseGenerator;
|
||||
CSAAEnv * const m_pcConnectedEnvGenerator;
|
||||
const int m_nConnectedMode; // 0 = nothing; 1 = envgenerator; 2 = noisegenerator
|
||||
|
|
10
extern/SAASound/src/SAAImpl.cpp
vendored
10
extern/SAASound/src/SAAImpl.cpp
vendored
|
@ -230,12 +230,12 @@ unsigned short CSAASoundInternal::GetCurrentBytesPerSample(void)
|
|||
}
|
||||
}
|
||||
|
||||
unsigned long CSAASoundInternal::GetCurrentSampleRate(void)
|
||||
unsigned int CSAASoundInternal::GetCurrentSampleRate(void)
|
||||
{
|
||||
return CSAASound::GetSampleRate(m_uParamRate);
|
||||
}
|
||||
|
||||
/*static*/ unsigned long CSAASound::GetSampleRate(SAAPARAM uParam) // static member function
|
||||
/*static*/ unsigned int CSAASound::GetSampleRate(SAAPARAM uParam) // static member function
|
||||
{
|
||||
switch (uParam & SAAP_MASK_SAMPLERATE)
|
||||
{
|
||||
|
@ -298,13 +298,13 @@ void scale_for_output(unsigned int left_input, unsigned int right_input,
|
|||
*pBuffer++ = (right_output >> 8) & 0x00ff;
|
||||
}
|
||||
|
||||
void CSAASoundInternal::GenerateMany(BYTE* pBuffer, unsigned long nSamples, DivDispatchOscBuffer** oscBuf)
|
||||
void CSAASoundInternal::GenerateMany(BYTE* pBuffer, unsigned int nSamples, DivDispatchOscBuffer** oscBuf)
|
||||
{
|
||||
unsigned int left_mixed, right_mixed;
|
||||
|
||||
#if defined(DEBUGSAA) || defined(USE_CONFIG_FILE)
|
||||
BYTE* pBufferStart = pBuffer;
|
||||
unsigned long nTotalSamples = nSamples;
|
||||
unsigned int nTotalSamples = nSamples;
|
||||
#endif
|
||||
|
||||
#if defined(DO_BOOST)
|
||||
|
@ -388,7 +388,7 @@ void CSAASoundInternal::GenerateMany(BYTE* pBuffer, unsigned long nSamples, DivD
|
|||
if (m_Config.m_bGeneratePcmLogs)
|
||||
{
|
||||
#endif
|
||||
m_pcmfile.write((const char *)pBufferStart, nTotalSamples * (unsigned long)GetCurrentBytesPerSample());
|
||||
m_pcmfile.write((const char *)pBufferStart, nTotalSamples * (unsigned int)GetCurrentBytesPerSample());
|
||||
m_nDebugSample += nTotalSamples;
|
||||
#ifdef USE_CONFIG_FILE
|
||||
}
|
||||
|
|
8
extern/SAASound/src/SAAImpl.h
vendored
8
extern/SAASound/src/SAAImpl.h
vendored
|
@ -41,7 +41,7 @@ private:
|
|||
SAAConfig m_Config;
|
||||
#endif
|
||||
#if defined(DEBUGSAA) || defined(USE_CONFIG_FILE)
|
||||
unsigned long m_nDebugSample;
|
||||
unsigned int m_nDebugSample;
|
||||
std::ofstream m_dbgfile, m_pcmfile;
|
||||
#if defined(USE_CONFIG_FILE)
|
||||
std::ofstream m_channel_pcmfile[6];
|
||||
|
@ -64,12 +64,12 @@ public:
|
|||
void Clear(void);
|
||||
|
||||
SAAPARAM GetCurrentSoundParameters(void);
|
||||
unsigned long GetCurrentSampleRate(void);
|
||||
static unsigned long GetSampleRate(SAAPARAM uParam);
|
||||
unsigned int GetCurrentSampleRate(void);
|
||||
static unsigned int GetSampleRate(SAAPARAM uParam);
|
||||
unsigned short GetCurrentBytesPerSample(void);
|
||||
static unsigned short GetBytesPerSample(SAAPARAM uParam);
|
||||
|
||||
void GenerateMany(BYTE * pBuffer, unsigned long nSamples, DivDispatchOscBuffer** oscBuf);
|
||||
void GenerateMany(BYTE * pBuffer, unsigned int nSamples, DivDispatchOscBuffer** oscBuf);
|
||||
|
||||
};
|
||||
|
||||
|
|
4
extern/SAASound/src/SAANoise.cpp
vendored
4
extern/SAASound/src/SAANoise.cpp
vendored
|
@ -36,7 +36,7 @@ m_nRand(1)
|
|||
m_nAdd = m_nAddBase;
|
||||
}
|
||||
|
||||
CSAANoise::CSAANoise(unsigned long seed)
|
||||
CSAANoise::CSAANoise(unsigned int seed)
|
||||
:
|
||||
m_nCounter(0),
|
||||
m_nCounter_low(0),
|
||||
|
@ -65,7 +65,7 @@ void CSAANoise::_SetClockRate(int nClockRate)
|
|||
m_nAddBase = nClockRate << (12 - 8);
|
||||
}
|
||||
|
||||
void CSAANoise::Seed(unsigned long seed)
|
||||
void CSAANoise::Seed(unsigned int seed)
|
||||
{
|
||||
m_nRand = seed;
|
||||
}
|
||||
|
|
18
extern/SAASound/src/SAANoise.h
vendored
18
extern/SAASound/src/SAANoise.h
vendored
|
@ -10,25 +10,25 @@
|
|||
class CSAANoise
|
||||
{
|
||||
private:
|
||||
unsigned long m_nCounter;
|
||||
unsigned long m_nAdd;
|
||||
unsigned long m_nCounter_low;
|
||||
unsigned int m_nCounter;
|
||||
uint64_t m_nAdd;
|
||||
unsigned int m_nCounter_low;
|
||||
unsigned int m_nOversample;
|
||||
unsigned long m_nCounterLimit_low;
|
||||
unsigned int m_nCounterLimit_low;
|
||||
bool m_bSync; // see description of "SYNC" bit of register 28
|
||||
unsigned long m_nSampleRate; // = 44100 when RateMode=0, for example
|
||||
uint64_t m_nSampleRate; // = 44100 when RateMode=0, for example
|
||||
int m_nSourceMode;
|
||||
unsigned long m_nAddBase; // nAdd for 31.25 kHz noise at 44.1 kHz samplerate
|
||||
uint64_t m_nAddBase; // nAdd for 31.25 kHz noise at 44.1 kHz samplerate
|
||||
|
||||
// pseudo-random number generator
|
||||
unsigned long m_nRand;
|
||||
unsigned int m_nRand;
|
||||
|
||||
void ChangeLevel(void);
|
||||
|
||||
|
||||
public:
|
||||
CSAANoise();
|
||||
CSAANoise(unsigned long seed);
|
||||
CSAANoise(unsigned int seed);
|
||||
~CSAANoise();
|
||||
|
||||
void SetSource(int nSource);
|
||||
|
@ -36,7 +36,7 @@ public:
|
|||
void _SetSampleRate(int nSampleRate);
|
||||
void _SetOversample(unsigned int oversample);
|
||||
void _SetClockRate(int nClockRate);
|
||||
void Seed(unsigned long seed);
|
||||
void Seed(unsigned int seed);
|
||||
|
||||
void Tick(void);
|
||||
int Level(void) const;
|
||||
|
|
6
extern/SAASound/src/SAASndC.cpp
vendored
6
extern/SAASound/src/SAASndC.cpp
vendored
|
@ -69,17 +69,17 @@ unsigned short SAAAPI SAASNDGetBytesPerSample(SAAPARAM uParam)
|
|||
return CSAASound::GetBytesPerSample(uParam);
|
||||
}
|
||||
|
||||
unsigned long SAAAPI SAASNDGetCurrentSampleRate(SAASND object)
|
||||
unsigned int SAAAPI SAASNDGetCurrentSampleRate(SAASND object)
|
||||
{
|
||||
return ((LPCSAASOUND)(object))->GetCurrentSampleRate();
|
||||
}
|
||||
|
||||
unsigned long SAAAPI SAASNDGetSampleRate(SAAPARAM uParam)
|
||||
unsigned int SAAAPI SAASNDGetSampleRate(SAAPARAM uParam)
|
||||
{
|
||||
return CSAASound::GetSampleRate(uParam);
|
||||
}
|
||||
|
||||
void SAAAPI SAASNDGenerateMany(SAASND object, BYTE * pBuffer, unsigned long nSamples)
|
||||
void SAAAPI SAASNDGenerateMany(SAASND object, BYTE * pBuffer, unsigned int nSamples)
|
||||
{
|
||||
((LPCSAASOUND)(object))->GenerateMany(pBuffer, nSamples, NULL);
|
||||
}
|
||||
|
|
10
extern/SAASound/src/SAASndC.h
vendored
10
extern/SAASound/src/SAASndC.h
vendored
|
@ -35,7 +35,7 @@
|
|||
#define SAAP_MONO 0x00000001
|
||||
|
||||
// Bitmasks for use with GetCurrentSoundParameters, for example,
|
||||
// unsigned long CurrentSampleRateParameter = GetCurrentSoundParameters()
|
||||
// unsigned int CurrentSampleRateParameter = GetCurrentSoundParameters()
|
||||
#define SAAP_MASK_FILTER 0x00000f00
|
||||
#define SAAP_MASK_FILTER_HIGHPASS 0x00000c00
|
||||
#define SAAP_MASK_FILTER_OVERSAMPLE 0x00000300
|
||||
|
@ -43,7 +43,7 @@
|
|||
#define SAAP_MASK_BITDEPTH 0x0000000c
|
||||
#define SAAP_MASK_CHANNELS 0x00000003
|
||||
|
||||
typedef unsigned long SAAPARAM;
|
||||
typedef unsigned int SAAPARAM;
|
||||
|
||||
|
||||
#ifndef BYTE
|
||||
|
@ -85,10 +85,10 @@ BYTE EXTAPI SAASNDReadAddress(SAASND object);
|
|||
SAAPARAM EXTAPI SAASNDGetCurrentSoundParameters(SAASND object);
|
||||
unsigned short EXTAPI SAASNDGetCurrentBytesPerSample(SAASND object);
|
||||
unsigned short EXTAPI SAASNDGetBytesPerSample(SAAPARAM uParam);
|
||||
unsigned long EXTAPI SAASNDGetCurrentSampleRate(SAASND object);
|
||||
unsigned long EXTAPI SAASNDGetSampleRate(SAAPARAM uParam);
|
||||
unsigned int EXTAPI SAASNDGetCurrentSampleRate(SAASND object);
|
||||
unsigned int EXTAPI SAASNDGetSampleRate(SAAPARAM uParam);
|
||||
|
||||
void EXTAPI SAASNDGenerateMany(SAASND object, BYTE * pBuffer, unsigned long nSamples);
|
||||
void EXTAPI SAASNDGenerateMany(SAASND object, BYTE * pBuffer, unsigned int nSamples);
|
||||
|
||||
void EXTAPI SAASNDSetClockRate(SAASND object, unsigned int nClockRate);
|
||||
void EXTAPI SAASNDSetSampleRate(SAASND object, unsigned int nSampleRate);
|
||||
|
|
20
extern/SAASound/src/SAASound.h
vendored
20
extern/SAASound/src/SAASound.h
vendored
|
@ -3,12 +3,12 @@
|
|||
// SAASound.h: interface for the CSAASound class.
|
||||
//
|
||||
// This corresponds to the public (exported) DLL interface, so all
|
||||
// APIs and client factory methods belong here.
|
||||
// APIs and client factory methods beint here.
|
||||
//
|
||||
// Compatibility notes : the intention is for this to be fully backwards
|
||||
// compatible across minor and patch versions. Any backwards breaking changes
|
||||
// should be reflected as a major version increment. New functionality can be added
|
||||
// in minor versions so long as backwards compatiblity is maintained
|
||||
// in minor versions so int as backwards compatiblity is maintained
|
||||
//
|
||||
// Version 3.3.0 (4th Dec 2018)
|
||||
//
|
||||
|
@ -37,7 +37,7 @@
|
|||
#define SAAP_MONO 0x00000001
|
||||
|
||||
// Bitmasks for use with GetCurrentSoundParameters, for example,
|
||||
// unsigned long CurrentSampleRateParameter = GetCurrentSoundParameters()
|
||||
// unsigned int CurrentSampleRateParameter = GetCurrentSoundParameters()
|
||||
#define SAAP_MASK_FILTER 0x00000f00
|
||||
#define SAAP_MASK_FILTER_HIGHPASS 0x00000c00
|
||||
#define SAAP_MASK_FILTER_OVERSAMPLE 0x00000300
|
||||
|
@ -45,7 +45,7 @@
|
|||
#define SAAP_MASK_BITDEPTH 0x0000000c
|
||||
#define SAAP_MASK_CHANNELS 0x00000003
|
||||
|
||||
typedef unsigned long SAAPARAM;
|
||||
typedef unsigned int SAAPARAM;
|
||||
|
||||
|
||||
#ifndef BYTE
|
||||
|
@ -76,12 +76,12 @@ public:
|
|||
virtual BYTE ReadAddress () = 0;
|
||||
|
||||
virtual SAAPARAM GetCurrentSoundParameters () = 0;
|
||||
virtual unsigned long GetCurrentSampleRate () = 0;
|
||||
static unsigned long GetSampleRate (SAAPARAM uParam);
|
||||
virtual unsigned int GetCurrentSampleRate () = 0;
|
||||
static unsigned int GetSampleRate (SAAPARAM uParam);
|
||||
virtual unsigned short GetCurrentBytesPerSample () = 0;
|
||||
static unsigned short GetBytesPerSample (SAAPARAM uParam);
|
||||
|
||||
virtual void GenerateMany (BYTE * pBuffer, unsigned long nSamples, DivDispatchOscBuffer** oscBuf) = 0;
|
||||
virtual void GenerateMany (BYTE * pBuffer, unsigned int nSamples, DivDispatchOscBuffer** oscBuf) = 0;
|
||||
|
||||
virtual void SetClockRate(unsigned int nClockRate) = 0;
|
||||
virtual void SetSampleRate(unsigned int nSampleRate) = 0;
|
||||
|
@ -115,10 +115,10 @@ void SAAAPI SAASNDClear(SAASND object);
|
|||
SAAPARAM SAAAPI SAASNDGetCurrentSoundParameters(SAASND object);
|
||||
unsigned short SAAAPI SAASNDGetCurrentBytesPerSample(SAASND object);
|
||||
unsigned short SAAAPI SAASNDGetBytesPerSample(SAAPARAM uParam);
|
||||
unsigned long SAAAPI SAASNDGetCurrentSampleRate(SAASND object);
|
||||
unsigned long SAAAPI SAASNDGetSampleRate(SAAPARAM uParam);
|
||||
unsigned int SAAAPI SAASNDGetCurrentSampleRate(SAASND object);
|
||||
unsigned int SAAAPI SAASNDGetSampleRate(SAAPARAM uParam);
|
||||
|
||||
void SAAAPI SAASNDGenerateMany(SAASND object, BYTE * pBuffer, unsigned long nSamples);
|
||||
void SAAAPI SAASNDGenerateMany(SAASND object, BYTE * pBuffer, unsigned int nSamples);
|
||||
void SAAAPI SAASNDSetClockRate(SAASND object, unsigned int nClockRate);
|
||||
void SAAAPI SAASNDSetSampleRate(SAASND object, unsigned int nSampleRate);
|
||||
void SAAAPI SAASNDSetOversample(SAASND object, unsigned int nOversample);
|
||||
|
|
Loading…
Reference in a new issue