mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-11 14:07:11 +03:00
move to new cspot
This commit is contained in:
31
components/spotify/cspot/bell/main/audio-dsp/Gain.cpp
Normal file
31
components/spotify/cspot/bell/main/audio-dsp/Gain.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "Gain.h"
|
||||
|
||||
using namespace bell;
|
||||
|
||||
Gain::Gain() : AudioTransform()
|
||||
{
|
||||
this->gainFactor = 1.0f;
|
||||
this->filterType = "gain";
|
||||
}
|
||||
|
||||
void Gain::configure(std::vector<int> channels, float gainDB)
|
||||
{
|
||||
this->channels = channels;
|
||||
this->gainDb = gainDB;
|
||||
this->gainFactor = std::pow(10.0f, gainDB / 20.0f);
|
||||
}
|
||||
|
||||
std::unique_ptr<StreamInfo> Gain::process(std::unique_ptr<StreamInfo> data)
|
||||
{
|
||||
std::scoped_lock lock(this->accessMutex);
|
||||
for (int i = 0; i < data->numSamples; i++)
|
||||
{
|
||||
// Apply gain to all channels
|
||||
for (auto &channel : channels)
|
||||
{
|
||||
data->data[channel][i] *= gainFactor;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
Reference in New Issue
Block a user