mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-11 22:17:17 +03:00
new cspot/bell
This commit is contained in:
@@ -1,47 +1,53 @@
|
||||
#include "AudioPipeline.h"
|
||||
#include <iostream>
|
||||
#include "BellLogger.h"
|
||||
|
||||
#include <type_traits> // for remove_extent_t
|
||||
#include <utility> // for move
|
||||
|
||||
#include "AudioTransform.h" // for AudioTransform
|
||||
#include "BellLogger.h" // for AbstractLogger, BELL_LOG
|
||||
#include "TransformConfig.h" // for TransformConfig
|
||||
|
||||
using namespace bell;
|
||||
|
||||
AudioPipeline::AudioPipeline() {
|
||||
AudioPipeline::AudioPipeline(){
|
||||
// this->headroomGainTransform = std::make_shared<Gain>(Channels::LEFT_RIGHT);
|
||||
// this->transforms.push_back(this->headroomGainTransform);
|
||||
};
|
||||
|
||||
void AudioPipeline::addTransform(std::shared_ptr<AudioTransform> transform) {
|
||||
transforms.push_back(transform);
|
||||
recalculateHeadroom();
|
||||
transforms.push_back(transform);
|
||||
recalculateHeadroom();
|
||||
}
|
||||
|
||||
void AudioPipeline::recalculateHeadroom() {
|
||||
float headroom = 0.0f;
|
||||
float headroom = 0.0f;
|
||||
|
||||
// Find largest headroom required by any transform down the chain, and apply it
|
||||
for (auto transform : transforms) {
|
||||
if (headroom < transform->calculateHeadroom()) {
|
||||
headroom = transform->calculateHeadroom();
|
||||
}
|
||||
// Find largest headroom required by any transform down the chain, and apply it
|
||||
for (auto transform : transforms) {
|
||||
if (headroom < transform->calculateHeadroom()) {
|
||||
headroom = transform->calculateHeadroom();
|
||||
}
|
||||
}
|
||||
|
||||
// headroomGainTransform->configure(-headroom);
|
||||
// headroomGainTransform->configure(-headroom);
|
||||
}
|
||||
|
||||
void AudioPipeline::volumeUpdated(int volume) {
|
||||
BELL_LOG(debug, "AudioPipeline", "Requested");
|
||||
std::scoped_lock lock(this->accessMutex);
|
||||
for (auto transform : transforms) {
|
||||
transform->config->currentVolume = volume;
|
||||
transform->reconfigure();
|
||||
}
|
||||
BELL_LOG(debug, "AudioPipeline", "Volume applied, DSP reconfigured");
|
||||
BELL_LOG(debug, "AudioPipeline", "Requested");
|
||||
std::scoped_lock lock(this->accessMutex);
|
||||
for (auto transform : transforms) {
|
||||
transform->config->currentVolume = volume;
|
||||
transform->reconfigure();
|
||||
}
|
||||
BELL_LOG(debug, "AudioPipeline", "Volume applied, DSP reconfigured");
|
||||
}
|
||||
|
||||
std::unique_ptr<StreamInfo> AudioPipeline::process(std::unique_ptr<StreamInfo> data) {
|
||||
std::scoped_lock lock(this->accessMutex);
|
||||
for (auto &transform : transforms) {
|
||||
data = transform->process(std::move(data));
|
||||
}
|
||||
std::unique_ptr<StreamInfo> AudioPipeline::process(
|
||||
std::unique_ptr<StreamInfo> data) {
|
||||
std::scoped_lock lock(this->accessMutex);
|
||||
for (auto& transform : transforms) {
|
||||
data = transform->process(std::move(data));
|
||||
}
|
||||
|
||||
return data;
|
||||
return data;
|
||||
}
|
||||
Reference in New Issue
Block a user