≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
[Util] load sounds from Irrlicht filesystem
Posted by:
(you are not logged in)
Enter the missing letter in: "Int?rnational"
(you are not logged in)
Text:
[quote][b]stefbuet[/b] wrote: Hi everybody.
As I was looking for some code without finding anything to be able to load my sound files from the Irrlicht engine, I'm creating this thread to share my own code. This allow you for exemple to load all your sounds from archives loaded previously with Irrlicht.
Includes there 4 files into your project :
-IrrlichtSoundFactory.hpp
-IrrlichtSoundFactory.cpp
-IrrlichtSoundFileReader.hpp
-IrrlichtSoundFileReader.cpp
Content of files :
IrrlichtSoundFactory.hpp :
[code]
#ifndef IRRLICHT_SOUND_FACTORY
#define IRRLICHT_SOUND_FACTORY
#include <KLANG/irrKlang.h>
#include <cstdlib>
#include <iostream>
#include <IRR/irrlicht.h>
using namespace irrklang;
using namespace irr;
class IrrlichtSoundFactory : public irrklang::IFileFactory {
public:
IrrlichtSoundFactory(io::IFileSystem *irrlichtFileSystem);
virtual IFileReader* createFileReader(const ik_c8* filename);
private:
io::IFileSystem *filesys;
};
#endif
[/code]
IrrlichtSoundFactory.cpp :
[code]
#include <KLANG/irrKlang.h>
#include <cstdlib>
#include <iostream>
#include "IrrlichtSoundFactory.hpp"
#include "IrrlichtSoundFileReader.hpp"
#include <IRR/irrlicht.h>
using namespace irrklang;
using namespace irr;
IrrlichtSoundFactory::IrrlichtSoundFactory(io::IFileSystem *irrlichtFileSystem) {
filesys=irrlichtFileSystem;
}
IFileReader* IrrlichtSoundFactory::createFileReader(const ik_c8* filename) {
io::IReadFile *file;
file=filesys->createAndOpenFile(filename);
if (!file) {
return 0;
}
return(new IrrlichtSoundFileReader(file));
}
[/code]
IrrlichtSoundFileReader.hpp :
[code]
#ifndef IRRLICHT_SOUND_FILE_READER
#define IRRLICHT_SOUND_FILE_READER
#include <KLANG/irrKlang.h>
#include <cstdlib>
#include <iostream>
#include <IRR/irrlicht.h>
using namespace irrklang;
using namespace irr;
class IrrlichtSoundFileReader : public irrklang::IFileReader {
public:
//functions
IrrlichtSoundFileReader(io::IReadFile *openedFile);
~IrrlichtSoundFileReader();
ik_s32 read(void* buffer, ik_u32 sizeToRead);
bool seek(ik_s32 finalPos, bool relativeMovement);
ik_s32 getSize();
ik_s32 getPos();
const ik_c8* getFileName();
//variables
io::IReadFile* file;
char Filename[1024];
ik_s32 FileSize;
};
#endif
[/code]
IrrlichtSoundFileReader.cpp :
[code]
#include <KLANG/irrKlang.h>
#include <cstdlib>
#include <iostream>
#include "IrrlichtSoundFileReader.hpp"
#include <IRR/irrlicht.h>
using namespace irrklang;
using namespace irr;
IrrlichtSoundFileReader::Irrlich[/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Image
[img]http://www.example.com/image.jpg[/img]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons
Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact