Smooth loop in mods doesn't work like it should to do

Hello!

I have a problem: in a part of modules, when a tune is over, instead of jumping to a required pattern in the loop, the player loops the whole tune.
Also, if I minimize the window, the player make a pause.

Here is my code (some parts are omitted and added, but it’s not so matter):

public class ModLoopTest extends BasicGame {

//In this way we can play the modules from the beginning

OpenALMODPlayer mod=new OpenALMODPlayer();

public ModLoopTest(String title) {
	super(title);
}
@Override
public void render(GameContainer gc, Graphics g) throws SlickException {
	
}

@Override
public void init(GameContainer gc) throws SlickException {
	mod.init();
	try {
		mod.play(ResourceLoader.getResourceAsStream("res/classic_tunes.mod"), true, true);
	} catch (IOException e) {
		e.printStackTrace();
	}
}

@Override
public void update(GameContainer gc, int delta) throws SlickException {
	mod.update();
}
public static void main(String[] args) {
	try {
		AppGameContainer a=new AppGameContainer(new ModLoopTest("Mod loop test"), 640, 480, false);
		a.setTargetFrameRate(60);
		a.start();
	} catch (SlickException e) {
		e.printStackTrace();
	}
}

}

I’m not a user of OpenAL myself, but am generally curious about sound-related matters. I tried looking up “OpenALModPlayer” in the OpenAL Specs and Programmers Guides, but wasn’t able to find the term.

Can you point me to the API for the root command used to play a file, and the syntax for setting the loop points? I’m interested in taking a look at them. With a javax.sound.sampled.Clip it’s easy to set the loop points, but not every sound API provides this capability.

Because I use IBXM library (alpha 45). Maybe, there is a newer version, where the problem is fixed.

You could make it easier to help you if you posted a link to the source of your library. I’ve looked at a couple different sites that came up when I searched IBXM, but it’s not clear that any of them are what you are using. One git hub source I found had a looping function but no ability to set loop points.

From what little I’ve been able to discern, this might be a library written by Paul Lamb, from back in 2007? At the least, there is a codec with that date that came up in my search.

The main next step, I think, is finding the API and verifying that the capability you want even exists.

I think that it’s from here: https://slick.ninjacave.com/

In this library, there is OpenALStreamPlayer, but no OpenALMODPlayer. There is a MODSound class, but it doesn’t have the ability to set loop points. There is an Audio interface which also has looping enabled but no provision for setting loop points. The positioning info that it does have pertains to 3D location.

If this is indeed the library you are using, I think you will just have to make a separate cue that has the beginning and end that you desire for the loop.

I use IBXM library separately, without any mediation from Slick2d

I founded a link to the source code: https://github.com/nguillaumin/slick2d-maven/tree/8251f88a0ed6a70e726d2468842455cd1f80893f/slick2d-core/src/main/java/ibxm. Maybe, there is the library I use

Progress! That definitely has the classes that you are using.
Interesting to see that this code was written by @kevglass

I’m not seeing any provision for setting loop points, though, at least not in OpenALMODPlayer. Looking at your code, where do you attempt to set your loop points?

Maybe this is more about the code not supporting what you want/hope to do rather than what it was built to do? That is going through my mind at the moment. Or maybe I misunderstood what you are looking to do.

Maybe, the loop points are in another classes. I found Envelope class, but I didn’t see/paid attention to its use😔.

I my code there are not any loop points, but in the module.

“Envelopes” don’t usually refer to loop points. They are more usually about dynamics (loudness).

If you are willing to consider another library, maybe look at TinySound. It supports settable loop points. It’s a pretty small and easy to use library. It’s plausible that loop points could be added to AudioCue but I’ve been pretty busy. I’d be open to someone else doing it, though. Both libraries rely on Java’s javax.sound.sampled.SourceDataLine for output, rather than OpenAL, if that makes a difference to your situation.

Do they support modules playback (.mod, .xm, etc.)?

I apologize–I didn’t pick up the part that you wanted to used this format for your project. The two libraries I mentioned don’t support MOD files. I’m curious why this is part of your project! I don’t mean to question the decision–am just curious. MOD looks very interesting, the way it’s a packaging of resources and a “score” rather than a representation of the audio signal.

I’ve been wanting to do something similar, for a long time, using FM synthesis playback code that I wrote. I think a playback that uses a set of FM synth objects (which can include additive synthesis), some rudimentary outboard effects, and a score for them could be viable. Potentially it could work well with real-time controls that affect playback based on game state. It could also be integrated with a DAW and the use of a tool such as the FM8 (allowing the preliminary scoring to occur in a realm more conducive to musical composition). It’s all rather ambitious, though, and I’m not clear there would be sufficient adoption to justify the investment required.

If I do look at this project again, the @kevglass library you cited will be very valuable for researching how he handled this!