added developer_font, set > 100 to also dump the generated images
[divverent/darkplaces.git] / snd_ogg.c
1 /*
2         Copyright (C) 2003-2005  Mathieu Olivier
3
4         This program is free software; you can redistribute it and/or
5         modify it under the terms of the GNU General Public License
6         as published by the Free Software Foundation; either version 2
7         of the License, or (at your option) any later version.
8
9         This program is distributed in the hope that it will be useful,
10         but WITHOUT ANY WARRANTY; without even the implied warranty of
11         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13         See the GNU General Public License for more details.
14
15         You should have received a copy of the GNU General Public License
16         along with this program; if not, write to:
17
18                 Free Software Foundation, Inc.
19                 59 Temple Place - Suite 330
20                 Boston, MA  02111-1307, USA
21
22 */
23
24
25 #include "quakedef.h"
26 #include "snd_main.h"
27 #include "snd_ogg.h"
28
29
30 /*
31 =================================================================
32
33   Minimal set of definitions from the Ogg Vorbis lib
34   (C) COPYRIGHT 1994-2001 by the XIPHOPHORUS Company
35   http://www.xiph.org/
36
37   WARNING: for a matter of simplicity, several pointer types are
38   casted to "void*", and most enumerated values are not included
39
40 =================================================================
41 */
42
43 #ifdef _MSC_VER
44 typedef __int64 ogg_int64_t;
45 #else
46 typedef long long ogg_int64_t;
47 #endif
48
49 typedef struct
50 {
51         size_t  (*read_func)    (void *ptr, size_t size, size_t nmemb, void *datasource);
52         int             (*seek_func)    (void *datasource, ogg_int64_t offset, int whence);
53         int             (*close_func)   (void *datasource);
54         long    (*tell_func)    (void *datasource);
55 } ov_callbacks;
56
57 typedef struct
58 {
59         unsigned char   *data;
60         int                             storage;
61         int                             fill;
62         int                             returned;
63         int                             unsynced;
64         int                             headerbytes;
65         int                             bodybytes;
66 } ogg_sync_state;
67
68 typedef struct
69 {
70         int             version;
71         int             channels;
72         long    rate;
73         long    bitrate_upper;
74         long    bitrate_nominal;
75         long    bitrate_lower;
76         long    bitrate_window;
77         void    *codec_setup;
78 } vorbis_info;
79
80 typedef struct
81 {
82         unsigned char   *body_data;
83         long                    body_storage;
84         long                    body_fill;
85         long                    body_returned;
86         int                             *lacing_vals;
87         ogg_int64_t             *granule_vals;
88         long                    lacing_storage;
89         long                    lacing_fill;
90         long                    lacing_packet;
91         long                    lacing_returned;
92         unsigned char   header[282];
93         int                             header_fill;
94         int                             e_o_s;
95         int                             b_o_s;
96         long                    serialno;
97         long                    pageno;
98         ogg_int64_t             packetno;
99         ogg_int64_t             granulepos;
100 } ogg_stream_state;
101
102 typedef struct
103 {
104         int                     analysisp;
105         vorbis_info     *vi;
106         float           **pcm;
107         float           **pcmret;
108         int                     pcm_storage;
109         int                     pcm_current;
110         int                     pcm_returned;
111         int                     preextrapolate;
112         int                     eofflag;
113         long            lW;
114         long            W;
115         long            nW;
116         long            centerW;
117         ogg_int64_t     granulepos;
118         ogg_int64_t     sequence;
119         ogg_int64_t     glue_bits;
120         ogg_int64_t     time_bits;
121         ogg_int64_t     floor_bits;
122         ogg_int64_t     res_bits;
123         void            *backend_state;
124 } vorbis_dsp_state;
125
126 typedef struct
127 {
128         long                    endbyte;
129         int                             endbit;
130         unsigned char   *buffer;
131         unsigned char   *ptr;
132         long                    storage;
133 } oggpack_buffer;
134
135 typedef struct
136 {
137         float                           **pcm;
138         oggpack_buffer          opb;
139         long                            lW;
140         long                            W;
141         long                            nW;
142         int                                     pcmend;
143         int                                     mode;
144         int                                     eofflag;
145         ogg_int64_t                     granulepos;
146         ogg_int64_t                     sequence;
147         vorbis_dsp_state        *vd;
148         void                            *localstore;
149         long                            localtop;
150         long                            localalloc;
151         long                            totaluse;
152         void                            *reap;  // VOIDED POINTER
153         long                            glue_bits;
154         long                            time_bits;
155         long                            floor_bits;
156         long                            res_bits;
157         void                            *internal;
158 } vorbis_block;
159
160 typedef struct
161 {
162         char **user_comments;
163         int   *comment_lengths;
164         int    comments;
165         char  *vendor;
166 } vorbis_comment;
167
168 typedef struct
169 {
170         void                            *datasource;
171         int                                     seekable;
172         ogg_int64_t                     offset;
173         ogg_int64_t                     end;
174         ogg_sync_state          oy;
175         int                                     links;
176         ogg_int64_t                     *offsets;
177         ogg_int64_t                     *dataoffsets;
178         long                            *serialnos;
179         ogg_int64_t                     *pcmlengths;
180         vorbis_info                     *vi;
181         vorbis_comment          *vc;
182         ogg_int64_t                     pcm_offset;
183         int                                     ready_state;
184         long                            current_serialno;
185         int                                     current_link;
186         double                          bittrack;
187         double                          samptrack;
188         ogg_stream_state        os;
189         vorbis_dsp_state        vd;
190         vorbis_block            vb;
191         ov_callbacks            callbacks;
192 } OggVorbis_File;
193
194
195 /*
196 =================================================================
197
198   DarkPlaces definitions
199
200 =================================================================
201 */
202
203 // Functions exported from the vorbisfile library
204 static int (*qov_clear) (OggVorbis_File *vf);
205 static vorbis_info* (*qov_info) (OggVorbis_File *vf,int link);
206 static vorbis_comment* (*qov_comment) (OggVorbis_File *vf,int link);
207 static char * (*qvorbis_comment_query) (vorbis_comment *vc, char *tag, int count);
208 static int (*qov_open_callbacks) (void *datasource, OggVorbis_File *vf,
209                                                                   char *initial, long ibytes,
210                                                                   ov_callbacks callbacks);
211 static int (*qov_pcm_seek) (OggVorbis_File *vf,ogg_int64_t pos);
212 static ogg_int64_t (*qov_pcm_total) (OggVorbis_File *vf,int i);
213 static long (*qov_read) (OggVorbis_File *vf,char *buffer,int length,
214                                                  int bigendianp,int word,int sgned,int *bitstream);
215
216 static dllfunction_t vorbisfilefuncs[] =
217 {
218         {"ov_clear",                            (void **) &qov_clear},
219         {"ov_info",                                     (void **) &qov_info},
220         {"ov_comment",                          (void **) &qov_comment},
221         {"ov_open_callbacks",           (void **) &qov_open_callbacks},
222         {"ov_pcm_seek",                         (void **) &qov_pcm_seek},
223         {"ov_pcm_total",                        (void **) &qov_pcm_total},
224         {"ov_read",                                     (void **) &qov_read},
225         {NULL, NULL}
226 };
227
228 static dllfunction_t vorbisfuncs[] =
229 {
230         {"vorbis_comment_query",        (void **) &qvorbis_comment_query},
231         {NULL, NULL}
232 };
233
234 // Handles for the Vorbis and Vorbisfile DLLs
235 static dllhandle_t vo_dll = NULL;
236 static dllhandle_t vf_dll = NULL;
237
238 typedef struct
239 {
240         unsigned char *buffer;
241         ogg_int64_t ind, buffsize;
242 } ov_decode_t;
243
244
245 static size_t ovcb_read (void *ptr, size_t size, size_t nb, void *datasource)
246 {
247         ov_decode_t *ov_decode = (ov_decode_t*)datasource;
248         size_t remain, len;
249
250         remain = ov_decode->buffsize - ov_decode->ind;
251         len = size * nb;
252         if (remain < len)
253                 len = remain - remain % size;
254
255         memcpy (ptr, ov_decode->buffer + ov_decode->ind, len);
256         ov_decode->ind += len;
257
258         return len / size;
259 }
260
261 static int ovcb_seek (void *datasource, ogg_int64_t offset, int whence)
262 {
263         ov_decode_t *ov_decode = (ov_decode_t*)datasource;
264
265         switch (whence)
266         {
267                 case SEEK_SET:
268                         break;
269                 case SEEK_CUR:
270                         offset += ov_decode->ind;
271                         break;
272                 case SEEK_END:
273                         offset += ov_decode->buffsize;
274                         break;
275                 default:
276                         return -1;
277         }
278         if (offset < 0 || offset > ov_decode->buffsize)
279                 return -1;
280
281         ov_decode->ind = offset;
282         return 0;
283 }
284
285 static int ovcb_close (void *ov_decode)
286 {
287         return 0;
288 }
289
290 static long ovcb_tell (void *ov_decode)
291 {
292         return ((ov_decode_t*)ov_decode)->ind;
293 }
294
295
296 /*
297 =================================================================
298
299   DLL load & unload
300
301 =================================================================
302 */
303
304 /*
305 ====================
306 OGG_OpenLibrary
307
308 Try to load the VorbisFile DLL
309 ====================
310 */
311 qboolean OGG_OpenLibrary (void)
312 {
313         const char* dllnames_vo [] =
314         {
315 #if defined(WIN32)
316                 "libvorbis.dll",
317                 "vorbis.dll",
318 #elif defined(MACOSX)
319                 "libvorbis.dylib",
320 #else
321                 "libvorbis.so.0",
322                 "libvorbis.so",
323 #endif
324                 NULL
325         };
326         const char* dllnames_vf [] =
327         {
328 #if defined(WIN32)
329                 "libvorbisfile.dll",
330                 "vorbisfile.dll",
331 #elif defined(MACOSX)
332                 "libvorbisfile.dylib",
333 #else
334                 "libvorbisfile.so.3",
335                 "libvorbisfile.so",
336 #endif
337                 NULL
338         };
339
340         // Already loaded?
341         if (vf_dll)
342                 return true;
343
344 // COMMANDLINEOPTION: Sound: -novorbis disables ogg vorbis sound support
345         if (COM_CheckParm("-novorbis"))
346                 return false;
347
348         // Load the DLLs
349         // We need to load both by hand because some OSes seem to not load
350         // the vorbis DLL automatically when loading the VorbisFile DLL
351         return Sys_LoadLibrary (dllnames_vo, &vo_dll, vorbisfuncs) && Sys_LoadLibrary (dllnames_vf, &vf_dll, vorbisfilefuncs);
352 }
353
354
355 /*
356 ====================
357 OGG_CloseLibrary
358
359 Unload the VorbisFile DLL
360 ====================
361 */
362 void OGG_CloseLibrary (void)
363 {
364         Sys_UnloadLibrary (&vf_dll);
365         Sys_UnloadLibrary (&vo_dll);
366 }
367
368
369 /*
370 =================================================================
371
372         Ogg Vorbis decoding
373
374 =================================================================
375 */
376
377 // Per-sfx data structure
378 typedef struct
379 {
380         unsigned char   *file;
381         size_t                  filesize;
382         snd_format_t    format;
383         unsigned int    total_length;
384         char                    name[128];
385 } ogg_stream_persfx_t;
386
387 // Per-channel data structure
388 typedef struct
389 {
390         OggVorbis_File  vf;
391         ov_decode_t             ov_decode;
392         unsigned int    sb_offset;
393         int                             bs;
394         snd_buffer_t    sb;             // must be at the end due to its dynamically allocated size
395 } ogg_stream_perchannel_t;
396
397
398 static const ov_callbacks callbacks = {ovcb_read, ovcb_seek, ovcb_close, ovcb_tell};
399
400 /*
401 ====================
402 OGG_FetchSound
403 ====================
404 */
405 static const snd_buffer_t* OGG_FetchSound (void *sfxfetcher, void **chfetcherpointer, unsigned int *start, unsigned int nbsampleframes)
406 {
407         ogg_stream_perchannel_t* per_ch = (ogg_stream_perchannel_t *)*chfetcherpointer;
408         ogg_stream_persfx_t* per_sfx = (ogg_stream_persfx_t *)sfxfetcher;
409         snd_buffer_t* sb;
410         int newlength, done, ret;
411         unsigned int real_start;
412         unsigned int factor;
413
414         // If there's no fetcher structure attached to the channel yet
415         if (per_ch == NULL)
416         {
417                 size_t buff_len, memsize;
418                 snd_format_t sb_format;
419
420                 sb_format.speed = snd_renderbuffer->format.speed;
421                 sb_format.width = per_sfx->format.width;
422                 sb_format.channels = per_sfx->format.channels;
423
424                 buff_len = STREAM_BUFFER_SIZE(&sb_format);
425                 memsize = sizeof (*per_ch) - sizeof (per_ch->sb.samples) + buff_len;
426                 per_ch = (ogg_stream_perchannel_t *)Mem_Alloc (snd_mempool, memsize);
427
428                 // Open it with the VorbisFile API
429                 per_ch->ov_decode.buffer = per_sfx->file;
430                 per_ch->ov_decode.ind = 0;
431                 per_ch->ov_decode.buffsize = per_sfx->filesize;
432                 if (qov_open_callbacks (&per_ch->ov_decode, &per_ch->vf, NULL, 0, callbacks) < 0)
433                 {
434                         Con_Printf("error while reading Ogg Vorbis stream \"%s\"\n", per_sfx->name);
435                         Mem_Free (per_ch);
436                         return NULL;
437                 }
438                 per_ch->bs = 0;
439
440                 per_ch->sb_offset = 0;
441                 per_ch->sb.format = sb_format;
442                 per_ch->sb.nbframes = 0;
443                 per_ch->sb.maxframes = buff_len / (per_ch->sb.format.channels * per_ch->sb.format.width);
444
445                 *chfetcherpointer = per_ch;
446         }
447
448         real_start = *start;
449
450         sb = &per_ch->sb;
451         factor = per_sfx->format.width * per_sfx->format.channels;
452
453         // If the stream buffer can't contain that much samples anyway
454         if (nbsampleframes > sb->maxframes)
455         {
456                 Con_Printf ("OGG_FetchSound: stream buffer too small (%u sample frames required)\n", nbsampleframes);
457                 return NULL;
458         }
459
460         // If the data we need has already been decompressed in the sfxbuffer, just return it
461         if (per_ch->sb_offset <= real_start && per_ch->sb_offset + sb->nbframes >= real_start + nbsampleframes)
462         {
463                 *start = per_ch->sb_offset;
464                 return sb;
465         }
466
467         newlength = (int)(per_ch->sb_offset + sb->nbframes) - real_start;
468
469         // If we need to skip some data before decompressing the rest, or if the stream has looped
470         if (newlength < 0 || per_ch->sb_offset > real_start)
471         {
472                 unsigned int time_start;
473                 ogg_int64_t ogg_start;
474                 int err;
475
476                 if (real_start > (unsigned int)per_sfx->total_length)
477                 {
478                         Con_Printf ("OGG_FetchSound: asked for a start position after the end of the sfx! (%u > %u)\n",
479                                                 real_start, per_sfx->total_length);
480                         return NULL;
481                 }
482
483                 // We work with 200ms (1/5 sec) steps to avoid rounding errors
484                 time_start = real_start * 5 / snd_renderbuffer->format.speed;
485                 ogg_start = time_start * (per_sfx->format.speed / 5);
486                 err = qov_pcm_seek (&per_ch->vf, ogg_start);
487                 if (err != 0)
488                 {
489                         Con_Printf ("OGG_FetchSound: qov_pcm_seek(..., %d) returned %d\n",
490                                                 real_start, err);
491                         return NULL;
492                 }
493                 sb->nbframes = 0;
494
495                 real_start = (unsigned int) ((float)ogg_start / per_sfx->format.speed * snd_renderbuffer->format.speed);
496                 if (*start - real_start + nbsampleframes > sb->maxframes)
497                 {
498                         Con_Printf ("OGG_FetchSound: stream buffer too small after seek (%u sample frames required)\n",
499                                                 *start - real_start + nbsampleframes);
500                         per_ch->sb_offset = real_start;
501                         return NULL;
502                 }
503         }
504         // Else, move forward the samples we need to keep in the sound buffer
505         else
506         {
507                 memmove (sb->samples, sb->samples + (real_start - per_ch->sb_offset) * factor, newlength * factor);
508                 sb->nbframes = newlength;
509         }
510
511         per_ch->sb_offset = real_start;
512
513         // We add more than one frame of sound to the buffer:
514         // 1- to ensure we won't lose many samples during the resampling process
515         // 2- to reduce calls to OGG_FetchSound to regulate workload
516         newlength = (int)(per_sfx->format.speed*STREAM_BUFFER_FILL);
517         if (newlength + sb->nbframes > sb->maxframes)
518         {
519                 Con_Printf ("OGG_FetchSound: stream buffer overflow (%u sample frames / %u)\n",
520                                         sb->format.speed + sb->nbframes, sb->maxframes);
521                 return NULL;
522         }
523         newlength *= factor; // convert from sample frames to bytes
524         if(newlength > (int)sizeof(resampling_buffer))
525                 newlength = sizeof(resampling_buffer);
526
527         // Decompress in the resampling_buffer
528         done = 0;
529         while ((ret = qov_read (&per_ch->vf, (char *)&resampling_buffer[done], (int)(newlength - done), mem_bigendian, 2, 1, &per_ch->bs)) > 0)
530                 done += ret;
531
532         Snd_AppendToSndBuffer (sb, resampling_buffer, (size_t)done / (size_t)factor, &per_sfx->format);
533
534         *start = per_ch->sb_offset;
535         return sb;
536 }
537
538
539 /*
540 ====================
541 OGG_FetchEnd
542 ====================
543 */
544 static void OGG_FetchEnd (void *chfetcherdata)
545 {
546         ogg_stream_perchannel_t* per_ch = (ogg_stream_perchannel_t *)chfetcherdata;
547
548         if (per_ch != NULL)
549         {
550                 // Free the ogg vorbis decoder
551                 qov_clear (&per_ch->vf);
552
553                 Mem_Free (per_ch);
554         }
555 }
556
557
558 /*
559 ====================
560 OGG_FreeSfx
561 ====================
562 */
563 static void OGG_FreeSfx (void *sfxfetcherdata)
564 {
565         ogg_stream_persfx_t* per_sfx = (ogg_stream_persfx_t *)sfxfetcherdata;
566
567         // Free the Ogg Vorbis file
568         Mem_Free(per_sfx->file);
569
570         // Free the stream structure
571         Mem_Free(per_sfx);
572 }
573
574
575 /*
576 ====================
577 OGG_GetFormat
578 ====================
579 */
580 static const snd_format_t* OGG_GetFormat (sfx_t* sfx)
581 {
582         ogg_stream_persfx_t* per_sfx = (ogg_stream_persfx_t *)sfx->fetcher_data;
583         return &per_sfx->format;
584 }
585
586 static const snd_fetcher_t ogg_fetcher = { OGG_FetchSound, OGG_FetchEnd, OGG_FreeSfx, OGG_GetFormat };
587
588 static void OGG_DecodeTags(vorbis_comment *vc, unsigned int *start, unsigned int *length, double samplesfactor, unsigned int numsamples, double *peak, double *gaindb)
589 {
590         const char *startcomment = NULL, *lengthcomment = NULL, *endcomment = NULL, *thiscomment = NULL;
591
592         *start = numsamples;
593         *length = numsamples;
594         *peak = 0.0;
595         *gaindb = 0.0;
596
597         if(!vc)
598                 return;
599
600         thiscomment = qvorbis_comment_query(vc, "REPLAYGAIN_TRACK_PEAK", 0);
601         if(thiscomment)
602                 *peak = atof(thiscomment);
603         thiscomment = qvorbis_comment_query(vc, "REPLAYGAIN_TRACK_GAIN", 0);
604         if(thiscomment)
605                 *gaindb = atof(thiscomment);
606         
607         startcomment = qvorbis_comment_query(vc, "LOOP_START", 0); // DarkPlaces, and some Japanese app
608         if(startcomment)
609         {
610                 endcomment = qvorbis_comment_query(vc, "LOOP_END", 0);
611                 if(!endcomment)
612                         lengthcomment = qvorbis_comment_query(vc, "LOOP_LENGTH", 0);
613         }
614         else
615         {
616                 startcomment = qvorbis_comment_query(vc, "LOOPSTART", 0); // RPG Maker VX
617                 if(startcomment)
618                 {
619                         lengthcomment = qvorbis_comment_query(vc, "LOOPLENGTH", 0);
620                         if(!lengthcomment)
621                                 endcomment = qvorbis_comment_query(vc, "LOOPEND", 0);
622                 }
623                 else
624                 {
625                         startcomment = qvorbis_comment_query(vc, "LOOPPOINT", 0); // Sonic Robo Blast 2
626                 }
627         }
628
629         if(startcomment)
630         {
631                 *start = (unsigned int) bound(0, atof(startcomment) * samplesfactor, numsamples);
632                 if(endcomment)
633                         *length = (unsigned int) bound(0, atof(endcomment) * samplesfactor, numsamples);
634                 else if(lengthcomment)
635                         *length = (unsigned int) bound(0, *start + atof(lengthcomment) * samplesfactor, numsamples);
636         }
637 }
638
639 /*
640 ====================
641 OGG_LoadVorbisFile
642
643 Load an Ogg Vorbis file into memory
644 ====================
645 */
646 qboolean OGG_LoadVorbisFile (const char *filename, sfx_t *sfx)
647 {
648         unsigned char *data;
649         fs_offset_t filesize;
650         ov_decode_t ov_decode;
651         OggVorbis_File vf;
652         ogg_stream_persfx_t* per_sfx;
653         vorbis_info *vi;
654         vorbis_comment *vc;
655         ogg_int64_t len;
656         double peak, gaindb;
657
658         if (!vf_dll)
659                 return false;
660
661         // Already loaded?
662         if (sfx->fetcher != NULL)
663                 return true;
664
665         // Load the file
666         data = FS_LoadFile (filename, snd_mempool, false, &filesize);
667         if (data == NULL)
668                 return false;
669
670         if (developer_loading.integer >= 2)
671                 Con_Printf ("Loading Ogg Vorbis file \"%s\"\n", filename);
672
673         // Open it with the VorbisFile API
674         ov_decode.buffer = data;
675         ov_decode.ind = 0;
676         ov_decode.buffsize = filesize;
677         if (qov_open_callbacks (&ov_decode, &vf, NULL, 0, callbacks) < 0)
678         {
679                 Con_Printf ("error while opening Ogg Vorbis file \"%s\"\n", filename);
680                 Mem_Free(data);
681                 return false;
682         }
683
684         // Get the stream information
685         vi = qov_info (&vf, -1);
686         if (vi->channels < 1 || vi->channels > 2)
687         {
688                 Con_Printf("%s has an unsupported number of channels (%i)\n",
689                                         sfx->name, vi->channels);
690                 qov_clear (&vf);
691                 Mem_Free(data);
692                 return false;
693         }
694
695         len = qov_pcm_total (&vf, -1) * vi->channels * 2;  // 16 bits => "* 2"
696
697         if (developer_loading.integer >= 2)
698                 Con_Printf ("Ogg sound file \"%s\" will be streamed\n", filename);
699         per_sfx = (ogg_stream_persfx_t *)Mem_Alloc (snd_mempool, sizeof (*per_sfx));
700         strlcpy(per_sfx->name, sfx->name, sizeof(per_sfx->name));
701         sfx->memsize += sizeof (*per_sfx);
702         per_sfx->file = data;
703         per_sfx->filesize = filesize;
704         sfx->memsize += filesize;
705
706         per_sfx->format.speed = vi->rate;
707         per_sfx->format.width = 2;  // We always work with 16 bits samples
708         per_sfx->format.channels = vi->channels;
709
710         sfx->fetcher_data = per_sfx;
711         sfx->fetcher = &ogg_fetcher;
712         sfx->flags |= SFXFLAG_STREAMED;
713         sfx->total_length = (int)((size_t)len / (per_sfx->format.channels * 2) * ((double)snd_renderbuffer->format.speed / per_sfx->format.speed));
714         vc = qov_comment(&vf, -1);
715         OGG_DecodeTags(vc, &sfx->loopstart, &sfx->total_length, (double)snd_renderbuffer->format.speed / (double)per_sfx->format.speed, sfx->total_length, &peak, &gaindb);
716         per_sfx->total_length = sfx->total_length;
717         qov_clear (&vf);
718
719         if(peak)
720         {
721                 sfx->volume_mult = min(1.0f / peak, exp(gaindb * 0.05f * log(10.0f)));
722                 sfx->volume_peak = peak;
723                 if (developer_loading.integer >= 2)
724                         Con_Printf ("Ogg sound file \"%s\" uses ReplayGain (gain %f, peak %f)\n", filename, sfx->volume_mult, sfx->volume_peak);
725         }
726
727         return true;
728 }