From 38a7059bdd234df8e5189b688f4b09f58d158c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 25 Dec 2012 10:08:57 +0100 Subject: [PATCH] Initialize some stuff in SasAudio, fixes some audio issues on my mac --- Core/HW/SasAudio.cpp | 20 ++++++++++++++++---- Core/HW/SasAudio.h | 21 ++++++++++----------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/Core/HW/SasAudio.cpp b/Core/HW/SasAudio.cpp index 6b56144d31..90b4894adb 100644 --- a/Core/HW/SasAudio.cpp +++ b/Core/HW/SasAudio.cpp @@ -20,7 +20,7 @@ #include "../MemMap.h" #include "SasAudio.h" -static const double f[5][2] = +static const double f[5][2] = { { 0.0, 0.0 }, { 60.0 / 64.0, 0.0 }, { 115.0 / 64.0, -52.0 / 64.0 }, @@ -58,7 +58,7 @@ bool VagDecoder::DecodeBlock() else if (flags == 3 && loopEnabled_) { loopAtNextBlock_ = true; } - for (int i = 0; i < 28; i += 2) + for (int i = 0; i < 28; i += 2) { int d = GetByte(); int s = (short)((d & 0xf) << 12); @@ -168,8 +168,14 @@ void ADSREnvelope::SetSimpleEnvelope(u32 ADSREnv1, u32 ADSREnv2) { sustainLevel = getSustainLevel(ADSREnv1); } -SasInstance::SasInstance() - : mixBuffer(0), sendBuffer(0), resampleBuffer(0), grainSize(0) { +SasInstance::SasInstance() + : maxVoices(PSP_SAS_VOICES_MAX), + sampleRate(44100), + outputMode(0), + mixBuffer(0), + sendBuffer(0), + resampleBuffer(0), + grainSize(0) { } SasInstance::~SasInstance() { @@ -409,6 +415,12 @@ static int getExpCurveAt(int index, int duration) { return (short)(sample); } +ADSREnvelope::ADSREnvelope() + : steps_(0), + state_(STATE_OFF), + height_(0) { +} + void ADSREnvelope::WalkCurve(int rate, int type) { short expFactor; int duration; diff --git a/Core/HW/SasAudio.h b/Core/HW/SasAudio.h index 3b776f5c6d..d913a03366 100644 --- a/Core/HW/SasAudio.h +++ b/Core/HW/SasAudio.h @@ -111,6 +111,7 @@ private: class ADSREnvelope { public: + ADSREnvelope(); void SetSimpleEnvelope(u32 ADSREnv1, u32 ADSREnv2); void WalkCurve(int rate, int type); @@ -121,7 +122,7 @@ public: void Step(); int GetHeight() const { - return height_ > PSP_SAS_ENVELOPE_HEIGHT_MAX ? PSP_SAS_ENVELOPE_HEIGHT_MAX : height_; + return height_ > PSP_SAS_ENVELOPE_HEIGHT_MAX ? PSP_SAS_ENVELOPE_HEIGHT_MAX : height_; } bool HasEnded() const { return state_ == STATE_OFF; @@ -158,7 +159,7 @@ struct SasVoice { SasVoice() : playing(false), paused(false), on(false), - type(VOICETYPE_OFF), + type(VOICETYPE_OFF), vagAddr(0), vagSize(0), pcmAddr(0), @@ -171,7 +172,13 @@ struct SasVoice volumeLeft(0), volumeRight(0), volumeLeftSend(0), - volumeRightSend(0) {} + volumeRightSend(0) { + } + + void Reset(); + void KeyOn(); + void KeyOff(); + void ChangedParams(bool changedVag); bool playing; bool paused; // a voice can be playing AND paused. In that case, it won't play. @@ -195,14 +202,6 @@ struct SasVoice int volumeRight; int volumeLeftSend; // volume to "Send" (audio-lingo) to the effects processing engine, like reverb int volumeRightSend; - - void Reset(); - - void KeyOn(); - void KeyOff(); - - void ChangedParams(bool changedVag); - s16 resampleHist[2]; ADSREnvelope envelope;