(C++) Integrating Audiere With Irrlicht Zip File System
Posted: Thu Mar 09, 2006 10:15 am
Hopefully this a suitable location for this post, I couldn't find anything in the forums (although I didn't really look that hard.) I hope this this will be usefull to some:
I'm going to leave a lot of details out here, assuming the user already knows how to setup Irrlicht / Audiere, so not a bunch of details, just implementation:
For simplicity sake, I'm using full namespace for both libs.
Here it is, in 9 Actual Lines of Code:
I'm sure someone could go all out and class crazy and make a nice wrapper for both, but I'm working on a large project, and 9 lines if good enough.....
I'm going to leave a lot of details out here, assuming the user already knows how to setup Irrlicht / Audiere, so not a bunch of details, just implementation:
For simplicity sake, I'm using full namespace for both libs.
Here it is, in 9 Actual Lines of Code:
Code: Select all
//First, we create the file system
irr::io::IFileSystem* fs = device->getFileSystem();
//Next, we add our zip archive
fs->addZipFileArchive("//path//to//archive");
//Next, load up our file (any supported by Audiere)
irr::io::IReadFile* rf = fs->createAndOpenFile("filename");
//Make room to copy our buffer temporarily
void* buffer = malloc(rf->getSize());
//Read our buffer
rf->read(buffer,rf->getSize());
//Create a file pointer object, Audiere makes a copy of this buffer
audiere::FilePtr mf = audiere::CreateMemoryFile(buffer,rf->getSize());
//Since Audiere made a copy, we can get rid of it
free(buffer);
//Get Rid of Drop our Opened File
fs->drop();
//Load up the audiere stream, when using this route, I have found that
//you cannot trust Audiere to Auto-Detect, to be safe, specify the file
//type.
audiere::OutputStreamPtr stream = audiere::OpenSound(aud_device,mf,true,audiere::FF_MP3);