mirror of https://github.com/raysan5/raylib
Corrected issue with MOD playing
Despite issue is corrected, now module loop doesn't work...
This commit is contained in:
parent
96207a8a02
commit
35a6e9a074
|
@ -30,11 +30,11 @@ int main()
|
|||
int screenWidth = 800;
|
||||
int screenHeight = 450;
|
||||
|
||||
SetConfigFlags(FLAG_MSAA_4X_HINT); // NOTE: Try to enable MSAA 4X
|
||||
SetConfigFlags(FLAG_MSAA_4X_HINT); // NOTE: Try to enable MSAA 4X
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - module playing (streaming)");
|
||||
|
||||
InitAudioDevice(); // Initialize audio device
|
||||
InitAudioDevice(); // Initialize audio device
|
||||
|
||||
Color colors[14] = { ORANGE, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK,
|
||||
YELLOW, GREEN, SKYBLUE, PURPLE, BEIGE };
|
||||
|
@ -52,7 +52,7 @@ int main()
|
|||
circles[i].color = colors[GetRandomValue(0, 13)];
|
||||
}
|
||||
|
||||
Music xm = LoadMusicStream("resources/mini1111.xm");
|
||||
Music xm = LoadMusicStream("resources/chiptun1.mod");
|
||||
|
||||
PlayMusicStream(xm);
|
||||
|
||||
|
|
20
src/audio.c
20
src/audio.c
|
@ -1176,14 +1176,15 @@ Music LoadMusicStream(const char *fileName)
|
|||
|
||||
if (jar_mod_load_file(&music->ctxMod, fileName))
|
||||
{
|
||||
// NOTE: Only stereo is supported for MOD
|
||||
music->stream = InitAudioStream(48000, 16, 2);
|
||||
music->totalSamples = (unsigned int)jar_mod_max_samples(&music->ctxMod);
|
||||
music->samplesLeft = music->totalSamples;
|
||||
music->ctxType = MUSIC_MODULE_MOD;
|
||||
music->loopCount = -1; // Infinite loop by default
|
||||
|
||||
TraceLog(LOG_DEBUG, "[%s] MOD number of samples: %i", fileName, music->samplesLeft);
|
||||
TraceLog(LOG_DEBUG, "[%s] MOD track length: %11.6f sec", fileName, (float)music->totalSamples/48000.0f);
|
||||
TraceLog(LOG_INFO, "[%s] MOD number of samples: %i", fileName, music->samplesLeft);
|
||||
TraceLog(LOG_INFO, "[%s] MOD track length: %11.6f sec", fileName, (float)music->totalSamples/48000.0f);
|
||||
}
|
||||
else musicLoaded = false;
|
||||
}
|
||||
|
@ -1345,18 +1346,27 @@ void UpdateMusicStream(Music music)
|
|||
#if defined(SUPPORT_FILEFORMAT_XM)
|
||||
case MUSIC_MODULE_XM:
|
||||
{
|
||||
// NOTE: Internally this function considers 2 channels generation, so samplesCount/2 --> WEIRD
|
||||
// NOTE: Internally this function considers 2 channels generation, so samplesCount/2
|
||||
jar_xm_generate_samples_16bit(music->ctxXm, (short *)pcm, samplesCount/2);
|
||||
} break;
|
||||
#endif
|
||||
#if defined(SUPPORT_FILEFORMAT_MOD)
|
||||
case MUSIC_MODULE_MOD: jar_mod_fillbuffer(&music->ctxMod, pcm, samplesCount, 0); break;
|
||||
case MUSIC_MODULE_MOD:
|
||||
{
|
||||
// NOTE: 3rd parameter (nbsample) specify the number of stereo 16bits samples you want, so sampleCount/2
|
||||
jar_mod_fillbuffer(&music->ctxMod, (short *)pcm, samplesCount/2, 0);
|
||||
} break;
|
||||
#endif
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
UpdateAudioStream(music->stream, pcm, samplesCount);
|
||||
music->samplesLeft -= samplesCount;
|
||||
if ((music->ctxType == MUSIC_MODULE_XM) || (music->ctxType == MUSIC_MODULE_MOD))
|
||||
{
|
||||
music->samplesLeft -= samplesCount/2;
|
||||
}
|
||||
else music->samplesLeft -= samplesCount;
|
||||
|
||||
if (music->samplesLeft <= 0)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue