Skip to content

Commit f777036

Browse files
committed
Make possible to save and load processor signal chains
1 parent 412c776 commit f777036

13 files changed

Lines changed: 261 additions & 35 deletions

File tree

Source/Processors/GenericProcessor/GenericProcessor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ enum ChannelType {HEADSTAGE_CHANNEL = 0, AUX_CHANNEL = 1, ADC_CHANNEL = 2, EVENT
3636
#include "../Parameter/Parameter.h"
3737
#include "../Channel/Channel.h"
3838
#include "../../CoreServices.h"
39-
#include "../PluginManager/OpenEphysPlugin.h"
39+
#include "../PluginManager/PluginClass.h"
4040

4141
#include <time.h>
4242
#include <stdio.h>
@@ -66,7 +66,7 @@ class Channel;
6666
6767
*/
6868

69-
class PLUGIN_API GenericProcessor : public AudioProcessor
69+
class PLUGIN_API GenericProcessor : public AudioProcessor, public PluginClass
7070
{
7171
public:
7272

@@ -101,7 +101,7 @@ class PLUGIN_API GenericProcessor : public AudioProcessor
101101
virtual AudioProcessorEditor* createEditor();
102102

103103
/** The default is to have no editor.*/
104-
bool hasEditor() const;
104+
virtual bool hasEditor() const;
105105

106106
/** JUCE method. Not used.*/
107107
void reset();

Source/Processors/PlaceholderProcessor/PlaceholderProcessor.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ bool PlaceholderProcessor::hasEditor() const
4343

4444
AudioProcessorEditor* PlaceholderProcessor::createEditor()
4545
{
46-
return new PlaceholderProcessorEditor(this, processorName, libName, libVersion);
46+
editor = new PlaceholderProcessorEditor(this, processorName, libName, libVersion);
47+
return editor;
4748
}
4849

4950
void PlaceholderProcessor::process(AudioSampleBuffer& continuousBuffer, MidiBuffer& eventBuffer)
@@ -60,7 +61,8 @@ bool PlaceholderProcessor::isSink()
6061
return processorSink;
6162
}
6263

63-
bool PlaceholderProcessor::enable()
64+
bool PlaceholderProcessor::isReady()
6465
{
66+
CoreServices::sendStatusMessage("Cannot acquire with placeholder nodes");
6567
return false; //This processor never allows processing
6668
}

Source/Processors/PlaceholderProcessor/PlaceholderProcessor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class PlaceholderProcessor : public GenericProcessor
3939
MidiBuffer& eventBuffer) override;
4040
bool isSource() override;
4141
bool isSink() override;
42-
bool enable() override;
42+
bool isReady() override;
4343
private:
4444
const String processorName;
4545
const String libName;

