aboutsummaryrefslogtreecommitdiffstats
path: root/examples/alconvolve.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-09-05 23:48:19 -0700
committerChris Robinson <[email protected]>2020-09-05 23:48:19 -0700
commitf5163ca98835c09439a87e598d0b0c61f1cf724b (patch)
treed19dbb35beb69cc8fa29f8ab922ba9ff60f6da2b /examples/alconvolve.c
parent800e2b61259ae96ae97e22d86a0fa4e2e8a07be6 (diff)
Print the name and format for alconvole's impulse response
Diffstat (limited to 'examples/alconvolve.c')
-rw-r--r--examples/alconvolve.c25
1 files 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;
}