...
 
Commits (3)
......@@ -39,17 +39,16 @@ public:
/// \brief Constructor.
/// \param[in] settings Synth settings to use.
/// \param[in] channel MIDI channel to use.
/// \param[in] envelopesettings Envelope settings to use.
/// \param[in] envelope_settings Envelope settings to use.
MultiSynth(const Audio::SynthSettings<CalcType>& settings,
MIDI::InputChannel& channel,
typename Audio::Envelope<CalcType>::Settings envelopesettings);
typename Audio::Envelope<CalcType>::Settings envelope_settings);
/// \brief Returns the type of the synth
/// \return Type of the synth.
Type GetType() const noexcept;
/// \brief Sets the type of the synth.
/// \return No return.
void SetType(Type type);
/// \brief Returns the reference to the envelope settings.
......@@ -58,13 +57,11 @@ public:
/// \brief Sets the envelope settings.
/// \param[in] settings Settings to set.
/// \return No return.
//void SetEnvelopeSettings(typename Envelope<CalcType>::Settings settings);
/// \brief Processes the audio data in the range [first, last).
/// \param[in] first Iterator to the beginning of the range.
/// \param[in] last Iterator past the end of the range.
/// \return No return.
void Render(typename Audio::MultichannelAudioBuffer<T, Allocator>::
iterator first, typename Audio::MultichannelAudioBuffer<T, Allocator>::
iterator last) override;
......@@ -72,7 +69,6 @@ public:
/// \brief Processes the audio data in the range [first, last).
/// \param[in] first Iterator to the beginning of the range.
/// \param[in] last Iterator past the end of the range.
/// \return No return.
void Render(typename Audio::MultichannelAudioBufferReference<T, false>::
iterator first, typename Audio::MultichannelAudioBufferReference<T,
false>::iterator last) override;
......@@ -81,7 +77,7 @@ private:
/// \brief Program change hook handle.
MIDI::InputChannel::ProgramChangeHookHandle prgchhook;
/// \brief Holds reference to the envelope settings.
const typename Audio::Envelope<CalcType>::Settings& envelopesettings;
const typename Audio::Envelope<CalcType>::Settings& envelope_settings;
Type type; ///< Holds the type of the synth.
/// \brief Holds current synth.
std::unique_ptr<Audio::SynthBase<T, Allocator>> synth;
......@@ -90,13 +86,11 @@ private:
/// \tparam ForwardIterator Type of the iterator.
/// \param[in] first Iterator to the beginning of the range.
/// \param[in] last Iterator past the end of the range.
/// \return No return.
template <typename ForwardIterator>
void ActualRender(ForwardIterator first, ForwardIterator last);
/// \brief Called when channel receives program change event.
/// \param[in] event Event to handle.
/// \return No return.
void OnProgramChange(const MIDI::ProgramChangeEvent& event);
};
......
......@@ -21,13 +21,13 @@ namespace ftz::Chiptune
template <typename T, typename Allocator>
MultiSynth<T, Allocator>::MultiSynth(
const Audio::SynthSettings<CalcType>& settings, MIDI::InputChannel& channel,
typename Audio::Envelope<CalcType>::Settings envelopesettings)
typename Audio::Envelope<CalcType>::Settings envelope_settings)
: Audio::SynthBase<T, Allocator>{settings}, channel{channel},
envelopesettings{envelopesettings}, type{Type::Sine},
synth{std::make_unique<Audio::PolyphonicSynth<Audio::OscillatorGenerator<
Audio::SineWave<CalcType>>, T, Allocator>>(settings, channel,
typename Audio::OscillatorGenerator<Audio::SineWave<CalcType>>::
Settings{{}, settings.GetSampleRate()}, envelopesettings)}
Settings{{}, settings.GetSampleRate()}, envelope_settings)}
{
prgchhook = channel.HookProgramChange([&](const auto& event){
this->OnProgramChange(event); });
......@@ -56,7 +56,7 @@ void MultiSynth<T, Allocator>::SetType(Type t)
Allocator>>(this->GetSynthSettings(), channel,
typename Audio::OscillatorGenerator<Audio::SineWave<CalcType>>::
Settings{{}, this->GetSynthSettings().GetSampleRate()},
envelopesettings);
envelope_settings);
break;
}
case Type::Pulse:
......@@ -66,7 +66,7 @@ void MultiSynth<T, Allocator>::SetType(Type t)
Allocator>>(this->GetSynthSettings(), channel,
typename Audio::OscillatorGenerator<Audio::PulseWave<
CalcType>>::Settings{{},
this->GetSynthSettings().GetSampleRate()}, envelopesettings);
this->GetSynthSettings().GetSampleRate()}, envelope_settings);
break;
}
case Type::Triangle:
......@@ -76,7 +76,7 @@ void MultiSynth<T, Allocator>::SetType(Type t)
Allocator>>(this->GetSynthSettings(), channel,
typename Audio::OscillatorGenerator<Audio::TriangleWave<
CalcType>>::Settings{{},
this->GetSynthSettings().GetSampleRate()}, envelopesettings);
this->GetSynthSettings().GetSampleRate()}, envelope_settings);
break;
}
case Type::Sawtooth:
......@@ -86,7 +86,7 @@ void MultiSynth<T, Allocator>::SetType(Type t)
Allocator>>(this->GetSynthSettings(), channel,
typename Audio::OscillatorGenerator<Audio::SawtoothWave<
CalcType>>::Settings{{},
this->GetSynthSettings().GetSampleRate()}, envelopesettings);
this->GetSynthSettings().GetSampleRate()}, envelope_settings);
break;
}
case Type::Noise:
......@@ -96,7 +96,7 @@ void MultiSynth<T, Allocator>::SetType(Type t)
Allocator>>(this->GetSynthSettings(), channel,
typename Audio::OscillatorGenerator<Audio::WhiteNoise<
CalcType>>::Settings{{},
this->GetSynthSettings().GetSampleRate()}, envelopesettings);
this->GetSynthSettings().GetSampleRate()}, envelope_settings);
break;
}
}
......@@ -140,4 +140,4 @@ void MultiSynth<T, Allocator>::OnProgramChange(
this->SetType(static_cast<Type>(event.GetValue().GetValue()));
}
}
\ No newline at end of file
}
......@@ -29,11 +29,9 @@ private:
/// \brief Called when channel receives control change event.
/// \param[in] event Event to handle.
/// \return No return.
void OnControlChange(const MIDI::ControlChangeEvent& event);
/// \brief Sets the duty cycle of the synth.
/// \return No return.
void SetDutyCycle();
};
......
......@@ -12,7 +12,8 @@ namespace ftz::Chiptune
template <typename CalcType>
PulseSynthMIDIControl<CalcType>::PulseSynthMIDIControl(
Audio::PulseWave<CalcType>& wave, MIDI::InputChannel& channel)
: wave{wave}, channel{channel}
: wave{wave},
channel{channel}
{
cchook = channel.HookControlChange([&](const auto& event){
this->OnControlChange(event); });
......@@ -45,4 +46,4 @@ void PulseSynthMIDIControl<CalcType>::SetDutyCycle()
wave.SetDutyCycle(cc.GetNormalizedValue<CalcType>());
}
}
\ No newline at end of file
}
......@@ -5,7 +5,7 @@
#pragma once
#include <ftz/Audio/SampleFormat.h>
#include <ftz/Audio/BasicSampleFormat.h>
#include <ftz/Audio/Time.h>
#include "DistrhoPlugin.hpp"
......@@ -16,13 +16,14 @@ namespace DISTRHO
/// \brief Version of the plugins.
const std::uint32_t PluginVersion = d_version(0, 2, 0);
template <typename T>
template <ftz::Audio::CalculationType CT>
struct Settings
{
using CalcType = T; ///< Type used in calculations.
using CalcType = CT; ///< Type used in calculations.
/// \brief Sample format used by aliased DPF plugins.
using SampleFormat = ftz::Audio::SampleFormat<float, CalcType>;
using SampleFormat = ftz::Audio::BasicSampleFormat<
ftz::Audio::BasicStorageType<float>, CalcType>;
/// \brief Default gain of the amplifier.
static constexpr auto DefaultGain = ftz::Audio::Gain<CalcType>{0.25};
......
......@@ -18,8 +18,8 @@
namespace DISTRHO
{
/// \brief A sine synth plugin.
/// \details This is a DPF wrapper of the sine synth.
/// \brief A synth plugin template.
/// \details This is a DPF wrapper template of the synth.
template <typename Generator, typename PluginSettings>
class PluginTemplate : public Plugin
......@@ -27,7 +27,7 @@ class PluginTemplate : public Plugin
public:
/// \brief Constructor.
/// \param[in] settings Settings of the generator.
PluginTemplate(typename Generator::Settings generatorsettings);
PluginTemplate(typename Generator::Settings generator_settings);
protected:
/// \brief Returns plugin author.
/// \return Plugin author.
......@@ -48,7 +48,6 @@ protected:
/// \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.
......@@ -59,11 +58,9 @@ protected:
/// \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.
......@@ -71,14 +68,12 @@ protected:
/// \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.
......
......@@ -26,9 +26,9 @@ enum class ParameterIndex
template <typename Generator, typename PluginSettings>
PluginTemplate<Generator, PluginSettings>::PluginTemplate(
typename Generator::Settings generatorsettings)
typename Generator::Settings generator_settings)
: Plugin{NumParameters, 0, 0},
synth{settings, channel, generatorsettings, {}},
synth{settings, channel, generator_settings, {}},
amp{PluginSettings::DefaultGain}
{
effects.PushBack(synth);
......