Skylicht Engine
Loading...
Searching...
No Matches
ISoundSource.h
1/*
2!@
3MIT License
4
5Copyright (c) 2012 - 2019 Skylicht Technology CO., LTD
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20This file is part of the "Skylicht Engine".
21https://github.com/skylicht-lab/skylicht-engine
22!#
23*/
24
25#ifndef _ISOUND_SOURCE_H_
26#define _ISOUND_SOURCE_H_
27
28namespace Skylicht
29{
30 namespace Audio
31 {
33 {
34 public:
35 int SamplingRate;
36 int NumBuffer;
37 int BufferSize;
38 int BitPerSampler;
39 };
40
41
42 struct STrackParams
43 {
44 int NumChannels;
45 int SamplingRate;
46 int BitsPerSample;
47 int NumSamples;
48
49 STrackParams() :NumChannels(0), SamplingRate(0), BitsPerSample(0), NumSamples(0)
50 {
51 }
52
53 void reset(void)
54 {
55 NumChannels = 0;
56 SamplingRate = 0;
57 BitsPerSample = 0;
58 NumSamples = 0;
59 }
60 };
61
62
64 {
65 unsigned char* Data;
66 unsigned int UsedSize; // In bytes.
67 unsigned int TotalSize; // In bytes.
68 bool Free;
69 };
70
71 struct SVector3
72 {
73 float X;
74 float Y;
75 float Z;
76
77 SVector3()
78 {
79 X = 0;
80 Y = 0;
81 Z = 0;
82 }
83 };
84
85 struct SListener
86 {
87 SVector3 Position;
88 SVector3 Up;
89 SVector3 LookAt;
90 };
91
93 {
94 public:
95
96 enum ESourceState
97 {
98 StateError = -1,
99 StateInitial,
100 StatePlaying,
101 StatePause,
102 StateStopped,
103 StatePauseWaitData,
104 };
105
106 public:
107 virtual ~ISoundSource()
108 {
109 }
110
111 virtual void init(const STrackParams& trackParam, const SSourceParam& driverParam) = 0;
112 virtual bool needData() = 0;
113
114 virtual void play() = 0;
115 virtual void stop() = 0;
116 virtual void pause() = 0;
117 virtual void reset() = 0;
118
119 virtual ESourceState getState() = 0;
120 virtual void setState(ESourceState state) = 0;
121
122 virtual long getByteOffset() = 0;
123 virtual void setByteOffset(int offset) = 0;
124
125 virtual int getBufferSize() = 0;
126 virtual void uploadData(void* soundData, unsigned int bufferSize) = 0;
127
128 virtual void lockThread() = 0;
129 virtual void unlockThread() = 0;
130
131 virtual void setGain(float gain) = 0;
132 virtual void setPitch(float pitch) = 0;
133 virtual void setPosition(const SVector3& pos) = 0;
134 virtual void setRollOff(float rollOff) = 0;
135 virtual void set3DSound(bool b) = 0;
136
137 virtual float getGain() = 0;
138 virtual float getPitch() = 0;
139
140 virtual void update(float dt) = 0;
141
142 virtual float getBufferLength() = 0;
143 virtual int getSampleRate() = 0;
144 };
145 }
146}
147
148#endif
Definition ISoundSource.h:93
Handles all core audio functionality.
Definition AudioDebugLog.h:31
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
Definition ISoundSource.h:64
Definition ISoundSource.h:86
Definition ISoundSource.h:33
Definition ISoundSource.h:43
Definition ISoundSource.h:72