XM & YM effects

While the audio mixer can be used to modify WAV file playback, there are some effects and functionalities that are unique to XM and YM files. Starting and stopping are covered in the audio basics page, so they won’t be repeated here.

XM audio

You can get the number of channels used by an XM file by using this function. This is useful if you’re playing multiple audio tracks and want to know which channel to play the next one on without manually calculating the channel.

int xm64player_num_channels (xm64player_t *player);

XM files will play in a loop by default, but this function can be used to cancel repetition:

void xm64player_set_loop(xm64player_t *player, bool loop);

During XM file play, you might want to know the current status of a track. This function can tell you at which point the XM file’s playback is currently at by pattern index, row or seconds. These can be set to NULL if you don’t need all of them.

void xm64player_tell(xm64player_t *player, int *patidx, int *row, float *secs);

More than that, you can also set the current position of the playback by using this function to set the pattern index, row and ticks. Generally speaking, Id rather set loops and such from within the XM file, but this can be useful if you want to trigger a particular part of the song when something happens in-game.

void xm64player_seek(xm64player_t *player, int patidx, int row, int tick);

You can set the volume with this function. Default volume is 1.0.

void xm64player_set_vol(xm64player_t *player, float volume);

This function can be used to create a custom callback when a custom effect is found in any channel. It’s best not to use any unsupported XM effects unless you really know what you’re doing.

void xm64player_set_effect_callback(xm64player_t *player, void (*cb)(void*, uint8_t, uint8_t, uint8_t), void *ctx);

YM Audio

You can also get the number of channels used by a YM file by using the following function. It is useful when you want to calculate where to start the next file if you want to play several at the same time.

int ym64player_num_channels(ym64player_t *player);

These next two functions return the current position and the total duration of the YM file, both in terms of ticks and seconds. The most obvious application would be to make a player showing how far the track has progressed, or to trigger an even upon reaching a certain position in the song. Parameters can be set to NULL if you don’t need them.

void ym64player_tell(ym64player_t *player, int *pos, float *secs);
void ym64player_duration(ym64player_t *player, int *len, float *secs);

And of course, you can change the YM player’s current position by using this function. It takes in the position to move to (in ticks) and returns whether it is able to seek to that position.

bool ym64player_seek(ym64player_t *player, int pos);

Further reading

To get more details about the parameters and output, read the documentation in the header files:

Search

Subscribe to the mailing list

Follow N64 Squid

  • RSS Feed
  • YouTube

Random featured posts