-fixed wrong played default wiiflow sounds (issue 23)

also replaced all spaces by tabs in the gui_sound.cpp ;)
-made the default wave sounds smaller
This commit is contained in:
fix94.1 2012-04-03 14:04:47 +00:00
parent 8ed9ea593d
commit 649dfd6731
4 changed files with 178 additions and 188 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -56,7 +56,8 @@ static inline int GetFirstUnusedVoice()
extern "C" void SoundCallback(s32 voice)
{
SoundDecoder * decoder = SoundHandler::Instance()->Decoder(voice);
if(!decoder) return;
if(!decoder)
return;
if(decoder->IsBufferReady())
{
@ -98,7 +99,8 @@ GuiSound::GuiSound(GuiSound *g)
voice = -1;
Init();
if (g == NULL) return;
if (g == NULL)
return;
if (g->sound != NULL)
{
@ -159,7 +161,8 @@ bool GuiSound::Load(const char * filepath)
FILE * f = fopen(filepath, "rb");
if(!f)
{ gprintf("Failed to load file %s!!\n", filepath);
{
gprintf("Failed to load file %s!!\n", filepath);
return false;
}
@ -171,12 +174,14 @@ bool GuiSound::Load(const char * filepath)
gprintf("Loading %s using voice %d\n", filepath, voice);
SoundDecoder * decoder = SoundHandler::Instance()->Decoder(voice);
if(!decoder)
{ gprintf("No Decoder!!!\n");
{
gprintf("No Decoder!!!\n");
return false;
}
if(!decoder->IsBufferReady())
{ gprintf("Buffer not ready!!n");
{
gprintf("Buffer not ready!!n");
SoundHandler::Instance()->RemoveDecoder(voice);
return false;
}
@ -193,19 +198,13 @@ bool GuiSound::Load(const u8 * snd, u32 len, bool isallocated)
this->voice = voice;
if(!snd)
{
return false;
}
if(!isallocated && *((u32 *) snd) == 'RIFF')
{
return LoadSoundEffect(snd, len);
}
if(*((u32 *) snd) == 'IMD5')
{
UncompressSoundbin(snd, len, isallocated);
}
else
{
sound = (u8 *) snd;
@ -217,9 +216,7 @@ bool GuiSound::Load(const u8 * snd, u32 len, bool isallocated)
SoundDecoder * decoder = SoundHandler::Instance()->Decoder(voice);
if(!decoder)
{
return false;
}
if(!decoder->IsBufferReady())
{
@ -273,25 +270,19 @@ void GuiSound::Play(int vol, bool restart)
if(SoundEffectLength > 0)
{
ASND_StopVoice(voice);
ASND_SetVoice(voice, VOICE_STEREO_16BIT, 32000, 0, sound, SoundEffectLength, vol, vol, NULL);
ASND_SetVoice(voice, VOICE_MONO_16BIT, 22050, 0, sound, SoundEffectLength, vol, vol, NULL);
return;
}
if(IsPlaying() && !restart)
{
return;
}
if(voice < 0 || voice >= 16)
{
return;
}
SoundDecoder * decoder = SoundHandler::Instance()->Decoder(voice);
if(!decoder)
{
return;
}
ASND_StopVoice(voice);
if(decoder->IsEOF())
@ -325,9 +316,7 @@ void GuiSound::Stop()
SoundDecoder * decoder = SoundHandler::Instance()->Decoder(voice);
if(!decoder)
{
return;
}
decoder->ClearBuffer();
Rewind();
@ -463,7 +452,8 @@ void GuiSound::UncompressSoundbin(const u8 * snd, u32 len, bool isallocated)
const u8 * file = snd+32;
length = len-32;
if (length <= 0) return;
if (length <= 0)
return;
if(*((u32 *) file) == 'LZ77')
{