Skylicht Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
Driver
CSoundSource.h
1
/*
2
!@
3
MIT License
4
5
Copyright (c) 2012 - 2019 Skylicht Technology CO., LTD
6
7
Permission 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,
9
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10
subject to the following conditions:
11
12
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20
This file is part of the "Skylicht Engine".
21
https://github.com/skylicht-lab/skylicht-engine
22
!#
23
*/
24
25
#pragma once
26
27
#include "stdafx.h"
28
#include "Thread/IMutex.h"
29
#include "ISoundSource.h"
30
31
using namespace
Skylicht::System
;
32
33
namespace
Skylicht
34
{
35
namespace
Audio
36
{
37
class
CSoundSource :
public
ISoundSource
38
{
39
public
:
40
CSoundSource(
float
length);
41
virtual
~CSoundSource();
42
43
virtual
void
init(
const
STrackParams
& trackParam,
const
SSourceParam
& driverParam);
44
virtual
bool
needData();
45
46
virtual
void
changeDuration(
float
duration);
47
48
virtual
void
play();
49
virtual
void
stop();
50
virtual
void
pause();
51
virtual
void
reset();
52
53
virtual
ESourceState getState();
54
virtual
void
setState(ESourceState state);
55
56
virtual
long
getByteOffset();
57
virtual
void
setByteOffset(
int
offset);
58
59
virtual
int
getBufferSize();
60
61
virtual
void
uploadData(
void
* soundData,
unsigned
int
bufferSize);
62
63
virtual
void
lockThread();
64
virtual
void
unlockThread();
65
66
virtual
void
fillBuffer(
int
* buffer,
int
nbSample,
float
gain = 1.0f);
67
68
virtual
void
setGain(
float
gain);
69
virtual
void
setPitch(
float
pitch);
70
virtual
void
setPosition(
const
SVector3
& pos);
71
virtual
void
setRollOff(
float
rollOff);
72
virtual
void
set3DSound(
bool
b);
73
74
virtual
float
getGain();
75
virtual
float
getPitch();
76
77
virtual
void
update(
float
dt);
78
79
virtual
float
getBufferLength();
80
virtual
int
getSampleRate();
81
82
protected
:
83
void
update3D();
84
float
calcDistanceGain(
const
SListener
& listener);
85
void
calcLeftRightGain(
const
SListener
& listener,
float
& left,
float
& right);
86
protected
:
87
STrackParams
m_trackParams;
88
int
m_numDriverBuffer;
89
int
m_driverBuffer;
90
int
m_driverBufferSize;
91
int
m_driverSamplingRate;
92
93
float
m_bufferDuration;
94
int
m_bufferSize;
95
int
m_bitPerSample;
96
int
m_numChannels;
97
98
std::vector<SDriverBuffer> m_buffers;
99
IMutex
* m_mutex;
100
101
float
m_distanceGain;
102
float
m_leftGain;
103
float
m_rightGain;
104
float
m_gain;
105
float
m_pitch;
106
107
bool
m_is3DSound;
108
SVector3
m_position;
109
float
m_rollOff;
110
111
ISoundSource::ESourceState m_state;
112
};
113
}
114
}
Skylicht::Audio::ISoundSource
Definition
ISoundSource.h:93
Skylicht::System::IMutex
Definition
IMutex.h:34
Skylicht::Audio
Handles all core audio functionality.
Definition
AudioDebugLog.h:31
Skylicht::System
The foundation for thread and process handling.
Definition
CNullMutex.h:32
Skylicht
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition
AudioDebugLog.h:29
Skylicht::Audio::SListener
Definition
ISoundSource.h:86
Skylicht::Audio::SSourceParam
Definition
ISoundSource.h:33
Skylicht::Audio::STrackParams
Definition
ISoundSource.h:43
Skylicht::Audio::SVector3
Definition
ISoundSource.h:72
Generated by
1.17.0