Skip to content
Snippets Groups Projects
Commit ead0842f authored by Sept_en's avatar Sept_en
Browse files

PluginGenerator: some refactoring. Added plugin helpers.

parent 9d007c76
Branches
Tags
No related merge requests found
Showing
with 524 additions and 375 deletions
/*
------------------------------------------------------------------
This file is part of the Open Ephys GUI
Copyright (C) 2016 Open Ephys
------------------------------------------------------------------
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 3 of the License, or
(at your option) 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../../../Source/Processors/PluginManager/PluginIDs.h"
using namespace Plugin;
static String getProcessorTypeString (PluginProcessorType processorType)
{
switch (processorType)
{
case PROCESSOR_TYPE_FILTER:
return "PROCESSOR_TYPE_FILTER";
case PROCESSOR_TYPE_SOURCE:
return "PROCESSOR_TYPE_SOURCE";
case PROCESSOR_TYPE_SINK:
return "PROCESSOR_TYPE_SINK";
case PROCESSOR_TYPE_SPLITTER:
return "PROCESSOR_TYPE_SPLITTER";
case PROCESSOR_TYPE_MERGER:
return "PROCESSOR_TYPE_MERGER";
case PROCESSOR_TYPE_UTILITY:
return "PROCESSOR_TYPE_UTILITY";
case PROCESSOR_TYPE_DATA_FORMAT:
return "PROCESSOR_TYPE_DATA_FORMAT";
default:
return "InvalidProcessorType";
};
}
/** Return the string representation of a given plugin type */
static String getLibPluginTypeString (PluginType pluginType)
{
switch (pluginType)
{
case PLUGIN_TYPE_PROCESSOR:
return "Plugin::ProcessorPlugin";
case PLUGIN_TYPE_RECORD_ENGINE:
return "Plugin::RecordEnginePlugin";
case PLUGIN_TYPE_DATA_THREAD:
return "Plugin::DatathreadPlugin";
case PLUGIN_TYPE_FILE_SOURCE:
return "Plugin::FileSourcePlugin";
default:
return "Plugin::NotAPlugin";
};
}
/** Returns the string representation (name) of the function which is used to create a plugin of a given type. */
static String getLibPluginCreateFunctionString (PluginType pluginType)
{
switch (pluginType)
{
case PLUGIN_TYPE_PROCESSOR:
return "createProcessor";
case PLUGIN_TYPE_RECORD_ENGINE:
return "createRecordEngine";
case PLUGIN_TYPE_DATA_THREAD:
return "createDataThread";
case PLUGIN_TYPE_FILE_SOURCE:
return "createFileSource";
default:
return "InvalidFunctionName";
};
}
/** Returns the string representation of a given plugin processor type. */
static String getLibProcessorTypeString (PluginProcessorType processorType)
{
switch (processorType)
{
case PROCESSOR_TYPE_FILTER:
return "Plugin::FilterProcessor";
case PROCESSOR_TYPE_SINK:
return "Plugin::SinkProcessor";
case PROCESSOR_TYPE_UTILITY:
case PROCESSOR_TYPE_MERGER:
case PROCESSOR_TYPE_SPLITTER:
// TODO <Kirill A>: Check where data format plugins should be placed.
case PROCESSOR_TYPE_DATA_FORMAT:
return "Plugin::UtilityProcessor";
default:
return "Plugin::InvalidProcessor";
};
}
......@@ -29,6 +29,7 @@
#include "../Project Saving/jucer_ProjectExporter.h"
#include "../Application/jucer_MainWindow.h"
#include "../Utility/jucer_SlidingPanelComponent.h"
#include "../Utility/openEphys_pluginHelpers.h"
struct NewProjectWizardClasses
{
......
......@@ -63,7 +63,7 @@ public:
and spikes) is contained in the "events" variable, and "nSamples" holds the
number of continous samples in the current buffer (which may differ from the
size of the buffer).
*/
*/
void process (AudioSampleBuffer& buffer, MidiBuffer& events) override;
/** Returns the current gain level that is set in the processor */
......
/*
------------------------------------------------------------------
This file is part of the Open Ephys GUI
Copyright (C) 2016 Open Ephys
------------------------------------------------------------------
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 3 of the License, or
(at your option) 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Plugin
{
enum PluginProcessorType
{
PROCESSOR_TYPE_FILTER = 1
, PROCESSOR_TYPE_SOURCE
, PROCESSOR_TYPE_SINK
, PROCESSOR_TYPE_SPLITTER
, PROCESSOR_TYPE_MERGER
, PROCESSOR_TYPE_UTILITY
, PROCESSOR_TYPE_DATA_FORMAT
, PROCESSOR_TYPE_INVALID
};
enum PluginType
{
PLUGIN_TYPE_PROCESSOR = 1
, PLUGIN_TYPE_RECORD_ENGINE
, PLUGIN_TYPE_DATA_THREAD
, PLUGIN_TYPE_FILE_SOURCE
, NOT_A_PLUGIN_TYPE = -1
};
}
/*
------------------------------------------------------------------
This file is part of the Open Ephys GUI
Copyright (C) 2016 Open Ephys
------------------------------------------------------------------
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 3 of the License, or
(at your option) 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <PluginInfo.h>
#include "FILTERCLASSNAME.h"
#include <string>
#ifdef WIN32
#include <Windows.h>
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
using namespace Plugin;
//Number of plugins defined on the library. Can be of different types (Processors, RecordEngines, etc...)
#define NUM_PLUGINS 1
extern "C" EXPORT void getLibInfo (Plugin::LibraryInfo* info)
{
/* API version, defined by the GUI source.
Should not be changed to ensure it is always equal to the one used in the latest codebase.
The GUI refueses to load plugins with mismatched API versions */
info->apiVersion = PLUGIN_API_VER;
//Name of the Library, used only for information
info->name = "FILTERLIBRARYNAME";
//Version of the library, used only for information
info->libVersion = FILTERLIBRARYVERSION;
info->numPlugins = NUM_PLUGINS;
}
extern "C" EXPORT int getPluginInfo (int index, Plugin::PluginInfo* info)
{
switch (index)
{
//one case per plugin. This example is for a processor which connects directly to the signal chain
case 0:
//Type of plugin. See "Source/Processors/PluginManager/OpenEphysPlugin.h" for complete info about the different type structures
info->type = LIBPLUGINTYPE;
//For processor
info->processor.name = "FILTERGUINAME"; //Processor name shown in the GUI
//Type of processor. Can be FilterProcessor, SourceProcessor, SinkProcessor or UtilityProcessor. Specifies where on the processor list will appear
info->processor.type = LIBPLUGINPROCESSORTYPE;
//Class factory pointer. Replace "ExampleProcessor" with the name of your class.
info->processor.creator = &(Plugin::LIBPLUGINCREATEFUNCTION<FILTERCLASSNAME>);
break;
/**
Examples for other plugin types
For a RecordEngine, which provides formats for recording data
case x:
info->type = Plugin::RecordEnginePlugin;
info->recordEngine.name = "Record Engine Name";
info->recordEngine.creator = &(Plugin::createRecordEngine<RecordEngineClassName>);
break;
For a DataThread, which allows to use the existing SourceNode to connect to an asynchronous data source, such as acquisition hardware
case x:
info->type = Plugin::DatathreadPlugin;
info->dataThread.name = "Source name"; //Name that will appear on the processor list
info->dataThread.creator = &createDataThread<DataThreadClassName>;
For a FileSource, which allows importing data formats into the FileReader
case x:
info->type = Plugin::FileSourcePlugin;
info->fileSource.name = "File Source Name";
info->fileSource.extensions = "xxx;xxx;xxx"; //Semicolon separated list of supported extensions. Eg: "txt;dat;info;kwd"
info->fileSource.creator = &(Plugin::createFileSource<FileSourceClassName>);
**/
default:
return -1;
break;
}
return 0;
}
#ifdef WIN32
BOOL WINAPI DllMain (IN HINSTANCE hDllHandle,
IN DWORD nReason,
IN LPVOID Reserved)
{
return TRUE;
}
#endif
/*
------------------------------------------------------------------
This file is part of the Open Ephys GUI
Copyright (C) 2016 Open Ephys
------------------------------------------------------------------
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 3 of the License, or
(at your option) 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <PluginInfo.h>
#include "PROCESSORCLASSNAME.h"
#include <string>
#ifdef WIN32
#include <Windows.h>
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
using namespace Plugin;
//Number of plugins defined on the library. Can be of different types (Processors, RecordEngines, etc...)
#define NUM_PLUGINS 1
extern "C" EXPORT void getLibInfo (Plugin::LibraryInfo* info)
{
/* API version, defined by the GUI source.
Should not be changed to ensure it is always equal to the one used in the latest codebase.
The GUI refueses to load plugins with mismatched API versions */
info->apiVersion = PLUGIN_API_VER;
//Name of the Library, used only for information
info->name = "PLUGINLIBRARYNAME";
//Version of the library, used only for information
info->libVersion = PLUGINLIBRARYVERSION;
info->numPlugins = NUM_PLUGINS;
}
extern "C" EXPORT int getPluginInfo (int index, Plugin::PluginInfo* info)
{
switch (index)
{
//one case per plugin. This example is for a processor which connects directly to the signal chain
case 0:
//Type of plugin. See "Source/Processors/PluginManager/OpenEphysPlugin.h" for complete info about the different type structures
info->type = LIBPLUGINTYPE;
//For processor
info->processor.name = "PLUGINGUINAME"; //Processor name shown in the GUI
//Type of processor. Can be FilterProcessor, SourceProcessor, SinkProcessor or UtilityProcessor. Specifies where on the processor list will appear
info->processor.type = LIBPLUGINPROCESSORTYPE;
//Class factory pointer. Replace "ExampleProcessor" with the name of your class.
info->processor.creator = &(Plugin::LIBPLUGINCREATEFUNCTION<PROCESSORCLASSNAME>);
break;
/**
Examples for other plugin types
For a RecordEngine, which provides formats for recording data
case x:
info->type = Plugin::RecordEnginePlugin;
info->recordEngine.name = "Record Engine Name";
info->recordEngine.creator = &(Plugin::createRecordEngine<RecordEngineClassName>);
break;
For a DataThread, which allows to use the existing SourceNode to connect to an asynchronous data source, such as acquisition hardware
case x:
info->type = Plugin::DatathreadPlugin;
info->dataThread.name = "Source name"; //Name that will appear on the processor list
info->dataThread.creator = &createDataThread<DataThreadClassName>;
For a FileSource, which allows importing data formats into the FileReader
case x:
info->type = Plugin::FileSourcePlugin;
info->fileSource.name = "File Source Name";
info->fileSource.extensions = "xxx;xxx;xxx"; //Semicolon separated list of supported extensions. Eg: "txt;dat;info;kwd"
info->fileSource.creator = &(Plugin::createFileSource<FileSourceClassName>);
**/
default:
return -1;
break;
}
return 0;
}
#ifdef WIN32
BOOL WINAPI DllMain (IN HINSTANCE hDllHandle,
IN DWORD nReason,
IN LPVOID Reserved)
{
return TRUE;
}
#endif
/*
------------------------------------------------------------------
------------------------------------------------------------------
This file is part of the Open Ephys GUI
Copyright (C) 2016 Open Ephys
This file is part of the Open Ephys GUI
Copyright (C) 2016 Open Ephys
------------------------------------------------------------------
------------------------------------------------------------------
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 3 of the License, or
(at your option) any later version.
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 3 of the License, or
(at your option) 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "EDITORCLASSNAME.h"
#include "FILTERCLASSNAME.h"
#include "PROCESSORCLASSNAME.h"
EDITORCLASSNAME::EDITORCLASSNAME (GenericProcessor* parentNode, bool useDefaultParameterEditors = true)
: GenericEditor (parentNode, useDefaultParameterEditors)
......@@ -43,9 +43,9 @@ EDITORCLASSNAME::~EDITORCLASSNAME()
/**
The listener methods that reacts to the button click. The same method is called for all buttons
on the editor, so the button variable, which cointains a pointer to the button that called the method
has to be checked to know which function to perform.
The listener methods that reacts to the button click. The same method is called for all buttons
on the editor, so the button variable, which cointains a pointer to the button that called the method
has to be checked to know which function to perform.
*/
void EDITORCLASSNAME::buttonEvent (Button* button)
{
......
/*
------------------------------------------------------------------
------------------------------------------------------------------
This file is part of the Open Ephys GUI
Copyright (C) 2016 Open Ephys
This file is part of the Open Ephys GUI
Copyright (C) 2016 Open Ephys
------------------------------------------------------------------
------------------------------------------------------------------
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 3 of the License, or
(at your option) any later version.
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 3 of the License, or
(at your option) 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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HEADERGUARD
......@@ -27,18 +26,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <EditorHeaders.h>
/**
This class serves as a template for creating new editors.
This class serves as a template for creating new editors.
If this were a real editor, this comment section would be used to
describe the editor's structure. In this example, the editor will
have a single button which will set a parameter in the processor.
@see GenericEditor
If this were a real editor, this comment section would be used to
describe the editor's structure. In this example, the editor will
have a single button which will set a parameter in the processor.
@see GenericEditor
*/
class EDITORCLASSNAME : public GenericEditor //Generic Editor adds listeners for buttons and sliders.
class EDITORCLASSNAME : public GenericEditor //Generic Editor adds listeners for buttons and sliders.
//Other possible JUCE controls can be added and listened by inheriting from the appropiate XXX:Listener class
//See JUCE documentation to find other available controls.
{
......
......@@ -24,14 +24,14 @@
#include <stdio.h>
FILTERHEADERS
PROCESSORHEADERS
//If the processor uses a custom editor, it needs its header to instantiate it
//#include "ExampleEditor.h"
FILTERCLASSNAME::FILTERCLASSNAME()
: GenericProcessor ("FILTERGUINAME") //, threshold(200.0), state(true)
PROCESSORCLASSNAME::PROCESSORCLASSNAME()
: GenericProcessor ("PLUGINGUINAME") //, threshold(200.0), state(true)
{
setProcessorType (PROCESSORTYPE);
......@@ -40,7 +40,7 @@ FILTERCLASSNAME::FILTERCLASSNAME()
}
FILTERCLASSNAME::~FILTERCLASSNAME()
PROCESSORCLASSNAME::~PROCESSORCLASSNAME()
{
}
......@@ -48,7 +48,7 @@ FILTERCLASSNAME::~FILTERCLASSNAME()
/**
If the processor uses a custom editor, this method must be present.
*/
AudioProcessorEditor* FILTERCLASSNAME::createEditor()
AudioProcessorEditor* PROCESSORCLASSNAME::createEditor()
{
editor = new EDITORCLASSNAME (this, true);
......@@ -58,7 +58,7 @@ AudioProcessorEditor* FILTERCLASSNAME::createEditor()
}
void FILTERCLASSNAME::setParameter (int parameterIndex, float newValue)
void PROCESSORCLASSNAME::setParameter (int parameterIndex, float newValue)
{
//Parameter& p = parameters.getReference(parameterIndex);
//p.setValue(newValue, 0);
......@@ -70,7 +70,7 @@ void FILTERCLASSNAME::setParameter (int parameterIndex, float newValue)
}
void FILTERCLASSNAME::process (AudioSampleBuffer& buffer, MidiBuffer& events)
void PROCESSORCLASSNAME::process (AudioSampleBuffer& buffer, MidiBuffer& events)
{
/**
Generic structure for processing buffer data
......
......@@ -31,25 +31,22 @@
#include <ProcessorHeaders.h>
/**
This class serves as a template for creating new processors.
This class serves as a template for creating new processors.
If this were a real processor, this comment section would be used to
describe the processor's function.
@see GenericProcessor
If this were a real processor, this comment section would be used to
describe the processor's function.
@see GenericProcessor
*/
class FILTERCLASSNAME : public GenericProcessor
class PROCESSORCLASSNAME : public GenericProcessor
{
public:
/** The class constructor, used to initialize any members. */
FILTERCLASSNAME();
PROCESSORCLASSNAME();
/** The class destructor, used to deallocate memory */
~FILTERCLASSNAME();
~PROCESSORCLASSNAME();
/** Indicates if the processor has a custom editor. Defaults to false */
//bool hasEditor() const { return true; }
......@@ -96,7 +93,7 @@ private:
// float threshold;
// bool state;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FILTERCLASSNAME);
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PROCESSORCLASSNAME);
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment