Commit 1ed37478 authored by Lyberta's avatar Lyberta

Updated noise plugin.

parent fc4d8556
......@@ -14,7 +14,7 @@ namespace DISTRHO
{
/// \brief Version of the plugins.
const std::uint32_t PluginVersion = d_version(0, 2, 5);
const std::uint32_t PluginVersion = d_version(0, 3, 0);
template <ftz::Audio::CalculationType CT>
struct Settings
......
......@@ -28,10 +28,10 @@ NoisePlugin::NoisePlugin()
{this->getSampleRate()}},
amp{AliasedSettings::DefaultGain}
{
effects.PushBack(synth);
effects.PushBack(pan);
effects.PushBack(amp);
effects.PushBack(clamp);
effects.push_back(synth);
effects.push_back(pan);
effects.push_back(amp);
effects.push_back(clamp);
}
const char* NoisePlugin::getName() const
......@@ -226,42 +226,36 @@ void NoisePlugin::setParameterValue(std::uint32_t index, float value)
void NoisePlugin::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);
}
void NoisePlugin::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)
{
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)
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;
}
effects.Render(first, std::end(buffer));
}
void NoisePlugin::sampleRateChanged(double newSampleRate)
void NoisePlugin::sampleRateChanged(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));
}
......
......@@ -64,7 +64,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.
......@@ -75,27 +74,23 @@ 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.
/// \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.
/// \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.
/// \return No return.
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<ftz::Audio::OscillatorGenerator<
......
Subproject commit 70cec6a9d0222b32abdcaec02cd7b01378c4d78b
Subproject commit e70a6d2719fc95dc5220e063ae9eb633adb3bede
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