- [FIX] Si no feia falta conversió de format, la música no apuntava correctament la duració al carregar

This commit is contained in:
2024-12-30 19:52:28 +01:00
parent 1b7fdbd230
commit 4fc5b47dc9
2 changed files with 5 additions and 1 deletions

View File

@@ -144,6 +144,7 @@ JA_Music_t *JA_LoadMusic(Uint8* buffer, Uint32 length)
free(music->output); free(music->output);
music->output = (short*)cvt.buf; music->output = (short*)cvt.buf;
} }
music->length = music->samples * chan * 2;
music->pos = 0; music->pos = 0;
music->state = JA_MUSIC_STOPPED; music->state = JA_MUSIC_STOPPED;

View File

@@ -16,7 +16,7 @@ int main(int argc, char **argv) {
JA_Sound_t *peiv = JA_LoadSound("menu_select.wav"); JA_Sound_t *peiv = JA_LoadSound("menu_select.wav");
int channel = -1; int channel = -1;
JA_PlayMusic(music, true); JA_PlayMusic(music, -1);
int volume = 128; int volume = 128;
bool should_exit = false; bool should_exit = false;
while(!should_exit) { while(!should_exit) {
@@ -42,6 +42,9 @@ int main(int argc, char **argv) {
case SDL_SCANCODE_6: // Si pulsem la tecla '6' stopem definitivament el wav infinit case SDL_SCANCODE_6: // Si pulsem la tecla '6' stopem definitivament el wav infinit
JA_StopChannel(channel); JA_StopChannel(channel);
break; break;
case SDL_SCANCODE_7:
JA_PlayMusic(music, 0);
break;
case SDL_SCANCODE_0: // Si pulsem la tecla '1' pausem o despausem la música case SDL_SCANCODE_0: // Si pulsem la tecla '1' pausem o despausem la música
JA_FadeOutMusic(1000); JA_FadeOutMusic(1000);
break; break;