Debian Codegraph @

src/pyqcsobject.h

raw symbols SCIP
1 /*
2 Copyright (C) 2010 Andres Cabrera
3 [email protected]
4
5 This file is part of CsoundQt.
6
7 CsoundQt is free software; you can redistribute it
8 and/or modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 CsoundQt is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with Csound; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 02111-1307 USA
21 */
22
23 #ifndef PYQCSOBJECT_H
24 #define PYQCSOBJECT_H
25
26 #include "PythonQt.h"
27
28 #include <QObject>
29 #include <QStringList>
30 #include <QMainWindow>
31 #include <QPushButton>
32 #include <QVariant>
33 #include <QLayout>
34
35 #include <csound.hpp>
36
37 #define PYQCSVERSION "1.0"
38
39 class CsoundQt;
40 class QuteSheet;
41
42 class PyQcsObject : public QObject {
43 Q_OBJECT
44
45 public:
46 PyQcsObject();
47 ~PyQcsObject();
48 void setCsoundQt(CsoundQt *qcs);
49
50 public slots:
51 // ! example for passing a PyObject directly from Qt to Python (without extra mashalling)
52 // PyObject* getMainModule();
53 // void showInformation(const QString& str);
54 // QStringList readDirectory(const QString& dir);
55 // QMainWindow* createWindow();
56 // QObject* findChild(QObject* o, const QString& name);
57 // QVariantMap testMap();
58
59 QString getVersion();
60 void refresh();
61
62 // Csound controls
63 void play(int index = -1, bool realtime = true);
64 void pause(int index = -1);
65 void stop(int index = -1);
66 void stopAll();
67 void record(int index = -1);
68 //void recordAll();
69 void setCsChannel(QString channel, double value, int index = -1); // sends value directly to Csound channel
70 void setCsChannel(QString channel, QString value, int index = -1);
71 double getCsChannel(QString channel, int index = -1);
72 QString getCsStringChannel(QString channel, int index = -1);
73 //Csound Language
74 bool opcodeExists(QString opcodeName);
75
76 // Editor
77 void setDocument(int index);
78 int loadDocument(QString name, bool runNow = false);
79 void insertText(QString text, int index = -1, int section = -1);
80 void setCsd(QString text, int index = -1);
81 void setFullText(QString text, int index = -1);
82 void setOrc(QString text, int index = -1);
83 void setSco(QString text, int index = -1);
84 void setWidgetsText(QString text, int index = -1); //FIXME how to handle parsing errors?
85 void setPresetsText(QString text, int index = -1); //FIXME how to handle parsing errors?
86 void setOptionsText(QString text, int index = -1);
87
88 int getDocument(QString name = ""); // Returns document index. -1 if not current open
89 int newDocument(QString name);
90
91 QString getSelectedText(int index = -1, int section = -1);
92 QString getCsd(int index = -1); // -1 uses current tab
93 QString getFullText(int index = -1);
94 QString getOrc(int index = -1);
95 QString getSco(int index = -1);
96 QString getWidgetsText(int index = -1);
97 QString getSelectedWidgetsText(int index = -1);
98 QString getPresetsText(int index = -1);
99 QString getOptionsText(int index = -1);
100 QString getFileName(int index = -1);
101 QString getFilePath(int index = -1);
102
103 //Widgets
104 void setChannelValue(QString channel, double value, int index = -1);
105 double getChannelValue(QString channel, int index = -1);
106 void setChannelString(QString channel, QString value, int index = -1);
107 QString getChannelString(QString channel, int index = -1);
108 void setWidgetProperty(QString widgetid, QString property, QVariant value, int index= -1); // widgetid can be eihter uuid (prefered) or channel
109 QVariant getWidgetProperty(QString widgetid, QString property, int index= -1);
110
111 void loadPreset(int presetIndex, int index = -1);
112
113 QStringList getWidgetUuids(int index = -1);
114 QStringList listWidgetProperties(QString widgetid, int index = -1);
115 QString createNewLabel(int x = 0, int y = 0, QString channel = QString(), int index = -1);
116 QString createNewDisplay(int x = 0, int y = 0, QString channel = QString(), int index = -1);
117 QString createNewScrollNumber(int x = 0, int y = 0, QString channel = QString(), int index = -1);
118 QString createNewLineEdit(int x = 0, int y = 0, QString channel = QString(), int index = -1);
119 QString createNewSpinBox(int x = 0, int y = 0, QString channel = QString(), int index = -1);
120 QString createNewSlider(QString channel, int index = -1);
121 QString createNewSlider(int x = 0, int y = 0, QString channel = QString(), int index = -1);
122 QString createNewButton(int x = 0, int y = 0, QString channel = QString(), int index = -1);
123 QString createNewKnob(int x = 0, int y = 0, QString channel = QString(), int index = -1);
124 QString createNewCheckBox(int x = 0, int y = 0, QString channel = QString(), int index = -1);
125 QString createNewMenu(int x = 0, int y = 0, QString channel = QString(), int index = -1);
126 QString createNewMeter(int x = 0, int y = 0, QString channel = QString(), int index = -1);
127 QString createNewConsole(int x = 0, int y = 0, QString channel = QString(), int index = -1);
128 QString createNewGraph(int x = 0, int y = 0, QString channel = QString(), int index = -1);
129 QString createNewScope(int x = 0, int y = 0, QString channel = QString(), int index = -1);
130
131 bool destroyWidget(QString widgetid);
132
133 // Live Events
134 QuteSheet* getSheet(int index = -1, int sheetIndex = -1); //TODO implement both getSheet functions
135 QuteSheet* getSheet(int index, QString sheetName);
136
137 //Scheduler
138 void schedule(QVariant time, QVariant event); // TODO implement receiving lists
139 void sendEvent(int index, QString events);
140 void sendEvent(QString events);
141
142 // To/From Csound
143 CSOUND* getCurrentCsound();
144 double getSampleRate(int index = -1);
145 int getKsmps(int index = -1);
146 int getNumChannels(int index = -1);
147 MYFLT *getTableArray(int ftable, int index = -1);
148
149 void evaluateCsound(QString code=QString());
150
151 // TODO implement these!
152 // getTablePointer(fn, index = -1)
153 // copyTableToList(fn, index = -1, offset = 0, number = -1)
154 // copyListToTable(list, fn, index = -1, offset = 0)
155
156
157 // void writeListToTable(int ftable, QVariantList values, int offset = 0, int count = -1);
158 // QVariantList readTableToList(int ftable, int offset = 0, int count = -1);
159 // void writeArrayToTable(int ftable, QVariantList values, int offset = 0, int count = -1); // Numpy arrays
160 // QVariantList readArrayToList(int ftable, int offset = 0, int count = -1); // Numpy arrays
161
162 // Register callback
163 void registerProcessCallback(QString func, int skipPeriods = 0, int index = -1);
164
165 private:
166 CsoundQt *m_qcs;
167 MYFLT **m_tablePtr;
168 };
169
170 #endif // PYQCSOBJECT_H