Mercurial > hg > pub > prymula > com
diff DPF-Prymula-audioplugins/plugins/CloneChannel/DistrhoPluginCloneChannel.cpp @ 3:84e66ea83026
DPF-Prymula-audioplugins-0.231015-2
author | prymula <prymula76@outlook.com> |
---|---|
date | Mon, 16 Oct 2023 21:53:34 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DPF-Prymula-audioplugins/plugins/CloneChannel/DistrhoPluginCloneChannel.cpp Mon Oct 16 21:53:34 2023 +0200 @@ -0,0 +1,208 @@ +/* + * DISTRHO CloneChannel - Copyright (C) 2023 Przemysław R. Pietraszczyk + * Based on DPF'ied SoulForce. + * Copyright (C) 2006 Niall Moody + * Copyright (C) 2015-2022 Filipe Coelho <falktx@falktx.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include <stdio.h> +#include "DistrhoPluginCloneChannel.hpp" + +START_NAMESPACE_DISTRHO + +// ----------------------------------------------------------------------- + +DistrhoPluginCloneChannel::DistrhoPluginCloneChannel() + : Plugin(kParameterCount, kProgramCount, 0) +{ + // set initial values + loadProgram(0); +} + +// ----------------------------------------------------------------------- +// Init + +void DistrhoPluginCloneChannel::initAudioPort(bool input, uint32_t index, AudioPort& port) +{ + port.groupId = kPortGroupStereo; + + Plugin::initAudioPort(input, index, port); +} + +void DistrhoPluginCloneChannel::initParameter(uint32_t index, Parameter& parameter) +{ + parameter.hints = kParameterIsAutomatable; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 1.0f; + + switch (index) + { + case kParameterSource: + parameter.hints |= kParameterIsBoolean; + parameter.name = "left/right"; + parameter.symbol = "left/right"; + parameter.ranges.def = 0.0f; + break; + case kParameterSource2: + parameter.hints |= kParameterIsBoolean; + parameter.name = "clone/move"; + parameter.symbol = "clone/move"; + parameter.ranges.def = 0.0f; + break; + } +} + +void DistrhoPluginCloneChannel::initProgramName(uint32_t index, String& programName) +{ + switch(index) + { + case kProgramDefault: + programName = "Default"; + break; + case kProgramStayDown: + programName = "Stay Down"; + break; + case kProgramLookingForTheWorld: + programName = "Looking for the World"; + break; + case kProgramGuerillaLove: + programName = "Guerilla Love"; + break; + case kProgramTumbleToThePower: + programName = "Tumble to the Power"; + break; + case kProgramDoYourselfFavour: + programName = "Do Yourself a Favour"; + break; + case kProgramPastIsPast: + programName = "Past is Past"; + break; + case kProgramYouAndOnlyYou: + programName = "You and Only You"; + break; + case kProgramCloneChannel: + programName = "Clone Channel"; + break; + } +} + +// ----------------------------------------------------------------------- +// Internal data + +float DistrhoPluginCloneChannel::getParameterValue(uint32_t index) const +{ + return parameters[index]; +} + +void DistrhoPluginCloneChannel::setParameterValue(uint32_t index, float value) +{ + asm("nop"); +} + +void DistrhoPluginCloneChannel::loadProgram(uint32_t index) +{ + switch(index) + { + case kProgramDefault: + parameters[kParameterSource] = 0.0f; + parameters[kParameterSource2] = 0.0f; + break; + case kProgramStayDown: + parameters[kParameterSource] = 0.0f; + parameters[kParameterSource2] = 0.0f; + break; + case kProgramLookingForTheWorld: + parameters[kParameterSource] = 0.0f; + parameters[kParameterSource2] = 0.0f; + break; + case kProgramGuerillaLove: + parameters[kParameterSource] = 0.0f; + parameters[kParameterSource2] = 0.0f; + break; + case kProgramTumbleToThePower: + parameters[kParameterSource] = 0.0f; + parameters[kParameterSource2] = 0.0f; + break; + case kProgramDoYourselfFavour: + parameters[kParameterSource] = 1.0f; + parameters[kParameterSource2] = 1.0f; + break; + case kProgramPastIsPast: + parameters[kParameterSource] = 1.0f; + parameters[kParameterSource2] = 1.0f; + break; + case kProgramYouAndOnlyYou: + parameters[kParameterSource] = 0.0f; + parameters[kParameterSource2] = 0.0f; + break; + case kProgramCloneChannel: + parameters[kParameterSource] = 1.0f; + parameters[kParameterSource2] = 1.0f; + break; + } +} + +// ----------------------------------------------------------------------- +// Process + +void DistrhoPluginCloneChannel::run(const float** inputs, float** outputs, uint32_t frames) +{ + + // Calculate audio. + for (uint32_t i=0; i<frames; ++i) + { + if (parameters[kParameterSource2] < 0.5f) { + // do lewego + if (parameters[kParameterSource] < 0.5f) { + outputs[0][i] = inputs[1][i]; + outputs[1][i] = inputs[1][i]; + } + // do prawego + if (parameters[kParameterSource] > 0.5f) { + outputs[0][i] = inputs[0][i]; + outputs[1][i] = inputs[0][i]; + } + } + // move + else if (parameters[kParameterSource2] > 0.5f) { + // na lewy + if (parameters[kParameterSource] < 0.5f) { + outputs[0][i] = inputs[1][i]; + outputs[1][i] = 0.0f; + } + // na prawy + if (parameters[kParameterSource] > 0.5f) { + outputs[0][i] = 0.0f; + outputs[1][i] = inputs[0][i]; + } + } + } +} + +// ----------------------------------------------------------------------- + +Plugin* createPlugin() +{ + return new DistrhoPluginCloneChannel(); +} + +// ----------------------------------------------------------------------- + +END_NAMESPACE_DISTRHO