Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
Sound.h
Go to the documentation of this file.
1/*
2 This source file is part of Rigs of Rods
3 Copyright 2005-2012 Pierre-Michel Ricordel
4 Copyright 2007-2012 Thomas Fischer
5
6 For more information, see http://www.rigsofrods.org/
7
8 Rigs of Rods is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 3, as
10 published by the Free Software Foundation.
11
12 Rigs of Rods is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21#ifdef USE_OPENAL
22
23#pragma once
24
25#include "Application.h"
26#include "RefCountingObject.h"
27
28#ifdef __APPLE__
29# include <OpenAL/al.h>
30#else
31# include <AL/al.h>
32#endif // __APPLE__
33
34namespace RoR {
35
38
39class Sound : public RefCountingObject<Sound>
40{
41 friend class SoundManager;
42
43public:
44 Sound(ALuint buffer, SoundManager* soundManager, int sourceIndex);
45 virtual ~Sound() override {};
46
47 void setPitch(float pitch);
48 void setGain(float gain);
49 void setPosition(Ogre::Vector3 pos);
50 void setVelocity(Ogre::Vector3 vel);
51 void setLoop(bool loop);
52 void setEnabled(bool e);
53 void play();
54 void stop();
55
56 bool getEnabled();
57 bool isPlaying();
58 float getAudibility() { return audibility; }
59 float getGain() { return gain; }
60 float getPitch() { return pitch; }
61 bool getLoop() { return loop; }
63 ALuint getBuffer() { return buffer; }
64 Ogre::Vector3 getPosition() { return position; }
65 Ogre::Vector3 getVelocity() { return velocity; }
66 int getSourceIndex() { return source_index; }
67
78
79private:
80 void computeAudibility(Ogre::Vector3 pos);
81
83 float gain;
84 float pitch;
85 bool loop;
86 bool enabled;
88
89 // this value is changed dynamically, depending on whether the input is played or not.
91 ALuint buffer;
92
93 Ogre::Vector3 position;
94 Ogre::Vector3 velocity;
95
97 // must not be changed during the lifetime of this object
99};
100
102
103} // namespace RoR
104
105#endif // USE_OPENAL
Central state/object manager and communications hub.
Self reference-counting objects, as requred by AngelScript garbage collector.
Ogre::Vector3 position
Definition Sound.h:93
void stop()
Definition Sound.cpp:119
void computeAudibility(Ogre::Vector3 pos)
Definition Sound.cpp:45
void setVelocity(Ogre::Vector3 vel)
Definition Sound.cpp:161
RecomputeSource
Definition Sound.h:69
@ REASON_POSN
Definition Sound.h:75
@ REASON_STOP
Definition Sound.h:71
@ REASON_LOOP
Definition Sound.h:73
@ REASON_PTCH
Definition Sound.h:74
@ REASON_PLAY
Definition Sound.h:70
@ REASON_VLCT
Definition Sound.h:76
@ REASON_GAIN
Definition Sound.h:72
bool isPlaying()
Definition Sound.cpp:88
float gain
Definition Sound.h:83
virtual ~Sound() override
Definition Sound.h:45
bool getLoop()
Definition Sound.h:61
void setPitch(float pitch)
Definition Sound.cpp:143
float getGain()
Definition Sound.h:59
void setGain(float gain)
Definition Sound.cpp:125
int source_index
Definition Sound.h:98
void setPosition(Ogre::Vector3 pos)
Definition Sound.cpp:152
float audibility
Definition Sound.h:82
ALuint buffer
Definition Sound.h:91
Ogre::Vector3 getVelocity()
Definition Sound.h:65
float getAudibility()
Definition Sound.h:58
bool enabled
Definition Sound.h:86
void setEnabled(bool e)
Definition Sound.cpp:99
Ogre::Vector3 getPosition()
Definition Sound.h:64
bool loop
Definition Sound.h:85
float getPitch()
Definition Sound.h:60
bool getEnabled()
Definition Sound.cpp:108
int getCurrentHardwareIndex()
Definition Sound.h:62
void play()
Definition Sound.cpp:113
float pitch
Definition Sound.h:84
Ogre::Vector3 velocity
Definition Sound.h:94
void setLoop(bool loop)
Definition Sound.cpp:134
SoundManager * sound_manager
Definition Sound.h:96
bool should_play
Definition Sound.h:87
int hardware_index
Definition Sound.h:90
int getSourceIndex()
Definition Sound.h:66
ALuint getBuffer()
Definition Sound.h:63