1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
/*
* DISTRHO glBars Plugin based on XMMS/XBMC "GL Bars"
* Copyright (C) 1998-2000 Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies
* Copyright (C) 2000 Christian Zander <phoenix@minion.de>
* Copyright (C) 2015 Nedko Arnaudov
* Copyright (C) 2016-2022 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the license see the LICENSE file.
*/
#include "DistrhoPluginGLBars.hpp"
#include "glBars.hpp"
START_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------
DistrhoPluginGLBars::DistrhoPluginGLBars()
: Plugin(kParameterCount, 0, 0),
fState(nullptr)
{
fParameters[kParameterScale] = 1.f / log(256.f);
fParameters[kParameterSpeed] = 0.025f;
fParameters[kParameterX] = 0.0f;
fParameters[kParameterY] = 0.5f;
fParameters[kParameterZ] = 0.0f;
}
DistrhoPluginGLBars::~DistrhoPluginGLBars()
{
DISTRHO_SAFE_ASSERT(fState == nullptr);
}
// -----------------------------------------------------------------------
// Init
void DistrhoPluginGLBars::initAudioPort(bool input, uint32_t index, AudioPort& port)
{
port.groupId = kPortGroupMono;
Plugin::initAudioPort(input, index, port);
}
void DistrhoPluginGLBars::initParameter(uint32_t index, Parameter& parameter)
{
switch (index)
{
case kParameterScale:
parameter.hints = kParameterIsAutomatable|kParameterIsLogarithmic;
parameter.name = "Scale";
parameter.symbol = "scale";
parameter.unit = "";
parameter.ranges.def = 1.0f / log(256.f);
parameter.ranges.min = 0.5f / log(256.f);
parameter.ranges.max = 3.0f / log(256.f);
break;
case kParameterSpeed:
parameter.hints = kParameterIsAutomatable|kParameterIsLogarithmic;
parameter.name = "Speed";
parameter.symbol = "speed";
parameter.unit = "";
parameter.ranges.def = 0.025f;
parameter.ranges.min = 0.0125f;
parameter.ranges.max = 0.1f;
break;
case kParameterX:
parameter.hints = kParameterIsAutomatable;
parameter.name = "X";
parameter.symbol = "x";
parameter.unit = "";
parameter.ranges.def = 0.0f;
parameter.ranges.min = -4.0f;
parameter.ranges.max = 4.0f;
break;
case kParameterY:
parameter.hints = kParameterIsAutomatable;
parameter.name = "Y";
parameter.symbol = "y";
parameter.unit = "";
parameter.ranges.def = 0.5f;
parameter.ranges.min = -4.0f;
parameter.ranges.max = 4.0f;
break;
case kParameterZ:
parameter.hints = kParameterIsAutomatable;
parameter.name = "Z";
parameter.symbol = "z";
parameter.unit = "";
parameter.ranges.def = 0.0f;
parameter.ranges.min = -4.0f;
parameter.ranges.max = 4.0f;
break;
}
}
// -----------------------------------------------------------------------
// Internal data
float DistrhoPluginGLBars::getParameterValue(uint32_t index) const
{
if (index >= kParameterCount)
return 0.0f;
return fParameters[index];
}
void DistrhoPluginGLBars::setParameterValue(uint32_t index, float value)
{
if (index >= kParameterCount)
return;
fParameters[index] = value;
}
// -----------------------------------------------------------------------
// Process
void DistrhoPluginGLBars::run(const float** inputs, float** outputs, uint32_t frames)
{
const float* in = inputs[0];
float* out = outputs[0];
if (out != in)
std::memcpy(out, in, sizeof(float)*frames);
const MutexLocker csm(fMutex);
if (fState != nullptr)
fState->AudioData(in, frames);
}
// -----------------------------------------------------------------------
Plugin* createPlugin()
{
return new DistrhoPluginGLBars();
}
// -----------------------------------------------------------------------
END_NAMESPACE_DISTRHO
|