Skip to content

Module loop fix for music files and is_sound_effect checking added - #3690

Open
RPGoogles wants to merge 2 commits into
EasyRPG:masterfrom
RPGoogles:Module-Loop-fix-for-Music-files-and-is_SE-checking-added
Open

RPGoogles wants to merge 2 commits into
EasyRPG:masterfrom
RPGoogles:Module-Loop-fix-for-Music-files-and-is_SE-checking-added

Conversation

@RPGoogles

Copy link
Copy Markdown

This should be an all in one fix for the Music Looping bug when using Tracker Module formats as well as allowing Tracker Module Formats to work as Sound Effects by adding an is_sound_effect parameter that when true, sets the loop limit within libxmp to 1( loop 1 once then finish ) and when false(so a Music Track) sets the loop limit to 0 ( endless looping determined by the module file( jump commands for example ) until the Game's developer changes the BGM or ends the BGM ).

@Ghabry

Ghabry commented Oct 3, 2026

Copy link
Copy Markdown
Member

For context: In the chat fdelapena sent two tracker files that have loop points:

Archiv.zip

It was noticed that looping isn't supported at all in our code.

The proposed solution is doing loops for BGM and no loops for SE.

@Ghabry

Ghabry commented Oct 3, 2026

Copy link
Copy Markdown
Member

@RPGoogles while your code works and you found the issue with the loop handlng are you okay with me proposing a different fix?


In general we need a bit more control here by using the low level xmp_play_frame function instead of xmp_play_buffer.

There are some interactions in the code you can't be aware of which will cause issues:

We need a way to track the loop count (to determine whether a track played once otherwise you will e.g. softlock when going to an Inn and the Inn Music Plays). When xmp does the looping internally this won't work.

There is already a GetLooping function which is true for BGM and false for SE.

@RPGoogles

Copy link
Copy Markdown
Author

@Ghabry

Of Course! I mean, I wasn't expecting my edits to be the perfect solution as if I have to be honest, I kinda just, fumbled my way around the code base lol, I am surprised I managed to get a working solution so quickly ngl.

We need a way to track the loop count (to determine whether a track played once otherwise you will e.g. softlock when going to an Inn and the Inn Music Plays). When xmp does the looping internally this won't work.

Do you mean by using the built in specify function under the Map Settings Tab/Window? As well as the default Music and Sound Effect Settings in the System Tabs? Which might cause this issue?
This is hard for me to test as Maniacs Patch doesn't give a String Option for those fields, which is fine for my use-case but maybe not for most users( but then again, modern module format use in RPG Maker 2003 is going to be a niche within a niche tbf ).

Although, it may have been possible in one of the old patches that had module format support maybe?( I remember it being mentioned that some old 2k3 games used tracker modules right?)

In general we need a bit more control here by using the low level xmp_play_frame function instead of xmp_play_buffer.
There is already a GetLooping function which is true for BGM and false for SE.

I see, in audio_decoder_base.cpp, I noticed there's also a GetLoopCount which returns loop_count? I would imagine this would go well if your wanting to track the loop count maybe?. In xmp_frame_info there is also a loop counter as one of the members called loop_count, not sure how useful this may end up being?

RPGoogles and others added 2 commits October 3, 2026 15:30
Adds functionality so the player can actually find tracker module files(.mod, .xm, .s3m and .it) for Music and Sound.
This feature is now enabled for BGM and disabled for SE

Migrated from xmp_play_buffer to the low level API xmp_play_frame for more control about the loop count
@Ghabry
Ghabry force-pushed the Module-Loop-fix-for-Music-files-and-is_SE-checking-added branch from edd9170 to 04ec288 Compare October 3, 2026 13:31
@Ghabry

Ghabry commented Oct 3, 2026

Copy link
Copy Markdown
Member

Jenkins: Test this please

Yes I mean the "Call Inn" Event Command. The Inn Music Plays until the track ends or for 10 seconds, whatever happens first. So this needed detection of the loop point.

Changed this now to the low level API (which made the code more complex than your solution xD) so the looping can be properly detected for this one edge case. Though in general the idea is the same as your solution.

@Ghabry
Ghabry requested a review from carstene1ns October 3, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants