aboutsummaryrefslogtreecommitdiff
path: root/visualization/renderer/qmppluginapistub.cpp
blob: 6c6424caedb3cee647a82b90448e79795fb54f6a (plain) (blame)
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
245
246
247
248
249
250
251
252
253
254
255
#include "qmpmidiplay.hpp"
#include "qmpvisrendercore.hpp"
#include "qmpsettingsro.hpp"
#include "qmppluginapistub.hpp"

#include <QTextCodec>

qmpPluginAPIStub::qmpPluginAPIStub(qmpVisRenderCore *_core):
    core(_core)
{
}

qmpPluginAPIStub::~qmpPluginAPIStub()
{
    core = nullptr;
}

uint32_t qmpPluginAPIStub::getDivision()
{
    return core->player->getDivision();
}
uint32_t qmpPluginAPIStub::getRawTempo()
{
    return 0;
}
double qmpPluginAPIStub::getRealTempo()
{
    return 0;
}
uint32_t qmpPluginAPIStub::getTimeSig()
{
    return 0;
}
int qmpPluginAPIStub::getKeySig()
{
    return 0;
}
uint32_t qmpPluginAPIStub::getNoteCount()
{
    return 0;
}
uint32_t qmpPluginAPIStub::getMaxTick()
{
    return core->player->getMaxTick();
}
uint32_t qmpPluginAPIStub::getCurrentPolyphone()
{
    return 0;
}
uint32_t qmpPluginAPIStub::getMaxPolyphone()
{
    return 0;
}
uint32_t qmpPluginAPIStub::getCurrentTimeStamp()
{
    return 0;
}
uint32_t qmpPluginAPIStub::getCurrentPlaybackPercentage()
{
    return 0;
}

PlaybackStatus qmpPluginAPIStub::getPlaybackStatus()
{
    return {false, 0, 0, 0, 0};
}
int qmpPluginAPIStub::getChannelCC(int ch, int cc)
{
    return 0;
}
int qmpPluginAPIStub::getChannelPreset(int ch)
{
    return 0;
}
void qmpPluginAPIStub::playerSeek(uint32_t percentage) {}
double qmpPluginAPIStub::getPitchBend(int ch)
{
    return 0;
}
void qmpPluginAPIStub::getPitchBendRaw(int ch, uint32_t *pb, uint32_t *pbr) {}
bool qmpPluginAPIStub::getChannelMask(int ch)
{
    return 0;
}
std::string qmpPluginAPIStub::getTitle()
{
    if (core->settings()->getOptionEnumIntOptName("Midi/TextEncoding") == "Unicode")
        return std::string(core->player->getTitle());
    return QTextCodec::codecForName(
            core->settings()->getOptionEnumIntOptName("Midi/TextEncoding").c_str())->
        toUnicode(core->player->getTitle()).toStdString();
}
std::wstring qmpPluginAPIStub::getWTitle()
{
    if (core->settings()->getOptionEnumIntOptName("Midi/TextEncoding") == "Unicode")
        return QString(core->player->getTitle()).toStdWString();
    return QTextCodec::codecForName(
            core->settings()->getOptionEnumIntOptName("Midi/TextEncoding").c_str())->
        toUnicode(core->player->getTitle()).toStdWString();
}
std::string qmpPluginAPIStub::getChannelPresetString(int ch)
{
    return std::string();
}
bool qmpPluginAPIStub::isDarkTheme()
{
    return false;
}
void *qmpPluginAPIStub::getMainWindow()
{
    return nullptr;
}
void qmpPluginAPIStub::discardCurrentEvent() {}
void qmpPluginAPIStub::commitEventChange(SEvent d) {}
void qmpPluginAPIStub::callEventReaderCB(SEvent d) {}
void qmpPluginAPIStub::setFuncState(std::string name, bool state) {}
void qmpPluginAPIStub::setFuncEnabled(std::string name, bool enable)
{}
void qmpPluginAPIStub::registerFunctionality(qmpFuncBaseIntf *i, std::string name, std::string desc, const char *icon, int iconlen, bool checkable)
{
    if (name == "Visualization")
        core->vf = i;
}
void qmpPluginAPIStub::unregisterFunctionality(std::string name)
{
    if (name == "Visualization")
        core->vf = nullptr;
}

int qmpPluginAPIStub::registerUIHook(std::string e, ICallBack *cb, void *userdat) {return -1;}
int qmpPluginAPIStub::registerUIHook(std::string e, callback_t cb, void *userdat)
{
    if (e == "main.start")
        core->startcb = cb;
    if (e == "main.reset")
        core->resetcb = cb;
    return 0;
}
void qmpPluginAPIStub::unregisterUIHook(std::string e, int hook)
{
    if (e == "main.start")
        core->startcb = nullptr;
    if (e == "main.reset")
        core->resetcb = nullptr;
}

