Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
|
Data Structures | |
struct | midiTrackState |
Contains all track-specific parsing state. More... | |
struct | midiSaveState_t |
Macros | |
#define | TRK_REMAIN() (track->track->length - (track->cur - track->track->data)) |
#define | ERR() |
Functions | |
bool | loadMidiFile (const char *name, midiFile_t *file, bool spiRam) |
Load a MIDI file from the filesystem. | |
void | unloadMidiFile (midiFile_t *file) |
Free the data associated with the given MIDI file. | |
bool | initMidiParser (midiFileReader_t *reader, const midiFile_t *file) |
Initialize or reset the MIDI file reader with a particular file. | |
void | midiParserSetFile (midiFileReader_t *reader, const midiFile_t *file) |
Set a new file for the MIDI file reader. The reader's state will be reset. | |
void | resetMidiParser (midiFileReader_t *reader) |
Reset the state of the MIDI parser without deinitializing it or changing the file. | |
void | deinitMidiParser (midiFileReader_t *reader) |
Deinitialize the MIDI file reader and free any memory it has allocated. | |
bool | midiNextEvent (midiFileReader_t *reader, midiEvent_t *event) |
Process and retrieve the next MIDI event in the file. | |
void * | globalMidiSave (void) |
Stop all MIDI playback and return a pointer containing the full playback state. This state must be passed to globalMidiRestore() later to restore the previous state. | |
void | globalMidiRestore (void *data) |
Resume MIDI playback from the state stored in the given pointer. The data will be freed after this call and cannot be reused. | |
int | midiWriteEvent (uint8_t *out, int max, const midiEvent_t *event) |
Writes a MIDI event to a byte buffer. | |
struct midiTrackState |
Data Fields | ||
---|---|---|
const midiTrack_t * | track | A pointer to the MIDI track itself. |
const uint8_t * | cur | The pointer to the current offset within this chunk. |
uint32_t | time | The accumulated delta times for this track, which nextEvent is relative to. |
bool | eventParsed | True if the next event in this channel has already been parsed. |
midiEvent_t | nextEvent |
The next event, when eventParsed is true. |
uint8_t | runningStatus | The last applicable running status command, or 0 if none. |
bool | done | Whether or not the END OF TRACK event has been read. |
struct midiSaveState_t |
Data Fields | ||
---|---|---|
midiPlayer_t | player | |
uint8_t | trackCount | |
midiTrackState_t * | trackStates |
#define TRK_REMAIN | ( | ) | (track->track->length - (track->cur - track->track->data)) |
#define ERR | ( | ) |
bool loadMidiFile | ( | const char * | name, |
midiFile_t * | file, | ||
bool | spiRam ) |
Load a MIDI file from the filesystem.
file | A pointer to a midiFile_t struct to load the file into |
name | The name of the MIDI file to load |
spiRam | Whether to load the MIDI file into SPIRAM |
void unloadMidiFile | ( | midiFile_t * | file | ) |
Free the data associated with the given MIDI file.
file | A pointer to the MIDI file to be unloaded |
bool initMidiParser | ( | midiFileReader_t * | reader, |
const midiFile_t * | file ) |
Initialize or reset the MIDI file reader with a particular file.
reader | A pointer to the MIDI file reader to initialize |
file | A pointer to the MIDI file to load |
void midiParserSetFile | ( | midiFileReader_t * | reader, |
const midiFile_t * | file ) |
Set a new file for the MIDI file reader. The reader's state will be reset.
reader | A pointer to the MIDI file reader to set the file of |
file | A pointer to the MIDI file to load |
void resetMidiParser | ( | midiFileReader_t * | reader | ) |
Reset the state of the MIDI parser without deinitializing it or changing the file.
The next event returned from this MIDI parser will be the first event in the file again.
reader | A pointer to the MIDI file reader to reset |
void deinitMidiParser | ( | midiFileReader_t * | reader | ) |
Deinitialize the MIDI file reader and free any memory it has allocated.
reader | The MIDI file reader to deinitialize |
bool midiNextEvent | ( | midiFileReader_t * | reader, |
midiEvent_t * | event ) |
Process and retrieve the next MIDI event in the file.
reader | The reader to read the event from |
event | A pointer to a MIDI event to be updated with the next event |
void * globalMidiSave | ( | void | ) |
Stop all MIDI playback and return a pointer containing the full playback state. This state must be passed to globalMidiRestore() later to restore the previous state.
void globalMidiRestore | ( | void * | data | ) |
Resume MIDI playback from the state stored in the given pointer. The data will be freed after this call and cannot be reused.
data | The playback state data returned by globalMidiSave() |
int midiWriteEvent | ( | uint8_t * | out, |
int | max, | ||
const midiEvent_t * | event ) |
Writes a MIDI event to a byte buffer.
out | The byte array |
max | The maximum number of bytes to write |
event | The event to write |