Skyscraper 2.0
soundsystem.h
Go to the documentation of this file.
1/*
2 Scalable Building Simulator - Sound System
3 The Skyscraper Project - Version 2.0
4 Copyright (C)2004-2024 Ryan Thoryk
5 https://www.skyscrapersim.net
6 https://sourceforge.net/projects/skyscraper/
7 Contact - ryan@skyscrapersim.net
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22*/
23
24#ifndef _SBS_SOUNDSYSTEM_H
25#define _SBS_SOUNDSYSTEM_H
26
27namespace FMOD {
28 class Sound;
29 class Channel;
30 class System;
31 class Reverb3D;
32}
33
34namespace SBS {
35
37{
38public:
39
40 SoundSystem(Object *parent, FMOD::System *fmodsystem);
41 SoundSystem(Object *parent);
43 void SetListenerPosition(const Vector3 &position);
44 void SetListenerDirection(const Vector3 &front, const Vector3 &top);
45 Vector3 GetListenerPosition() { return listener_position; }
46 void Loop();
47 void Cleanup(int index = -1);
48 unsigned int GetLength(SoundData *data);
49 SoundData* Load(const std::string &filename);
50 bool IsLoaded(std::string filename);
51 void Report(const std::string &message);
52 bool ReportError(const std::string &message);
53#ifndef DISABLE_SOUND
54 FMOD::Channel* Prepare(SoundData *data);
55 FMOD::System* GetFmodSystem();
56#endif
57 SoundData* GetSoundData(std::string filename);
58 SoundData* GetSoundData(int number);
59 int GetPlayingCount();
60 int GetSoundCount();
61 void ShowLoadedSounds();
62 void ShowPlayingSounds(bool verbose = true);
63 void ShowPlayingTotal();
64
65private:
66
67#ifndef DISABLE_SOUND
68 //FMOD system
69 FMOD::System *soundsys;
70#endif
71
72 //listener sound data
77
78 //sound data array
79 std::vector<SoundData*> sounds;
80
82
83 //reverbs
84 struct Reverb
85 {
86#ifndef DISABLE_SOUND
87 FMOD::Reverb3D* object;
88#endif
90 };
91 std::vector<Reverb> reverbs;
92};
93
95{
96 SoundData();
97 ~SoundData();
98 void AddHandle(Sound *handle);
99 void RemoveHandle(Sound *handle);
100 int GetHandleCount() { return (int)handles.size(); }
101#ifndef DISABLE_SOUND
102 void AddChannel(FMOD::Channel *channel);
103 void RemoveChannel(FMOD::Channel *channel);
104 int GetChannelCount() { return (int)channels.size(); }
105#else
106 int GetChannelCount() { return 0; }
107#endif
108 FMOD::Sound* sound; //sound data object
109 std::string filename; //filename of sound file
110 std::vector<Sound*> handles; //associated sound objects
111#ifndef DISABLE_SOUND
112 std::vector<FMOD::Channel*> channels; //associated sound channels
113#endif
114};
115
116}
117
118#endif
std::vector< Reverb > reverbs
Definition soundsystem.h:91
Vector3 listener_velocity
Definition soundsystem.h:74
Vector3 listener_up
Definition soundsystem.h:76
Vector3 GetListenerPosition()
Definition soundsystem.h:45
Vector3 listener_position
Definition soundsystem.h:73
std::vector< SoundData * > sounds
Definition soundsystem.h:79
FMOD::System * soundsys
Definition soundsystem.h:69
Vector3 listener_forward
Definition soundsystem.h:75
Ogre::Vector3 Vector3
Definition globals.h:58
#define SBSIMPEXP
Definition globals.h:53
std::vector< FMOD::Channel * > channels
FMOD::Sound * sound
std::string filename
int GetChannelCount()
std::vector< Sound * > handles
FMOD::Reverb3D * object
Definition soundsystem.h:87