...
 
Commits (1)
......@@ -5,7 +5,6 @@
#pragma once
#include <ftz/Audio/Synth/SynthSettings.h>
#include <ftz/Audio/Effect/Pan.h>
#include <ftz/Audio/Effect/Amplifier.h>
#include <ftz/Audio/Effect/Clamper.h>
......@@ -99,8 +98,6 @@ protected:
void SampleRateChanged(Synth& synth, double new_sample_rate);
ftz::MIDI::InputChannel channel; ///< Holds the MIDI channel.
/// \brief Holds synth settings.
ftz::Audio::SynthSettings<typename PluginSettings::CalcType> settings;
/// \brief Holds the pan.
ftz::Audio::Pan<typename PluginSettings::SampleFormat> pan;
/// \brief Holds the amplifier.
......
......@@ -149,19 +149,19 @@ float PluginBaseTemplate<PluginSettings>::GetParameterValue(const Synth& synth,
}
case BaseParameterIndex::AttackTime:
{
return synth.GetEnvelopeSettings().GetAttackTime().count();
return synth.GetEnvelope().GetAttackTime().count();
}
case BaseParameterIndex::DecayTime:
{
return synth.GetEnvelopeSettings().GetDecayTime().count();
return synth.GetEnvelope().GetDecayTime().count();
}
case BaseParameterIndex::SustainLevel:
{
return synth.GetEnvelopeSettings().GetSustainLevel();
return synth.GetEnvelope().GetSustainLevel();
}
case BaseParameterIndex::ReleaseTime:
{
return synth.GetEnvelopeSettings().GetDecayTime().count();
return synth.GetEnvelope().GetDecayTime().count();
}
}
return 0.0f;
......@@ -191,33 +191,33 @@ void PluginBaseTemplate<PluginSettings>::SetParameterValue(Synth& synth,
}
case BaseParameterIndex::AttackTime:
{
auto envelope = synth.GetEnvelopeSettings();
auto envelope = synth.GetEnvelope();
envelope.SetAttackTime(ftz::Audio::TimeDuration<
typename PluginSettings::CalcType>{value});
synth.SetEnvelopeSettings(std::move(envelope));
synth.SetEnvelope(std::move(envelope));
return;
}
case BaseParameterIndex::DecayTime:
{
auto envelope = synth.GetEnvelopeSettings();
auto envelope = synth.GetEnvelope();
envelope.SetDecayTime(ftz::Audio::TimeDuration<
typename PluginSettings::CalcType>{value});
synth.SetEnvelopeSettings(std::move(envelope));
synth.SetEnvelope(std::move(envelope));
return;
}
case BaseParameterIndex::SustainLevel:
{
auto envelope = synth.GetEnvelopeSettings();
auto envelope = synth.GetEnvelope();
envelope.SetSustainLevel(value);
synth.SetEnvelopeSettings(std::move(envelope));
synth.SetEnvelope(std::move(envelope));
return;
}
case BaseParameterIndex::ReleaseTime:
{
auto envelope = synth.GetEnvelopeSettings();
auto envelope = synth.GetEnvelope();
envelope.SetReleaseTime(ftz::Audio::TimeDuration<
typename PluginSettings::CalcType>{value});
synth.SetEnvelopeSettings(std::move(envelope));
synth.SetEnvelope(std::move(envelope));
return;
}
}
......@@ -254,13 +254,7 @@ template <typename PluginSettings> template <typename Synth>
void PluginBaseTemplate<PluginSettings>::SampleRateChanged(Synth& synth,
double new_sample_rate)
{
settings.SetSampleRate(new_sample_rate);
auto generator_settings = synth.GetGeneratorSettings();
generator_settings.SetSampleRate(new_sample_rate);
synth.SetGeneratorSettings(std::move(generator_settings));
auto envelope = synth.GetEnvelopeSettings();
envelope.SetSampleRate(new_sample_rate);
synth.SetEnvelopeSettings(std::move(envelope));
synth.SetSampleRate(new_sample_rate);
}
}
......@@ -34,8 +34,8 @@ class PulsePluginTemplate : public PluginBaseTemplate<PluginSettings>
{
public:
/// \brief Constructor.
/// \param[in] settings Settings of the generator.
PulsePluginTemplate(typename Generator::Settings generator_settings);
/// \param[in] generator Generator to use.
PulsePluginTemplate(Generator generator);
protected:
/// \brief Initializes plugin parameter.
/// \param[in] index Index of the parameter.
......
......@@ -53,9 +53,9 @@ inline BaseParameterIndex ToBaseParameterIndex(std::uint32_t index)
template <typename Generator, typename PluginSettings>
PulsePluginTemplate<Generator, PluginSettings>::PulsePluginTemplate(
typename Generator::Settings generator_settings)
Generator generator)
: PluginBaseTemplate<PluginSettings>{NumParameters},
synth{this->settings, this->channel, generator_settings, {}}
synth{{}, {}, this->channel, std::move(generator), {}}
{
this->effects.insert(std::begin(this->effects), synth);
}
......
......@@ -22,8 +22,8 @@ class SimplePluginTemplate : public PluginBaseTemplate<PluginSettings>
{
public:
/// \brief Constructor.
/// \param[in] settings Settings of the generator.
SimplePluginTemplate(typename Generator::Settings generator_settings);
/// \param[in] generator Generator to use.
SimplePluginTemplate(Generator generator);
protected:
/// \brief Initializes plugin parameter.
/// \param[in] index Index of the parameter.
......
......@@ -13,9 +13,9 @@ const std::uint32_t NumParameters = 7;
template <typename Generator, typename PluginSettings>
SimplePluginTemplate<Generator, PluginSettings>::SimplePluginTemplate(
typename Generator::Settings generator_settings)
Generator generator)
: PluginBaseTemplate<PluginSettings>{NumParameters},
synth{this->settings, this->channel, generator_settings}
synth{{}, {}, this->channel, std::move(generator)}
{
this->effects.insert(std::begin(this->effects), synth);
}
......
......@@ -24,7 +24,7 @@ enum class ParameterIndex
NoisePlugin::NoisePlugin()
: Plugin{NumParameters, 0, 0},
synth{settings, channel, {{}, this->getSampleRate()},
synth{this->getSampleRate(), {}, channel, {{}, this->getSampleRate()},
{this->getSampleRate()}},
amp{AliasedSettings::DefaultGain}
{
......@@ -158,19 +158,19 @@ float NoisePlugin::getParameterValue(std::uint32_t index) const
}
case ParameterIndex::AttackTime:
{
return synth.GetEnvelopeSettings().GetAttackTime().count();
return synth.GetEnvelope().GetAttackTime().count();
}
case ParameterIndex::DecayTime:
{
return synth.GetEnvelopeSettings().GetDecayTime().count();
return synth.GetEnvelope().GetDecayTime().count();
}
case ParameterIndex::SustainLevel:
{
return synth.GetEnvelopeSettings().GetSustainLevel();
return synth.GetEnvelope().GetSustainLevel();
}
case ParameterIndex::ReleaseTime:
{
return synth.GetEnvelopeSettings().GetDecayTime().count();
return synth.GetEnvelope().GetDecayTime().count();
}
}
return 0.0f;
......@@ -192,33 +192,33 @@ void NoisePlugin::setParameterValue(std::uint32_t index, float value)
}
case ParameterIndex::AttackTime:
{
auto envelope = synth.GetEnvelopeSettings();
auto envelope = synth.GetEnvelope();
envelope.SetAttackTime(
ftz::Audio::TimeDuration<AliasedSettings::CalcType>{value});
synth.SetEnvelopeSettings(std::move(envelope));
synth.SetEnvelope(std::move(envelope));
return;
}
case ParameterIndex::DecayTime:
{
auto envelope = synth.GetEnvelopeSettings();
auto envelope = synth.GetEnvelope();
envelope.SetDecayTime(
ftz::Audio::TimeDuration<AliasedSettings::CalcType>{value});
synth.SetEnvelopeSettings(std::move(envelope));
synth.SetEnvelope(std::move(envelope));
return;
}
case ParameterIndex::SustainLevel:
{
auto envelope = synth.GetEnvelopeSettings();
auto envelope = synth.GetEnvelope();
envelope.SetSustainLevel(value);
synth.SetEnvelopeSettings(std::move(envelope));
synth.SetEnvelope(std::move(envelope));
return;
}
case ParameterIndex::ReleaseTime:
{
auto envelope = synth.GetEnvelopeSettings();
auto envelope = synth.GetEnvelope();
envelope.SetReleaseTime(
ftz::Audio::TimeDuration<AliasedSettings::CalcType>{value});
synth.SetEnvelopeSettings(std::move(envelope));
synth.SetEnvelope(std::move(envelope));
return;
}
}
......@@ -250,13 +250,7 @@ void NoisePlugin::run(const float**, float** outputs, std::uint32_t frames,
void NoisePlugin::sampleRateChanged(double new_sample_rate)
{
settings.SetSampleRate(new_sample_rate);
auto generator_settings = synth.GetGeneratorSettings();
generator_settings.SetSampleRate(new_sample_rate);
synth.SetGeneratorSettings(std::move(generator_settings));
auto envelope = synth.GetEnvelopeSettings();
envelope.SetSampleRate(new_sample_rate);
synth.SetEnvelopeSettings(std::move(envelope));
synth.SetSampleRate(new_sample_rate);
}
Plugin* createPlugin()
......
......@@ -5,7 +5,6 @@
#pragma once
#include <ftz/Audio/Synth/SynthSettings.h>
#include <ftz/Audio/Oscillator/WhiteNoise.h>
#include <ftz/Audio/Generator/OscillatorGenerator.h>
#include <ftz/Audio/Generator/EnvelopeSettings.h>
......@@ -97,7 +96,6 @@ private:
ftz::Audio::WhiteNoise<AliasedSettings::CalcType>>,
AliasedSettings::SampleFormat>;
ftz::MIDI::InputChannel channel; ///< Holds the MIDI channel.
ftz::Audio::SynthSettings<AliasedSettings::CalcType> settings;
Synth synth; ///< Holds the synth.
ftz::Audio::Pan<AliasedSettings::SampleFormat> pan; ///< Holds the pan.
/// \brief Holds the amplifier.
......
......@@ -45,7 +45,7 @@ float AliasedPulsePlugin::getParameterValue(std::uint32_t index) const
ftz::Audio::PulseWave<AliasedSettings::CalcType>>,
AliasedSettings>::getParameterValue(index);
}
return synth.GetGeneratorSettings().GetOscillator().GetDutyCycle();
return synth.GetGenerator().GetOscillator().GetDutyCycle();
}
void AliasedPulsePlugin::setParameterValue(std::uint32_t index, float value)
......@@ -58,9 +58,9 @@ void AliasedPulsePlugin::setParameterValue(std::uint32_t index, float value)
AliasedSettings>::setParameterValue(index, value);
return;
}
auto generator_settings = synth.GetGeneratorSettings();
generator_settings.GetOscillator().SetDutyCycle(value);
synth.SetGeneratorSettings(std::move(generator_settings));
auto generator = synth.GetGenerator();
generator.GetOscillator().SetDutyCycle(value);
synth.SetGenerator(std::move(generator));
}
Plugin* createPlugin()
......
......@@ -45,7 +45,7 @@ float BandlimitedPulsePlugin::getParameterValue(std::uint32_t index) const
BandlimitedSettings::CalcType>, BandlimitedSettings>::
getParameterValue(index);
}
return synth.GetGeneratorSettings().GetDutyCycle();
return synth.GetGenerator().GetDutyCycle();
}
void BandlimitedPulsePlugin::setParameterValue(std::uint32_t index, float value)
......@@ -58,9 +58,9 @@ void BandlimitedPulsePlugin::setParameterValue(std::uint32_t index, float value)
setParameterValue(index, value);
return;
}
auto generator_settings = synth.GetGeneratorSettings();
generator_settings.SetDutyCycle(value);
synth.SetGeneratorSettings(std::move(generator_settings));
auto generator = synth.GetGenerator();
generator.SetDutyCycle(value);
synth.SetGenerator(std::move(generator));
}
Plugin* createPlugin()
......
......@@ -70,10 +70,12 @@ OpenCLPulsePlugin::OpenCLPulsePlugin()
cl::Platform::get(&platforms);
std::vector<cl::Device> devices;
platforms[0].getDevices(CL_DEVICE_TYPE_GPU, &devices);
synth.emplace(settings, channel,
ftz::Audio::OpenCL::BandlimitedPulseWave<OpenCLSettings::CalcType>::
Settings{{}, devices[0]},
ftz::Audio::Envelope<OpenCLSettings::CalcType>::Settings{});
synth.emplace(ftz::Audio::SampleRate<OpenCLSettings::CalcType>{},
ftz::Audio::NoteFrequencies<OpenCLSettings::CalcType>{},
channel,
ftz::Audio::OpenCL::BandlimitedPulseWave<OpenCLSettings::CalcType>{{},
devices[0]},
ftz::Audio::Envelope<OpenCLSettings::CalcType>{});
effects.insert(std::begin(effects), *synth);
}
......@@ -122,7 +124,7 @@ float OpenCLPulsePlugin::getParameterValue(std::uint32_t index) const
{
return this->GetParameterValue(*synth, ToBaseParameterIndex(index));
}
return synth->GetGeneratorSettings().GetDutyCycle();
return synth->GetGenerator().GetDutyCycle();
}
void OpenCLPulsePlugin::setParameterValue(std::uint32_t index, float value)
......@@ -133,9 +135,9 @@ void OpenCLPulsePlugin::setParameterValue(std::uint32_t index, float value)
this->SetParameterValue(*synth, ToBaseParameterIndex(index), value);
return;
}
auto generator_settings = synth->GetGeneratorSettings();
generator_settings.SetDutyCycle(value);
synth->SetGeneratorSettings(std::move(generator_settings));
auto generator = synth->GetGenerator();
generator.SetDutyCycle(value);
synth->SetGenerator(std::move(generator));
}
void OpenCLPulsePlugin::sampleRateChanged(double new_sample_rate)
......
......@@ -11,9 +11,11 @@ namespace DISTRHO
OpenCLSawtoothPlugin::OpenCLSawtoothPlugin()
{
this->synth.emplace(this->settings, this->channel,
ftz::Audio::OpenCL::BandlimitedSawtoothWave<OpenCLSettings::CalcType>::
Settings{{}, this->device});
this->synth.emplace(ftz::Audio::SampleRate<OpenCLSettings::CalcType>{},
ftz::Audio::NoteFrequencies<OpenCLSettings::CalcType>{},
this->channel,
ftz::Audio::OpenCL::BandlimitedSawtoothWave<OpenCLSettings::CalcType>{
{}, this->device});
this->effects.insert(std::begin(this->effects), *this->synth);
}
......
......@@ -11,9 +11,11 @@ namespace DISTRHO
OpenCLTrianglePlugin::OpenCLTrianglePlugin()
{
this->synth.emplace(this->settings, this->channel,
ftz::Audio::OpenCL::BandlimitedTriangleWave<OpenCLSettings::CalcType>::
Settings{{}, this->device});
this->synth.emplace(ftz::Audio::SampleRate<OpenCLSettings::CalcType>{},
ftz::Audio::NoteFrequencies<OpenCLSettings::CalcType>{},
this->channel,
ftz::Audio::OpenCL::BandlimitedTriangleWave<OpenCLSettings::CalcType>{
{}, this->device});
this->effects.insert(std::begin(this->effects), *this->synth);
}
......