|
| 1 | +/* ======================================================================================== */ |
| 2 | +/* FMOD Core API - Codec development header file. */ |
| 3 | +/* Copyright (c), Firelight Technologies Pty, Ltd. 2004-2020. */ |
| 4 | +/* */ |
| 5 | +/* Use this header if you are wanting to develop your own file format plugin to use with */ |
| 6 | +/* FMOD's codec system. With this header you can make your own fileformat plugin that FMOD */ |
| 7 | +/* can register and use. See the documentation and examples on how to make a working */ |
| 8 | +/* plugin. */ |
| 9 | +/* */ |
| 10 | +/* For more detail visit: */ |
| 11 | +/* https://fmod.com/resources/documentation-api?version=2.0&page=core-api.html */ |
| 12 | +/* ======================================================================================== */ |
| 13 | +#ifndef _FMOD_CODEC_H |
| 14 | +#define _FMOD_CODEC_H |
| 15 | + |
| 16 | +/* |
| 17 | + Codec types |
| 18 | +*/ |
| 19 | +typedef struct FMOD_CODEC_STATE FMOD_CODEC_STATE; |
| 20 | +typedef struct FMOD_CODEC_WAVEFORMAT FMOD_CODEC_WAVEFORMAT; |
| 21 | + |
| 22 | +/* |
| 23 | + Codec constants |
| 24 | +*/ |
| 25 | +#define FMOD_CODEC_WAVEFORMAT_VERSION 3 |
| 26 | + |
| 27 | +/* |
| 28 | + Codec callbacks |
| 29 | +*/ |
| 30 | +typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_OPEN_CALLBACK) (FMOD_CODEC_STATE *codec_state, FMOD_MODE usermode, FMOD_CREATESOUNDEXINFO *userexinfo); |
| 31 | +typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_CLOSE_CALLBACK) (FMOD_CODEC_STATE *codec_state); |
| 32 | +typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_READ_CALLBACK) (FMOD_CODEC_STATE *codec_state, void *buffer, unsigned int samples_in, unsigned int *samples_out); |
| 33 | +typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_GETLENGTH_CALLBACK) (FMOD_CODEC_STATE *codec_state, unsigned int *length, FMOD_TIMEUNIT lengthtype); |
| 34 | +typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_SETPOSITION_CALLBACK) (FMOD_CODEC_STATE *codec_state, int subsound, unsigned int position, FMOD_TIMEUNIT postype); |
| 35 | +typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_GETPOSITION_CALLBACK) (FMOD_CODEC_STATE *codec_state, unsigned int *position, FMOD_TIMEUNIT postype); |
| 36 | +typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_SOUNDCREATE_CALLBACK) (FMOD_CODEC_STATE *codec_state, int subsound, FMOD_SOUND *sound); |
| 37 | +typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_METADATA_CALLBACK) (FMOD_CODEC_STATE *codec_state, FMOD_TAGTYPE tagtype, char *name, void *data, unsigned int datalen, FMOD_TAGDATATYPE datatype, int unique); |
| 38 | +typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_GETWAVEFORMAT_CALLBACK)(FMOD_CODEC_STATE *codec_state, int index, FMOD_CODEC_WAVEFORMAT *waveformat); |
| 39 | + |
| 40 | +/* |
| 41 | + Codec structures |
| 42 | +*/ |
| 43 | +typedef struct FMOD_CODEC_DESCRIPTION |
| 44 | +{ |
| 45 | + const char *name; |
| 46 | + unsigned int version; |
| 47 | + int defaultasstream; |
| 48 | + FMOD_TIMEUNIT timeunits; |
| 49 | + FMOD_CODEC_OPEN_CALLBACK open; |
| 50 | + FMOD_CODEC_CLOSE_CALLBACK close; |
| 51 | + FMOD_CODEC_READ_CALLBACK read; |
| 52 | + FMOD_CODEC_GETLENGTH_CALLBACK getlength; |
| 53 | + FMOD_CODEC_SETPOSITION_CALLBACK setposition; |
| 54 | + FMOD_CODEC_GETPOSITION_CALLBACK getposition; |
| 55 | + FMOD_CODEC_SOUNDCREATE_CALLBACK soundcreate; |
| 56 | + FMOD_CODEC_GETWAVEFORMAT_CALLBACK getwaveformat; |
| 57 | +} FMOD_CODEC_DESCRIPTION; |
| 58 | + |
| 59 | +struct FMOD_CODEC_WAVEFORMAT |
| 60 | +{ |
| 61 | + const char* name; |
| 62 | + FMOD_SOUND_FORMAT format; |
| 63 | + int channels; |
| 64 | + int frequency; |
| 65 | + unsigned int lengthbytes; |
| 66 | + unsigned int lengthpcm; |
| 67 | + unsigned int pcmblocksize; |
| 68 | + int loopstart; |
| 69 | + int loopend; |
| 70 | + FMOD_MODE mode; |
| 71 | + FMOD_CHANNELMASK channelmask; |
| 72 | + FMOD_CHANNELORDER channelorder; |
| 73 | + float peakvolume; |
| 74 | +}; |
| 75 | + |
| 76 | +struct FMOD_CODEC_STATE |
| 77 | +{ |
| 78 | + int numsubsounds; |
| 79 | + FMOD_CODEC_WAVEFORMAT *waveformat; |
| 80 | + void *plugindata; |
| 81 | + |
| 82 | + void *filehandle; |
| 83 | + unsigned int filesize; |
| 84 | + FMOD_FILE_READ_CALLBACK fileread; |
| 85 | + FMOD_FILE_SEEK_CALLBACK fileseek; |
| 86 | + FMOD_CODEC_METADATA_CALLBACK metadata; |
| 87 | + |
| 88 | + int waveformatversion; |
| 89 | +}; |
| 90 | + |
| 91 | +#endif |
| 92 | + |
| 93 | + |
0 commit comments