diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2026-08-24 11:16:07 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2026-08-24 11:16:07 +0200 |
| commit | c068f22329d5cc722622a2183bbb22eef2093df7 (patch) | |
| tree | 12d56c1aede67988a55e241364606bfbb4dba933 /src/parsec/include/aud_supp.h | |
| download | openparsec-c068f22329d5cc722622a2183bbb22eef2093df7.tar.xz openparsec-c068f22329d5cc722622a2183bbb22eef2093df7.zip | |
Diffstat (limited to 'src/parsec/include/aud_supp.h')
| -rw-r--r-- | src/parsec/include/aud_supp.h | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/src/parsec/include/aud_supp.h b/src/parsec/include/aud_supp.h new file mode 100644 index 0000000..a5819ff --- /dev/null +++ b/src/parsec/include/aud_supp.h @@ -0,0 +1,129 @@ +/* + * PARSEC HEADER: aud_supp.h + */ + +#ifndef _AUD_SUPP_H_ +#define _AUD_SUPP_H_ + + +// sample-channel relation (holds id once sample is fetched by name) ---------- +// +struct sample_channel_info_s { + + const char* samplename; + const char* fallbacksample; + int sampleid; + int channel; + int interruptold; +}; + + +// macro to fetch a wave for sample x ----------------------------------------- +// +#define AUD_FETCHSAMPLE(x) \ +\ + audiowave_t fetch_wave = NULL; \ + sampleinfo_s* fetch_pSampleInfo; \ + SoundParams_s fetch_params; \ + memset( &fetch_params, 0, sizeof( fetch_params ) ); \ + static int sampleid = -1; \ + if ( sampleid == -1 ) { \ + fetch_pSampleInfo = AUD_FetchSampleByName((x),&sampleid); \ + } else { \ + fetch_pSampleInfo = AUD_FetchSampleById(sampleid); \ + } \ + if(fetch_pSampleInfo != NULL) { \ + fetch_wave = (audiowave_t)fetch_pSampleInfo->samplepointer; \ + fetch_params.volume = ( fetch_pSampleInfo->volume == -1 ) ? \ + AUD_MAX_VOLUME : fetch_pSampleInfo->volume; \ + fetch_params.flags = SOUNDPARAMS_VOLUME; \ + } + + +// macro to fetch a wave for sample x store id in y --------------------------- +// +#define AUD_FETCHSAMPLE_EX(x,y) \ +\ + audiowave_t fetch_wave = NULL; \ + sampleinfo_s* fetch_pSampleInfo; \ + SoundParams_s fetch_params; \ + memset( &fetch_params, 0, sizeof( fetch_params ) ); \ + if ( (y) == -1 ) { \ + fetch_pSampleInfo = AUD_FetchSampleByName((x),&(y)); \ + } else { \ + fetch_pSampleInfo = AUD_FetchSampleById(y); \ + } \ + if(fetch_pSampleInfo != NULL) { \ + fetch_wave = (audiowave_t)fetch_pSampleInfo->samplepointer; \ + fetch_params.volume = ( fetch_pSampleInfo->volume == -1 ) ? \ + AUD_MAX_VOLUME : fetch_pSampleInfo->volume; \ + fetch_params.flags = SOUNDPARAMS_VOLUME; \ + } + + +// macro to fetch a wave for sample x, fallback to sample y ------------------- +// +#define AUD_FETCHSAMPLE_FALLBACK(x,y) \ +\ + audiowave_t fetch_wave = NULL; \ + sampleinfo_s* fetch_pSampleInfo; \ + SoundParams_s fetch_params; \ + memset( &fetch_params, 0, sizeof( fetch_params ) ); \ + static int sampleid = -1; \ + if ( sampleid == -1 ) { \ + fetch_pSampleInfo = AUD_FetchSampleByName( (x) ,&sampleid); \ + if(fetch_pSampleInfo == NULL) { \ + fetch_pSampleInfo = AUD_FetchSampleByName( (y) ,&sampleid); \ + } \ + } else { \ + fetch_pSampleInfo = AUD_FetchSampleById(sampleid); \ + } \ + if(fetch_pSampleInfo != NULL) { \ + fetch_wave = (audiowave_t)fetch_pSampleInfo->samplepointer; \ + fetch_params.volume = ( fetch_pSampleInfo->volume == -1 ) ? \ + AUD_MAX_VOLUME : fetch_pSampleInfo->volume; \ + fetch_params.flags = SOUNDPARAMS_VOLUME; \ + } + + +// macro to fetch a wave for sample x, fallback to sample z, store id in y ---- +// +#define AUD_FETCHSAMPLE_FALLBACK_EX(x,y,z) \ +\ + audiowave_t fetch_wave = NULL; \ + sampleinfo_s* fetch_pSampleInfo; \ + SoundParams_s fetch_params; \ + memset( &fetch_params, 0, sizeof( fetch_params ) ); \ + if ( (y) == -1 ) { \ + fetch_pSampleInfo = AUD_FetchSampleByName( (x) ,&(y)); \ + if(fetch_pSampleInfo == NULL) { \ + fetch_pSampleInfo = AUD_FetchSampleByName( (z) ,&(y)); \ + } \ + } else { \ + fetch_pSampleInfo = AUD_FetchSampleById((y)); \ + } \ + if(fetch_pSampleInfo != NULL) { \ + fetch_wave = (audiowave_t)fetch_pSampleInfo->samplepointer; \ + fetch_params.volume = ( fetch_pSampleInfo->volume == -1 ) ? \ + AUD_MAX_VOLUME : fetch_pSampleInfo->volume; \ + fetch_params.flags = SOUNDPARAMS_VOLUME; \ + } + + +// encapsulate global audio disabling ----------------------------------------- +// +#define DISABLE_AUDIO_FUNCTIONS (!Op_SoundEffects) +#define DISABLE_MUSIC_FUNCTIONS (!Op_Music) + + +// external functions --------------------------------------------------------- +// +sampleinfo_s* AUD_FetchSampleByName( const char *name, int *id ); +sampleinfo_s* AUD_FetchSampleById( int id ); +int AUD_SetSampleVolume( int id, int volume ); +int AUD_PlaySampleOnChannel( sample_channel_info_s *info ); + + +#endif // _AUD_SUPP_H_ + + |
