-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEffect.cpp
42 lines (39 loc) · 1.12 KB
/
Effect.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// by Weikton 05.09.23
//
#include "Effect.h"
Effect::Effect(const uint32_t type, const int priority,
const void* const paramPtr, const uint32_t paramSize)
: type(type), priority(priority), params(paramSize)
{
memcpy(this->params.data(), paramPtr, paramSize);
}
Effect::~Effect() noexcept
{
for(const auto& fxHandle : this->fxHandles)
{
BASS_ChannelRemoveFX(fxHandle.first, fxHandle.second);
}
}
void Effect::Apply(const Channel& channel)
{
if(const auto fxHandle = BASS_ChannelSetFX(channel.GetHandle(),
this->type/*, this->priority*/); fxHandle != NULL)
{
if(BASS_FXSetParameters(fxHandle, this->params.data()) == FALSE)
{
LogVoice("[sv:err:effect:apply] : failed "
"to set parameters (code:%d)", BASS_ErrorGetCode());
BASS_ChannelRemoveFX(channel.GetHandle(), fxHandle);
}
else
{
this->fxHandles[channel.GetHandle()] = fxHandle;
}
}
else
{
LogVoice("[sv:err:effect:apply] : failed to create "
"effect (code:%d)", BASS_ErrorGetCode());
}
}