Commit f4179532 authored by Lyberta's avatar Lyberta

Updated OpenCL plugins.

parent d7ef05a7
......@@ -255,43 +255,37 @@ void OpenCLSawtoothPlugin::setParameterValue(std::uint32_t index, float value)
void OpenCLSawtoothPlugin::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 OpenCLSawtoothPlugin::run(const float**, float** outputs,
std::uint32_t frames, const MidiEvent* midiEvents,
std::uint32_t midiEventCount)
std::uint32_t frames, const MidiEvent* midi_events,
std::uint32_t midi_event_count)
{
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)
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 OpenCLSawtoothPlugin::sampleRateChanged(double newSampleRate)
void OpenCLSawtoothPlugin::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::ParallelPolyphonicSynth<
......
......@@ -255,43 +255,37 @@ void OpenCLTrianglePlugin::setParameterValue(std::uint32_t index, float value)
void OpenCLTrianglePlugin::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 OpenCLTrianglePlugin::run(const float**, float** outputs,
std::uint32_t frames, const MidiEvent* midiEvents,
std::uint32_t midiEventCount)
std::uint32_t frames, const MidiEvent* midi_events,
std::uint32_t midi_event_count)
{
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)
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 OpenCLTrianglePlugin::sampleRateChanged(double newSampleRate)
void OpenCLTrianglePlugin::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::ParallelPolyphonicSynth<
......
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