aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/examples/21.Quake3Explorer/sound.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libraries/irrlicht-1.8/examples/21.Quake3Explorer/sound.cpp196
1 files changed, 98 insertions, 98 deletions
diff --git a/libraries/irrlicht-1.8/examples/21.Quake3Explorer/sound.cpp b/libraries/irrlicht-1.8/examples/21.Quake3Explorer/sound.cpp
index 75615c1..876c498 100644
--- a/libraries/irrlicht-1.8/examples/21.Quake3Explorer/sound.cpp
+++ b/libraries/irrlicht-1.8/examples/21.Quake3Explorer/sound.cpp
@@ -1,98 +1,98 @@
1/*! 1/*!
2 Sound Factory. 2 Sound Factory.
3 provides a sound interface 3 provides a sound interface
4 4
5*/ 5*/
6 6
7#include "sound.h" 7#include "sound.h"
8 8
9 9
10//#define USE_IRRKLANG 10//#define USE_IRRKLANG
11 11
12#ifdef USE_IRRKLANG 12#ifdef USE_IRRKLANG
13 13
14#include <irrKlang.h> 14#include <irrKlang.h>
15#ifdef _IRR_WINDOWS_ 15#ifdef _IRR_WINDOWS_
16 #pragma comment (lib, "irrKlang.lib") 16 #pragma comment (lib, "irrKlang.lib")
17#endif 17#endif
18 18
19using namespace irrklang; 19using namespace irrklang;
20 20
21struct soundfile: public IFileReader 21struct soundfile: public IFileReader
22{ 22{
23 soundfile ( io::IReadFile* f ): file (f ) {} 23 soundfile ( io::IReadFile* f ): file (f ) {}
24 virtual ~soundfile () { file->drop (); } 24 virtual ~soundfile () { file->drop (); }
25 25
26 virtual ik_s32 read(void* buffer, ik_u32 sizeToRead) { return file->read ( buffer, sizeToRead ); } 26 virtual ik_s32 read(void* buffer, ik_u32 sizeToRead) { return file->read ( buffer, sizeToRead ); }
27 virtual bool seek(ik_s32 finalPos, bool relativeMovement = false) { return file->seek ( finalPos, relativeMovement ); } 27 virtual bool seek(ik_s32 finalPos, bool relativeMovement = false) { return file->seek ( finalPos, relativeMovement ); }
28 virtual ik_s32 getSize(){ return file->getSize (); } 28 virtual ik_s32 getSize(){ return file->getSize (); }
29 virtual ik_s32 getPos() {return file->getPos (); } 29 virtual ik_s32 getPos() {return file->getPos (); }
30 virtual const ik_c8* getFileName() { return file->getFileName (); } 30 virtual const ik_c8* getFileName() { return file->getFileName (); }
31 io::IReadFile* file; 31 io::IReadFile* file;
32}; 32};
33 33
34struct klangFactory : public irrklang::IFileFactory 34struct klangFactory : public irrklang::IFileFactory
35{ 35{
36 klangFactory ( IrrlichtDevice *device ) { Device = device; } 36 klangFactory ( IrrlichtDevice *device ) { Device = device; }
37 37
38 virtual irrklang::IFileReader* createFileReader(const ik_c8* filename) 38 virtual irrklang::IFileReader* createFileReader(const ik_c8* filename)
39 { 39 {
40 io::IReadFile* file = Device->getFileSystem()->createAndOpenFile(filename); 40 io::IReadFile* file = Device->getFileSystem()->createAndOpenFile(filename);
41 if ( 0 == file ) 41 if ( 0 == file )
42 return 0; 42 return 0;
43 43
44 return new soundfile ( file ); 44 return new soundfile ( file );
45 } 45 }
46 46
47 IrrlichtDevice *Device; 47 IrrlichtDevice *Device;
48}; 48};
49 49
50ISoundEngine *engine = 0; 50ISoundEngine *engine = 0;
51ISound *backMusic = 0; 51ISound *backMusic = 0;
52 52
53void sound_init ( IrrlichtDevice *device ) 53void sound_init ( IrrlichtDevice *device )
54{ 54{
55 engine = createIrrKlangDevice (); 55 engine = createIrrKlangDevice ();
56 if ( 0 == engine ) 56 if ( 0 == engine )
57 return; 57 return;
58 58
59 klangFactory *f = new klangFactory ( device ); 59 klangFactory *f = new klangFactory ( device );
60 engine->addFileFactory ( f ); 60 engine->addFileFactory ( f );
61} 61}
62 62
63void sound_shutdown () 63void sound_shutdown ()
64{ 64{
65 if ( backMusic ) 65 if ( backMusic )
66 backMusic->drop (); 66 backMusic->drop ();
67 67
68 if ( engine ) 68 if ( engine )
69 engine->drop (); 69 engine->drop ();
70} 70}
71 71
72void background_music ( const c8 * file ) 72void background_music ( const c8 * file )
73{ 73{
74 if ( 0 == engine ) 74 if ( 0 == engine )
75 return; 75 return;
76 76
77 if ( backMusic ) 77 if ( backMusic )
78 { 78 {
79 backMusic->stop (); 79 backMusic->stop ();
80 backMusic->drop (); 80 backMusic->drop ();
81 } 81 }
82 82
83 backMusic = engine->play2D ( file, true, false, true ); 83 backMusic = engine->play2D ( file, true, false, true );
84 84
85 if ( backMusic ) 85 if ( backMusic )
86 { 86 {
87 backMusic->setVolume ( 0.5f ); 87 backMusic->setVolume ( 0.5f );
88 } 88 }
89} 89}
90 90
91#else 91#else
92 92
93void sound_init ( IrrlichtDevice *device ) {} 93void sound_init ( IrrlichtDevice *device ) {}
94void sound_shutdown () {} 94void sound_shutdown () {}
95void background_music ( const c8 * file ) {} 95void background_music ( const c8 * file ) {}
96 96
97#endif 97#endif
98 98