|
Play sound from file in memory |
nujuwhite
Member #14,390
June 2012
|
I'm using miniz to load files from a .zip archive into memory. I'm hoping to put my resources in this .zip and distribute it alongside my program. My question: Is it possible to use Allegro to play a sound file stored in memory, or will i have to resort to a separate audio library? |
SiegeLord
Member #7,827
October 2006
|
Allegro already supports loading files directly from zip files using the PhysFS addon... if you stick with miniz, however, you can use the memfile addon and then use the loading functions with the _f suffix. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
nujuwhite
Member #14,390
June 2012
|
PhysFS seems too big and complicated... I think i'll use memfile and al_load_sample_f(). Thanks So if i load the file into memory, will al_load_sample_f() duplicate it, or just read from what i've already stored? |
SiegeLord
Member #7,827
October 2006
|
nujuwhite said: So if i load the file into memory, will al_load_sample_f() duplicate it, or just read from what i've already stored? It will duplicate it (because it needs to decode it into the format Allegro uses to play sounds). If you don't want to duplicate, then look into the streaming API, e.g. al_load_audio_stream_f. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Thomas Fjellstrom
Member #476
June 2000
|
You can stick with miniz and al_load_audio_stream if you set up your own fshook driver. nujuwhite said: PhysFS seems too big and complicated... Um, its like two or three PhysFS calls, and one allegro_physfs call. It's pretty easy, and you can stick things in zip files. -- |
|