#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <limits.h>
#include <string.h>
#include <stdbool.h>
Go to the source code of this file.
Macros | |
#define | JAR_XM_DEBUG 0 |
#define | JAR_XM_LINEAR_INTERPOLATION 1 |
#define | JAR_XM_DEFENSIVE 1 |
#define | JAR_XM_RAMPING 1 |
Typedefs | |
typedef struct jar_xm_context_s | jar_xm_context_t |
Functions | |
int | jar_xm_create_context_from_file (jar_xm_context_t **ctx, uint32_t rate, const char *filename) |
Create a XM context. More... | |
int | jar_xm_create_context (jar_xm_context_t **, const char *moddata, uint32_t rate) |
Create a XM context. More... | |
int | jar_xm_create_context_safe (jar_xm_context_t **, const char *moddata, size_t moddata_length, uint32_t rate) |
Create a XM context. More... | |
void | jar_xm_free_context (jar_xm_context_t *) |
Free a XM context created by jar_xm_create_context(). More... | |
void | jar_xm_generate_samples (jar_xm_context_t *, float *output, size_t numsamples) |
Play the module and put the sound samples in an output buffer. More... | |
void | jar_xm_generate_samples_16bit (jar_xm_context_t *ctx, short *output, size_t numsamples) |
Play the module, resample from 32 bit to 16 bit, and put the sound samples in an output buffer. More... | |
void | jar_xm_generate_samples_8bit (jar_xm_context_t *ctx, char *output, size_t numsamples) |
Play the module, resample from 32 bit to 8 bit, and put the sound samples in an output buffer. More... | |
void | jar_xm_set_max_loop_count (jar_xm_context_t *, uint8_t loopcnt) |
Set the maximum number of times a module can loop. More... | |
uint8_t | jar_xm_get_loop_count (jar_xm_context_t *) |
Get the loop count of the currently playing module. More... | |
bool | jar_xm_mute_channel (jar_xm_context_t *, uint16_t, bool) |
Mute or unmute a channel. More... | |
bool | jar_xm_mute_instrument (jar_xm_context_t *, uint16_t, bool) |
Mute or unmute an instrument. More... | |
const char * | jar_xm_get_module_name (jar_xm_context_t *) |
Get the module name as a NUL-terminated string. More... | |
const char * | jar_xm_get_tracker_name (jar_xm_context_t *) |
Get the tracker name as a NUL-terminated string. More... | |
uint16_t | jar_xm_get_number_of_channels (jar_xm_context_t *) |
Get the number of channels. More... | |
uint16_t | jar_xm_get_module_length (jar_xm_context_t *) |
Get the module length (in patterns). More... | |
uint16_t | jar_xm_get_number_of_patterns (jar_xm_context_t *) |
Get the number of patterns. More... | |
uint16_t | jar_xm_get_number_of_rows (jar_xm_context_t *, uint16_t) |
Get the number of rows of a pattern. More... | |
uint16_t | jar_xm_get_number_of_instruments (jar_xm_context_t *) |
Get the number of instruments. More... | |
uint16_t | jar_xm_get_number_of_samples (jar_xm_context_t *, uint16_t) |
Get the number of samples of an instrument. More... | |
void | jar_xm_get_playing_speed (jar_xm_context_t *, uint16_t *bpm, uint16_t *tempo) |
Get the current module speed. More... | |
void | jar_xm_get_position (jar_xm_context_t *, uint8_t *pattern_index, uint8_t *pattern, uint8_t *row, uint64_t *samples) |
Get the current position in the module being played. More... | |
uint64_t | jar_xm_get_latest_trigger_of_instrument (jar_xm_context_t *, uint16_t) |
Get the latest time (in number of generated samples) when a particular instrument was triggered in any channel. More... | |
uint64_t | jar_xm_get_latest_trigger_of_sample (jar_xm_context_t *, uint16_t instr, uint16_t sample) |
Get the latest time (in number of generated samples) when a particular sample was triggered in any channel. More... | |
uint64_t | jar_xm_get_latest_trigger_of_channel (jar_xm_context_t *, uint16_t) |
Get the latest time (in number of generated samples) when any instrument was triggered in a given channel. More... | |
uint64_t | jar_xm_get_remaining_samples (jar_xm_context_t *) |
Get the number of remaining samples. More... | |
typedef struct jar_xm_context_s jar_xm_context_t |
int jar_xm_create_context | ( | jar_xm_context_t ** | , |
const char * | moddata, | ||
uint32_t | rate | ||
) |
Create a XM context.
moddata | the contents of the module |
rate | play rate in Hz, recommended value of 48000 |
int jar_xm_create_context_from_file | ( | jar_xm_context_t ** | ctx, |
uint32_t | rate, | ||
const char * | filename | ||
) |
Create a XM context.
moddata | the contents of the module |
rate | play rate in Hz, recommended value of 48000 |
int jar_xm_create_context_safe | ( | jar_xm_context_t ** | , |
const char * | moddata, | ||
size_t | moddata_length, | ||
uint32_t | rate | ||
) |
Create a XM context.
moddata | the contents of the module |
moddata_length | the length of the contents of the module, in bytes |
rate | play rate in Hz, recommended value of 48000 |
void jar_xm_free_context | ( | jar_xm_context_t * | ) |
Free a XM context created by jar_xm_create_context().
void jar_xm_generate_samples | ( | jar_xm_context_t * | , |
float * | output, | ||
size_t | numsamples | ||
) |
Play the module and put the sound samples in an output buffer.
output | buffer of 2*numsamples elements (A left and right value for each sample) |
numsamples | number of samples to generate |
Referenced by jar_xm_generate_samples_16bit(), and jar_xm_generate_samples_8bit().
void jar_xm_generate_samples_16bit | ( | jar_xm_context_t * | ctx, |
short * | output, | ||
size_t | numsamples | ||
) |
Play the module, resample from 32 bit to 16 bit, and put the sound samples in an output buffer.
output | buffer of 2*numsamples elements (A left and right value for each sample) |
numsamples | number of samples to generate |
void jar_xm_generate_samples_8bit | ( | jar_xm_context_t * | ctx, |
char * | output, | ||
size_t | numsamples | ||
) |
Play the module, resample from 32 bit to 8 bit, and put the sound samples in an output buffer.
output | buffer of 2*numsamples elements (A left and right value for each sample) |
numsamples | number of samples to generate |
uint64_t jar_xm_get_latest_trigger_of_channel | ( | jar_xm_context_t * | , |
uint16_t | |||
) |
Get the latest time (in number of generated samples) when any instrument was triggered in a given channel.
uint64_t jar_xm_get_latest_trigger_of_instrument | ( | jar_xm_context_t * | , |
uint16_t | |||
) |
Get the latest time (in number of generated samples) when a particular instrument was triggered in any channel.
uint64_t jar_xm_get_latest_trigger_of_sample | ( | jar_xm_context_t * | , |
uint16_t | instr, | ||
uint16_t | sample | ||
) |
Get the latest time (in number of generated samples) when a particular sample was triggered in any channel.
uint8_t jar_xm_get_loop_count | ( | jar_xm_context_t * | ) |
Get the loop count of the currently playing module.
This value is 0 when the module is still playing, 1 when the module has looped once, etc.
uint16_t jar_xm_get_module_length | ( | jar_xm_context_t * | ) |
Get the module length (in patterns).
const char* jar_xm_get_module_name | ( | jar_xm_context_t * | ) |
Get the module name as a NUL-terminated string.
uint16_t jar_xm_get_number_of_channels | ( | jar_xm_context_t * | ) |
Get the number of channels.
uint16_t jar_xm_get_number_of_instruments | ( | jar_xm_context_t * | ) |
Get the number of instruments.
uint16_t jar_xm_get_number_of_patterns | ( | jar_xm_context_t * | ) |
Get the number of patterns.
uint16_t jar_xm_get_number_of_rows | ( | jar_xm_context_t * | , |
uint16_t | |||
) |
Get the number of rows of a pattern.
uint16_t jar_xm_get_number_of_samples | ( | jar_xm_context_t * | , |
uint16_t | |||
) |
Get the number of samples of an instrument.
void jar_xm_get_playing_speed | ( | jar_xm_context_t * | , |
uint16_t * | bpm, | ||
uint16_t * | tempo | ||
) |
Get the current module speed.
bpm | will receive the current BPM |
tempo | will receive the current tempo (ticks per line) |
void jar_xm_get_position | ( | jar_xm_context_t * | , |
uint8_t * | pattern_index, | ||
uint8_t * | pattern, | ||
uint8_t * | row, | ||
uint64_t * | samples | ||
) |
Get the current position in the module being played.
pattern_index | if not NULL, will receive the current pattern index in the POT (pattern order table) |
pattern | if not NULL, will receive the current pattern number |
row | if not NULL, will receive the current row |
samples | if not NULL, will receive the total number of generated samples (divide by sample rate to get seconds of generated audio) |
uint64_t jar_xm_get_remaining_samples | ( | jar_xm_context_t * | ) |
Get the number of remaining samples.
Divide by 2 to get the number of individual LR data samples.
const char* jar_xm_get_tracker_name | ( | jar_xm_context_t * | ) |
Get the tracker name as a NUL-terminated string.
bool jar_xm_mute_channel | ( | jar_xm_context_t * | , |
uint16_t | , | ||
bool | |||
) |
Mute or unmute a channel.
bool jar_xm_mute_instrument | ( | jar_xm_context_t * | , |
uint16_t | , | ||
bool | |||
) |
Mute or unmute an instrument.
void jar_xm_set_max_loop_count | ( | jar_xm_context_t * | , |
uint8_t | loopcnt | ||
) |
Set the maximum number of times a module can loop.
After the specified number of loops, calls to jar_xm_generate_samples will only generate silence. You can control the current number of loops with jar_xm_get_loop_count().
loopcnt | maximum number of loops. Use 0 to loop indefinitely. |