Source/Processors/PlaceholderProcessor/PlaceholderProcessorEditor.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ PlaceholderProcessorEditor::PlaceholderProcessorEditor(GenericProcessor* parentN
2727
: GenericEditor(parentNode, true), processorName(pName), libName(lName), libVersion(lVer)
2828
{
2929
notfoundLabel = new Label("Not found", "Plugin not found");
30-
notfoundLabel->setBounds(30, 30, 100, 20);
30+
notfoundLabel->setBounds(10, 25, 100, 20);
3131
addAndMakeVisible(notfoundLabel);
3232

3333
libLabel = new Label("Plugin", libName + " ver. " + String(libVersion));
34-
libLabel->setBounds(30, 70, 100, 20);
34+
libLabel->setBounds(10, 40, 160, 40);
3535
addAndMakeVisible(libLabel);
3636

3737
nameLabel = new Label("Processor", "Missing processor: " + processorName);
38-
libLabel->setBounds(30, 110, 100, 20);
38+
nameLabel->setBounds(10, 75, 160, 40);
3939
addAndMakeVisible(nameLabel);
4040

41-
desiredWidth = 150;
41+
desiredWidth = 180;
4242
setEnabledState(false);
4343
}
4444

Source/Processors/PluginManager/PluginClass.cpp

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,91 @@
2222
*/
2323

2424
#include "PluginClass.h"
25+
#include "PluginManager.h"
26+
#include "../../AccessClass.h"
27+
#include "../ProcessorManager/ProcessorManager.h"
28+
29+
PluginClass::PluginClass()
30+
{
31+
libName = String::empty;
32+
pluginName = String::empty;
33+
libVersion = -1;
34+
pluginType = Plugin::NotAPlugin;
35+
}
36+
37+
PluginClass::~PluginClass()
38+
{
39+
40+
}
41+
42+
void PluginClass::setPluginData(Plugin::PluginType type, int index)
43+
{
44+
PluginManager* pm = AccessClass::getPluginManager();
45+
String name;
46+
pluginType = type;
47+
pluginIndex = index;
48+
switch (type)
49+
{
50+
case Plugin::ProcessorPlugin:
51+
{
52+
Plugin::ProcessorInfo i = pm->getProcessorInfo(index);
53+
name = i.name;
54+
}
55+
break;
56+
case Plugin::RecordEnginePlugin:
57+
{
58+
Plugin::RecordEngineInfo i = pm->getRecordEngineInfo(index);
59+
name = i.name;
60+
}
61+
break;
62+
case Plugin::DatathreadPlugin:
63+
{
64+
Plugin::DataThreadInfo i = pm->getDataThreadInfo(index);
65+
name = i.name;
66+
}
67+
break;
68+
case Plugin::FileSourcePlugin:
69+
{
70+
Plugin::FileSourceInfo i = pm->getFileSourceInfo(index);
71+
name = i.name;
72+
}
73+
break;
74+
case Plugin::NotAPlugin:
75+
{
76+
String pName;
77+
int pType;
78+
ProcessorManager::getProcessorNameAndType(BuiltInProcessor, index, pName, pType);
79+
name = pName;
80+
}
81+
default:
82+
return;
83+
}
84+
pluginName = name;
85+
libName = pm->getLibraryName(pm->getLibraryIndexFromPlugin(type, index));
86+
libVersion = pm->getLibraryVersion(pm->getLibraryIndexFromPlugin(type, index));
87+
}
88+
89+
String PluginClass::getLibName() const
90+
{
91+
return libName;
92+
}
93+
94+
String PluginClass::getPluginName() const
95+
{
96+
return pluginName;
97+
}
98+
99+
int PluginClass::getLibVersion() const
100+
{
101+
return libVersion;
102+
}
103+
104+
Plugin::PluginType PluginClass::getPluginType() const
105+
{
106+
return pluginType;
107+
}
108+
109+
int PluginClass::getIndex() const
110+
{
111+
return pluginIndex;
112+
}

Source/Processors/PluginManager/PluginClass.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,20 @@
2828
class PluginClass
2929
{
3030
public:
31+
PluginClass();
32+
~PluginClass();
3133
void setPluginData(Plugin::PluginType type, int index);
34+
String getLibName() const;
35+
String getPluginName() const;
36+
int getLibVersion() const;
37+
Plugin::PluginType getPluginType() const;
38+
int getIndex() const;
3239
private:
3340
String libName;
3441
String pluginName;
42+
Plugin::PluginType pluginType;
3543
int libVersion;
44+
int pluginIndex;
3645
};
3746

3847

Source/Processors/PluginManager/PluginManager.cpp

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ int PluginManager::loadPlugin(const String& pluginLoc) {
179179
LoadedLibInfo lib;
180180
lib.apiVersion = libInfo.apiVersion;
181181
lib.name = libInfo.name;
182+
lib.libVersion = libInfo.libVersion;
182183
lib.numPlugins = libInfo.numPlugins;
183184
lib.handle = handle;
184185

@@ -197,7 +198,7 @@ int PluginManager::loadPlugin(const String& pluginLoc) {
197198
info.creator = pInfo.processor.creator;
198199
info.name = pInfo.processor.name;
199200
info.type = pInfo.processor.type;
200-
info.libIndex = libArray.size();
201+
info.libIndex = libArray.size()-1;
201202
processorPlugins.add(info);
202203
break;
203204
}
@@ -314,14 +315,37 @@ Plugin::FileSourceInfo PluginManager::getFileSourceInfo(String name, String libN
314315
return i;
315316
}
316317

317-
String PluginManager::getPluginName(int index) const
318+
String PluginManager::getLibraryName(int index) const
319+
{
320+
if (index < 0 || index >= libArray.size())
321+
return String::empty;
322+
else
323+
return libArray[index].name;
324+
}
325+
326+
int PluginManager::getLibraryVersion(int index) const
318327
{
319-
return libArray[index].name;
328+
if (index < 0 || index >= libArray.size())
329+
return -1;
330+
else
331+
return libArray[index].libVersion;
320332
}
321333

322-
int PluginManager::getPluginVersion(int index) const
334+
int PluginManager::getLibraryIndexFromPlugin(Plugin::PluginType type, int index)
323335
{
324-
return libArray[index].libVersion;
336+
switch (type)
337+
{
338+
case Plugin::ProcessorPlugin:
339+
return processorPlugins[index].libIndex;
340+
case Plugin::RecordEnginePlugin:
341+
return recordEnginePlugins[index].libIndex;
342+
case Plugin::DatathreadPlugin:
343+
return dataThreadPlugins[index].libIndex;
344+
case Plugin::FileSourcePlugin:
345+
return fileSourcePlugins[index].libIndex;
346+
default:
347+
return -1;
348+
}
325349
}
326350

327351
Plugin::ProcessorInfo PluginManager::getEmptyProcessorInfo()

Source/Processors/PluginManager/PluginManager.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ class PluginManager {
7474
Plugin::RecordEngineInfo getRecordEngineInfo(String name, String libName = String::empty) const;
7575
Plugin::FileSourceInfo getFileSourceInfo(int index) const;
7676
Plugin::FileSourceInfo getFileSourceInfo(String name, String libName = String::empty) const;
77-
String getPluginName(int index) const;
78-
int getPluginVersion(int index) const;
77+
String getLibraryName(int index) const;
78+
int getLibraryVersion(int index) const;
79+
int getLibraryIndexFromPlugin(Plugin::PluginType type, int index);
7980

8081
private:
8182
Array<LoadedLibInfo> libArray;

Source/Processors/ProcessorGraph/ProcessorGraph.cpp

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -470,16 +470,34 @@ void ProcessorGraph::connectProcessorToAudioAndRecordNodes(GenericProcessor* sou
470470

471471
GenericProcessor* ProcessorGraph::createProcessorFromDescription(Array<var>& description)
472472
{
473-
String processorName = description[0];
474-
int processorType = description[1];
475-
int processorIndex = description[2];
476-
String processorCategory = description[3];
473+
GenericProcessor* processor = nullptr;
477474

478-
std::cout << "Creating from description..." << std::endl;
479-
std::cout << processorCategory << "::" << processorName << " (" << processorType << "-" << processorIndex << ")" << std::endl;
475+
bool fromProcessorList = description[0];
476+
String processorName = description[1];
477+
int processorType = description[2];
478+
int processorIndex = description[3];
480479

481-
GenericProcessor* processor = nullptr;
482-
processor = ProcessorManager::createProcessor((ProcessorClasses)processorType, processorIndex);
480+
if (fromProcessorList)
481+
{
482+
String processorCategory = description[4];
483+
484+
std::cout << "Creating from description..." << std::endl;
485+
std::cout << processorCategory << "::" << processorName << " (" << processorType << "-" << processorIndex << ")" << std::endl;
486+
487+
processor = ProcessorManager::createProcessor((ProcessorClasses)processorType, processorIndex);
488+
}
489+
else
490+
{
491+
String libName = description[4];
492+
int libVersion = description[5];
493+
bool isSource = description[6];
494+
bool isSink = description[7];
495+
496+
std::cout << "Creating from plugin info..." << std::endl;
497+
std::cout << libName << "(" << libVersion << ")::" << processorName << std::endl;
498+
499+
processor = ProcessorManager::createProcessorFromPluginInfo((Plugin::PluginType)processorType, processorIndex, processorName, libName, libVersion, isSource, isSink);
500+
}
483501

484502
String msg = "New " + processorName + " created";
485503
CoreServices::sendStatusMessage(msg);

0 commit comments

Comments
 (0)