Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
AudioAPIWrapper.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_AUDIO_API_H
34#define DVD_AUDIO_API_H
35
36#include "AudioDescriptor.h"
39
40namespace Divide {
41
42class PlatformContext;
43
45 public:
46 AudioState([[maybe_unused]] bool enableA, [[maybe_unused]] bool enableB, [[maybe_unused]] bool enableC, [[maybe_unused]] bool enableD) noexcept
47 {
48 }
49};
50
51constexpr U32 MAX_SOUND_BUFFERS = 64;
52
55{
56 public:
57 using MusicPlaylist = std::pair<U32, vector< Handle<AudioDescriptor>>>;
59
60 public:
61 explicit AudioAPIWrapper( const Str<64>& name, PlatformContext& context );
62
63 protected:
64 [[nodiscard]] virtual bool frameStarted( const FrameEvent& evt ) override { DIVIDE_UNUSED(evt); return true; }
65 [[nodiscard]] virtual bool frameEnded( const FrameEvent& evt ) noexcept override { DIVIDE_UNUSED(evt); return true; }
66
67 protected:
68 friend class SFXDevice;
69 virtual ErrorCode initAudioAPI() = 0;
70 virtual void closeAudioAPI() = 0;
71
72 virtual void playSound( Handle<AudioDescriptor> sound ) = 0;
73
74 // this stops the current track, if any, and plays the specified song
75 virtual void playMusic( Handle<AudioDescriptor> music ) = 0;
76
77 virtual void pauseMusic() = 0;
78 virtual void stopMusic() = 0;
79 virtual void stopAllSounds() = 0;
80
81 virtual void setMusicVolume(I8 value) = 0;
82 virtual void setSoundVolume(I8 value) = 0;
83
84 virtual void musicFinished() = 0;
85};
86
88
89}; // namespace Divide
90
91#endif //DVD_AUDIO_API_H
#define DIVIDE_UNUSED(X)
#define FWD_DECLARE_MANAGED_CLASS(T)
#define NOINITVTABLE
Audio Programming Interface.
virtual void playSound(Handle< AudioDescriptor > sound)=0
hashMap< U32, MusicPlaylist > MusicPlaylists
virtual bool frameEnded(const FrameEvent &evt) noexcept override
frameEnded is called after the buffers have been swapped
virtual void setMusicVolume(I8 value)=0
std::pair< U32, vector< Handle< AudioDescriptor > > > MusicPlaylist
virtual void playMusic(Handle< AudioDescriptor > music)=0
virtual bool frameStarted(const FrameEvent &evt) override
virtual ErrorCode initAudioAPI()=0
virtual void closeAudioAPI()=0
virtual void stopMusic()=0
virtual void pauseMusic()=0
virtual void stopAllSounds()=0
virtual void setSoundVolume(I8 value)=0
virtual void musicFinished()=0
AudioState(bool enableA, bool enableB, bool enableC, bool enableD) noexcept
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
hashAlg::unordered_map< K, V, HashFun, Predicate > hashMap
Definition: HashMap.h:55
constexpr U32 MAX_SOUND_BUFFERS
uint32_t U32