mirror of
https://github.com/AndroidAudioMods/ViPERFX_RE.git
synced 2025-06-08 02:29:40 +08:00
Reverberation
This commit is contained in:
parent
3765ce1b7b
commit
f7cdd16376
@ -20,6 +20,7 @@ set(FILES
|
||||
|
||||
# Effects
|
||||
src/effects/Cure.cpp
|
||||
src/effects/Reverberation.cpp
|
||||
src/effects/TubeSimulator.cpp
|
||||
|
||||
# Utils
|
||||
|
70
src/effects/Reverberation.cpp
Normal file
70
src/effects/Reverberation.cpp
Normal 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();
|
||||
}
|
35
src/effects/Reverberation.h
Normal file
35
src/effects/Reverberation.h
Normal 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;
|
||||
};
|
||||
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user