-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSlideController.cpp
More file actions
29 lines (26 loc) · 994 Bytes
/
SlideController.cpp
File metadata and controls
29 lines (26 loc) · 994 Bytes
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
//
// by Weikton 05.09.23
//
#include "SlideController.h"
SlideController::SlideController(const uint32_t parameter, const float startValue,
const float endValue, const uint32_t time) noexcept
: Parameter(parameter)
, ratio((endValue - startValue) / static_cast<float>(time))
, endTime(Timer::Get() + time)
, endValue(endValue)
{}
void SlideController::Apply(const Channel& channel) const noexcept
{
if(Timer::Get() < this->endTime)
{
const Timer::time_t timeLeft = this->endTime - Timer::Get();
const float startValue = this->endValue - static_cast<float>(timeLeft) * this->ratio;
BASS_ChannelSetAttribute(channel.GetHandle(), this->parameter, startValue);
BASS_ChannelSlideAttribute(channel.GetHandle(), this->parameter, this->endValue,
static_cast<uint32_t>(timeLeft));
}
else
{
BASS_ChannelSetAttribute(channel.GetHandle(), this->parameter, this->endValue);
}
}