Fork me on GitHub

SoLoud::Openmpt

Openmpt is a module-playing engine, capable of replaying wide variety of multichannel music (669, amf, ams, dbm, digi, dmf, dsm, far, gdm, ice, imf, it, itp, j2b, m15, mdl, med, mid, mo3, mod, mptm, mt2, mtm, okt, plm, psm, ptm, s3m, stm, ult, umx, wow, xm). It also loads wav files, and may support wider support for wav files than the stand-alone wav audio source.

SoLoud uses Openmpt through DLL, available from https://lib.openmpt.org/. Note that Openmpt has a more restrictive license than SoLoud, so be sure to check the license.

The midi formats (.mid and .abc) require a library of instruments (patches) to be available. One free set can be downloaded from the SoLoud downloads page.

If the DLL is not available, the SoLoud::Openmpt interfaces will silently fail.

Openmpt.load()

You tell Openmpt to load a file with the load function:


result load(const char *aFilename); // File to load

If loading fails, the function returns an error code.


SoLoud::Openmpt spacedeb;
spacedeb.load("spacedeb.mod");

Openmpt.loadFile()

The loadFile() can be used to load audio from a SoLoud::File object. This is useful for integrating with virtual filesystems / packfiles, such as PhysFS.

Openmpt.loadMem()

Alternate way of loading the file is to read from a memory buffer.


result loadMem(unsigned char *aMem, int aLength, 
               bool aCopy, bool aTakeOwnership);

The aTakeOwnership parameter can be used to tell SoLoud to free the pointer once it's done with it. The aCopy parameter is here for compatibility with the other loadMem functions.

Openmpt.setLooping()

Adjusting the looping of a Openmpt sound does not currently have any effect. All music is set to loop by default.

Openmpt.setFilter()

As with any other audio source, you can attach filters to Openmpt audio sources.


gMusic.setFilter(0, &gLofi);

Openmpt.stop()

You can stop all instances of a Openmpt sound source with stop(). This is equivalent of calling soloud.stopAudioSource() with the sound source.


gMusic.stop();

Openmpt.setInaudibleBehavior()

Set the inaudible behavior of the sound. By default, if a sound is inaudible, it's paused, and will resume when it becomes audible again. With this function you can tell SoLoud to either kill the sound if it becomes inaudible, or to keep ticking the sound even if it's inaudible.


// Keep on talking even if I'm not around
gSpeech.setInaudibleBehavior(true, false);

Openmpt.setVolume()

Set the default volume of the instances created from this audio source.


gTinyVoice.setVolume(0.1);

Openmpt.setLoopPoint(), Openmpt.getLoopPoint()

If looping is enabled, the loop point is, by default, the start of the stream. The loop point can be changed, and current loop point can be queried with these functions.


double t = snd.getLoopPoint();
snd.setLoopPoint(t + 1); // skip 1 second more when looping
...
snd.setLoopPoint(0); // loop from start

Note that since looping occurs on openmpt's side, this setting currently has no effect.

Inherited 3d audio interfaces

Like all other audio sources, Openmpt inherits the 3d audio interfaces. Please refer to the 3d audio chapter for details on:

Copyright©2013-2018 Jari Komppa