mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2025-01-12 11:59:08 +01:00
-added looping of banner wav sound files (its not 100% exact as you
will hear but better than no looping at all)
This commit is contained in:
parent
efaa4ea569
commit
7e9fd00e83
@ -130,6 +130,12 @@ void SoundDecoder::Decode()
|
||||
Rewind();
|
||||
continue;
|
||||
}
|
||||
else if(LoopStart)
|
||||
{
|
||||
Rewind();
|
||||
CurPos = LoopStart;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
EndOfFile = true;
|
||||
|
@ -68,6 +68,7 @@ public:
|
||||
virtual bool IsLastBufferReady() { return SoundBuffer.IsLastBufferReady(); };
|
||||
virtual bool IsEOF() { return EndOfFile; };
|
||||
virtual void SetLoop(bool l) { Loop = l; };
|
||||
virtual void SetLoopStart(int s) { LoopStart = s; };
|
||||
virtual u8 GetSoundType() { return SoundType; };
|
||||
virtual void ClearBuffer() { SoundBuffer.ClearBuffer(); };
|
||||
virtual bool IsStereo() { return (GetFormat() == VOICE_STEREO_16BIT || GetFormat() == VOICE_STEREO_8BIT); };
|
||||
@ -82,6 +83,7 @@ protected:
|
||||
int SoundBlockSize;
|
||||
int CurPos;
|
||||
bool Loop;
|
||||
int LoopStart;
|
||||
bool EndOfFile;
|
||||
bool Decoding;
|
||||
bool ExitRequested;
|
||||
|
@ -121,6 +121,22 @@ void WavDecoder::OpenFile()
|
||||
else if(le16(FmtChunk.channels) == 2 && le16(FmtChunk.bps) == 16 && le16(FmtChunk.alignment) <= 4)
|
||||
Format = VOICE_STEREO_16BIT;
|
||||
|
||||
SWaveChunk LoopChunk;
|
||||
SWaveSmplChunk SmplChunk;
|
||||
SmplChunk.Start = 0;
|
||||
file_fd->seek(DataOffset + DataSize, SEEK_SET);
|
||||
while(file_fd->read((u8 *)&LoopChunk, sizeof(SWaveChunk)) == sizeof(SWaveChunk))
|
||||
{
|
||||
if(LoopChunk.magicDATA == 'smpl')
|
||||
{
|
||||
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) + 8091) & ~8091;
|
||||
break;
|
||||
}
|
||||
file_fd->seek(le32(LoopChunk.size), SEEK_CUR);
|
||||
}
|
||||
SetLoopStart(SmplChunk.Start);
|
||||
Decode();
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,29 @@ typedef struct
|
||||
u32 size;
|
||||
} SWaveChunk;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 magicDATA;
|
||||
u32 size;
|
||||
/* Bleh */
|
||||
u32 Manufacturer;
|
||||
u32 Product;
|
||||
u32 SamplePeriod;
|
||||
u32 MIDIUnityNote;
|
||||
u32 MIDIPitchFraction;
|
||||
u32 SMPTEFormat;
|
||||
u32 SMPTEOffset;
|
||||
u32 SampleLoops;
|
||||
u32 SamplerData;
|
||||
/* The important stuff */
|
||||
u32 Identifier;
|
||||
u32 Type;
|
||||
u32 Start;
|
||||
u32 End;
|
||||
u32 Fraction;
|
||||
u32 PlayCount;
|
||||
} SWaveSmplChunk;
|
||||
|
||||
class WavDecoder : public SoundDecoder
|
||||
{
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user