mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-24 05:49:58 +00:00
Stop ADPCM decoder from running off into space. improves motogp audio.
This commit is contained in:
parent
1b35964445
commit
27e8e4c6fb
@ -27,11 +27,11 @@ static const double f[5][2] =
|
||||
{ 98.0 / 64.0, -55.0 / 64.0 },
|
||||
{ 122.0 / 64.0, -60.0 / 64.0 } };
|
||||
|
||||
void VagDecoder::Start(u8 *data, bool loopEnabled)
|
||||
{
|
||||
void VagDecoder::Start(u8 *data, int vagSize, bool loopEnabled) {
|
||||
loopEnabled_ = loopEnabled;
|
||||
loopAtNextBlock_ = false;
|
||||
loopStartBlock_ = 0;
|
||||
numBlocks_ = vagSize / 16;
|
||||
end_ = false;
|
||||
data_ = data;
|
||||
read_ = data;
|
||||
@ -41,8 +41,7 @@ void VagDecoder::Start(u8 *data, bool loopEnabled)
|
||||
s_2 = 0.0;
|
||||
}
|
||||
|
||||
bool VagDecoder::DecodeBlock()
|
||||
{
|
||||
bool VagDecoder::DecodeBlock() {
|
||||
int predict_nr = GetByte();
|
||||
int shift_factor = predict_nr & 0xf;
|
||||
predict_nr >>= 4;
|
||||
@ -71,6 +70,9 @@ bool VagDecoder::DecodeBlock()
|
||||
}
|
||||
curSample = 0;
|
||||
curBlock_++;
|
||||
if (curBlock_ == numBlocks_) {
|
||||
end_ = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -307,7 +309,7 @@ void SasVoice::KeyOn() {
|
||||
switch (type) {
|
||||
case VOICETYPE_VAG:
|
||||
if (Memory::IsValidAddress(vagAddr)) {
|
||||
vag.Start(Memory::GetPointer(vagAddr), loop);
|
||||
vag.Start(Memory::GetPointer(vagAddr), vagSize, loop);
|
||||
} else {
|
||||
ERROR_LOG(SAS, "Invalid VAG address %08x", vagAddr);
|
||||
return;
|
||||
@ -330,7 +332,7 @@ void SasVoice::ChangedParams(bool changedVag) {
|
||||
if (!playing && on) {
|
||||
playing = true;
|
||||
if (changedVag)
|
||||
vag.Start(Memory::GetPointer(vagAddr), loop);
|
||||
vag.Start(Memory::GetPointer(vagAddr), vagSize, loop);
|
||||
}
|
||||
// TODO: restart VAG somehow
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class VagDecoder
|
||||
{
|
||||
public:
|
||||
VagDecoder() : data_(0), read_(0) {}
|
||||
void Start(u8 *data, bool loopEnabled);
|
||||
void Start(u8 *data, int vagSize, bool loopEnabled);
|
||||
|
||||
void GetSamples(s16 *outSamples, int numSamples);
|
||||
|
||||
@ -97,6 +97,7 @@ private:
|
||||
u8 *read_;
|
||||
int curBlock_;
|
||||
int loopStartBlock_;
|
||||
int numBlocks_;
|
||||
|
||||
// rolling state. start at 0, should probably reset to 0 on loops?
|
||||
double s_1;
|
||||
|
Loading…
Reference in New Issue
Block a user