~mixxxdevelopers/mixxx/mixxx-buildserver

« back to all changes in this revision

Viewing changes to mixxx/src/midi/midiscriptengine.h

  • Committer: Albert Santoni
  • Date: 2011-03-20 00:27:15 UTC
  • mfrom: (2607.1.162 mixxx-1.9)
  • Revision ID: alberts@mixxx.org-20110320002715-sa2d88zbuc5kkyya
MergedĀ fromĀ 1.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
class ControlObjectThread;
30
30
 
31
31
class MidiScriptEngine : public QThread {
32
 
 
33
32
    Q_OBJECT
34
 
 
35
 
public:
 
33
  public:
36
34
    MidiScriptEngine(MidiDevice* midiDevice);
37
 
    ~MidiScriptEngine();
 
35
    virtual ~MidiScriptEngine();
38
36
 
39
37
    bool isReady();
40
38
    bool hasErrors(QString filename);
41
39
    const QStringList getErrors(QString filename);
42
40
 
 
41
    void setMidiDebug(bool bDebug) {
 
42
        m_midiDebug = bDebug;
 
43
    }
 
44
 
 
45
    void setMidiPopups(bool bPopups) {
 
46
        m_midiPopups = bPopups;
 
47
    }
 
48
 
43
49
    // Lookup registered script functions
44
50
    QStringList getScriptFunctions();
45
51
 
57
63
    Q_INVOKABLE void scratchTick(int deck, int interval);
58
64
    Q_INVOKABLE void scratchDisable(int deck);
59
65
 
60
 
public slots:
 
66
  public slots:
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);
76
 
    
77
 
signals:
 
82
 
 
83
  signals:
78
84
    void initialized();
79
85
    void resetController();
80
86
 
81
 
protected:
 
87
  protected:
82
88
    void run();
83
89
    void timerEvent(QTimerEvent *event);
84
90
 
85
 
private slots:
 
91
  private slots:
86
92
    void errorDialogButton(QString key, QMessageBox::StandardButton button);
87
 
    
88
 
private:
 
93
 
 
94
  private:
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();
98
 
    
 
104
 
99
105
    void scriptErrorDialog(QString detailedError);
100
106
    void generateScriptFunctions(QString code);
101
107
    bool checkException();
102
108
    void stopAllTimers();
103
109
 
104
110
    ControlObjectThread* getControlObjectThread(QString group, QString name);
105
 
        
 
111
 
106
112
    MidiDevice* m_pMidiDevice;
107
113
    bool m_midiDebug;
 
114
    bool m_midiPopups;
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;
115
 
    
 
122
 
116
123
    // Scratching functions & variables
117
124
    void scratchProcess(int timerId);
118
 
    
 
125
 
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;