From f5163ca98835c09439a87e598d0b0c61f1cf724b Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 5 Sep 2020 23:48:19 -0700 Subject: [PATCH] Print the name and format for alconvole's impulse response --- examples/alconvolve.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/examples/alconvolve.c b/examples/alconvolve.c index 05804dbe..4f0eb53d 100644 --- a/examples/alconvolve.c +++ b/examples/alconvolve.c @@ -286,6 +286,7 @@ static ALuint CreateEffect(void) */ static ALuint LoadSound(const char *filename) { + const char *namepart; ALenum err, format; ALuint buffer; SNDFILE *sndfile; @@ -322,6 +323,16 @@ static ALuint LoadSound(const char *filename) return 0; } + namepart = strrchr(filename, '/'); + if(namepart || (namepart=strrchr(filename, '\\'))) + namepart++; + else + namepart = filename; + printf("Loading: %s (%s, %dhz, %" PRId64 " samples / %.2f seconds)\n", namepart, + FormatName(format), sfinfo.samplerate, sfinfo.frames, + (double)sfinfo.frames / sfinfo.samplerate); + fflush(stdout); + /* Decode the whole audio file to a buffer. */ membuf = malloc((size_t)(sfinfo.frames * sfinfo.channels) * sizeof(float)); @@ -418,19 +429,19 @@ int main(int argc, char **argv) LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTFV, alGetAuxiliaryEffectSlotfv); #undef LOAD_PROC - /* Load the impulse response sound into a buffer. */ - ir_buffer = LoadSound(argv[0]); - if(!ir_buffer) + /* Load the reverb into an effect. */ + effect = CreateEffect(); + if(!effect) { CloseAL(); return 1; } - /* Load the reverb into an effect. */ - effect = CreateEffect(); - if(!effect) + /* Load the impulse response sound into a buffer. */ + ir_buffer = LoadSound(argv[0]); + if(!ir_buffer) { - alDeleteBuffers(1, &ir_buffer); + alDeleteEffects(1, &effect); CloseAL(); return 1; } -- 2.11.4.GIT