🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

594 lines
18 KiB

  1. /*
  2. * OpenAL Convolution Reverb Example
  3. *
  4. * Copyright (c) 2020 by Chris Robinson <chris.kcat@gmail.com>
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * THE SOFTWARE.
  23. */
  24. /* This file contains an example for applying convolution reverb to a source. */
  25. #include <assert.h>
  26. #include <inttypes.h>
  27. #include <limits.h>
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30. #include <string.h>
  31. #include "sndfile.h"
  32. #include "AL/al.h"
  33. #include "AL/alext.h"
  34. #include "common/alhelpers.h"
  35. #ifndef AL_SOFT_convolution_reverb
  36. #define AL_SOFT_convolution_reverb
  37. #define AL_EFFECT_CONVOLUTION_REVERB_SOFT 0xA000
  38. #endif
  39. /* Filter object functions */
  40. static LPALGENFILTERS alGenFilters;
  41. static LPALDELETEFILTERS alDeleteFilters;
  42. static LPALISFILTER alIsFilter;
  43. static LPALFILTERI alFilteri;
  44. static LPALFILTERIV alFilteriv;
  45. static LPALFILTERF alFilterf;
  46. static LPALFILTERFV alFilterfv;
  47. static LPALGETFILTERI alGetFilteri;
  48. static LPALGETFILTERIV alGetFilteriv;
  49. static LPALGETFILTERF alGetFilterf;
  50. static LPALGETFILTERFV alGetFilterfv;
  51. /* Effect object functions */
  52. static LPALGENEFFECTS alGenEffects;
  53. static LPALDELETEEFFECTS alDeleteEffects;
  54. static LPALISEFFECT alIsEffect;
  55. static LPALEFFECTI alEffecti;
  56. static LPALEFFECTIV alEffectiv;
  57. static LPALEFFECTF alEffectf;
  58. static LPALEFFECTFV alEffectfv;
  59. static LPALGETEFFECTI alGetEffecti;
  60. static LPALGETEFFECTIV alGetEffectiv;
  61. static LPALGETEFFECTF alGetEffectf;
  62. static LPALGETEFFECTFV alGetEffectfv;
  63. /* Auxiliary Effect Slot object functions */
  64. static LPALGENAUXILIARYEFFECTSLOTS alGenAuxiliaryEffectSlots;
  65. static LPALDELETEAUXILIARYEFFECTSLOTS alDeleteAuxiliaryEffectSlots;
  66. static LPALISAUXILIARYEFFECTSLOT alIsAuxiliaryEffectSlot;
  67. static LPALAUXILIARYEFFECTSLOTI alAuxiliaryEffectSloti;
  68. static LPALAUXILIARYEFFECTSLOTIV alAuxiliaryEffectSlotiv;
  69. static LPALAUXILIARYEFFECTSLOTF alAuxiliaryEffectSlotf;
  70. static LPALAUXILIARYEFFECTSLOTFV alAuxiliaryEffectSlotfv;
  71. static LPALGETAUXILIARYEFFECTSLOTI alGetAuxiliaryEffectSloti;
  72. static LPALGETAUXILIARYEFFECTSLOTIV alGetAuxiliaryEffectSlotiv;
  73. static LPALGETAUXILIARYEFFECTSLOTF alGetAuxiliaryEffectSlotf;
  74. static LPALGETAUXILIARYEFFECTSLOTFV alGetAuxiliaryEffectSlotfv;
  75. /* This stuff defines a simple streaming player object, the same as alstream.c.
  76. * Comments are removed for brevity, see alstream.c for more details.
  77. */
  78. #define NUM_BUFFERS 4
  79. #define BUFFER_SAMPLES 8192
  80. typedef struct StreamPlayer {
  81. ALuint buffers[NUM_BUFFERS];
  82. ALuint source;
  83. SNDFILE *sndfile;
  84. SF_INFO sfinfo;
  85. float *membuf;
  86. ALenum format;
  87. } StreamPlayer;
  88. static StreamPlayer *NewPlayer(void)
  89. {
  90. StreamPlayer *player;
  91. player = calloc(1, sizeof(*player));
  92. assert(player != NULL);
  93. alGenBuffers(NUM_BUFFERS, player->buffers);
  94. assert(alGetError() == AL_NO_ERROR && "Could not create buffers");
  95. alGenSources(1, &player->source);
  96. assert(alGetError() == AL_NO_ERROR && "Could not create source");
  97. alSource3i(player->source, AL_POSITION, 0, 0, -1);
  98. alSourcei(player->source, AL_SOURCE_RELATIVE, AL_TRUE);
  99. alSourcei(player->source, AL_ROLLOFF_FACTOR, 0);
  100. assert(alGetError() == AL_NO_ERROR && "Could not set source parameters");
  101. return player;
  102. }
  103. static void ClosePlayerFile(StreamPlayer *player)
  104. {
  105. if(player->sndfile)
  106. sf_close(player->sndfile);
  107. player->sndfile = NULL;
  108. free(player->membuf);
  109. player->membuf = NULL;
  110. }
  111. static void DeletePlayer(StreamPlayer *player)
  112. {
  113. ClosePlayerFile(player);
  114. alDeleteSources(1, &player->source);
  115. alDeleteBuffers(NUM_BUFFERS, player->buffers);
  116. if(alGetError() != AL_NO_ERROR)
  117. fprintf(stderr, "Failed to delete object IDs\n");
  118. memset(player, 0, sizeof(*player));
  119. free(player);
  120. }
  121. static int OpenPlayerFile(StreamPlayer *player, const char *filename)
  122. {
  123. size_t frame_size;
  124. ClosePlayerFile(player);
  125. player->sndfile = sf_open(filename, SFM_READ, &player->sfinfo);
  126. if(!player->sndfile)
  127. {
  128. fprintf(stderr, "Could not open audio in %s: %s\n", filename, sf_strerror(NULL));
  129. return 0;
  130. }
  131. player->format = AL_NONE;
  132. if(player->sfinfo.channels == 1)
  133. player->format = AL_FORMAT_MONO_FLOAT32;
  134. else if(player->sfinfo.channels == 2)
  135. player->format = AL_FORMAT_STEREO_FLOAT32;
  136. else if(player->sfinfo.channels == 6)
  137. player->format = AL_FORMAT_51CHN32;
  138. else if(player->sfinfo.channels == 3)
  139. {
  140. if(sf_command(player->sndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT)
  141. player->format = AL_FORMAT_BFORMAT2D_FLOAT32;
  142. }
  143. else if(player->sfinfo.channels == 4)
  144. {
  145. if(sf_command(player->sndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT)
  146. player->format = AL_FORMAT_BFORMAT3D_FLOAT32;
  147. }
  148. if(!player->format)
  149. {
  150. fprintf(stderr, "Unsupported channel count: %d\n", player->sfinfo.channels);
  151. sf_close(player->sndfile);
  152. player->sndfile = NULL;
  153. return 0;
  154. }
  155. frame_size = (size_t)(BUFFER_SAMPLES * player->sfinfo.channels) * sizeof(float);
  156. player->membuf = malloc(frame_size);
  157. return 1;
  158. }
  159. static int StartPlayer(StreamPlayer *player)
  160. {
  161. ALsizei i;
  162. alSourceRewind(player->source);
  163. alSourcei(player->source, AL_BUFFER, 0);
  164. for(i = 0;i < NUM_BUFFERS;i++)
  165. {
  166. sf_count_t slen = sf_readf_float(player->sndfile, player->membuf, BUFFER_SAMPLES);
  167. if(slen < 1) break;
  168. slen *= player->sfinfo.channels * (sf_count_t)sizeof(float);
  169. alBufferData(player->buffers[i], player->format, player->membuf, (ALsizei)slen,
  170. player->sfinfo.samplerate);
  171. }
  172. if(alGetError() != AL_NO_ERROR)
  173. {
  174. fprintf(stderr, "Error buffering for playback\n");
  175. return 0;
  176. }
  177. alSourceQueueBuffers(player->source, i, player->buffers);
  178. alSourcePlay(player->source);
  179. if(alGetError() != AL_NO_ERROR)
  180. {
  181. fprintf(stderr, "Error starting playback\n");
  182. return 0;
  183. }
  184. return 1;
  185. }
  186. static int UpdatePlayer(StreamPlayer *player)
  187. {
  188. ALint processed, state;
  189. alGetSourcei(player->source, AL_SOURCE_STATE, &state);
  190. alGetSourcei(player->source, AL_BUFFERS_PROCESSED, &processed);
  191. if(alGetError() != AL_NO_ERROR)
  192. {
  193. fprintf(stderr, "Error checking source state\n");
  194. return 0;
  195. }
  196. while(processed > 0)
  197. {
  198. ALuint bufid;
  199. sf_count_t slen;
  200. alSourceUnqueueBuffers(player->source, 1, &bufid);
  201. processed--;
  202. slen = sf_readf_float(player->sndfile, player->membuf, BUFFER_SAMPLES);
  203. if(slen > 0)
  204. {
  205. slen *= player->sfinfo.channels * (sf_count_t)sizeof(float);
  206. alBufferData(bufid, player->format, player->membuf, (ALsizei)slen,
  207. player->sfinfo.samplerate);
  208. alSourceQueueBuffers(player->source, 1, &bufid);
  209. }
  210. if(alGetError() != AL_NO_ERROR)
  211. {
  212. fprintf(stderr, "Error buffering data\n");
  213. return 0;
  214. }
  215. }
  216. if(state != AL_PLAYING && state != AL_PAUSED)
  217. {
  218. ALint queued;
  219. alGetSourcei(player->source, AL_BUFFERS_QUEUED, &queued);
  220. if(queued == 0)
  221. return 0;
  222. alSourcePlay(player->source);
  223. if(alGetError() != AL_NO_ERROR)
  224. {
  225. fprintf(stderr, "Error restarting playback\n");
  226. return 0;
  227. }
  228. }
  229. return 1;
  230. }
  231. /* CreateEffect creates a new OpenAL effect object with a convolution reverb
  232. * type, and returns the new effect ID.
  233. */
  234. static ALuint CreateEffect(void)
  235. {
  236. ALuint effect = 0;
  237. ALenum err;
  238. printf("Using Convolution Reverb\n");
  239. /* Create the effect object and set the convolution reverb effect type. */
  240. alGenEffects(1, &effect);
  241. alEffecti(effect, AL_EFFECT_TYPE, AL_EFFECT_CONVOLUTION_REVERB_SOFT);
  242. /* Check if an error occured, and clean up if so. */
  243. err = alGetError();
  244. if(err != AL_NO_ERROR)
  245. {
  246. fprintf(stderr, "OpenAL error: %s\n", alGetString(err));
  247. if(alIsEffect(effect))
  248. alDeleteEffects(1, &effect);
  249. return 0;
  250. }
  251. return effect;
  252. }
  253. /* LoadBuffer loads the named audio file into an OpenAL buffer object, and
  254. * returns the new buffer ID.
  255. */
  256. static ALuint LoadSound(const char *filename)
  257. {
  258. const char *namepart;
  259. ALenum err, format;
  260. ALuint buffer;
  261. SNDFILE *sndfile;
  262. SF_INFO sfinfo;
  263. float *membuf;
  264. sf_count_t num_frames;
  265. ALsizei num_bytes;
  266. /* Open the audio file and check that it's usable. */
  267. sndfile = sf_open(filename, SFM_READ, &sfinfo);
  268. if(!sndfile)
  269. {
  270. fprintf(stderr, "Could not open audio in %s: %s\n", filename, sf_strerror(sndfile));
  271. return 0;
  272. }
  273. if(sfinfo.frames < 1 || sfinfo.frames > (sf_count_t)(INT_MAX/sizeof(float))/sfinfo.channels)
  274. {
  275. fprintf(stderr, "Bad sample count in %s (%" PRId64 ")\n", filename, sfinfo.frames);
  276. sf_close(sndfile);
  277. return 0;
  278. }
  279. /* Get the sound format, and figure out the OpenAL format. Use floats since
  280. * impulse responses will usually have more than 16-bit precision.
  281. */
  282. format = AL_NONE;
  283. if(sfinfo.channels == 1)
  284. format = AL_FORMAT_MONO_FLOAT32;
  285. else if(sfinfo.channels == 2)
  286. format = AL_FORMAT_STEREO_FLOAT32;
  287. else if(sfinfo.channels == 3)
  288. {
  289. if(sf_command(sndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT)
  290. format = AL_FORMAT_BFORMAT2D_FLOAT32;
  291. }
  292. else if(sfinfo.channels == 4)
  293. {
  294. if(sf_command(sndfile, SFC_WAVEX_GET_AMBISONIC, NULL, 0) == SF_AMBISONIC_B_FORMAT)
  295. format = AL_FORMAT_BFORMAT3D_FLOAT32;
  296. }
  297. if(!format)
  298. {
  299. fprintf(stderr, "Unsupported channel count: %d\n", sfinfo.channels);
  300. sf_close(sndfile);
  301. return 0;
  302. }
  303. namepart = strrchr(filename, '/');
  304. if(namepart || (namepart=strrchr(filename, '\\')))
  305. namepart++;
  306. else
  307. namepart = filename;
  308. printf("Loading: %s (%s, %dhz, %" PRId64 " samples / %.2f seconds)\n", namepart,
  309. FormatName(format), sfinfo.samplerate, sfinfo.frames,
  310. (double)sfinfo.frames / sfinfo.samplerate);
  311. fflush(stdout);
  312. /* Decode the whole audio file to a buffer. */
  313. membuf = malloc((size_t)(sfinfo.frames * sfinfo.channels) * sizeof(float));
  314. num_frames = sf_readf_float(sndfile, membuf, sfinfo.frames);
  315. if(num_frames < 1)
  316. {
  317. free(membuf);
  318. sf_close(sndfile);
  319. fprintf(stderr, "Failed to read samples in %s (%" PRId64 ")\n", filename, num_frames);
  320. return 0;
  321. }
  322. num_bytes = (ALsizei)(num_frames * sfinfo.channels) * (ALsizei)sizeof(float);
  323. /* Buffer the audio data into a new buffer object, then free the data and
  324. * close the file.
  325. */
  326. buffer = 0;
  327. alGenBuffers(1, &buffer);
  328. alBufferData(buffer, format, membuf, num_bytes, sfinfo.samplerate);
  329. free(membuf);
  330. sf_close(sndfile);
  331. /* Check if an error occured, and clean up if so. */
  332. err = alGetError();
  333. if(err != AL_NO_ERROR)
  334. {
  335. fprintf(stderr, "OpenAL Error: %s\n", alGetString(err));
  336. if(buffer && alIsBuffer(buffer))
  337. alDeleteBuffers(1, &buffer);
  338. return 0;
  339. }
  340. return buffer;
  341. }
  342. int main(int argc, char **argv)
  343. {
  344. ALuint ir_buffer, filter, effect, slot;
  345. StreamPlayer *player;
  346. int i;
  347. /* Print out usage if no arguments were specified */
  348. if(argc < 2)
  349. {
  350. fprintf(stderr, "Usage: %s [-device <name>] <impulse response file> "
  351. "<[-dry | -nodry] filename>...\n", argv[0]);
  352. return 1;
  353. }
  354. argv++; argc--;
  355. if(InitAL(&argv, &argc) != 0)
  356. return 1;
  357. if(!alIsExtensionPresent("AL_SOFTX_convolution_reverb"))
  358. {
  359. CloseAL();
  360. fprintf(stderr, "Error: Convolution revern not supported\n");
  361. return 1;
  362. }
  363. if(argc < 2)
  364. {
  365. CloseAL();
  366. fprintf(stderr, "Error: Missing impulse response or sound files\n");
  367. return 1;
  368. }
  369. /* Define a macro to help load the function pointers. */
  370. #define LOAD_PROC(T, x) ((x) = FUNCTION_CAST(T, alGetProcAddress(#x)))
  371. LOAD_PROC(LPALGENFILTERS, alGenFilters);
  372. LOAD_PROC(LPALDELETEFILTERS, alDeleteFilters);
  373. LOAD_PROC(LPALISFILTER, alIsFilter);
  374. LOAD_PROC(LPALFILTERI, alFilteri);
  375. LOAD_PROC(LPALFILTERIV, alFilteriv);
  376. LOAD_PROC(LPALFILTERF, alFilterf);
  377. LOAD_PROC(LPALFILTERFV, alFilterfv);
  378. LOAD_PROC(LPALGETFILTERI, alGetFilteri);
  379. LOAD_PROC(LPALGETFILTERIV, alGetFilteriv);
  380. LOAD_PROC(LPALGETFILTERF, alGetFilterf);
  381. LOAD_PROC(LPALGETFILTERFV, alGetFilterfv);
  382. LOAD_PROC(LPALGENEFFECTS, alGenEffects);
  383. LOAD_PROC(LPALDELETEEFFECTS, alDeleteEffects);
  384. LOAD_PROC(LPALISEFFECT, alIsEffect);
  385. LOAD_PROC(LPALEFFECTI, alEffecti);
  386. LOAD_PROC(LPALEFFECTIV, alEffectiv);
  387. LOAD_PROC(LPALEFFECTF, alEffectf);
  388. LOAD_PROC(LPALEFFECTFV, alEffectfv);
  389. LOAD_PROC(LPALGETEFFECTI, alGetEffecti);
  390. LOAD_PROC(LPALGETEFFECTIV, alGetEffectiv);
  391. LOAD_PROC(LPALGETEFFECTF, alGetEffectf);
  392. LOAD_PROC(LPALGETEFFECTFV, alGetEffectfv);
  393. LOAD_PROC(LPALGENAUXILIARYEFFECTSLOTS, alGenAuxiliaryEffectSlots);
  394. LOAD_PROC(LPALDELETEAUXILIARYEFFECTSLOTS, alDeleteAuxiliaryEffectSlots);
  395. LOAD_PROC(LPALISAUXILIARYEFFECTSLOT, alIsAuxiliaryEffectSlot);
  396. LOAD_PROC(LPALAUXILIARYEFFECTSLOTI, alAuxiliaryEffectSloti);
  397. LOAD_PROC(LPALAUXILIARYEFFECTSLOTIV, alAuxiliaryEffectSlotiv);
  398. LOAD_PROC(LPALAUXILIARYEFFECTSLOTF, alAuxiliaryEffectSlotf);
  399. LOAD_PROC(LPALAUXILIARYEFFECTSLOTFV, alAuxiliaryEffectSlotfv);
  400. LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTI, alGetAuxiliaryEffectSloti);
  401. LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTIV, alGetAuxiliaryEffectSlotiv);
  402. LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTF, alGetAuxiliaryEffectSlotf);
  403. LOAD_PROC(LPALGETAUXILIARYEFFECTSLOTFV, alGetAuxiliaryEffectSlotfv);
  404. #undef LOAD_PROC
  405. /* Load the reverb into an effect. */
  406. effect = CreateEffect();
  407. if(!effect)
  408. {
  409. CloseAL();
  410. return 1;
  411. }
  412. /* Load the impulse response sound into a buffer. */
  413. ir_buffer = LoadSound(argv[0]);
  414. if(!ir_buffer)
  415. {
  416. alDeleteEffects(1, &effect);
  417. CloseAL();
  418. return 1;
  419. }
  420. /* Create the effect slot object. This is what "plays" an effect on sources
  421. * that connect to it.
  422. */
  423. slot = 0;
  424. alGenAuxiliaryEffectSlots(1, &slot);
  425. /* Set the impulse response sound buffer on the effect slot. This allows
  426. * effects to access it as needed. In this case, convolution reverb uses it
  427. * as the filter source. NOTE: Unlike the effect object, the buffer *is*
  428. * kept referenced and may not be changed or deleted as long as it's set,
  429. * just like with a source. When another buffer is set, or the effect slot
  430. * is deleted, the buffer reference is released.
  431. *
  432. * The effect slot's gain is reduced because the impulse responses I've
  433. * tested with result in excessively loud reverb. Is that normal? Even with
  434. * this, it seems a bit on the loud side.
  435. *
  436. * Also note: unlike standard or EAX reverb, there is no automatic
  437. * attenuation of a source's reverb response with distance, so the reverb
  438. * will remain full volume regardless of a given sound's distance from the
  439. * listener. You can use a send filter to alter a given source's
  440. * contribution to reverb.
  441. */
  442. alAuxiliaryEffectSloti(slot, AL_BUFFER, (ALint)ir_buffer);
  443. alAuxiliaryEffectSlotf(slot, AL_EFFECTSLOT_GAIN, 1.0f / 16.0f);
  444. alAuxiliaryEffectSloti(slot, AL_EFFECTSLOT_EFFECT, (ALint)effect);
  445. assert(alGetError()==AL_NO_ERROR && "Failed to set effect slot");
  446. /* Create a filter that can silence the dry path. */
  447. filter = 0;
  448. alGenFilters(1, &filter);
  449. alFilteri(filter, AL_FILTER_TYPE, AL_FILTER_LOWPASS);
  450. alFilterf(filter, AL_LOWPASS_GAIN, 0.0f);
  451. player = NewPlayer();
  452. /* Connect the player's source to the effect slot. */
  453. alSource3i(player->source, AL_AUXILIARY_SEND_FILTER, (ALint)slot, 0, AL_FILTER_NULL);
  454. assert(alGetError()==AL_NO_ERROR && "Failed to setup sound source");
  455. /* Play each file listed on the command line */
  456. for(i = 1;i < argc;i++)
  457. {
  458. const char *namepart;
  459. if(argc-i > 1)
  460. {
  461. if(strcasecmp(argv[i], "-nodry") == 0)
  462. {
  463. alSourcei(player->source, AL_DIRECT_FILTER, (ALint)filter);
  464. ++i;
  465. }
  466. else if(strcasecmp(argv[i], "-dry") == 0)
  467. {
  468. alSourcei(player->source, AL_DIRECT_FILTER, AL_FILTER_NULL);
  469. ++i;
  470. }
  471. }
  472. if(!OpenPlayerFile(player, argv[i]))
  473. continue;
  474. namepart = strrchr(argv[i], '/');
  475. if(namepart || (namepart=strrchr(argv[i], '\\')))
  476. namepart++;
  477. else
  478. namepart = argv[i];
  479. printf("Playing: %s (%s, %dhz)\n", namepart, FormatName(player->format),
  480. player->sfinfo.samplerate);
  481. fflush(stdout);
  482. if(!StartPlayer(player))
  483. {
  484. ClosePlayerFile(player);
  485. continue;
  486. }
  487. while(UpdatePlayer(player))
  488. al_nssleep(10000000);
  489. ClosePlayerFile(player);
  490. }
  491. printf("Done.\n");
  492. /* All files done. Delete the player and effect resources, and close down
  493. * OpenAL.
  494. */
  495. DeletePlayer(player);
  496. player = NULL;
  497. alDeleteAuxiliaryEffectSlots(1, &slot);
  498. alDeleteEffects(1, &effect);
  499. alDeleteFilters(1, &filter);
  500. alDeleteBuffers(1, &ir_buffer);
  501. CloseAL();
  502. return 0;
  503. }