diff options
author | Chris Robinson <[email protected]> | 2020-09-22 08:30:04 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-09-22 08:30:04 -0700 |
commit | 844e6c881b55e1dac6d754a9d103e04a0d15b636 (patch) | |
tree | 8d89e79bbff203396083b82a55717d488a024dce /examples | |
parent | d912b92a6042464546d0588313741b46d63ec297 (diff) |
Add an alconvolve option to silence the dry signal
Diffstat (limited to 'examples')
-rw-r--r-- | examples/alconvolve.c | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/examples/alconvolve.c b/examples/alconvolve.c index 4f0eb53d..bc6ac311 100644 --- a/examples/alconvolve.c +++ b/examples/alconvolve.c @@ -45,6 +45,19 @@ #endif +/* Filter object functions */ +static LPALGENFILTERS alGenFilters; +static LPALDELETEFILTERS alDeleteFilters; +static LPALISFILTER alIsFilter; +static LPALFILTERI alFilteri; +static LPALFILTERIV alFilteriv; +static LPALFILTERF alFilterf; +static LPALFILTERFV alFilterfv; +static LPALGETFILTERI alGetFilteri; +static LPALGETFILTERIV alGetFilteriv; +static LPALGETFILTERF alGetFilterf; +static LPALGETFILTERFV alGetFilterfv; + /* Effect object functions */ static LPALGENEFFECTS alGenEffects; static LPALDELETEEFFECTS alDeleteEffects; @@ -372,15 +385,15 @@ static ALuint LoadSound(const char *filename) int main(int argc, char **argv) { - ALuint ir_buffer, effect, slot; + ALuint ir_buffer, filter, effect, slot; StreamPlayer *player; int i; /* Print out usage if no arguments were specified */ if(argc < 2) { - fprintf(stderr, "Usage: %s [-device <name>] <impulse response file> <filenames...>\n", - argv[0]); + fprintf(stderr, "Usage: %s [-device <name>] <impulse response file> " + "<[-dry | -nodry] filename>...\n", argv[0]); return 1; } @@ -404,6 +417,18 @@ int main(int argc, char **argv) /* Define a macro to help load the function pointers. */ #define LOAD_PROC(T, x) ((x) = (T)alGetProcAddress(#x)) + LOAD_PROC(LPALGENFILTERS, alGenFilters); + LOAD_PROC(LPALDELETEFILTERS, alDeleteFilters); + LOAD_PROC(LPALISFILTER, alIsFilter); + LOAD_PROC(LPALFILTERI, alFilteri); + LOAD_PROC(LPALFILTERIV, alFilteriv); + LOAD_PROC(LPALFILTERF, alFilterf); + LOAD_PROC(LPALFILTERFV, alFilterfv); + LOAD_PROC(LPALGETFILTERI, alGetFilteri); + LOAD_PROC(LPALGETFILTERIV, alGetFilteriv); + LOAD_PROC(LPALGETFILTERF, alGetFilterf); + LOAD_PROC(LPALGETFILTERFV, alGetFilterfv); + LOAD_PROC(LPALGENEFFECTS, alGenEffects); LOAD_PROC(LPALDELETEEFFECTS, alDeleteEffects); LOAD_PROC(LPALISEFFECT, alIsEffect); @@ -474,6 +499,12 @@ int main(int argc, char **argv) alAuxiliaryEffectSloti(slot, AL_EFFECTSLOT_EFFECT, (ALint)effect); assert(alGetError()==AL_NO_ERROR && "Failed to set effect slot"); + /* Create a filter that can silence the dry path. */ + filter = 0; + alGenFilters(1, &filter); + alFilteri(filter, AL_FILTER_TYPE, AL_FILTER_LOWPASS); + alFilterf(filter, AL_LOWPASS_GAIN, 0.0f); + player = NewPlayer(); /* Connect the player's source to the effect slot. */ alSource3i(player->source, AL_AUXILIARY_SEND_FILTER, (ALint)slot, 0, AL_FILTER_NULL); @@ -484,6 +515,20 @@ int main(int argc, char **argv) { const char *namepart; + if(argc-i > 1) + { + if(strcasecmp(argv[i], "-nodry") == 0) + { + alSourcei(player->source, AL_DIRECT_FILTER, (ALint)filter); + ++i; + } + else if(strcasecmp(argv[i], "-dry") == 0) + { + alSourcei(player->source, AL_DIRECT_FILTER, AL_FILTER_NULL); + ++i; + } + } + if(!OpenPlayerFile(player, argv[i])) continue; @@ -518,6 +563,7 @@ int main(int argc, char **argv) alDeleteAuxiliaryEffectSlots(1, &slot); alDeleteEffects(1, &effect); + alDeleteFilters(1, &filter); alDeleteBuffers(1, &ir_buffer); CloseAL(); |