Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOD music playing through libmodplug doesn't respect restart position #87

Open
zeesworth opened this issue Sep 30, 2024 · 10 comments
Open
Labels
external bug Problem of external library affected the MixerX (Should be fixed at the external library side)

Comments

@zeesworth
Copy link

Hi, I'm starting to use this library for one of my projects,
I'm noticing that whenever i load a .MOD file as Music with the ModPlug library enabled, the module's Restart Position does not get respected (haven't tested with XMP)
I've attached an example MOD file that shows what I mean, the file should loop back to the point where the screaming starts.
However playing this with the playmus example, it loops back to the beginning of the file after pausing for a moment.
TEST.MOD.zip

@Wohlstand
Copy link
Member

Let me check this, sounds like more like a bug, or setup confusion. Did you set the "loop infinite"?

@zeesworth
Copy link
Author

Yes, the output in both my program, and the playmus example with the loop argument set, play identically

@Wohlstand
Copy link
Member

I checked just now, looks like both libXMP and libModPlug has this bug. A good reason to report this problem to https://github.com/libxmp/libxmp

@Wohlstand Wohlstand added the bug label Sep 30, 2024
@zeesworth
Copy link
Author

I'll report it there too, after getting libxmp compiled on my machine so I can test and verify

@Wohlstand Wohlstand added external bug Problem of external library affected the MixerX (Should be fixed at the external library side) and removed bug labels Sep 30, 2024
@zeesworth
Copy link
Author

Boy do I feel like a dummy.
The program I'm building uses the data from an external source, which uses MOD files to store some audio.
I had neglected to test any of those original MOD files with playmus, and had only tested my example MOD, which was made in a newer software and had different handling.

The looping issue with my example file was in fact an external bug, but it wasn't the issue I thought it was.
However, I cannot test any of the original files in playmus, since it doesn't seem to want to play it. It always outputs Unrecognized audio format and quits

Here is the file I'm trying to play: BIZARRETUNE.MOD.zip
I can verify this file loops correctly in libxmp, but I haven't been able to test with libmodplug for the above reason

@Wohlstand
Copy link
Member

Tested it just now, and it got been misdetected as an IdSoftware IMF file (a stream of raw OPL2 commands), that's another bug.

@Wohlstand
Copy link
Member

Fixed that detection quickly on MixerX side.

@zeesworth
Copy link
Author

zeesworth commented Oct 4, 2024

I've had a chance to test this and the file does get loaded now, and I'm happy to report this song loops correctly with libxmp! However it does not loop correctly with libmodplug, that still needs to be figured out.
I remember I had gotten it to work once in a different library using libmodplug by changing something, I'll have to look and see what exactly I changed

@zeesworth
Copy link
Author

Looping in libmodplug can be fixed by uncommenting these lines in libmodplug/src/sndmix.cpp

				// End of song ?
				if ((m_nPattern == 0xFF) || (m_nCurrentPattern >= MAX_ORDERS))
				{
-					//if (!m_nRepeatCount)
+					if (!m_nRepeatCount)
						return FALSE;     //never repeat entire song
					if (!m_nRestartPos)
					{
						m_nMusicSpeed = m_nDefaultSpeed;
						m_nMusicTempo = m_nDefaultTempo;
							}
						}
					}
-					//if (m_nRepeatCount > 0) m_nRepeatCount--;
+					if (m_nRepeatCount > 0) m_nRepeatCount--;
					m_nCurrentPattern = m_nRestartPos;
					m_nRow = 0;

@Wohlstand
Copy link
Member

Interesting, I should apply this at the copy of libModPlug at the AudioCodecs side (the collection of dependencies for MixerX).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external bug Problem of external library affected the MixerX (Should be fixed at the external library side)
Projects
None yet
Development

No branches or pull requests

2 participants