Commit dfcb42dc authored by Lyberta's avatar Lyberta

Updated PluginTemplate.

parent d604b91a
......@@ -20,6 +20,8 @@ namespace DISTRHO
/// \brief A synth plugin template.
/// \details This is a DPF wrapper template of the synth.
/// \tparam Generator Generator of the synth.
/// \tparam PluginSettings Settings of the plugin. See Config.h.
template <typename Generator, typename PluginSettings>
class PluginTemplate : public Plugin
......@@ -66,15 +68,15 @@ protected:
/// \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.
/// \param[in] midi_events MIDI events to process.
/// \param[in] midi_event_count Number of MIDI events to process.
void run(const float**, float** outputs, std::uint32_t frames,
const MidiEvent* midiEvents, std::uint32_t midiEventCount)
const MidiEvent* midi_events, std::uint32_t midi_event_count)
override;
/// \brief Called when sample rate has changed.
/// \param[in] newSampleRate Sample rate to set.
void sampleRateChanged(double newSampleRate) override;
/// \param[in] new_sample_rate Sample rate to set.
void sampleRateChanged(double new_sample_rate) override;
private:
/// \brief Type of the synth.
using Synth = ftz::Audio::PolyphonicSynth<Generator,
......
......@@ -240,30 +240,24 @@ void PluginTemplate<Generator, PluginSettings>::setParameterValue(
template <typename Generator, typename PluginSettings>
void PluginTemplate<Generator, PluginSettings>::activate()
{
auto samplerate = this->getSampleRate();
settings.SetSampleRate(samplerate);
auto generatorsettings = synth.GetGeneratorSettings();
generatorsettings.SetSampleRate(samplerate);
synth.SetGeneratorSettings(std::move(generatorsettings));
auto envelope = synth.GetEnvelopeSettings();
envelope.SetSampleRate(samplerate);
synth.SetEnvelopeSettings(std::move(envelope));
auto sample_rate = this->getSampleRate();
this->sampleRateChanged(sample_rate);
}
template <typename Generator, typename PluginSettings>
void PluginTemplate<Generator, PluginSettings>::run(const float**,
float** outputs, std::uint32_t frames, const MidiEvent* midiEvents,
std::uint32_t midiEventCount)
float** outputs, std::uint32_t frames, const MidiEvent* midi_events,
std::uint32_t midi_event_count)
{
ftz::Audio::MultichannelAudioBufferReference<
typename PluginSettings::SampleFormat> buffer{outputs, 2, frames};
auto first = std::begin(buffer);
decltype(first) last;
for (std::uint32_t i = 0; i < midiEventCount; ++i)
for (std::uint32_t i = 0; i < midi_event_count; ++i)
{
last = std::begin(buffer) + midiEvents[i].frame;
last = std::begin(buffer) + midi_events[i].frame;
effects.Render(first, last);
auto event = Utils::ConvertEvent(midiEvents[i]);
auto event = Utils::ConvertEvent(midi_events[i]);
channel.HandleEvent(*event);
first = last;
}
......@@ -272,14 +266,14 @@ void PluginTemplate<Generator, PluginSettings>::run(const float**,
template <typename Generator, typename PluginSettings>
void PluginTemplate<Generator, PluginSettings>::sampleRateChanged(
double newSampleRate)
double new_sample_rate)
{
settings.SetSampleRate(newSampleRate);
auto generatorsettings = synth.GetGeneratorSettings();
generatorsettings.SetSampleRate(newSampleRate);
synth.SetGeneratorSettings(std::move(generatorsettings));
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(newSampleRate);
envelope.SetSampleRate(new_sample_rate);
synth.SetEnvelopeSettings(std::move(envelope));
}
......
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