1 // Copyright (C) 2015 Lucas Pires Camargo
3 // This file is part of neiasound - Qt-style OpenAL wrapper for games.
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
9 // 1. Redistributions of source code must retain the above copyright notice,
10 // this list of conditions and the following disclaimer.
12 // 2. Redistributions in binary form must reproduce the above copyright notice,
13 // this list of conditions and the following disclaimer in the documentation
14 // and/or other materials provided with the distribution.
16 // THIS SOFTWARE IS PROVIDED BY THE FREEBSD PROJECT ``AS IS'' AND ANY EXPRESS
17 // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
19 // NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef NSOUNDSYSTEM_H
27 #define NSOUNDSYSTEM_H
29 #include "neiasound_global.h"
32 #include "nSoundSourceRole.h"
33 #include "nSoundFormat.h"
35 // *sigh* ugly but necessary
36 struct ALCcontext_struct;
37 struct ALCdevice_struct;
38 typedef struct ALCcontext_struct ALCcontext;
39 typedef struct ALCdevice_struct ALCdevice;
45 class nSoundStreamerPlaylist;
47 class NEIASOUNDSHARED_EXPORT nSoundSystem : public QObject
50 Q_PROPERTY(int supportedAuxiliarySends READ supportedAuxiliarySends)
51 Q_PROPERTY(qreal masterGain READ masterGain WRITE setMasterGain NOTIFY masterGainChanged)
52 Q_PROPERTY(nSoundListener * listener READ listener)
53 Q_PROPERTY(ALCcontext * openalContext READ openalContext)
54 Q_PROPERTY(ALCdevice * openalDevice READ openalDevice)
56 Q_ENUMS(nSoundSourceRole)
58 explicit nSoundSystem(QObject *parent = 0);
59 virtual ~nSoundSystem();
61 ALCcontext * openalContext(){return m_context;}
62 ALCdevice * openalDevice(){return m_device;}
64 nSoundListener * listener(){return m_listener;}
68 int supportedAuxiliarySends(){return m_numSends;}
72 void masterGainChanged(qreal arg);
78 void setMasterGain(qreal gain);
80 nSoundSource * createSource(QString name = "", nSoundSourceRole = SSR_SFX);
81 nSoundSource * source(QString name);
82 bool destroySource(QString name);
83 bool destroySource(nSoundSource * source);
85 nSoundBuffer * createBuffer(QString name);
86 nSoundBuffer * buffer(QString name);
87 bool destroyBuffer(QString name);
88 bool destroyBuffer(nSoundBuffer * buffer);
91 nSoundStreamer * createStreamer(QString name, nSoundSource * source, nSoundStreamerPlaylist * playlist = 0);
92 nSoundStreamerPlaylist * createStreamerPlaylist(QObject * parent);
93 nSoundStreamer * streamer(QString name);
94 bool destroyStreamer(QString name);
95 bool destroyStreamer(nSoundStreamer * streamer);
98 QHash<QString, nSoundSource*> m_sources;
99 QHash<QString, nSoundBuffer*> m_buffers;
100 QHash<QString, nSoundStreamer*> m_streamers;
102 nSoundListener * m_listener;
106 ALCcontext * m_context;
107 ALCdevice * m_device;
111 #endif // NSOUNDSYSTEM_H