diff options
Diffstat (limited to 'src/SPU.h')
-rw-r--r-- | src/SPU.h | 120 |
1 files changed, 57 insertions, 63 deletions
@@ -31,7 +31,6 @@ class SPUChannel { public: SPUChannel(u32 num, melonDS::NDS& nds); - ~SPUChannel(); void Reset(); void DoSavestate(Savestate* file); @@ -39,44 +38,40 @@ public: static const u16 ADPCMTable[89]; static const s16 PSGTable[8][8]; - static s16 InterpCos[0x100]; - static s16 InterpCubic[0x100][4]; - static bool InterpInited; - // audio interpolation is an improvement upon the original hardware // (which performs no interpolation) - int InterpType; - - u32 Num; - - u32 Cnt; - u32 SrcAddr; - u16 TimerReload; - u32 LoopPos; - u32 Length; - - u8 Volume; - u8 VolumeShift; - u8 Pan; - - bool KeyOn; - u32 Timer; - s32 Pos; - s16 PrevSample[3]; - s16 CurSample; - u16 NoiseVal; - - s32 ADPCMVal; - s32 ADPCMIndex; - s32 ADPCMValLoop; - s32 ADPCMIndexLoop; - u8 ADPCMCurByte; - - u32 FIFO[8]; - u32 FIFOReadPos; - u32 FIFOWritePos; - u32 FIFOReadOffset; - u32 FIFOLevel; + int InterpType = 0; + + const u32 Num; + + u32 Cnt = 0; + u32 SrcAddr = 0; + u16 TimerReload = 0; + u32 LoopPos = 0; + u32 Length = 0; + + u8 Volume = 0; + u8 VolumeShift = 0; + u8 Pan = 0; + + bool KeyOn = false; + u32 Timer = 0; + s32 Pos = 0; + s16 PrevSample[3] {}; + s16 CurSample = 0; + u16 NoiseVal = 0; + + s32 ADPCMVal = 0; + s32 ADPCMIndex = 0; + s32 ADPCMValLoop = 0; + s32 ADPCMIndexLoop = 0; + u8 ADPCMCurByte = 0; + + u32 FIFO[8] {}; + u32 FIFOReadPos = 0; + u32 FIFOWritePos = 0; + u32 FIFOReadOffset = 0; + u32 FIFOLevel = 0; void FIFO_BufferData(); template<typename T> T FIFO_ReadData(); @@ -150,25 +145,24 @@ class SPUCaptureUnit { public: SPUCaptureUnit(u32 num, melonDS::NDS&); - ~SPUCaptureUnit(); void Reset(); void DoSavestate(Savestate* file); - u32 Num; + const u32 Num; - u8 Cnt; - u32 DstAddr; - u16 TimerReload; - u32 Length; + u8 Cnt = 0; + u32 DstAddr = 0; + u16 TimerReload = 0; + u32 Length = 0; - u32 Timer; - s32 Pos; + u32 Timer = 0; + s32 Pos = 0; - u32 FIFO[4]; - u32 FIFOReadPos; - u32 FIFOWritePos; - u32 FIFOWriteOffset; - u32 FIFOLevel; + u32 FIFO[4] {}; + u32 FIFOReadPos = 0; + u32 FIFOWritePos = 0; + u32 FIFOWriteOffset = 0; + u32 FIFOLevel = 0; void FIFO_FlushData(); template<typename T> void FIFO_WriteData(T val); @@ -206,7 +200,7 @@ private: class SPU { public: - SPU(melonDS::NDS& nds); + explicit SPU(melonDS::NDS& nds); ~SPU(); void Reset(); void DoSavestate(Savestate* file); @@ -242,23 +236,23 @@ public: private: static const u32 OutputBufferSize = 2*2048; melonDS::NDS& NDS; - s16 OutputBackbuffer[2 * OutputBufferSize]; - u32 OutputBackbufferWritePosition; + s16 OutputBackbuffer[2 * OutputBufferSize] {}; + u32 OutputBackbufferWritePosition = 0; - s16 OutputFrontBuffer[2 * OutputBufferSize]; - u32 OutputFrontBufferWritePosition; - u32 OutputFrontBufferReadPosition; + s16 OutputFrontBuffer[2 * OutputBufferSize] {}; + u32 OutputFrontBufferWritePosition = 0; + u32 OutputFrontBufferReadPosition = 0; Platform::Mutex* AudioLock; - u16 Cnt; - u8 MasterVolume; - u16 Bias; - bool ApplyBias; - bool Degrade10Bit; + u16 Cnt = 0; + u8 MasterVolume = 0; + u16 Bias = 0; + bool ApplyBias = true; + bool Degrade10Bit = false; - SPUChannel* Channels[16]; - SPUCaptureUnit* Capture[2]; + std::array<SPUChannel, 16> Channels; + std::array<SPUCaptureUnit, 2> Capture; }; } |