mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-23 19:59:16 +01:00
-improved wav banner sound loop support
This commit is contained in:
parent
db0ca2e965
commit
dcdf6ceb10
@ -66,6 +66,7 @@ void SoundDecoder::Init()
|
||||
SoundBlockSize = 8192;
|
||||
CurPos = 0;
|
||||
LoopStart = 0;
|
||||
LoopEnd = 0;
|
||||
Loop = false;
|
||||
EndOfFile = false;
|
||||
Decoding = false;
|
||||
@ -126,15 +127,11 @@ void SoundDecoder::Decode()
|
||||
|
||||
if(ret <= 0)
|
||||
{
|
||||
if(Loop)
|
||||
if(Loop || LoopStart || LoopEnd)
|
||||
{
|
||||
Rewind();
|
||||
continue;
|
||||
}
|
||||
else if(LoopStart)
|
||||
{
|
||||
Rewind();
|
||||
CurPos = LoopStart;
|
||||
if(LoopStart)
|
||||
CurPos = LoopStart;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
|
@ -69,6 +69,7 @@ public:
|
||||
virtual bool IsEOF() { return EndOfFile; };
|
||||
virtual void SetLoop(bool l) { Loop = l; };
|
||||
virtual void SetLoopStart(int s) { LoopStart = s; };
|
||||
virtual void SetLoopEnd(int e) { LoopEnd = e; };
|
||||
virtual u8 GetSoundType() { return SoundType; };
|
||||
virtual void ClearBuffer() { SoundBuffer.ClearBuffer(); };
|
||||
virtual bool IsStereo() { return (GetFormat() == VOICE_STEREO_16BIT || GetFormat() == VOICE_STEREO_8BIT); };
|
||||
@ -84,6 +85,7 @@ protected:
|
||||
int CurPos;
|
||||
bool Loop;
|
||||
int LoopStart;
|
||||
int LoopEnd;
|
||||
bool EndOfFile;
|
||||
bool Decoding;
|
||||
bool ExitRequested;
|
||||
|
@ -124,6 +124,7 @@ void WavDecoder::OpenFile()
|
||||
SWaveChunk LoopChunk;
|
||||
SWaveSmplChunk SmplChunk;
|
||||
SmplChunk.Start = 0;
|
||||
SmplChunk.End = 0;
|
||||
file_fd->seek(DataOffset + DataSize, SEEK_SET);
|
||||
while(file_fd->read((u8 *)&LoopChunk, sizeof(SWaveChunk)) == sizeof(SWaveChunk))
|
||||
{
|
||||
@ -132,11 +133,13 @@ void WavDecoder::OpenFile()
|
||||
file_fd->seek(-8, SEEK_CUR);
|
||||
file_fd->read((u8*)&SmplChunk, sizeof(SWaveSmplChunk));
|
||||
SmplChunk.Start = ((le32(SmplChunk.Start) * le16(FmtChunk.channels) * le16(FmtChunk.bps) / 8) + 8191) & ~8191;
|
||||
SmplChunk.End = ((le32(SmplChunk.End) * le16(FmtChunk.channels) * le16(FmtChunk.bps) / 8) + 8191) & ~8191;
|
||||
break;
|
||||
}
|
||||
file_fd->seek(le32(LoopChunk.size), SEEK_CUR);
|
||||
}
|
||||
SetLoopStart(SmplChunk.Start);
|
||||
SetLoopEnd(SmplChunk.End);
|
||||
Decode();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user