29
29
class ControlObjectThread;
31
31
class MidiScriptEngine : public QThread {
36
34
MidiScriptEngine(MidiDevice* midiDevice);
35
virtual ~MidiScriptEngine();
40
38
bool hasErrors(QString filename);
41
39
const QStringList getErrors(QString filename);
41
void setMidiDebug(bool bDebug) {
45
void setMidiPopups(bool bPopups) {
46
m_midiPopups = bPopups;
43
49
// Lookup registered script functions
44
50
QStringList getScriptFunctions();
57
63
Q_INVOKABLE void scratchTick(int deck, int interval);
58
64
Q_INVOKABLE void scratchDisable(int deck);
61
67
void slotValueChanged(double value);
62
68
// Evaluate a script file
63
69
bool evaluate(QString filepath);
64
70
// Execute a particular function
65
bool execute(QString function);
71
bool execute(QString function);
66
72
// Execute a particular function with a data string (e.g. a device ID)
67
73
bool execute(QString function, QString data);
68
74
// Execute a particular function with a data buffer (e.g. a SysEx message)
73
79
void loadScriptFiles(QList<QString> scriptFileNames);
74
80
void initializeScripts(QList<QString> scriptFunctionPrefixes);
75
81
void gracefulShutdown(QList<QString> scriptFunctionPrefixes);
78
84
void initialized();
79
85
void resetController();
83
89
void timerEvent(QTimerEvent *event);
86
92
void errorDialogButton(QString key, QMessageBox::StandardButton button);
89
95
// Only call these with the scriptEngineLock
90
96
bool safeEvaluate(QString scriptName, QList<QString> scriptPaths);
91
97
bool internalExecute(QString scriptCode);
92
98
bool safeExecute(QString function);
93
99
bool safeExecute(QString function, QString data);
94
100
bool safeExecute(QString function, const unsigned char data[], unsigned int length);
95
bool safeExecute(QString function, char channel,
101
bool safeExecute(QString function, char channel,
96
102
char control, char value, MidiStatusByte status, QString group);
97
103
void initializeScriptEngine();
99
105
void scriptErrorDialog(QString detailedError);
100
106
void generateScriptFunctions(QString code);
101
107
bool checkException();
102
108
void stopAllTimers();
104
110
ControlObjectThread* getControlObjectThread(QString group, QString name);
106
112
MidiDevice* m_pMidiDevice;
107
113
bool m_midiDebug;
108
115
QMultiHash<ConfigKey, QString> m_connectedControls;
109
116
QScriptEngine *m_pEngine;
110
117
QStringList m_scriptFunctions;
112
119
QMutex m_scriptEngineLock;
113
120
QHash<ConfigKey, ControlObjectThread*> m_controlCache;
114
121
QHash<int, QPair<QString, bool> > m_timers;
116
123
// Scratching functions & variables
117
124
void scratchProcess(int timerId);
119
126
// 256 (default) available virtual decks is enough I would think.
120
127
// If more are needed at run-time, these will move to the heap automatically
121
128
QVarLengthArray <int> m_intervalAccumulator;