2013-10-27 18:04:37 +01:00
|
|
|
// Qt includes
|
|
|
|
#include <QDateTime>
|
2018-12-27 23:11:32 +01:00
|
|
|
#include <QTimer>
|
2013-10-27 18:04:37 +01:00
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
#include <hyperion/LinearColorSmoothing.h>
|
2016-09-07 20:10:37 +02:00
|
|
|
#include <hyperion/Hyperion.h>
|
2013-10-27 18:04:37 +01:00
|
|
|
|
2016-10-08 08:14:36 +02:00
|
|
|
#include <cmath>
|
2020-11-02 07:52:33 +01:00
|
|
|
#include <chrono>
|
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
#if defined(COMPILER_GCC)
|
|
|
|
#define ALWAYS_INLINE inline __attribute__((__always_inline__))
|
|
|
|
#elif defined(COMPILER_MSVC)
|
|
|
|
#define ALWAYS_INLINE __forceinline
|
|
|
|
#else
|
|
|
|
#define ALWAYS_INLINE inline
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/// Clamps the rounded values to the byte-interval of [0, 255].
|
|
|
|
ALWAYS_INLINE long clampRounded(const floatT x) {
|
2020-11-14 17:58:56 +01:00
|
|
|
return std::min(255L, std::max(0L, std::lroundf(x)));
|
2020-11-02 07:52:33 +01:00
|
|
|
}
|
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
// Constants
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
const bool verbose = false;
|
|
|
|
|
|
|
|
/// The number of microseconds per millisecond = 1000.
|
|
|
|
const int64_t MS_PER_MICRO = 1000;
|
|
|
|
|
2020-11-02 07:52:33 +01:00
|
|
|
/// The number of bits that are used for shifting the fixed point values
|
|
|
|
const int FPShift = (sizeof(uint64_t)*8 - (12 + 9));
|
|
|
|
|
|
|
|
/// The number of bits that are reduce the shifting when converting from fixed to floating point. 8 bits = 256 values
|
|
|
|
const int SmallShiftBis = sizeof(uint8_t)*8;
|
|
|
|
|
|
|
|
/// The number of bits that are used for shifting the fixed point values plus SmallShiftBis
|
|
|
|
const int FPShiftSmall = (sizeof(uint64_t)*8 - (12 + 9 + SmallShiftBis));
|
|
|
|
|
|
|
|
const char* SETTINGS_KEY_SMOOTHING_TYPE = "type";
|
2022-03-16 09:28:00 +01:00
|
|
|
|
|
|
|
const char* SETTINGS_KEY_SETTLING_TIME = "time_ms";
|
|
|
|
const char* SETTINGS_KEY_UPDATE_FREQUENCY = "updateFrequency";
|
|
|
|
const char* SETTINGS_KEY_OUTPUT_DELAY = "updateDelay";
|
|
|
|
|
|
|
|
const char* SETTINGS_KEY_DECAY = "decay";
|
2020-11-02 07:52:33 +01:00
|
|
|
const char* SETTINGS_KEY_INTERPOLATION_RATE = "interpolationRate";
|
|
|
|
const char* SETTINGS_KEY_OUTPUT_RATE = "outputRate";
|
|
|
|
const char* SETTINGS_KEY_DITHERING = "dithering";
|
2016-10-08 08:14:36 +02:00
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
const int64_t DEFAULT_SETTLINGTIME = 200; // in ms
|
|
|
|
const int DEFAULT_UPDATEFREQUENCY = 25; // in Hz
|
2016-08-11 07:13:55 +02:00
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
constexpr std::chrono::milliseconds DEFAULT_UPDATEINTERVALL{MS_PER_MICRO/ DEFAULT_UPDATEFREQUENCY};
|
|
|
|
const unsigned DEFAULT_OUTPUTDEPLAY = 0; // in frames
|
|
|
|
}
|
2020-11-14 17:58:56 +01:00
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
using namespace hyperion;
|
2020-02-10 15:21:58 +01:00
|
|
|
|
2020-11-02 07:52:33 +01:00
|
|
|
LinearColorSmoothing::LinearColorSmoothing(const QJsonDocument &config, Hyperion *hyperion)
|
2020-02-10 15:21:58 +01:00
|
|
|
: QObject(hyperion)
|
2022-01-22 17:48:03 +01:00
|
|
|
, _log(nullptr)
|
2021-08-31 10:56:06 +02:00
|
|
|
, _hyperion(hyperion)
|
2022-03-16 09:28:00 +01:00
|
|
|
, _prioMuxer(_hyperion->getMuxerInstance())
|
|
|
|
, _updateInterval(DEFAULT_UPDATEINTERVALL.count())
|
|
|
|
, _settlingTime(DEFAULT_SETTLINGTIME)
|
|
|
|
, _timer(nullptr)
|
|
|
|
, _outputDelay(DEFAULT_OUTPUTDEPLAY)
|
2021-08-31 10:56:06 +02:00
|
|
|
, _pause(false)
|
2022-03-16 09:28:00 +01:00
|
|
|
, _currentConfigId(SmoothingConfigID::SYSTEM)
|
2021-08-31 10:56:06 +02:00
|
|
|
, _enabled(false)
|
2022-03-16 09:28:00 +01:00
|
|
|
, _smoothingType(SmoothingType::Linear)
|
2021-08-31 10:56:06 +02:00
|
|
|
, tempValues(std::vector<uint64_t>(0, 0L))
|
2013-10-27 18:04:37 +01:00
|
|
|
{
|
2022-01-22 17:48:03 +01:00
|
|
|
QString subComponent = hyperion->property("instance").toString();
|
|
|
|
_log= Logger::getInstance("SMOOTHING", subComponent);
|
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
// timer
|
|
|
|
_timer = new QTimer(this);
|
|
|
|
_timer->setTimerType(Qt::PreciseTimer);
|
|
|
|
|
|
|
|
// init cfg (default)
|
|
|
|
updateConfig(SmoothingConfigID::SYSTEM, DEFAULT_SETTLINGTIME, DEFAULT_UPDATEFREQUENCY, DEFAULT_OUTPUTDEPLAY);
|
2018-12-27 23:11:32 +01:00
|
|
|
handleSettingsUpdate(settings::SMOOTHING, config);
|
2013-10-27 18:04:37 +01:00
|
|
|
|
2017-08-04 12:01:45 +02:00
|
|
|
// add pause on cfg 1
|
2022-03-16 09:28:00 +01:00
|
|
|
SmoothingCfg cfg {true, 0, 0};
|
2017-08-04 12:01:45 +02:00
|
|
|
_cfgList.append(cfg);
|
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
// listen for comp changes
|
2020-02-26 18:54:56 +01:00
|
|
|
connect(_hyperion, &Hyperion::compStateChangeRequest, this, &LinearColorSmoothing::componentStateChange);
|
2020-02-10 15:21:58 +01:00
|
|
|
connect(_timer, &QTimer::timeout, this, &LinearColorSmoothing::updateLeds);
|
2020-11-02 07:52:33 +01:00
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
connect(_prioMuxer, &PriorityMuxer::prioritiesChanged, this, [=] (int priority){
|
|
|
|
const PriorityMuxer::InputInfo priorityInfo = _prioMuxer->getInputInfo(priority);
|
|
|
|
int smooth_cfg = priorityInfo.smooth_cfg;
|
|
|
|
if (smooth_cfg != _currentConfigId || smooth_cfg == SmoothingConfigID::EFFECT_DYNAMIC)
|
|
|
|
{
|
|
|
|
this->selectConfig(smooth_cfg, false);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
LinearColorSmoothing::~LinearColorSmoothing()
|
|
|
|
{
|
|
|
|
delete _timer;
|
2013-10-27 18:04:37 +01:00
|
|
|
}
|
|
|
|
|
2020-11-02 07:52:33 +01:00
|
|
|
void LinearColorSmoothing::handleSettingsUpdate(settings::type type, const QJsonDocument &config)
|
2018-12-27 23:11:32 +01:00
|
|
|
{
|
2022-03-16 09:28:00 +01:00
|
|
|
if (type == settings::type::SMOOTHING)
|
2018-12-27 23:11:32 +01:00
|
|
|
{
|
|
|
|
QJsonObject obj = config.object();
|
2022-07-30 17:32:12 +02:00
|
|
|
|
|
|
|
setEnable(obj["enable"].toBool(_enabled));
|
2020-02-10 15:21:58 +01:00
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
SmoothingCfg cfg(false,
|
|
|
|
static_cast<int64_t>(obj[SETTINGS_KEY_SETTLING_TIME].toInt(DEFAULT_SETTLINGTIME)),
|
|
|
|
static_cast<int64_t>(MS_PER_MICRO / obj[SETTINGS_KEY_UPDATE_FREQUENCY].toDouble(DEFAULT_UPDATEFREQUENCY))
|
|
|
|
);
|
2020-11-02 07:52:33 +01:00
|
|
|
|
|
|
|
const QString typeString = obj[SETTINGS_KEY_SMOOTHING_TYPE].toString();
|
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
if(typeString == SETTINGS_KEY_DECAY) {
|
|
|
|
cfg._type = SmoothingType::Decay;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
cfg._type = SmoothingType::Linear;
|
2020-11-02 07:52:33 +01:00
|
|
|
}
|
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
cfg._pause = false;
|
|
|
|
cfg._outputDelay = static_cast<unsigned>(obj[SETTINGS_KEY_OUTPUT_DELAY].toInt(DEFAULT_OUTPUTDEPLAY));
|
2020-11-02 07:52:33 +01:00
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
cfg._outputRate = obj[SETTINGS_KEY_OUTPUT_RATE].toDouble(DEFAULT_UPDATEFREQUENCY);
|
|
|
|
cfg._interpolationRate = obj[SETTINGS_KEY_INTERPOLATION_RATE].toDouble(DEFAULT_UPDATEFREQUENCY);
|
|
|
|
cfg._dithering = obj[SETTINGS_KEY_DITHERING].toBool(false);
|
|
|
|
cfg._decay = obj[SETTINGS_KEY_DECAY].toDouble(1.0);
|
|
|
|
|
|
|
|
_cfgList[SmoothingConfigID::SYSTEM] = cfg;
|
|
|
|
DebugIf(_enabled,_log,"%s", QSTRING_CSTR(getConfig(SmoothingConfigID::SYSTEM)));
|
2020-02-10 15:21:58 +01:00
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
// if current id is 0, we need to apply the settings (forced)
|
2022-03-16 09:28:00 +01:00
|
|
|
if (_currentConfigId == SmoothingConfigID::SYSTEM)
|
2020-02-10 15:21:58 +01:00
|
|
|
{
|
2022-03-16 09:28:00 +01:00
|
|
|
selectConfig(SmoothingConfigID::SYSTEM, true);
|
2020-02-10 15:21:58 +01:00
|
|
|
}
|
2018-12-27 23:11:32 +01:00
|
|
|
}
|
2013-10-27 18:04:37 +01:00
|
|
|
}
|
|
|
|
|
2013-11-11 10:00:37 +01:00
|
|
|
int LinearColorSmoothing::write(const std::vector<ColorRgb> &ledValues)
|
2013-10-27 18:04:37 +01:00
|
|
|
{
|
2020-11-02 07:52:33 +01:00
|
|
|
_targetTime = micros() + (MS_PER_MICRO * _settlingTime);
|
2020-07-12 09:20:58 +02:00
|
|
|
_targetValues = ledValues;
|
|
|
|
|
2020-11-02 07:52:33 +01:00
|
|
|
rememberFrame(ledValues);
|
|
|
|
|
2016-09-08 16:32:42 +02:00
|
|
|
// received a new target color
|
|
|
|
if (_previousValues.empty())
|
2013-10-27 18:04:37 +01:00
|
|
|
{
|
2016-09-08 16:32:42 +02:00
|
|
|
// not initialized yet
|
2020-11-02 07:52:33 +01:00
|
|
|
_previousWriteTime = micros();
|
2016-09-08 16:32:42 +02:00
|
|
|
_previousValues = ledValues;
|
2020-11-02 07:52:33 +01:00
|
|
|
_previousInterpolationTime = micros();
|
2020-02-10 15:21:58 +01:00
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
_timer->start(_updateInterval);
|
2013-10-27 18:04:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-11-02 07:52:33 +01:00
|
|
|
int LinearColorSmoothing::updateLedValues(const std::vector<ColorRgb> &ledValues)
|
2013-10-27 18:04:37 +01:00
|
|
|
{
|
2020-02-10 15:21:58 +01:00
|
|
|
int retval = 0;
|
|
|
|
if (!_enabled)
|
2014-09-22 21:28:38 +02:00
|
|
|
{
|
2020-11-14 17:58:56 +01:00
|
|
|
retval = -1;
|
2014-09-22 21:28:38 +02:00
|
|
|
}
|
2020-02-10 15:21:58 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
retval = write(ledValues);
|
|
|
|
}
|
|
|
|
return retval;
|
2013-10-27 18:04:37 +01:00
|
|
|
}
|
|
|
|
|
2020-11-02 07:52:33 +01:00
|
|
|
void LinearColorSmoothing::intitializeComponentVectors(const size_t ledCount)
|
2013-10-27 18:04:37 +01:00
|
|
|
{
|
2020-11-02 07:52:33 +01:00
|
|
|
// (Re-)Initialize the color-vectors that store the Mean-Value
|
|
|
|
if (_ledCount != ledCount)
|
|
|
|
{
|
|
|
|
_ledCount = ledCount;
|
2013-10-27 18:04:37 +01:00
|
|
|
|
2020-11-02 07:52:33 +01:00
|
|
|
const size_t len = 3 * ledCount;
|
|
|
|
|
2020-11-14 17:58:56 +01:00
|
|
|
meanValues = std::vector<floatT>(len, 0.0F);
|
|
|
|
residualErrors = std::vector<floatT>(len, 0.0F);
|
|
|
|
tempValues = std::vector<uint64_t>(len, 0L);
|
2020-11-02 07:52:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Zero the temp vector
|
2020-11-14 17:58:56 +01:00
|
|
|
std::fill(tempValues.begin(), tempValues.end(), 0L);
|
2020-11-02 07:52:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void LinearColorSmoothing::writeDirect()
|
|
|
|
{
|
|
|
|
const int64_t now = micros();
|
|
|
|
_previousValues = _targetValues;
|
|
|
|
_previousWriteTime = now;
|
|
|
|
|
|
|
|
queueColors(_previousValues);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LinearColorSmoothing::writeFrame()
|
|
|
|
{
|
|
|
|
const int64_t now = micros();
|
|
|
|
_previousWriteTime = now;
|
|
|
|
queueColors(_previousValues);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
ALWAYS_INLINE int64_t LinearColorSmoothing::micros()
|
2020-11-02 07:52:33 +01:00
|
|
|
{
|
|
|
|
const auto now = std::chrono::high_resolution_clock::now();
|
|
|
|
return (std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch())).count();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LinearColorSmoothing::assembleAndDitherFrame()
|
|
|
|
{
|
|
|
|
if (meanValues.empty())
|
2013-10-27 18:04:37 +01:00
|
|
|
{
|
2020-11-02 07:52:33 +01:00
|
|
|
return;
|
|
|
|
}
|
2013-10-27 18:04:37 +01:00
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
// The number of LEDs present in each frame
|
2020-11-02 07:52:33 +01:00
|
|
|
const size_t N = _targetValues.size();
|
|
|
|
|
|
|
|
for (size_t i = 0; i < N; ++i)
|
|
|
|
{
|
|
|
|
// Add residuals for error diffusion (temporal dithering)
|
|
|
|
const floatT fr = meanValues[3 * i + 0] + residualErrors[3 * i + 0];
|
|
|
|
const floatT fg = meanValues[3 * i + 1] + residualErrors[3 * i + 1];
|
|
|
|
const floatT fb = meanValues[3 * i + 2] + residualErrors[3 * i + 2];
|
|
|
|
|
|
|
|
// Convert to to 8-bit value
|
|
|
|
const long ir = clampRounded(fr);
|
|
|
|
const long ig = clampRounded(fg);
|
|
|
|
const long ib = clampRounded(fb);
|
|
|
|
|
|
|
|
// Update the colors
|
|
|
|
ColorRgb &prev = _previousValues[i];
|
2020-11-14 17:58:56 +01:00
|
|
|
prev.red = static_cast<uint8_t>(ir);
|
|
|
|
prev.green = static_cast<uint8_t>(ig);
|
|
|
|
prev.blue = static_cast<uint8_t>(ib);
|
2020-11-02 07:52:33 +01:00
|
|
|
|
|
|
|
// Determine the component errors
|
|
|
|
residualErrors[3 * i + 0] = fr - ir;
|
|
|
|
residualErrors[3 * i + 1] = fg - ig;
|
|
|
|
residualErrors[3 * i + 2] = fb - ib;
|
2013-10-27 18:04:37 +01:00
|
|
|
}
|
2020-11-02 07:52:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void LinearColorSmoothing::assembleFrame()
|
|
|
|
{
|
|
|
|
if (meanValues.empty())
|
2013-10-27 18:04:37 +01:00
|
|
|
{
|
2020-11-02 07:52:33 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
// The number of LEDs present in each frame
|
2020-11-02 07:52:33 +01:00
|
|
|
const size_t N = _targetValues.size();
|
|
|
|
|
|
|
|
for (size_t i = 0; i < N; ++i)
|
|
|
|
{
|
|
|
|
// Convert to to 8-bit value
|
|
|
|
const long ir = clampRounded(meanValues[3 * i + 0]);
|
|
|
|
const long ig = clampRounded(meanValues[3 * i + 1]);
|
|
|
|
const long ib = clampRounded(meanValues[3 * i + 2]);
|
|
|
|
|
|
|
|
// Update the colors
|
|
|
|
ColorRgb &prev = _previousValues[i];
|
2020-11-14 17:58:56 +01:00
|
|
|
prev.red = static_cast<uint8_t>(ir);
|
|
|
|
prev.green = static_cast<uint8_t>(ig);
|
|
|
|
prev.blue = static_cast<uint8_t>(ib);
|
2020-11-02 07:52:33 +01:00
|
|
|
}
|
|
|
|
}
|
2020-02-10 15:21:58 +01:00
|
|
|
|
2020-11-02 07:52:33 +01:00
|
|
|
ALWAYS_INLINE void LinearColorSmoothing::aggregateComponents(const std::vector<ColorRgb>& colors, std::vector<uint64_t>& weighted, const floatT weight) {
|
|
|
|
// Determine the integer-scale by converting the weight to fixed point
|
2020-11-14 17:58:56 +01:00
|
|
|
const uint64_t scale = (static_cast<uint64_t>(1L)<<FPShift) * static_cast<double>(weight);
|
2020-02-10 15:21:58 +01:00
|
|
|
|
2020-11-02 07:52:33 +01:00
|
|
|
const size_t N = colors.size();
|
2013-10-27 18:04:37 +01:00
|
|
|
|
2020-11-02 07:52:33 +01:00
|
|
|
for (size_t i = 0; i < N; ++i)
|
|
|
|
{
|
|
|
|
const ColorRgb &color = colors[i];
|
2013-10-27 18:04:37 +01:00
|
|
|
|
2020-11-02 07:52:33 +01:00
|
|
|
// Scale the colors
|
|
|
|
const uint64_t red = scale * color.red;
|
|
|
|
const uint64_t green = scale * color.green;
|
|
|
|
const uint64_t blue = scale * color.blue;
|
2016-10-04 22:13:29 +02:00
|
|
|
|
2020-11-02 07:52:33 +01:00
|
|
|
// Accumulate in the vector
|
|
|
|
weighted[3 * i + 0] += red;
|
|
|
|
weighted[3 * i + 1] += green;
|
|
|
|
weighted[3 * i + 2] += blue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LinearColorSmoothing::interpolateFrame()
|
|
|
|
{
|
|
|
|
const int64_t now = micros();
|
|
|
|
|
|
|
|
// The number of leds present in each frame
|
|
|
|
const size_t N = _targetValues.size();
|
|
|
|
|
|
|
|
intitializeComponentVectors(N);
|
|
|
|
|
|
|
|
/// Time where the frame has been shown
|
|
|
|
int64_t frameStart;
|
|
|
|
|
|
|
|
/// Time where the frame display would have ended
|
|
|
|
int64_t frameEnd = now;
|
|
|
|
|
|
|
|
/// Time where the current window has started
|
|
|
|
const int64_t windowStart = now - (MS_PER_MICRO * _settlingTime);
|
|
|
|
|
|
|
|
/// The total weight of the frames that were included in our window; sum of the individual weights
|
2020-11-14 17:58:56 +01:00
|
|
|
floatT fs = 0.0F;
|
2020-11-02 07:52:33 +01:00
|
|
|
|
|
|
|
// To calculate the mean component we iterate over all relevant frames;
|
|
|
|
// from the most recent to the oldest frame that still clips our moving-average window given by time (now)
|
|
|
|
for (auto it = _frameQueue.rbegin(); it != _frameQueue.rend() && frameEnd > windowStart; ++it)
|
|
|
|
{
|
|
|
|
// Starting time of a frame in the window is clipped to the window start
|
|
|
|
frameStart = std::max(windowStart, it->time);
|
|
|
|
|
|
|
|
// Weight the current frame relative to the overall window based on start and end times
|
|
|
|
const floatT weight = _weightFrame(frameStart, frameEnd, windowStart);
|
|
|
|
fs += weight;
|
|
|
|
|
|
|
|
// Aggregate the RGB components of this frame's LED colors using the individual weighting
|
|
|
|
aggregateComponents(it->colors, tempValues, weight);
|
|
|
|
|
|
|
|
// The previous (earlier) frame display has ended when the current frame stared to show,
|
|
|
|
// so we can use this as the frame-end time for next iteration
|
|
|
|
frameEnd = frameStart;
|
|
|
|
}
|
2016-10-04 22:13:29 +02:00
|
|
|
|
2020-11-02 07:52:33 +01:00
|
|
|
/// The inverse scaling factor for the color components, clamped to (0, 1.0]; 1.0 for fs < 1, 1 : fs otherwise
|
2020-11-14 17:58:56 +01:00
|
|
|
const floatT inv_fs = ((fs < 1.0F) ? 1.0F : 1.0F / fs) / (1 << SmallShiftBis);
|
2020-11-02 07:52:33 +01:00
|
|
|
|
|
|
|
// Normalize the mean component values for the window (fs)
|
|
|
|
for (size_t i = 0; i < 3 * N; ++i)
|
|
|
|
{
|
|
|
|
meanValues[i] = (tempValues[i] >> FPShiftSmall) * inv_fs;
|
|
|
|
}
|
|
|
|
|
|
|
|
_previousInterpolationTime = now;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LinearColorSmoothing::performDecay(const int64_t now) {
|
|
|
|
/// The target time when next frame interpolation should be performed
|
|
|
|
const int64_t interpolationTarget = _previousInterpolationTime + _interpolationIntervalMicros;
|
|
|
|
|
|
|
|
/// The target time when next write operation should be performed
|
|
|
|
const int64_t writeTarget = _previousWriteTime + _outputIntervalMicros;
|
|
|
|
|
|
|
|
/// Whether a frame interpolation is pending
|
|
|
|
const bool interpolatePending = now > interpolationTarget;
|
|
|
|
|
|
|
|
/// Whether a write is pending
|
|
|
|
const bool writePending = now > writeTarget;
|
|
|
|
|
|
|
|
// Check whether a new interpolation frame is due
|
|
|
|
if (interpolatePending)
|
|
|
|
{
|
|
|
|
interpolateFrame();
|
|
|
|
++_interpolationCounter;
|
|
|
|
|
|
|
|
// Assemble the frame now when no dithering is applied
|
|
|
|
if(!_dithering) {
|
|
|
|
assembleFrame();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether to frame output is due
|
|
|
|
if (writePending)
|
|
|
|
{
|
|
|
|
// Dither the frame to diffuse rounding errors
|
|
|
|
if(_dithering) {
|
|
|
|
assembleAndDitherFrame();
|
2016-10-08 08:14:36 +02:00
|
|
|
}
|
2013-10-27 18:04:37 +01:00
|
|
|
|
2020-11-02 07:52:33 +01:00
|
|
|
writeFrame();
|
|
|
|
++_renderedCounter;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check for sleep when no operation is pending.
|
|
|
|
// As our QTimer is not capable of sub 1ms timing but instead performs spinning -
|
|
|
|
// we have to do µsec-sleep to free CPU time; otherwise the thread would consume 100% CPU time.
|
|
|
|
if(_updateInterval <= 0 && !(interpolatePending || writePending)) {
|
|
|
|
const int64_t nextActionExpected = std::min(interpolationTarget, writeTarget);
|
|
|
|
const int64_t microsTillNextAction = nextActionExpected - now;
|
2020-11-14 17:58:56 +01:00
|
|
|
const int64_t SLEEP_MAX_MICROS = 1000L; // We want to use usleep for up to 1ms
|
|
|
|
const int64_t SLEEP_RES_MICROS = 100L; // Expected resolution is >= 100µs on stock linux
|
2020-11-02 07:52:33 +01:00
|
|
|
|
|
|
|
if(microsTillNextAction > SLEEP_RES_MICROS) {
|
|
|
|
const int64_t wait = std::min(microsTillNextAction - SLEEP_RES_MICROS, SLEEP_MAX_MICROS);
|
|
|
|
//usleep(wait);
|
|
|
|
std::this_thread::sleep_for(std::chrono::microseconds(wait));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write stats every 30 sec
|
|
|
|
if ((now > (_renderedStatTime + 30 * 1000000)) && (_renderedCounter > _renderedStatCounter))
|
|
|
|
{
|
2020-11-14 17:58:56 +01:00
|
|
|
Debug(_log, "decay - rendered frames [%d] (%f/s), interpolated frames [%d] (%f/s) in [%f ms]"
|
2021-08-31 10:56:06 +02:00
|
|
|
, _renderedCounter - _renderedStatCounter
|
|
|
|
, (1.0F * (_renderedCounter - _renderedStatCounter) / ((now - _renderedStatTime) / 1000000.0F))
|
|
|
|
, _interpolationCounter - _interpolationStatCounter
|
|
|
|
, (1.0F * (_interpolationCounter - _interpolationStatCounter) / ((now - _renderedStatTime) / 1000000.0F))
|
|
|
|
, (now - _renderedStatTime) / 1000.0F
|
|
|
|
);
|
2020-11-02 07:52:33 +01:00
|
|
|
_renderedStatTime = now;
|
|
|
|
_renderedStatCounter = _renderedCounter;
|
|
|
|
_interpolationStatCounter = _interpolationCounter;
|
|
|
|
}
|
|
|
|
}
|
2020-02-10 15:21:58 +01:00
|
|
|
|
2020-11-02 07:52:33 +01:00
|
|
|
void LinearColorSmoothing::performLinear(const int64_t now) {
|
|
|
|
const int64_t deltaTime = _targetTime - now;
|
2020-11-14 17:58:56 +01:00
|
|
|
const float k = 1.0F - 1.0F * deltaTime / (_targetTime - _previousWriteTime);
|
2020-11-02 07:52:33 +01:00
|
|
|
const size_t N = _previousValues.size();
|
|
|
|
|
|
|
|
for (size_t i = 0; i < N; ++i)
|
|
|
|
{
|
|
|
|
const ColorRgb &target = _targetValues[i];
|
|
|
|
ColorRgb &prev = _previousValues[i];
|
|
|
|
|
|
|
|
const int reddif = target.red - prev.red;
|
|
|
|
const int greendif = target.green - prev.green;
|
|
|
|
const int bluedif = target.blue - prev.blue;
|
|
|
|
|
|
|
|
prev.red += (reddif < 0 ? -1:1) * std::ceil(k * std::abs(reddif));
|
|
|
|
prev.green += (greendif < 0 ? -1:1) * std::ceil(k * std::abs(greendif));
|
|
|
|
prev.blue += (bluedif < 0 ? -1:1) * std::ceil(k * std::abs(bluedif));
|
2014-09-22 21:28:38 +02:00
|
|
|
}
|
2020-11-02 07:52:33 +01:00
|
|
|
|
|
|
|
writeFrame();
|
2014-09-22 21:28:38 +02:00
|
|
|
}
|
|
|
|
|
2020-11-02 07:52:33 +01:00
|
|
|
void LinearColorSmoothing::updateLeds()
|
|
|
|
{
|
|
|
|
const int64_t now = micros();
|
|
|
|
const int64_t deltaTime = _targetTime - now;
|
|
|
|
|
|
|
|
if (deltaTime < 0)
|
|
|
|
{
|
|
|
|
writeDirect();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (_smoothingType)
|
|
|
|
{
|
2022-03-16 09:28:00 +01:00
|
|
|
case SmoothingType::Decay:
|
2020-11-02 07:52:33 +01:00
|
|
|
performDecay(now);
|
|
|
|
break;
|
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
case SmoothingType::Linear:
|
2020-11-02 07:52:33 +01:00
|
|
|
default:
|
|
|
|
performLinear(now);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LinearColorSmoothing::rememberFrame(const std::vector<ColorRgb> &ledColors)
|
|
|
|
{
|
|
|
|
const int64_t now = micros();
|
|
|
|
|
|
|
|
// Maintain the queue by removing outdated frames
|
|
|
|
const int64_t windowStart = now - (MS_PER_MICRO * _settlingTime);
|
|
|
|
|
|
|
|
int p = -1; // Start with -1 instead of 0, so we keep the last frame at least partially clipping the window
|
|
|
|
|
|
|
|
// As the frames are ordered chronologically we scan from the front (oldest) till we find the first fresh frame
|
|
|
|
for (auto it = _frameQueue.begin(); it != _frameQueue.end() && it->time < windowStart; ++it)
|
|
|
|
{
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p > 0)
|
|
|
|
{
|
|
|
|
_frameQueue.erase(_frameQueue.begin(), _frameQueue.begin() + p);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Append the latest frame at back of the queue
|
|
|
|
const REMEMBERED_FRAME frame = REMEMBERED_FRAME(now, ledColors);
|
|
|
|
_frameQueue.push_back(frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LinearColorSmoothing::clearRememberedFrames()
|
|
|
|
{
|
|
|
|
_frameQueue.clear();
|
|
|
|
|
|
|
|
_ledCount = 0;
|
|
|
|
meanValues.clear();
|
|
|
|
residualErrors.clear();
|
|
|
|
tempValues.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LinearColorSmoothing::queueColors(const std::vector<ColorRgb> &ledColors)
|
2014-09-22 21:28:38 +02:00
|
|
|
{
|
|
|
|
if (_outputDelay == 0)
|
|
|
|
{
|
2014-09-25 22:05:01 +02:00
|
|
|
// No output delay => immediate write
|
2021-08-31 10:56:06 +02:00
|
|
|
if (!_pause)
|
2020-02-10 15:21:58 +01:00
|
|
|
{
|
2019-01-01 19:47:07 +01:00
|
|
|
emit _hyperion->ledDeviceData(ledColors);
|
2020-02-10 15:21:58 +01:00
|
|
|
}
|
2014-09-22 21:28:38 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-07-13 11:18:12 +02:00
|
|
|
// Push new colors in the delay-buffer
|
2021-08-31 10:56:06 +02:00
|
|
|
_outputQueue.push_back(ledColors);
|
2016-07-13 11:18:12 +02:00
|
|
|
|
2014-09-25 22:05:01 +02:00
|
|
|
// If the delay-buffer is filled pop the front and write to device
|
2020-11-14 17:58:56 +01:00
|
|
|
if (!_outputQueue.empty())
|
2014-09-22 21:28:38 +02:00
|
|
|
{
|
2021-08-31 10:56:06 +02:00
|
|
|
if (_outputQueue.size() > _outputDelay)
|
2016-07-13 11:18:12 +02:00
|
|
|
{
|
2017-03-30 06:20:20 +02:00
|
|
|
if (!_pause)
|
|
|
|
{
|
2019-01-01 19:47:07 +01:00
|
|
|
emit _hyperion->ledDeviceData(_outputQueue.front());
|
2017-03-30 06:20:20 +02:00
|
|
|
}
|
2016-07-13 11:18:12 +02:00
|
|
|
_outputQueue.pop_front();
|
|
|
|
}
|
2014-09-22 21:28:38 +02:00
|
|
|
}
|
2013-10-27 18:04:37 +01:00
|
|
|
}
|
|
|
|
}
|
2016-08-11 07:13:55 +02:00
|
|
|
|
2020-02-10 15:21:58 +01:00
|
|
|
void LinearColorSmoothing::clearQueuedColors()
|
|
|
|
{
|
2022-03-16 09:28:00 +01:00
|
|
|
_timer->stop();
|
|
|
|
//QMetaObject::invokeMethod(_timer, "stop", Qt::QueuedConnection);
|
2020-02-10 15:21:58 +01:00
|
|
|
_previousValues.clear();
|
|
|
|
|
|
|
|
_targetValues.clear();
|
2020-11-02 07:52:33 +01:00
|
|
|
|
|
|
|
clearRememberedFrames();
|
2020-02-10 15:21:58 +01:00
|
|
|
}
|
|
|
|
|
2020-08-08 13:09:15 +02:00
|
|
|
void LinearColorSmoothing::componentStateChange(hyperion::Components component, bool state)
|
2018-12-27 23:11:32 +01:00
|
|
|
{
|
2020-11-02 07:52:33 +01:00
|
|
|
if (component == hyperion::COMP_SMOOTHING)
|
2019-12-08 13:12:01 +01:00
|
|
|
{
|
2018-12-27 23:11:32 +01:00
|
|
|
setEnable(state);
|
2019-12-08 13:12:01 +01:00
|
|
|
}
|
2018-12-27 23:11:32 +01:00
|
|
|
}
|
2016-09-08 16:32:42 +02:00
|
|
|
|
|
|
|
void LinearColorSmoothing::setEnable(bool enable)
|
2016-08-11 07:13:55 +02:00
|
|
|
{
|
2020-02-10 15:21:58 +01:00
|
|
|
_enabled = enable;
|
|
|
|
if (!_enabled)
|
2016-09-08 18:07:57 +02:00
|
|
|
{
|
2020-02-10 15:21:58 +01:00
|
|
|
clearQueuedColors();
|
2016-09-08 18:07:57 +02:00
|
|
|
}
|
2020-02-10 15:21:58 +01:00
|
|
|
// update comp register
|
2020-02-26 18:54:56 +01:00
|
|
|
_hyperion->setNewComponentState(hyperion::COMP_SMOOTHING, enable);
|
2016-08-11 07:13:55 +02:00
|
|
|
}
|
2017-03-30 06:20:20 +02:00
|
|
|
|
|
|
|
void LinearColorSmoothing::setPause(bool pause)
|
|
|
|
{
|
|
|
|
_pause = pause;
|
|
|
|
}
|
|
|
|
|
2017-08-04 12:01:45 +02:00
|
|
|
unsigned LinearColorSmoothing::addConfig(int settlingTime_ms, double ledUpdateFrequency_hz, unsigned updateDelay)
|
|
|
|
{
|
2022-03-16 09:28:00 +01:00
|
|
|
SmoothingCfg cfg {
|
2020-11-02 07:52:33 +01:00
|
|
|
false,
|
|
|
|
settlingTime_ms,
|
2022-03-16 09:28:00 +01:00
|
|
|
static_cast<int>(MS_PER_MICRO / ledUpdateFrequency_hz),
|
|
|
|
SmoothingType::Linear,
|
2020-11-02 07:52:33 +01:00
|
|
|
ledUpdateFrequency_hz,
|
|
|
|
ledUpdateFrequency_hz,
|
2022-03-16 09:28:00 +01:00
|
|
|
updateDelay
|
2020-11-02 07:52:33 +01:00
|
|
|
};
|
2017-08-04 12:01:45 +02:00
|
|
|
_cfgList.append(cfg);
|
2018-12-27 23:11:32 +01:00
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
DebugIf(verbose && _enabled, _log,"%s", QSTRING_CSTR(getConfig(_cfgList.count()-1)));
|
|
|
|
|
2017-08-04 12:01:45 +02:00
|
|
|
return _cfgList.count() - 1;
|
|
|
|
}
|
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
unsigned LinearColorSmoothing::updateConfig(int cfgID, int settlingTime_ms, double ledUpdateFrequency_hz, unsigned updateDelay)
|
2020-02-10 15:21:58 +01:00
|
|
|
{
|
2022-03-16 09:28:00 +01:00
|
|
|
int updatedCfgID = cfgID;
|
|
|
|
if (cfgID < _cfgList.count())
|
2020-02-10 15:21:58 +01:00
|
|
|
{
|
2022-03-16 09:28:00 +01:00
|
|
|
SmoothingCfg cfg {
|
2020-11-02 07:52:33 +01:00
|
|
|
false,
|
|
|
|
settlingTime_ms,
|
2022-03-16 09:28:00 +01:00
|
|
|
static_cast<int>(MS_PER_MICRO / ledUpdateFrequency_hz),
|
|
|
|
SmoothingType::Linear,
|
2020-11-02 07:52:33 +01:00
|
|
|
ledUpdateFrequency_hz,
|
|
|
|
ledUpdateFrequency_hz,
|
2022-03-16 09:28:00 +01:00
|
|
|
updateDelay
|
|
|
|
};
|
2020-02-10 15:21:58 +01:00
|
|
|
_cfgList[updatedCfgID] = cfg;
|
2022-03-16 09:28:00 +01:00
|
|
|
DebugIf(verbose && _enabled, _log,"%s", QSTRING_CSTR(getConfig(updatedCfgID)));
|
2020-02-10 15:21:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-11-02 07:52:33 +01:00
|
|
|
updatedCfgID = addConfig(settlingTime_ms, ledUpdateFrequency_hz, updateDelay);
|
2020-02-10 15:21:58 +01:00
|
|
|
}
|
|
|
|
return updatedCfgID;
|
|
|
|
}
|
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
bool LinearColorSmoothing::selectConfig(int cfgID, bool force)
|
2017-08-04 12:01:45 +02:00
|
|
|
{
|
2022-03-16 09:28:00 +01:00
|
|
|
if (_currentConfigId == cfgID && !force)
|
2017-08-04 12:01:45 +02:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
if (cfgID < _cfgList.count() )
|
2017-08-04 12:01:45 +02:00
|
|
|
{
|
2022-03-16 09:28:00 +01:00
|
|
|
_smoothingType = _cfgList[cfgID]._type;
|
|
|
|
_settlingTime = _cfgList[cfgID]._settlingTime;
|
|
|
|
_outputDelay = _cfgList[cfgID]._outputDelay;
|
|
|
|
_pause = _cfgList[cfgID]._pause;
|
|
|
|
_outputRate = _cfgList[cfgID]._outputRate;
|
2020-11-02 07:52:33 +01:00
|
|
|
_outputIntervalMicros = int64_t(1000000.0 / _outputRate); // 1s = 1e6 µs
|
2022-03-16 09:28:00 +01:00
|
|
|
_interpolationRate = _cfgList[cfgID]._interpolationRate;
|
2020-11-02 07:52:33 +01:00
|
|
|
_interpolationIntervalMicros = int64_t(1000000.0 / _interpolationRate);
|
2022-03-16 09:28:00 +01:00
|
|
|
_dithering = _cfgList[cfgID]._dithering;
|
|
|
|
_decay = _cfgList[cfgID]._decay;
|
2020-11-14 17:58:56 +01:00
|
|
|
_invWindow = 1.0F / (MS_PER_MICRO * _settlingTime);
|
2020-11-02 07:52:33 +01:00
|
|
|
|
|
|
|
// Set _weightFrame based on the given decay
|
|
|
|
const float decay = _decay;
|
|
|
|
const floatT inv_window = _invWindow;
|
|
|
|
|
|
|
|
// For decay != 1 use power-based approach for calculating the moving average values
|
2020-11-14 17:58:56 +01:00
|
|
|
if(std::abs(decay - 1.0F) > std::numeric_limits<float>::epsilon()) {
|
2020-11-02 07:52:33 +01:00
|
|
|
// Exponential Decay
|
|
|
|
_weightFrame = [inv_window,decay](const int64_t fs, const int64_t fe, const int64_t ws) {
|
|
|
|
const floatT s = (fs - ws) * inv_window;
|
|
|
|
const floatT t = (fe - ws) * inv_window;
|
|
|
|
|
|
|
|
return (decay + 1) * (std::pow(t, decay) - std::pow(s, decay));
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
// For decay == 1 use linear interpolation of the moving average values
|
|
|
|
// Linear Decay
|
2020-11-14 17:58:56 +01:00
|
|
|
_weightFrame = [inv_window](const int64_t fs, const int64_t fe, const int64_t /*ws*/) {
|
2020-11-02 07:52:33 +01:00
|
|
|
// Linear weighting = (end - start) * scale
|
|
|
|
return static_cast<floatT>((fe - fs) * inv_window);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
_renderedStatTime = micros();
|
|
|
|
_renderedCounter = 0;
|
|
|
|
_renderedStatCounter = 0;
|
|
|
|
_interpolationCounter = 0;
|
|
|
|
_interpolationStatCounter = 0;
|
2017-08-04 12:01:45 +02:00
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
if (_cfgList[cfgID]._updateInterval != _updateInterval)
|
2017-08-04 12:01:45 +02:00
|
|
|
{
|
2020-02-10 15:21:58 +01:00
|
|
|
|
2022-03-16 09:28:00 +01:00
|
|
|
_timer->stop();
|
|
|
|
_updateInterval = _cfgList[cfgID]._updateInterval;
|
2021-08-31 10:56:06 +02:00
|
|
|
if (this->enabled())
|
2020-02-10 15:21:58 +01:00
|
|
|
{
|
2022-03-16 09:28:00 +01:00
|
|
|
_timer->start(_updateInterval);
|
2020-02-10 15:21:58 +01:00
|
|
|
}
|
2017-08-04 12:01:45 +02:00
|
|
|
}
|
2022-03-16 09:28:00 +01:00
|
|
|
_currentConfigId = cfgID;
|
|
|
|
DebugIf(_enabled, _log,"%s", QSTRING_CSTR(getConfig(_currentConfigId)));
|
2020-11-02 07:52:33 +01:00
|
|
|
|
2017-08-04 12:01:45 +02:00
|
|
|
return true;
|
|
|
|
}
|
2018-12-27 23:11:32 +01:00
|
|
|
|
2017-08-04 12:01:45 +02:00
|
|
|
// reset to default
|
2022-03-16 09:28:00 +01:00
|
|
|
_currentConfigId = SmoothingConfigID::SYSTEM;
|
2017-08-04 12:01:45 +02:00
|
|
|
return false;
|
|
|
|
}
|
2022-03-16 09:28:00 +01:00
|
|
|
|
|
|
|
QString LinearColorSmoothing::getConfig(int cfgID)
|
|
|
|
{
|
|
|
|
QString configText;
|
|
|
|
|
|
|
|
if (cfgID < _cfgList.count())
|
|
|
|
{
|
|
|
|
SmoothingCfg cfg = _cfgList[cfgID];
|
|
|
|
|
|
|
|
configText = QString ("[%1] - type: %2, pause: %3, settlingTime: %4ms, interval: %5ms (%6Hz), delay: %7 frames")
|
|
|
|
.arg(cfgID)
|
|
|
|
.arg(SmoothingCfg::EnumToString(cfg._type),(cfg._pause) ? "true" : "false")
|
|
|
|
.arg(cfg._settlingTime)
|
|
|
|
.arg(cfg._updateInterval)
|
|
|
|
.arg(int(MS_PER_MICRO/cfg._updateInterval))
|
|
|
|
.arg(cfg._outputDelay);
|
|
|
|
|
|
|
|
switch (cfg._type) {
|
|
|
|
case SmoothingType::Linear:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SmoothingType::Decay:
|
|
|
|
{
|
|
|
|
const double thalf = (1.0-std::pow(1.0/2, 1.0/_decay))*_settlingTime;
|
|
|
|
configText += QString (", outputRate %1Hz, interpolationRate: %2Hz, dithering: %3, decay: %4 -> halftime: %5ms")
|
|
|
|
.arg(cfg._outputRate,0,'f',2)
|
|
|
|
.arg(cfg._interpolationRate,0,'f',2)
|
|
|
|
.arg((cfg._dithering) ? "true" : "false")
|
|
|
|
.arg(cfg._decay,0,'f',2)
|
|
|
|
.arg(thalf,0,'f',2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return configText;
|
|
|
|
}
|
|
|
|
|
|
|
|
LinearColorSmoothing::SmoothingCfg::SmoothingCfg() :
|
|
|
|
_pause(false),
|
|
|
|
_settlingTime(DEFAULT_SETTLINGTIME),
|
|
|
|
_updateInterval(DEFAULT_UPDATEFREQUENCY),
|
|
|
|
_type(SmoothingType::Linear)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
LinearColorSmoothing::SmoothingCfg::SmoothingCfg(bool pause, int64_t settlingTime, int updateInterval, SmoothingType type, double outputRate, double interpolationRate, unsigned outputDelay, bool dithering, double decay) :
|
|
|
|
_pause(pause),
|
|
|
|
_settlingTime(settlingTime),
|
|
|
|
_updateInterval(updateInterval),
|
|
|
|
_type(type),
|
|
|
|
_outputRate(outputRate),
|
|
|
|
_interpolationRate(interpolationRate),
|
|
|
|
_outputDelay(outputDelay),
|
|
|
|
_dithering(dithering),
|
|
|
|
_decay(decay)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString LinearColorSmoothing::SmoothingCfg::EnumToString(SmoothingType type)
|
|
|
|
{
|
|
|
|
if (type == SmoothingType::Linear) {
|
|
|
|
return QString("Linear");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == SmoothingType::Decay)
|
|
|
|
{
|
|
|
|
return QString("Decay");
|
|
|
|
}
|
|
|
|
|
|
|
|
return QString("Unknown");
|
|
|
|
}
|