Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/openAL/src/lib/sound/sound_engine.h @ 4197

Last change on this file since 4197 was 4197, checked in by bensch, 19 years ago

orxonox/branches/openAL: playing some sound.

File size: 2.0 KB
Line 
1/*!
2    \file sound_engine.h
3    \brief Definition of the SoundEngine singleton Class
4   
5*/
6
7#ifndef _SOUND_ENGINE_H
8#define _SOUND_ENGINE_H
9
10#include "base_object.h"
11#include "alincl.h"
12
13// FORWARD DEFINITION
14class PNode;
15template<class T> class tList;
16
17
18//! A class that represents a datastructure to play Sounds.
19class SoundBuffer
20{
21 public:
22  SoundBuffer(const char* fileName);
23  ~SoundBuffer(void);
24
25  inline ALuint getID(void) { return this->bufferID; }
26
27 private:
28  ALuint bufferID;              //!< The address of the Buffer.
29
30  ALsizei size;                 //!< The size of the Buffer.
31  ALboolean loop;               //!< loop information.
32};
33
34//! A class that represents a SoundSource
35class SoundSource
36{
37 public:
38  SoundSource(SoundBuffer* buffer, PNode* sourceNode = NULL);
39  ~SoundSource(void);
40
41  // user interaction
42  void play();
43  void stop();
44  void pause();
45 
46
47  // development functions
48  /** \retruns The ID of the Source */
49  inline ALuint getID(void) { return this->sourceID; }
50  /** \returns the SourceNode of this Source */
51  inline PNode* getNode(void) { return this->sourceNode;}
52
53 private:
54  ALuint sourceID;              //!< The ID of the Source
55  SoundBuffer* buffer;          //!< The buffer to play in this source.
56  PNode* sourceNode;            //!< The SourceNode represente the position/velocity... of this source.
57};
58
59
60
61//! A class that handles audio via the openAudioLibrary
62class SoundEngine : public BaseObject {
63
64 public:
65  static SoundEngine* getInstance(void);
66  virtual ~SoundEngine(void);
67
68  void setListener(PNode* listener);
69
70  void addBuffer(SoundBuffer* buffer);
71  void removeBuffer(SoundBuffer* buffer);
72  void addSource(SoundSource* source);
73  void removeSource(SoundSource* source);
74
75
76  void update(void);
77
78 private:
79  SoundEngine(void);
80  static SoundEngine* singletonRef;
81
82  bool initAudio(void);
83
84  PNode* listener;                 //!< The listener of the Scene
85  tList<SoundBuffer>* bufferList;  //!< A list of buffers
86  tList<SoundSource>* sourceList;  //!< A list for all the sources in the scene.
87
88};
89
90#endif /* _SOUND_ENGINE_H */
Note: See TracBrowser for help on using the repository browser.