Commit f9a2454a authored by Benjamin Heisch's avatar Benjamin Heisch
Browse files

Appended Mozilla C++ StyleGuide to all Files.

parent d065ad2d
Pipeline #19108 failed with stages
in 1 minute and 56 seconds
---
Language: Cpp
# BasedOnStyle: Mozilla
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: TopLevel
AlwaysBreakAfterReturnType: TopLevel
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: false
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Mozilla
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeComma
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: false
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
- Regex: '.*'
Priority: 1
SortPriority: 0
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: true
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: false
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Latest
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
...
This diff is collapsed.
This diff is collapsed.
......@@ -2,42 +2,40 @@
#include <base/Ports.hpp>
#include <tools/PortHandling.hpp>
using namespace XPlug;
class MidiForwarder :public LazyPlugin {
class MidiForwarder : public LazyPlugin
{
public:
MidiForwarder() {
this->portComponent->addPort(std::make_shared<QueueMidiPort>("MidiIn", PortDirection::Input));
this->portComponent->addPort(std::make_shared<QueueMidiPort>("MidiOut", PortDirection::Output));
this->portComponent->addPort(std::make_shared<QueueMidiPort>("MidiOut2", PortDirection::Output));
this->featureComponent->detectFeatures(this->getPortComponent());
this->infoComponent->pluginName = "MidiForwarder";
this->infoComponent->creatorName="Benjamin Heisch";
this->infoComponent->pluginUri = "http://xplug_plug.in/examples/MidiForwarder";
}
// Geerbt ber IPlugin
virtual void processAudio() override {
auto in0 = getPortAt<IMidiPort>(this, 0,PortDirection::Input);
auto out0 = getPortAt<IMidiPort>(this, 0, PortDirection::Output);
auto out1 = getPortAt<IMidiPort>(this, 1, PortDirection::Output);
while (!in0->empty()) {
auto midiMsg = in0->get();
auto midiMsg2= midiMsg;
out0->feed(std::move(midiMsg));
out1->feed(std::move(midiMsg2));
}
}
virtual void init() override {
}
virtual void deinit() override {
}
virtual void activate() override {
}
virtual void deactivate() override {
}
//virtual PluginInfo* getPluginInfo() override;
MidiForwarder()
{
this->portComponent->addPort(
std::make_shared<QueueMidiPort>("MidiIn", PortDirection::Input));
this->portComponent->addPort(
std::make_shared<QueueMidiPort>("MidiOut", PortDirection::Output));
this->portComponent->addPort(
std::make_shared<QueueMidiPort>("MidiOut2", PortDirection::Output));
this->featureComponent->detectFeatures(this->getPortComponent());
this->infoComponent->pluginName = "MidiForwarder";
this->infoComponent->creatorName = "Benjamin Heisch";
this->infoComponent->pluginUri =
"http://xplug_plug.in/examples/MidiForwarder";
}
// Geerbt ber IPlugin
virtual void processAudio() override
{
auto in0 = getPortAt<IMidiPort>(this, 0, PortDirection::Input);
auto out0 = getPortAt<IMidiPort>(this, 0, PortDirection::Output);
auto out1 = getPortAt<IMidiPort>(this, 1, PortDirection::Output);
while (!in0->empty()) {
auto midiMsg = in0->get();
auto midiMsg2 = midiMsg;
out0->feed(std::move(midiMsg));
out1->feed(std::move(midiMsg2));
}
}
virtual void init() override {}
virtual void deinit() override {}
virtual void activate() override {}
virtual void deactivate() override {}
// virtual PluginInfo* getPluginInfo() override;
};
REGISTER_PLUGIN(MidiForwarder);
......@@ -2,45 +2,42 @@
#include <base/Ports.hpp>
#include <tools/PortHandling.hpp>
using namespace XPlug;
class VolumePlugin :public LazyPlugin {
class VolumePlugin : public LazyPlugin
{
protected:
std::shared_ptr<IAudioPort> in0= std::make_shared<MonoPort>("In0", PortDirection::Input);
std::shared_ptr<IAudioPort> out0= std::make_shared<MonoPort>("Out0", PortDirection::Output);
public:
VolumePlugin()
{
this->portComponent->addPort(in0);
this->portComponent->addPort(out0);
this->infoComponent->pluginName = "VolumePlugin";
this->infoComponent->creatorName="Benjamin Heisch";
this->infoComponent->pluginUri = "http://xplug_plug.in/examples/VolumePlugin";
}
// Geerbt ber IPlugin
virtual void processAudio() override
{
// auto in0 = getPortAt<IAudioPort>(this, 0,PortDirection::Input);
// auto out0 = getPortAt<IAudioPort>(this, 0, PortDirection::Output);
for (size_t i = 0; i < in0->size(); i++) {
for (size_t s = 0; s < in0->getSampleSize(); s++) {
if(in0->at(i)->getData() != nullptr && out0->at(i)->getData()!=nullptr )
out0->at(i)->getData()[s] = in0->at(i)->getData()[s];
}
}
}
virtual void init() override {
}
virtual void deinit() override {
std::shared_ptr<IAudioPort> in0 =
std::make_shared<MonoPort>("In0", PortDirection::Input);
std::shared_ptr<IAudioPort> out0 =
std::make_shared<MonoPort>("Out0", PortDirection::Output);
}
virtual void activate() override {
}
virtual void deactivate() override {
public:
VolumePlugin()
{
this->portComponent->addPort(in0);
this->portComponent->addPort(out0);
this->infoComponent->pluginName = "VolumePlugin";
this->infoComponent->creatorName = "Benjamin Heisch";
this->infoComponent->pluginUri =
"http://xplug_plug.in/examples/VolumePlugin";
}
// Geerbt ber IPlugin
virtual void processAudio() override
{
// auto in0 = getPortAt<IAudioPort>(this, 0,PortDirection::Input);
// auto out0 = getPortAt<IAudioPort>(this, 0, PortDirection::Output);
for (size_t i = 0; i < in0->size(); i++) {
for (size_t s = 0; s < in0->getSampleSize(); s++) {
if (in0->at(i)->getData() != nullptr &&
out0->at(i)->getData() != nullptr)
out0->at(i)->getData()[s] = in0->at(i)->getData()[s];
}
}
//virtual PluginInfo* getPluginInfo() override;
}
virtual void init() override {}
virtual void deinit() override {}
virtual void activate() override {}
virtual void deactivate() override {}
// virtual PluginInfo* getPluginInfo() override;
};
REGISTER_PLUGIN(VolumePlugin);
......@@ -2,17 +2,17 @@
#define EXAMPLE_PLUGIN_HPP
#include <base/LazyPlugin.hpp>
using namespace XPlug;
class VolumePlugin :public LazyPlugin {
class VolumePlugin : public LazyPlugin
{
public:
VolumePlugin();
// Geerbt ber IPlugin
virtual void processAudio() override;
virtual void init() override;
virtual void deinit() override;
virtual void activate() override;
virtual void deactivate() override;
//virtual PluginInfo* getInfoComponent() override;
VolumePlugin();
// Geerbt ber IPlugin
virtual void processAudio() override;
virtual void init() override;
virtual void deinit() override;
virtual void activate() override;
virtual void deactivate() override;
// virtual PluginInfo* getInfoComponent() override;
};
#endif //! EXAMPLE_PLUGIN_HPP
\ No newline at end of file
......@@ -9,74 +9,93 @@ using namespace XPlug;
static std::vector<LADSPA_Descriptor*> ladspaDescriptorArray;
struct LADSPAHandleDataType {
IPlugin* plug;
const LADSPA_Descriptor* desc;
struct LADSPAHandleDataType
{
IPlugin* plug;
const LADSPA_Descriptor* desc;
};
extern "C" {
const LADSPA_Descriptor* ladspa_descriptor(unsigned long index)
extern "C"
{
const LADSPA_Descriptor* ladspa_descriptor(unsigned long index)
{
if (index >= GlobalData().getNumberOfRegisteredPlugins())
return nullptr;
return nullptr;
PluginPtr plug = GlobalData().getPlugin(index);
auto desc = new LADSPA_Descriptor();
desc->ImplementationData = new LADSPAHandleDataType { GlobalData().getPlugin(index).get(), desc };
desc->ImplementationData =
new LADSPAHandleDataType{ GlobalData().getPlugin(index).get(), desc };
/******************* INSTANTIATION**********************/
desc->instantiate = [](const LADSPA_Descriptor* descriptor, unsigned long ) -> LADSPA_Handle {
auto data = static_cast<LADSPAHandleDataType*>(descriptor->ImplementationData);
data->plug->init();
return data;
//return NULL;
desc->instantiate = [](const LADSPA_Descriptor* descriptor,
unsigned long) -> LADSPA_Handle {
auto data =
static_cast<LADSPAHandleDataType*>(descriptor->ImplementationData);
data->plug->init();
return data;
// return NULL;
};
desc->activate = [](LADSPA_Handle instance) {
auto data = static_cast<LADSPAHandleDataType*>(instance);
data->plug->activate();
auto data = static_cast<LADSPAHandleDataType*>(instance);
data->plug->activate();
};
desc->deactivate = [](LADSPA_Handle instance) {
auto data = static_cast<LADSPAHandleDataType*>(instance);
data->plug->deactivate();
auto data = static_cast<LADSPAHandleDataType*>(instance);
data->plug->deactivate();
};
desc->cleanup = [](LADSPA_Handle instance) {
auto data = static_cast<LADSPAHandleDataType*>(instance);
data->plug->deinit();
for (size_t i = 0; i < data->desc->PortCount; i++) {
delete[] data->desc->PortNames[i];
}
delete data->desc->PortNames;
delete data->desc->PortDescriptors;
delete data->desc;
delete data;
auto data = static_cast<LADSPAHandleDataType*>(instance);
data->plug->deinit();
for (size_t i = 0; i < data->desc->PortCount; i++) {
delete[] data->desc->PortNames[i];
}
delete data->desc->PortNames;
delete data->desc->PortDescriptors;
delete data->desc;
delete data;
};
desc->Properties = 0; // LADSPA_PROPERTY_HARD_RT_CAPABLE and other stuff, not supported yet.
desc->Properties =
0; // LADSPA_PROPERTY_HARD_RT_CAPABLE and other stuff, not supported yet.
/*********************PORT HANDLING*********************/
desc->PortCount = static_cast<unsigned long>(getAudioChannelCount(plug.get()));
desc->connect_port = [](LADSPA_Handle instance, unsigned long portIndex, LADSPA_Data* DataLocation) {
auto data = static_cast<LADSPAHandleDataType*>(instance);
if (portIndex < getAudioChannelCount(data->plug)) { // portIndex is in or outputPort
getAudioChannelFromIndex(data->plug, portIndex)->feed( DataLocation);
} else {
//Not SUpported yet
}
desc->PortCount =
static_cast<unsigned long>(getAudioChannelCount(plug.get()));
desc->connect_port = [](LADSPA_Handle instance,
unsigned long portIndex,
LADSPA_Data* DataLocation) {
auto data = static_cast<LADSPAHandleDataType*>(instance);
if (portIndex <
getAudioChannelCount(data->plug)) { // portIndex is in or outputPort
getAudioChannelFromIndex(data->plug, portIndex)->feed(DataLocation);
} else {
// Not SUpported yet
}
};
//TODO: When adding Parameter, the have to be mapped to ports here.
// TODO: When adding Parameter, the have to be mapped to ports here.
int curIndex = 0;
char** portNamesCArray = new char*[desc->PortCount * sizeof(const char*)];
auto portDescripors = new LADSPA_PortDescriptor[desc->PortCount * sizeof(LADSPA_PortDescriptor)];
auto rangeHints = new LADSPA_PortRangeHint[desc->PortCount * sizeof(LADSPA_PortDescriptor)];
iteratePorts<IAudioPort>(plug.get(), [&portNamesCArray, &portDescripors, &rangeHints, &curIndex](IAudioPort* p, size_t ) {
auto portDescripors =
new LADSPA_PortDescriptor[desc->PortCount *
sizeof(LADSPA_PortDescriptor)];
auto rangeHints =
new LADSPA_PortRangeHint[desc->PortCount * sizeof(LADSPA_PortDescriptor)];
iteratePorts<IAudioPort>(
plug.get(),
[&portNamesCArray, &portDescripors, &rangeHints, &curIndex](IAudioPort* p,
size_t) {
for (size_t i = 0; i < p->size(); i++) {
std::string name = p->getPortName().to_string() + (p->at(i)->getName()!= "" ? static_cast<std::string>(p->at(i)->getName()): std::to_string(i));
portNamesCArray[curIndex] = new char[name.length() + 1];
std::strcpy(portNamesCArray[curIndex], name.c_str());
rangeHints[curIndex] = { 0, 0, 0 };
curIndex++;
std::string name = p->getPortName().to_string() +
(p->at(i)->getName() != ""
? static_cast<std::string>(p->at(i)->getName())
: std::to_string(i));
portNamesCArray[curIndex] = new char[name.length() + 1];
std::strcpy(portNamesCArray[curIndex], name.c_str());
rangeHints[curIndex] = { 0, 0, 0 };
curIndex++;
}
return false;
});
});
desc->PortNames = portNamesCArray;
......@@ -88,24 +107,26 @@ const LADSPA_Descriptor* ladspa_descriptor(unsigned long index)
desc->Label = nullptr;
desc->Maker = plug->getInfoComponent()->getCreatorName().data();
desc->Name = plug->getInfoComponent()->getPluginName().data();
//desc->Name = "Hans peter";
// desc->Name = "Hans peter";
desc->UniqueID = 278375745;
desc->run = [](LADSPA_Handle instance, unsigned long SampleCount) {
auto data = static_cast<LADSPAHandleDataType*>(instance);
iteratePorts<IAudioPort>(data->plug, [SampleCount](IAudioPort* p, size_t) {
p->setSampleSize(SampleCount);
return false;
});
data->plug->processAudio();
auto data = static_cast<LADSPAHandleDataType*>(instance);
iteratePorts<IAudioPort>(data->plug,
[SampleCount](IAudioPort* p, size_t) {
p->setSampleSize(SampleCount);
return false;
});
data->plug->processAudio();
};
/* desc->run_adding = [](LADSPA_Handle instance, unsigned long SampleCount) {
LADSPA_Descriptor* desc = (LADSPA_Descriptor*)instance;
/* desc->run_adding = [](LADSPA_Handle instance, unsigned long
SampleCount) { LADSPA_Descriptor* desc = (LADSPA_Descriptor*)instance;
IPlugin* plug = (IPlugin*)desc->ImplementationData;
plug->processAudio(plug->getPortComponent()->getInputPorts(), plug->getPortComponent()->getOutputPorts());
plug->processAudio(plug->getPortComponent()->getInputPorts(),
plug->getPortComponent()->getOutputPorts());
};*/
//desc->set_run_adding_gain;
// desc->set_run_adding_gain;
return desc;
}
}
}
#include "IFormatTestSuite.hpp"
#include "tools/LibLoading.hpp"
#include "ladspa.h"
#include "tools/LibLoading.hpp"
#include <vector>
using namespace XPlug;
class LADSPATestSuite :public FormatTestSuiteBase{
class LADSPATestSuite : public FormatTestSuiteBase
{
public:
virtual std::string getFormatName() override
{
return "LADSPA";
}
virtual std::string getFormatName() override { return "LADSPA"; }
virtual bool isSupported(std::string pluginPath) override
{
auto lib = LoadLib(pluginPath.c_str());
if (lib == nullptr) return false;
bool isSupp= LoadFunc<LADSPA_Descriptor_Function>(lib, "ladspa_descriptor")!=nullptr;
UnloadLib(lib);
return isSupp;
}
virtual bool isSupported(std::string pluginPath) override
{
auto lib = LoadLib(pluginPath.c_str());
if (lib == nullptr)
return false;
bool isSupp =
LoadFunc<LADSPA_Descriptor_Function>(lib, "ladspa_descriptor") != nullptr;
UnloadLib(lib);
return isSupp;
}
virtual SucceedState run() override
{
size_t sampleRate = 512;
SucceedState ret = TEST_SUCCEEDED;
auto lib = LoadLib(data.pluginPath.c_str());
if (lib == nullptr) return false;
auto ladspa_descriptor_fnc = LoadFunc<LADSPA_Descriptor_Function>(lib, "ladspa_descriptor");
size_t index = 0;
const LADSPA_Descriptor* desc = nullptr;
while (desc = ladspa_descriptor_fnc(index++), desc != nullptr) {
auto handle = desc->instantiate(desc, sampleRate);
desc->activate(handle);
auto portData = std::vector<LADSPA_Data*>(desc->PortCount);
for (unsigned long i = 0; i < desc->PortCount; i++) {
portData[i] = new LADSPA_Data[sampleRate];
desc->connect_port(handle, i, portData[i]);
}
desc->run(handle, sampleRate);
for (unsigned long i = 0; i < desc->PortCount; i++) {
delete[] portData[i];
}
desc->deactivate(handle);
desc->cleanup(handle);
}
return ret;
virtual SucceedState run() override
{
size_t sampleRate = 512;
SucceedState ret = TEST_SUCCEEDED;
auto lib = LoadLib(data.pluginPath.c_str());
if (lib == nullptr)
return false;
auto ladspa_descriptor_fnc =
LoadFunc<LADSPA_Descriptor_Function>(lib, "ladspa_descriptor");
size_t index = 0;
const LADSPA_Descriptor* desc = nullptr;
while (desc = ladspa_descriptor_fnc(index++), desc != nullptr) {
auto handle = desc->instantiate(desc, sampleRate);
desc->activate(handle);
auto portData = std::vector<LADSPA_Data*>(desc->PortCount);
for (unsigned long i = 0; i < desc->PortCount; i++) {
portData[i] = new LADSPA_Data[sampleRate];
desc->connect_port(handle, i, portData[i]);
}
desc->run(handle, sampleRate);
for (unsigned long i = 0; i < desc->PortCount; i++) {
delete[] portData[i];
}
desc->deactivate(handle);
desc->cleanup(handle);
}
return ret;
}
};
REGISTER_TEST_SUITE(LADSPATestSuite);
\ No newline at end of file