#include "CMLSReverb.h";

CMLSReverb::CMLSReverb()
{
    // Default parameters declaration
    this->reverbParams.dryLevel = 1.0f;
	this->reverbParams.wetLevel = 0.0f;
	this->reverbParams.roomSize = 0.0f;
	this->reverbParams.damping = 0.5f;
	this->reverbParams.width = 0.0f;

	this->reverb.setParameters(this->reverbParams);
}

CMLSReverb::~CMLSReverb() {}

void CMLSReverb::reset() {
	this->reverb.reset();
}

void CMLSReverb::prepare(const juce::dsp::ProcessSpec& spec) {
	this->reverb.setSampleRate(spec.sampleRate);
}

void CMLSReverb::process(const juce::dsp::ProcessContextReplacing<float>& context) {
	juce::dsp::AudioBlock<float> buffer = context.getOutputBlock();
	this->reverb.processStereo(buffer.getChannelPointer(0), buffer.getChannelPointer(1), buffer.getNumSamples());
}

void CMLSReverb::setDryWet(float value)
{
	// Set the dry/wet mix value
	this->reverbParams.wetLevel = value;
	this->reverbParams.dryLevel = 1.0f - value;
    this->reverb.setParameters(this->reverbParams);
}

void CMLSReverb::setRoomSize(float value)
{
	// Set the room size value
	this->reverbParams.roomSize = value;
    this->reverbParams.width = value / 2;
	this->reverb.setParameters(this->reverbParams);
}

const float CMLSReverb::getDryWet()
{
	// Get the dry/wet mix value
	return this->reverbParams.wetLevel;
}

const float CMLSReverb::getRoomSize()
{
	// Get the room size value
	return this->reverbParams.roomSize;
}