void qmpPluginAPIStub::registerMidiOutDevice(qmpMidiOutDevice *dev, std::string name) {}
void qmpPluginAPIStub::unregisterMidiOutDevice(std::string name) {}

int qmpPluginAPIStub::registerEventReaderIntf(ICallBack *cb, void *userdata) {return -1;}
void qmpPluginAPIStub::unregisterEventReaderIntf(int intfhandle) {}
int qmpPluginAPIStub::registerEventHandlerIntf(ICallBack *cb, void *userdata) {return -1;}
void qmpPluginAPIStub::unregisterEventHandlerIntf(int intfhandle) {}
int qmpPluginAPIStub::registerFileReadFinishedHandlerIntf(ICallBack *cb, void *userdata) {return -1;}
void qmpPluginAPIStub::unregisterFileReadFinishedHandlerIntf(int intfhandle) {}

int qmpPluginAPIStub::registerEventHandler(callback_t cb, void *userdata, bool post) {return -1;}
void qmpPluginAPIStub::unregisterEventHandler(int id) {}
int qmpPluginAPIStub::registerEventReadHandler(callback_t cb, void *userdata)
{
    return core->player->registerEventReadHandler(cb, userdata);
}
void qmpPluginAPIStub::unregisterEventReadHandler(int id)
{
    core->player->unregisterEventReadHandler(id);
}
int qmpPluginAPIStub::registerFileReadFinishHook(callback_t cb, void *userdata)
{
    return core->player->registerFileReadFinishHook(cb, userdata);
}
void qmpPluginAPIStub::unregisterFileReadFinishHook(int id)
{
    core->player->unregisterFileReadFinishHook(id);
}

void qmpPluginAPIStub::registerFileReader(qmpFileReader *reader, std::string name) {}
void qmpPluginAPIStub::unregisterFileReader(std::string name) {}

void qmpPluginAPIStub::registerOptionInt(std::string tab, std::string desc, std::string key, int min, int max, int defaultval)
{
    core->settings()->registerOptionInt(tab, desc, key, min, max, defaultval);
}
int qmpPluginAPIStub::getOptionInt(std::string key)
{
    return core->settings()->getOptionInt(key);
}
void qmpPluginAPIStub::setOptionInt(std::string key, int val)
{
    core->settings()->setOptionInt(key, val);
}

void qmpPluginAPIStub::registerOptionUint(std::string tab, std::string desc, std::string key, unsigned min, unsigned max, unsigned defaultval)
{
    core->settings()->registerOptionUint(tab, desc, key, min, max, defaultval);
}
unsigned qmpPluginAPIStub::getOptionUint(std::string key)
{
    return core->settings()->getOptionUint(key);
}
void qmpPluginAPIStub::setOptionUint(std::string key, unsigned val)
{
    return core->settings()->setOptionUint(key, val);
}

void qmpPluginAPIStub::registerOptionBool(std::string tab, std::string desc, std::string key, bool defaultval)
{
    core->settings()->registerOptionBool(tab, desc, key, defaultval);
}
bool qmpPluginAPIStub::getOptionBool(std::string key)
{
    return core->settings()->getOptionBool(key);
}
void qmpPluginAPIStub::setOptionBool(std::string key, bool val)
{
    core->settings()->setOptionBool(key, val);
}

void qmpPluginAPIStub::registerOptionDouble(std::string tab, std::string desc, std::string key, double min, double max, double defaultval)
{
    core->settings()->registerOptionDouble(tab, desc, key, min, max, defaultval);
}
double qmpPluginAPIStub::getOptionDouble(std::string key)
{
    return core->settings()->getOptionDouble(key);
}
void qmpPluginAPIStub::setOptionDouble(std::string key, double val)
{
    core->settings()->setOptionDouble(key, val);
}

void qmpPluginAPIStub::registerOptionString(std::string tab, std::string desc, std::string key, std::string defaultval, bool ispath)
{
    core->settings()->registerOptionString(tab, desc, key, defaultval, ispath);
}
std::string qmpPluginAPIStub::getOptionString(std::string key)
{
    return core->settings()->getOptionString(key);
}
void qmpPluginAPIStub::setOptionString(std::string key, std::string val)
{
    core->settings()->setOptionString(key, val);
}

void qmpPluginAPIStub::registerOptionEnumInt(std::string tab, std::string desc, std::string key, std::vector<std::string> options, int defaultval)
{
    core->settings()->registerOptionEnumInt(tab, desc, key, options, defaultval);
}
int qmpPluginAPIStub::getOptionEnumInt(std::string key)
{
    return core->settings()->getOptionEnumInt(key);
}
void qmpPluginAPIStub::setOptionEnumInt(std::string key, int val)
{
    core->settings()->setOptionEnumInt(key, val);
}