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
31 #include "nSoundSourceRole.h"
32 #include "nSoundFormat.h"
34 // *sigh* ugly but necessary
35 struct ALCcontext_struct;
36 struct ALCdevice_struct;
37 typedef struct ALCcontext_struct ALCcontext;
38 typedef struct ALCdevice_struct ALCdevice;
44 class nSoundStreamerPlaylist;
46 class nSoundSystem : public QObject
49 Q_PROPERTY(int supportedAuxiliarySends READ supportedAuxiliarySends)
50 Q_PROPERTY(qreal masterGain READ masterGain WRITE setMasterGain NOTIFY masterGainChanged)
51 Q_PROPERTY(nSoundListener * listener READ listener)
52 Q_PROPERTY(ALCcontext * openalContext READ openalContext)
53 Q_PROPERTY(ALCdevice * openalDevice READ openalDevice)
55 Q_ENUMS(nSoundSourceRole)
57 explicit nSoundSystem(QObject *parent = 0);
58 virtual ~nSoundSystem();
60 ALCcontext * openalContext(){return m_context;}
61 ALCdevice * openalDevice(){return m_device;}
63 nSoundListener * listener(){return m_listener;}
67 int supportedAuxiliarySends(){return m_numSends;}
71 void masterGainChanged(qreal arg);
77 void setMasterGain(qreal gain);
79 nSoundSource * createSource(QString name = "", nSoundSourceRole = SSR_SFX);
80 nSoundSource * source(QString name);
81 bool destroySource(QString name);
82 bool destroySource(nSoundSource * source);
84 nSoundBuffer * createBuffer(QString name);
85 nSoundBuffer * buffer(QString name);
86 bool destroyBuffer(QString name);
87 bool destroyBuffer(nSoundBuffer * buffer);
90 nSoundStreamer * createStreamer(QString name, nSoundSource * source, nSoundStreamerPlaylist * playlist = 0);
91 nSoundStreamerPlaylist * createStreamerPlaylist(QObject * parent);
92 nSoundStreamer * streamer(QString name);
93 bool destroyStreamer(QString name);
94 bool destroyStreamer(nSoundStreamer * streamer);
97 QHash<QString, nSoundSource*> m_sources;
98 QHash<QString, nSoundBuffer*> m_buffers;
99 QHash<QString, nSoundStreamer*> m_streamers;
101 nSoundListener * m_listener;
105 ALCcontext * m_context;
106 ALCdevice * m_device;
110 #endif // NSOUNDSYSTEM_H