-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathofxVisualProgramming.h
More file actions
executable file
·244 lines (198 loc) · 10 KB
/
ofxVisualProgramming.h
File metadata and controls
executable file
·244 lines (198 loc) · 10 KB
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
/*==============================================================================
ofxVisualProgramming: A visual programming patching environment for OF
Copyright (c) 2018 Emanuele Mazza aka n3m3da <emanuelemazza@d3cod3.org>
ofxVisualProgramming is distributed under the MIT License.
This gives everyone the freedoms to use ofxVisualProgramming in any context:
commercial or non-commercial, public or private, open or closed source.
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.
See https://github.com/d3cod3/ofxVisualProgramming for documentation
==============================================================================*/
#pragma once
#include "ofMain.h"
#include "ofxVPConfig.h"
#include "ofxVPXmlEngine.h"
#include "ofxPDSP.h"
#include "ofxImGui.h"
#include "imgui_node_canvas.h"
#include "imgui_profiler.h"
#include "FileBrowser/ImGuiFileBrowser.h"
#include "IconsFontAwesome5.h"
#include "Kernel.h"
#include "PatchObject.h"
struct SubpatchConnection{
int objID;
std::string name;
uint8_t type; // LINK_TYPE
uint8_t inOut; // 0 receive, 1 send
};
class ofxVisualProgramming : public pdsp::Wrapper {
public:
ofxVisualProgramming();
~ofxVisualProgramming();
void setRetina(bool retina, float retinaScale=1);
void setup(ofxImGui::Gui* guiRef = nullptr, std::string release="");
void setupFailsafeWindow();
void update();
void updateRetina(float scale);
void updateCanvasViewport();
void updateSubpatchNavigation();
void draw();
void closeDrawMainMenu();
void drawInspector();
void drawLivePatchingSession();
void drawSubpatchNavigation();
void resetTempFolder();
void cleanPatchDataFolder();
void reloadFont();
void exit();
void mouseMoved(ofMouseEventArgs &e);
void mouseDragged(ofMouseEventArgs &e);
void mousePressed(ofMouseEventArgs &e);
void mouseReleased(ofMouseEventArgs &e);
void mouseScrolled(ofMouseEventArgs &e);
void keyPressed(ofKeyEventArgs &e);
void keyReleased(ofKeyEventArgs &e);
void activeObject(int oid);
std::shared_ptr<PatchObject> selectObject(std::string objname);
void addObject(std::string name, ofVec2f pos,std::string fp="none");
std::shared_ptr<PatchObject> getLastAddedObject();
void resetObject(int &id);
void resetObject(int id);
void reconnectObjectOutlets(int &id);
void removeObject(int &id);
void duplicateObject(int &id);
void disconnectObject(int id);
bool connect(int fromID, int fromOutlet, int toID,int toInlet, int linkType);
void checkSpecialConnection(int fromID, int toID, int linkType);
void resetSystemObjects();
void resetSpecificSystemObjects(std::string name);
bool weAlreadyHaveObject(std::string name);
void clearObjectsMap();
bool isObjectInLibrary(std::string name);
bool isObjectIDInPatchMap(int id);
std::string getObjectNameFromID(int id);
int getSubpatchIndex(string name);
void newPatch(std::string release);
void newTempPatchFromFile(std::string patchFile);
void preloadPatch(std::string patchFile);
void openPatch(std::string patchFile);
void loadPatch(std::string patchFile);
void loadPatchSharedContextObjects();
void reloadPatch();
void savePatchAs(std::string patchFile);
void setPatchVariable(std::string var, int value);
void setAudioInDevice(int ind);
void setAudioOutDevice(int ind);
void setAudioDevices(int ind, int outd);
void setAudioSampleRate(int sr);
void setAudioBufferSize(int bs);
void activateDSP();
void deactivateDSP();
void resetCanvas();
// PATCH FILE
ofxVPXmlEngine ofxVPXml;
bool isPrePugiXmlRelease;
// PATCH CANVAS
ofRectangle canvasViewport;
ofxImGui::Gui* ofxVPGui;
ImGuiEx::NodeCanvas nodeCanvas;
ImGuiEx::ProfilersWindow profiler;
ImGuiEx::ProfilerTask *pt;
bool isCanvasVisible;
bool isCanvasActive;
// PATCH DRAWING RESOURCES
ofTrueTypeFont *font;
int fontSize;
bool isRetina;
float scaleFactor;
// PUGG external plugins objects
pugg::Kernel plugins_kernel;
// PATCH OBJECTS
std::map<int,std::shared_ptr<PatchObject>> patchObjects;
std::map<std::string,std::string> scriptsObjectsFilesPaths;
std::vector<std::pair<int,int>> leftToRightIndexOrder;
std::vector<int> eraseIndexes;
ofPoint nextObjectPosition;
std::map<std::string,std::vector<SubpatchConnection>> subpatchesMap;
std::string currentSubpatch;
std::string newSubpatchName;
int selectedObjectID;
int actualObjectID;
int lastAddedObjectID;
bool bLoadingNewObject;
bool bLoadingNewPatch;
bool bPopulatingObjectsMap;
bool clearingObjectsMap;
// LOAD/SAVE
std::string currentPatchFile;
std::string currentPatchFolderPath;
int output_width;
int output_height;
std::string alphabet;
int newFileCounter;
// SYSTEM
std::shared_ptr<ofAppGLFWWindow> mainWindow;
bool profilerActive;
bool inspectorActive;
bool navigationActive;
bool isOverProfiler;
bool isOverInspector;
bool isOverSubpatchNavigator;
bool inited;
// LIVE PATCHING
int livePatchingObiID;
// Sound Stream
pdsp::Engine *engine;
ofSoundBuffer inputBuffer;
ofSoundBuffer emptyBuffer;
std::vector<ofSoundDevice> audioDevices;
std::vector<std::string> audioDevicesStringIN;
std::vector<std::string> audioDevicesStringOUT;
std::vector<int> audioDevicesID_IN;
std::vector<int> audioDevicesID_OUT;
std::vector<std::string> audioDevicesSR;
std::vector<std::string> audioDevicesBS;
ofSoundStream soundStreamIN;
ofSoundBuffer lastInputBuffer;
ofPolyline inputBufferWaveform;
int audioINDev;
int audioOUTDev;
int audioGUIINIndex;
int audioGUIOUTIndex;
int audioGUIINChannels;
int audioGUIOUTChannels;
int audioGUISRIndex;
int audioGUIBSIndex;
int audioSampleRate;
int audioBufferSize;
int audioNumBuffers;
int bpm;
bool isInputDeviceAvailable;
bool isOutputDeviceAvailable;
bool dspON;
bool pauseDSP;
// MEMORY
uint64_t loadPatchTime;
uint64_t resetTime;
uint64_t deferredLoadTime;
uint64_t wait;
bool deferredLoad;
private:
void audioProcess(float *input, int bufferSize, int nChannels);
mutable ofMutex vp_mutex;
std::shared_ptr<ofAppGLFWWindow> failsafeWindow;
};