Commit 902bc617 by Lyberta

Fixed wrappers.

parent 067e94e6
......@@ -16,17 +16,17 @@ ifeq ($(HAVE_DGL),true)
endif
plugins: libs
#$(MAKE) all -C Src/DPF_Sine
#$(MAKE) all -C Src/DPF_PulseAliased
#$(MAKE) all -C Src/DPF_TriangleAliased
#$(MAKE) all -C Src/DPF_SawtoothAliased
#$(MAKE) all -C Src/DPF_Noise
$(MAKE) all -C Src/DPF_Sine
$(MAKE) all -C Src/DPF_PulseAliased
$(MAKE) all -C Src/DPF_TriangleAliased
$(MAKE) all -C Src/DPF_SawtoothAliased
$(MAKE) all -C Src/DPF_Noise
#$(MAKE) all -C Src/DPF_PulseBandlimited
#$(MAKE) all -C Src/DPF_TriangleBandlimited
$(MAKE) all -C Src/DPF_TriangleBandlimited
$(MAKE) all -C Src/DPF_SawtoothBandlimited
#$(MAKE) all -C Src/DPF_PulseOpenCL
#$(MAKE) all -C Src/DPF_TriangleOpenCL
#$(MAKE) all -C Src/DPF_SawtoothOpenCL
$(MAKE) all -C Src/DPF_TriangleOpenCL
$(MAKE) all -C Src/DPF_SawtoothOpenCL
#$(MAKE) all -C Src/DPF_Multi
#$(MAKE) all -C Src/DPF_Multi16
......
......@@ -26,7 +26,7 @@ NoisePlugin::NoisePlugin()
: Plugin{NumParameters, 0, 0},
synth{settings, channel, {{}, this->getSampleRate()},
{this->getSampleRate()}},
amp{DefaultGain}
amp{AliasedSettings::DefaultGain}
{
effects.PushBack(synth);
effects.PushBack(pan);
......@@ -85,7 +85,7 @@ void NoisePlugin::initParameter(std::uint32_t index, Parameter& parameter)
parameter.symbol = "master_volume";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
parameter.ranges.def = DefaultGain.GetValue();
parameter.ranges.def = AliasedSettings::DefaultGain.GetValue();
return;
}
case ParameterIndex::Pan:
......@@ -105,7 +105,7 @@ void NoisePlugin::initParameter(std::uint32_t index, Parameter& parameter)
parameter.symbol = "decay_time";
parameter.unit = "seconds";
parameter.ranges.min = 0.0f;
parameter.ranges.max = MaxAttackTime.count();
parameter.ranges.max = AliasedSettings::MaxAttackTime.count();
parameter.ranges.def = 0.0f;
return;
}
......@@ -116,7 +116,7 @@ void NoisePlugin::initParameter(std::uint32_t index, Parameter& parameter)
parameter.symbol = "decay_time";
parameter.unit = "seconds";
parameter.ranges.min = 0.0f;
parameter.ranges.max = MaxDecayTime.count();
parameter.ranges.max = AliasedSettings::MaxDecayTime.count();
parameter.ranges.def = 0.0f;
return;
}
......@@ -137,7 +137,7 @@ void NoisePlugin::initParameter(std::uint32_t index, Parameter& parameter)
parameter.symbol = "release_time";
parameter.unit = "seconds";
parameter.ranges.min = 0.0f;
parameter.ranges.max = MaxReleaseTime.count();
parameter.ranges.max = AliasedSettings::MaxReleaseTime.count();
parameter.ranges.def = 0.0f;
return;
}
......@@ -182,7 +182,7 @@ void NoisePlugin::setParameterValue(std::uint32_t index, float value)
{
case ParameterIndex::MasterVolume:
{
amp.SetGain(ftz::Audio::Gain<CalcType>{value});
amp.SetGain(ftz::Audio::Gain<AliasedSettings::CalcType>{value});
return;
}
case ParameterIndex::Pan:
......@@ -193,14 +193,16 @@ void NoisePlugin::setParameterValue(std::uint32_t index, float value)
case ParameterIndex::AttackTime:
{
auto envelope = synth.GetEnvelopeSettings();
envelope.SetAttackTime(ftz::Audio::TimeDuration<CalcType>{value});
envelope.SetAttackTime(
ftz::Audio::TimeDuration<AliasedSettings::CalcType>{value});
synth.SetEnvelopeSettings(std::move(envelope));
return;
}
case ParameterIndex::DecayTime:
{
auto envelope = synth.GetEnvelopeSettings();
envelope.SetDecayTime(ftz::Audio::TimeDuration<CalcType>{value});
envelope.SetDecayTime(
ftz::Audio::TimeDuration<AliasedSettings::CalcType>{value});
synth.SetEnvelopeSettings(std::move(envelope));
return;
}
......@@ -214,7 +216,8 @@ void NoisePlugin::setParameterValue(std::uint32_t index, float value)
case ParameterIndex::ReleaseTime:
{
auto envelope = synth.GetEnvelopeSettings();
envelope.SetReleaseTime(ftz::Audio::TimeDuration<CalcType>{value});
envelope.SetReleaseTime(
ftz::Audio::TimeDuration<AliasedSettings::CalcType>{value});
synth.SetEnvelopeSettings(std::move(envelope));
return;
}
......@@ -236,8 +239,8 @@ void NoisePlugin::activate()
void NoisePlugin::run(const float**, float** outputs, std::uint32_t frames,
const MidiEvent* midiEvents, std::uint32_t midiEventCount)
{
ftz::Audio::MultichannelAudioBufferReference<SampleFormat> buffer{outputs,
2, frames};
ftz::Audio::MultichannelAudioBufferReference<
AliasedSettings::SampleFormat> buffer{outputs, 2, frames};
auto first = std::begin(buffer);
decltype(first) last;
for (std::uint32_t i = 0; i < midiEventCount; ++i)
......
......@@ -5,10 +5,17 @@
#pragma once
#include <ftz/Audio/SynthSettings.h>
#include <ftz/Audio/WhiteNoise.h>
#include <ftz/Audio/OscillatorGenerator.h>
#include <ftz/Audio/EnvelopeSettings.h>
#include <ftz/Audio/PolyphonicSynth.h>
#include <ftz/Audio/Pan.h>
#include <ftz/Audio/Amplifier.h>
#include <ftz/Audio/Clamper.h>
#include <ftz/Audio/EffectChain.h>
#include "../DPF/PluginTemplate.h"
#include "../DPF/Config.h"
namespace DISTRHO
{
......@@ -16,8 +23,7 @@ namespace DISTRHO
/// \brief A noise synth plugin.
/// \details This is a DPF wrapper of the noise synth.
class NoisePlugin final : public PluginTemplate<ftz::Audio::OscillatorGenerator<
ftz::Audio::TriangleWave<AliasedSettings::CalcType>>, AliasedSettings>
class NoisePlugin final : public Plugin
{
public:
/// \brief Constructor.
......@@ -35,9 +41,76 @@ protected:
/// \return Plugin description.
const char* getDescription() const override;
/// \brief Returns plugin author.
/// \return Plugin author.
const char* getMaker() const override;
/// \brief Returns plugin home page.
/// \return Plugin home page.
const char* getHomePage() const override;
/// \brief Returns plugin license.
/// \return Plugin license.
const char* getLicense() const override;
/// \brief Returns plugin version.
/// \return Plugin version.
std::uint32_t getVersion() const override;
/// \brief Returns plugin unique id.
/// \return Plugin unique id.
std::int64_t getUniqueId() const override;
/// \brief Initializes plugin parameter.
/// \param[in] index Index of the parameter.
/// \param[out] parameter Parameter info.
/// \return No return.
void initParameter(std::uint32_t index, Parameter& parameter) override;
/// \brief Returns the value of the plugin parameter.
/// \param[in] index Index of the parameter.
/// \return Parameter value.
float getParameterValue(std::uint32_t index) const override;
/// \brief Sets the value of the plugin parameter.
/// \param[in] index Index of the parameter.
/// \param[in] value Value to set.
/// \return No return.
void setParameterValue(std::uint32_t index, float value) override;
/// \brief Activates the plugin.
/// \return No return.
void activate() override;
/// \brief Processes MIDI input and renders audio.
/// \param[out] outputs Array of output channels.
/// \param[in] frames Number of frames to process.
/// \param[in] midiEvents MIDI events to process.
/// \param[in] midiEventCount Number of MIDI events to process.
/// \return No return.
void run(const float**, float** outputs, std::uint32_t frames,
const MidiEvent* midiEvents, std::uint32_t midiEventCount)
override;
/// \brief Called when sample rate has changed.
/// \param[in] newSampleRate Sample rate to set.
/// \return No return.
void sampleRateChanged(double newSampleRate) override;
private:
/// \brief Type of the synth.
using Synth = ftz::Audio::PolyphonicSynth<ftz::Audio::OscillatorGenerator<
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.
ftz::Audio::Amplifier<AliasedSettings::SampleFormat> amp;
/// \brief Holds the clamper.
ftz::Audio::Clamper<AliasedSettings::SampleFormat> clamp;
/// \brief Holds the effect chain.
ftz::Audio::EffectChain<AliasedSettings::SampleFormat> effects;
};
}
......@@ -29,7 +29,7 @@ AliasedPulsePlugin::AliasedPulsePlugin()
: Plugin{NumParameters, 0, 0},
synth{settings, channel, {{}, this->getSampleRate()},
{this->getSampleRate()}},
amp{DefaultGain}
amp{AliasedSettings::DefaultGain}
{
effects.PushBack(synth);
effects.PushBack(pan);
......@@ -89,7 +89,7 @@ void AliasedPulsePlugin::initParameter(std::uint32_t index,
parameter.symbol = "master_volume";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
parameter.ranges.def = DefaultGain.GetValue();
parameter.ranges.def = AliasedSettings::DefaultGain.GetValue();
return;
}
case ParameterIndex::Pan:
......@@ -108,7 +108,7 @@ void AliasedPulsePlugin::initParameter(std::uint32_t index,
parameter.name = "Pitch bend range";
parameter.symbol = "pitch_bend_range";
parameter.ranges.min = 0.0f;
parameter.ranges.max = MaxPitchBend;
parameter.ranges.max = AliasedSettings::MaxPitchBend;
parameter.ranges.def = Synth::DefaultPitchBendRange;
return;
}
......@@ -119,8 +119,8 @@ void AliasedPulsePlugin::initParameter(std::uint32_t index,
parameter.symbol = "duty_cycle";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
parameter.ranges.def =
ftz::Audio::PulseWave<CalcType>::DefaultDutyCycle;
parameter.ranges.def = ftz::Audio::PulseWave<
AliasedSettings::CalcType>::DefaultDutyCycle;
return;
}
case ParameterIndex::AttackTime:
......@@ -130,7 +130,7 @@ void AliasedPulsePlugin::initParameter(std::uint32_t index,
parameter.symbol = "decay_time";
parameter.unit = "seconds";
parameter.ranges.min = 0.0f;
parameter.ranges.max = MaxAttackTime.count();
parameter.ranges.max = AliasedSettings::MaxAttackTime.count();
parameter.ranges.def = 0.0f;
return;
}
......@@ -141,7 +141,7 @@ void AliasedPulsePlugin::initParameter(std::uint32_t index,
parameter.symbol = "decay_time";
parameter.unit = "seconds";
parameter.ranges.min = 0.0f;
parameter.ranges.max = MaxDecayTime.count();
parameter.ranges.max = AliasedSettings::MaxDecayTime.count();
parameter.ranges.def = 0.0f;
return;
}
......@@ -162,7 +162,7 @@ void AliasedPulsePlugin::initParameter(std::uint32_t index,
parameter.symbol = "release_time";
parameter.unit = "seconds";
parameter.ranges.min = 0.0f;
parameter.ranges.max = MaxReleaseTime.count();
parameter.ranges.max = AliasedSettings::MaxReleaseTime.count();
parameter.ranges.def = 0.0f;
return;
}
......@@ -215,7 +215,7 @@ void AliasedPulsePlugin::setParameterValue(std::uint32_t index, float value)
{
case ParameterIndex::MasterVolume:
{
amp.SetGain(ftz::Audio::Gain<CalcType>{value});
amp.SetGain(ftz::Audio::Gain<AliasedSettings::CalcType>{value});
return;
}
case ParameterIndex::Pan:
......@@ -238,14 +238,16 @@ void AliasedPulsePlugin::setParameterValue(std::uint32_t index, float value)
case ParameterIndex::AttackTime:
{
auto envelope = synth.GetEnvelopeSettings();
envelope.SetAttackTime(ftz::Audio::TimeDuration<CalcType>{value});
envelope.SetAttackTime(
ftz::Audio::TimeDuration<AliasedSettings::CalcType>{value});
synth.SetEnvelopeSettings(std::move(envelope));
return;
}
case ParameterIndex::DecayTime:
{
auto envelope = synth.GetEnvelopeSettings();
envelope.SetDecayTime(ftz::Audio::TimeDuration<CalcType>{value});
envelope.SetDecayTime(
ftz::Audio::TimeDuration<AliasedSettings::CalcType>{value});
synth.SetEnvelopeSettings(std::move(envelope));
return;
}
......@@ -259,7 +261,8 @@ void AliasedPulsePlugin::setParameterValue(std::uint32_t index, float value)
case ParameterIndex::ReleaseTime:
{
auto envelope = synth.GetEnvelopeSettings();
envelope.SetReleaseTime(ftz::Audio::TimeDuration<CalcType>{value});
envelope.SetReleaseTime(
ftz::Audio::TimeDuration<AliasedSettings::CalcType>{value});
synth.SetEnvelopeSettings(std::move(envelope));
return;
}
......@@ -282,8 +285,8 @@ void AliasedPulsePlugin::run(const float**, float** outputs,
std::uint32_t frames, const MidiEvent* midiEvents,
std::uint32_t midiEventCount)
{
ftz::Audio::MultichannelAudioBufferReference<SampleFormat> buffer{outputs,
2, frames};
ftz::Audio::MultichannelAudioBufferReference<
AliasedSettings::SampleFormat> buffer{outputs, 2, frames};
auto first = std::begin(buffer);
decltype(first) last;
for (std::uint32_t i = 0; i < midiEventCount; ++i)
......
......@@ -99,14 +99,19 @@ protected:
private:
/// \brief Type of the synth.
using Synth = ftz::Audio::PolyphonicSynth<ftz::Audio::OscillatorGenerator<
ftz::Audio::PulseWave<CalcType>>, SampleFormat>;
ftz::Audio::PulseWave<AliasedSettings::CalcType>>,
AliasedSettings::SampleFormat>;
ftz::MIDI::InputChannel channel; ///< Holds the MIDI channel.
ftz::Audio::SynthSettings<CalcType> settings; ///< Holds synth settings.
/// \brief Holds synth settings.
ftz::Audio::SynthSettings<AliasedSettings::CalcType> settings;
Synth synth; ///< Holds the synth.
ftz::Audio::Pan<SampleFormat> pan; ///< Holds the pan.
ftz::Audio::Amplifier<SampleFormat> amp; ///< Holds the amplifier.
ftz::Audio::Clamper<SampleFormat> clamp; ///< Holds the clamper.
ftz::Audio::EffectChain<SampleFormat> effects; ///< Holds the effect chain.
ftz::Audio::Pan<AliasedSettings::SampleFormat> pan; ///< Holds the pan.
/// \brief Holds the amplifier.
ftz::Audio::Amplifier<AliasedSettings::SampleFormat> amp;
/// \brief Holds the clamper.
ftz::Audio::Clamper<AliasedSettings::SampleFormat> clamp;
/// \brief Holds the effect chain.
ftz::Audio::EffectChain<AliasedSettings::SampleFormat> effects;
};
}
......@@ -26,16 +26,17 @@ enum class ParameterIndex
OpenCLSawtoothPlugin::OpenCLSawtoothPlugin()
: Plugin{NumParameters, 0, 0},
amp{DefaultGain}
amp{OpenCLSettings::DefaultGain}
{
std::vector<cl::Platform> platforms;
cl::Platform::get(&platforms);
std::vector<cl::Device> devices;
platforms[0].getDevices(CL_DEVICE_TYPE_GPU, &devices);
synth = std::make_unique<Synth>(settings, channel,
ftz::Audio::OpenCL::BandlimitedSawtoothWave<CalcType>::Settings{
this->getSampleRate(), devices[0]},
ftz::Audio::Envelope<CalcType>::Settings{this->getSampleRate()});
synth.emplace(settings, channel,
ftz::Audio::OpenCL::BandlimitedSawtoothWave<OpenCLSettings::CalcType>::
Settings{this->getSampleRate(), devices[0]},
ftz::Audio::Envelope<OpenCLSettings::CalcType>::Settings{
this->getSampleRate()});
effects.PushBack(*synth);
effects.PushBack(pan);
effects.PushBack(amp);
......@@ -94,7 +95,7 @@ void OpenCLSawtoothPlugin::initParameter(std::uint32_t index,
parameter.symbol = "master_volume";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
parameter.ranges.def = DefaultGain.GetValue();
parameter.ranges.def = OpenCLSettings::DefaultGain.GetValue();
return;
}
case ParameterIndex::Pan:
......@@ -113,7 +114,7 @@ void OpenCLSawtoothPlugin::initParameter(std::uint32_t index,
parameter.name = "Pitch bend range";
parameter.symbol = "pitch_bend_range";
parameter.ranges.min = 0.0f;
parameter.ranges.max = MaxPitchBend;
parameter.ranges.max = OpenCLSettings::MaxPitchBend;
parameter.ranges.def = Synth::DefaultPitchBendRange;
return;
}
......@@ -124,7 +125,7 @@ void OpenCLSawtoothPlugin::initParameter(std::uint32_t index,
parameter.symbol = "decay_time";
parameter.unit = "seconds";
parameter.ranges.min = 0.0f;
parameter.ranges.max = MaxAttackTime.count();
parameter.ranges.max = OpenCLSettings::MaxAttackTime.count();
parameter.ranges.def = 0.0f;
return;
}
......@@ -135,7 +136,7 @@ void OpenCLSawtoothPlugin::initParameter(std::uint32_t index,
parameter.symbol = "decay_time";
parameter.unit = "seconds";
parameter.ranges.min = 0.0f;
parameter.ranges.max = MaxDecayTime.count();
parameter.ranges.max = OpenCLSettings::MaxDecayTime.count();
parameter.ranges.def = 0.0f;
return;
}
......@@ -156,7 +157,7 @@ void OpenCLSawtoothPlugin::initParameter(std::uint32_t index,
parameter.symbol = "release_time";
parameter.unit = "seconds";
parameter.ranges.min = 0.0f;
parameter.ranges.max = MaxReleaseTime.count();
parameter.ranges.max = OpenCLSettings::MaxReleaseTime.count();
parameter.ranges.def = 0.0f;
return;
}
......@@ -205,7 +206,7 @@ void OpenCLSawtoothPlugin::setParameterValue(std::uint32_t index, float value)
{
case ParameterIndex::MasterVolume:
{
amp.SetGain(ftz::Audio::Gain<CalcType>{value});
amp.SetGain(ftz::Audio::Gain<OpenCLSettings::CalcType>{value});
return;
}
case ParameterIndex::Pan:
......@@ -221,14 +222,16 @@ void OpenCLSawtoothPlugin::setParameterValue(std::uint32_t index, float value)
case ParameterIndex::AttackTime:
{
auto envelope = synth->GetEnvelopeSettings();
envelope.SetAttackTime(ftz::Audio::TimeDuration<CalcType>{value});
envelope.SetAttackTime(
ftz::Audio::TimeDuration<OpenCLSettings::CalcType>{value});
synth->SetEnvelopeSettings(std::move(envelope));
return;
}
case ParameterIndex::DecayTime:
{
auto envelope = synth->GetEnvelopeSettings();
envelope.SetDecayTime(ftz::Audio::TimeDuration<CalcType>{value});
envelope.SetDecayTime(
ftz::Audio::TimeDuration<OpenCLSettings::CalcType>{value});
synth->SetEnvelopeSettings(std::move(envelope));
return;
}
......@@ -242,7 +245,8 @@ void OpenCLSawtoothPlugin::setParameterValue(std::uint32_t index, float value)
case ParameterIndex::ReleaseTime:
{
auto envelope = synth->GetEnvelopeSettings();
envelope.SetReleaseTime(ftz::Audio::TimeDuration<CalcType>{value});
envelope.SetReleaseTime(
ftz::Audio::TimeDuration<OpenCLSettings::CalcType>{value});
synth->SetEnvelopeSettings(std::move(envelope));
return;
}
......@@ -265,8 +269,8 @@ void OpenCLSawtoothPlugin::run(const float**, float** outputs,
std::uint32_t frames, const MidiEvent* midiEvents,
std::uint32_t midiEventCount)
{
ftz::Audio::MultichannelAudioBufferReference<SampleFormat> buffer{outputs,
2, frames};
ftz::Audio::MultichannelAudioBufferReference<
OpenCLSettings::SampleFormat> buffer{outputs, 2, frames};
auto first = std::begin(buffer);
decltype(first) last;
for (std::uint32_t i = 0; i < midiEventCount; ++i)
......
......@@ -99,14 +99,19 @@ protected:
private:
/// \brief Type of the synth.
using Synth = ftz::Audio::ParallelPolyphonicSynth<
ftz::Audio::OpenCL::BandlimitedSawtoothWave<CalcType>, SampleFormat>;
ftz::Audio::OpenCL::BandlimitedSawtoothWave<OpenCLSettings::CalcType>,
OpenCLSettings::SampleFormat>;
ftz::MIDI::InputChannel channel; ///< Holds the MIDI channel.
ftz::Audio::SynthSettings<CalcType> settings; ///< Holds synth settings.
std::unique_ptr<Synth> synth; ///< Holds the synth.
ftz::Audio::Pan<SampleFormat> pan; ///< Holds the pan.
ftz::Audio::Amplifier<SampleFormat> amp; ///< Holds the amplifier.
ftz::Audio::Clamper<SampleFormat> clamp; ///< Holds the clamper.
ftz::Audio::EffectChain<SampleFormat> effects; ///< Holds the effect chain.
/// \brief Holds synth settings.
ftz::Audio::SynthSettings<OpenCLSettings::CalcType> settings;
std::optional<Synth> synth; ///< Holds the synth.
ftz::Audio::Pan<OpenCLSettings::SampleFormat> pan; ///< Holds the pan.
/// \brief Holds the amplifier.
ftz::Audio::Amplifier<OpenCLSettings::SampleFormat> amp;
/// \brief Holds the clamper.
ftz::Audio::Clamper<OpenCLSettings::SampleFormat> clamp;
/// \brief Holds the effect chain.
ftz::Audio::EffectChain<OpenCLSettings::SampleFormat> effects;
};
}
......@@ -26,16 +26,17 @@ enum class ParameterIndex
OpenCLTrianglePlugin::OpenCLTrianglePlugin()
: Plugin{NumParameters, 0, 0},
amp{DefaultGain}
amp{OpenCLSettings::DefaultGain}
{
std::vector<cl::Platform> platforms;
cl::Platform::get(&platforms);
std::vector<cl::Device> devices;
platforms[0].getDevices(CL_DEVICE_TYPE_GPU, &devices);
synth = std::make_unique<Synth>(settings, channel,
ftz::Audio::OpenCL::BandlimitedTriangleWave<CalcType>::Settings{
this->getSampleRate(), devices[0]},
ftz::Audio::Envelope<CalcType>::Settings{this->getSampleRate()});
synth.emplace(settings, channel,
ftz::Audio::OpenCL::BandlimitedTriangleWave<OpenCLSettings::CalcType>::
Settings{this->getSampleRate(), devices[0]},
ftz::Audio::Envelope<OpenCLSettings::CalcType>::Settings{
this->getSampleRate()});
effects.PushBack(*synth);
effects.PushBack(pan);
effects.PushBack(amp);
......@@ -94,7 +95,7 @@ void OpenCLTrianglePlugin::initParameter(std::uint32_t index,
parameter.symbol = "master_volume";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 1.0f;
parameter.ranges.def = DefaultGain.GetValue();
parameter.ranges.def = OpenCLSettings::DefaultGain.GetValue();
return;
}
case ParameterIndex::Pan:
......@@ -113,7 +114,7 @@ void OpenCLTrianglePlugin::initParameter(std::uint32_t index,
parameter.name = "Pitch bend range";
parameter.symbol = "pitch_bend_range";
parameter.ranges.min = 0.0f;
parameter.ranges.max = MaxPitchBend;
parameter.ranges.max = OpenCLSettings::MaxPitchBend;
parameter.ranges.def = Synth::DefaultPitchBendRange;
return;
}
......@@ -124,7 +125,7 @@ void OpenCLTrianglePlugin::initParameter(std::uint32_t index,
parameter.symbol = "decay_time";
parameter.unit = "seconds";
parameter.ranges.min = 0.0f;
parameter.ranges.max = MaxAttackTime.count();
parameter.ranges.max = OpenCLSettings::MaxAttackTime.count();
parameter.ranges.def = 0.0f;
return;
}
......@@ -135,7 +136,7 @@ void OpenCLTrianglePlugin::initParameter(std::uint32_t index,
parameter.symbol = "decay_time";
parameter.unit = "seconds";
parameter.ranges.min = 0.0f;
parameter.ranges.max = MaxDecayTime.count();
parameter.ranges.max = OpenCLSettings::MaxDecayTime.count();
parameter.ranges.def = 0.0f;
return;
}
......@@ -156,7 +157,7 @@ void OpenCLTrianglePlugin::initParameter(std::uint32_t index,
parameter.symbol = "release_time";
parameter.unit = "seconds";
parameter.ranges.min = 0.0f;
parameter.ranges.max = MaxReleaseTime.count();
parameter.ranges.max = OpenCLSettings::MaxReleaseTime.count();
parameter.ranges.def = 0.0f;
return;
}
......@@ -205,7 +206,7 @@ void OpenCLTrianglePlugin::setParameterValue(std::uint32_t index, float value)
{
case ParameterIndex::MasterVolume:
{
amp.SetGain(ftz::Audio::Gain<CalcType>{value});
amp.SetGain(ftz::Audio::Gain<OpenCLSettings::CalcType>{value});
return;
}
case ParameterIndex::Pan:
......@@ -221,14 +222,16 @@ void OpenCLTrianglePlugin::setParameterValue(std::uint32_t index, float value)
case ParameterIndex::AttackTime:
{
auto envelope = synth->GetEnvelopeSettings();
envelope.SetAttackTime(ftz::Audio::TimeDuration<CalcType>{value});
envelope.SetAttackTime(
ftz::Audio::TimeDuration<OpenCLSettings::CalcType>{value});
synth->SetEnvelopeSettings(std::move(envelope));
return;
}
case ParameterIndex::DecayTime:
{
auto envelope = synth->GetEnvelopeSettings();
envelope.SetDecayTime(ftz::Audio::TimeDuration<CalcType>{value});
envelope.SetDecayTime(
ftz::Audio::TimeDuration<OpenCLSettings::CalcType>{value});
synth->SetEnvelopeSettings(std::move(envelope));
return;
}
......@@ -242,7 +245,8 @@ void OpenCLTrianglePlugin::setParameterValue(std::uint32_t index, float value)
case ParameterIndex::ReleaseTime:
{
auto envelope = synth->GetEnvelopeSettings();
envelope.SetReleaseTime(ftz::Audio::TimeDuration<CalcType>{value});
envelope.SetReleaseTime(
ftz::Audio::TimeDuration<OpenCLSettings::CalcType>{value});
synth->SetEnvelopeSettings(std::move(envelope));
return;
}
......@@ -265,8 +269,8 @@ void OpenCLTrianglePlugin::run(const float**, float** outputs,
std::uint32_t frames, const MidiEvent* midiEvents,
std::uint32_t midiEventCount)
{
ftz::Audio::MultichannelAudioBufferReference<SampleFormat> buffer{outputs,
2, frames};
ftz::Audio::MultichannelAudioBufferReference<
OpenCLSettings::SampleFormat> buffer{outputs, 2, frames};
auto first = std::begin(buffer);
decltype(first) last;
for (std::uint32_t i = 0; i < midiEventCount; ++i)
......
......@@ -99,14 +99,19 @@ protected:
private:
/// \brief Type of the synth.
using Synth = ftz::Audio::ParallelPolyphonicSynth<
ftz::Audio::OpenCL::BandlimitedTriangleWave<CalcType>, SampleFormat>;
ftz::Audio::OpenCL::BandlimitedTriangleWave<OpenCLSettings::CalcType>,
OpenCLSettings::SampleFormat>;
ftz::MIDI::InputChannel channel; ///< Holds the MIDI channel.
ftz::Audio::SynthSettings<CalcType> settings; ///< Holds synth settings.
std::unique_ptr<Synth> synth; ///< Holds the synth.
ftz::Audio::Pan<SampleFormat> pan; ///< Holds the pan.
ftz::Audio::Amplifier<SampleFormat> amp; ///< Holds the amplifier.
ftz::Audio::Clamper<SampleFormat> clamp; ///< Holds the clamper.
ftz::Audio::EffectChain<SampleFormat> effects; ///< Holds the effect chain.
/// \brief Holds synth settings.
ftz::Audio::SynthSettings<OpenCLSettings::CalcType> settings;
std::optional<Synth> synth; ///< Holds the synth.
ftz::Audio::Pan<OpenCLSettings::SampleFormat> pan; ///< Holds the pan.
/// \brief Holds the amplifier.
ftz::Audio::Amplifier<OpenCLSettings::SampleFormat> amp;
/// \brief Holds the clamper.
ftz::Audio::Clamper<OpenCLSettings::SampleFormat> clamp;
/// \brief Holds the effect chain.
ftz::Audio::EffectChain<OpenCLSettings::SampleFormat> effects;
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment