Debian Codegraph @

src/game/audio/audioworker.hpp

raw symbols SCIP
1 // This file is part of Dust Racing 2D.
2 // Copyright (C) 2013 Jussi Lind <[email protected]>
3 //
4 // Dust Racing 2D is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 // Dust Racing 2D is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with Dust Racing 2D. If not, see <http://www.gnu.org/licenses/>.
15
16 #ifndef AUDIOWORKER_HPP
17 #define AUDIOWORKER_HPP
18
19 #include <QObject>
20 #include <QString>
21
22 #include <map>
23
24 #include "openaldevice.hpp"
25 #include "openalsource.hpp"
26
27 class AudioSource;
28
29 class AudioWorker : public QObject
30 {
31 Q_OBJECT
32
33 public:
34 AudioWorker(int numCars, bool enabled);
35
36 virtual ~AudioWorker() override;
37
38 void connectAudioSource(AudioSource & source);
39
40 void disconnectAudioSource(AudioSource & source);
41
42 bool enabled() const;
43
44 public slots:
45
46 void init();
47
48 void loadSounds();
49
50 void playSound(const QString & handle, bool loop = false);
51
52 void stopSound(const QString & handle);
53
54 void setPitch(const QString & handle, float pitch);
55
56 void setVolume(const QString & handle, float pitch);
57
58 void setDefaultVolume(float volume);
59
60 void setLocation(const QString & handle, float x, float y);
61
62 void setListenerLocation(float x, float y);
63
64 void setEnabled(bool enabled);
65
66 private:
67 void checkFile(QString path);
68
69 void loadCommonSound(QString handle, QString path, float volume = 1.0f);
70
71 void loadSingleInstanceCarSound(QString handle, QString path, float volume = 1.0f);
72
73 void loadMultiInstanceCarSound(QString baseName, QString path, float volume = 1.0f);
74
75 STFH::DevicePtr m_openALDevice;
76
77 typedef std::map<QString, STFH::SourcePtr> SoundMap;
78 SoundMap m_soundMap;
79
80 bool m_inited;
81
82 float m_defaultVolume;
83
84 int m_numCars;
85
86 bool m_enabled;
87 };
88
89 #endif // AUDIOWORKER_HPP