Reverberation

This commit is contained in:
Martmists 2021-07-28 00:54:15 +02:00
parent 3765ce1b7b
commit f7cdd16376
5 changed files with 120 additions and 1 deletions

View File

@ -20,6 +20,7 @@ set(FILES
# Effects
src/effects/Cure.cpp
src/effects/Reverberation.cpp
src/effects/TubeSimulator.cpp
# Utils

View File

@ -0,0 +1,70 @@
//
// Created by mart on 7/28/21.
//
#include "Reverberation.h"
#include "../constants.h"
Reverberation::Reverberation() {
this->roomsize = 0.f;
this->width = 0.f;
this->damp = 0.f;
this->wet = 0.f;
this->dry = 0.5f;
this->model.SetRoomSize(0.f);
this->model.SetWidth(0.f);
this->model.SetDamp(0.f);
this->model.SetWet(0.f);
this->model.SetDry(0.5f);
this->samplerate = DEFAULT_SAMPLERATE;
this->enabled = false;
}
void Reverberation::Reset() {
this->model.Reset();
}
void Reverberation::Process(float *buffer, uint32_t size) {
if (this->enabled) {
this->model.ProcessReplace(buffer, &buffer[1], size);
}
}
void Reverberation::SetEnable(bool enable) {
if (!this->enabled && enable) {
Reset();
}
this->enabled = enable;
}
void Reverberation::SetRoomSize(float value) {
this->roomsize = value;
this->model.SetRoomSize(value);
}
void Reverberation::SetDamp(float value) {
this->damp = value;
this->model.SetDamp(value);
}
void Reverberation::SetWet(float value) {
this->wet = value;
this->model.SetWet(value);
}
void Reverberation::SetDry(float value) {
this->dry = value;
this->model.SetDry(value);
}
void Reverberation::SetWidth(float value) {
this->width = value;
this->model.SetWidth(value);
}
void Reverberation::SetSamplingRate(uint32_t value) {
this->samplerate = value;
this->model.Reset();
}

View File

@ -0,0 +1,35 @@
//
// Created by mart on 7/28/21.
//
#pragma once
#include "../utils/CRevModel.h"
class Reverberation {
public:
Reverberation();
void Reset();
void Process(float* buffer, uint32_t size);
void SetEnable(bool enable);
void SetRoomSize(float value);
void SetDamp(float value);
void SetWet(float value);
void SetDry(float value);
void SetWidth(float value);
void SetSamplingRate(uint32_t value);
float roomsize;
float width;
float damp;
float wet;
float dry;
CRevModel model;
uint32_t samplerate;
bool enabled;
};

View File

@ -144,6 +144,18 @@ void CRevModel::UpdateCoeffs() {
}
}
void CRevModel::Reset() {
for (int i=0; i<8; i++) {
combL[i].Mute();
combR[i].Mute();
}
for(int i=0; i<4; i++) {
allpassL[i].Mute();
allpassR[i].Mute();
}
}
void CRevModel::SetRoomSize(float value) {
roomsize = (value*0.28f) + 0.7f;
UpdateCoeffs();
@ -193,7 +205,7 @@ float CRevModel::GetWidth() {
return width;
}
float CRevModel::GetMode() {
int CRevModel::GetMode() {
if (mode == 1) {
return 1.f;
} else {

View File

@ -15,6 +15,7 @@ public:
void Mute();
void ProcessReplace(float *bufL, float *bufR, uint32_t size);
void UpdateCoeffs();
void Reset();
void SetRoomSize(float value);
void SetDamp(float value);