forked from hselasky/midipp
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmidipp_mainwindow.h
364 lines (273 loc) · 9 KB
/
midipp_mainwindow.h
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
/*-
* Copyright (c) 2009-2019 Hans Petter Selasky. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _MIDIPP_MAINWINDOW_H_
#define _MIDIPP_MAINWINDOW_H_
#include "midipp.h"
class MppMainWindow : public QWidget
{
Q_OBJECT;
public:
MppMainWindow(QWidget *parent = 0);
~MppMainWindow();
#ifdef HAVE_SCREENSHOT
void ScreenShot(QApplication &);
#endif
void MidiInit(void);
void MidiUnInit(void);
void atomic_lock(void);
void atomic_unlock(void);
void closeEvent(QCloseEvent *event);
void handle_stop(int flag = 0);
void handle_midi_file_open(int);
void handle_midi_file_clear_name(void);
void handle_midi_file_instr_prepend(void);
void handle_midi_file_instr_delete(void);
void handle_jump_locked(int index);
void handle_make_scores_visible(MppScoreMain *);
void handle_make_tab_visible(QWidget *);
QString get_midi_score_duration(uint32_t *psum);
int log_midi_score_duration();
int convert_midi_duration(struct umidi20_track *, uint32_t thres, uint32_t chan_mask);
void import_midi_track(struct umidi20_track *, uint32_t = 0, int = -1, int = 0);
void update_play_device_no(void);
void do_clock_stats(void);
int do_extended_alloc(int key, int refcount);
void do_key_press(int key, int vel, int dur);
void do_key_pressure(int key, int pressure);
void output_key(int index, int chan, int key, int vel, int delay, int dur);
void output_key_pressure(int index, int chan, int key, int pressure, int delay = 0);
uint32_t get_time_offset(void);
uint8_t noise8(uint8_t factor);
uint8_t do_instr_check(struct umidi20_event *event, uint8_t *pchan);
bool check_play(uint8_t index, uint8_t chan, uint32_t off, uint8_t = MPP_MAGIC_DEVNO);
bool check_record(uint8_t index, uint8_t chan, uint32_t off);
void handle_watchdog_sub(MppScoreMain *, int);
void send_song_stop_locked();
void send_song_trigger_locked();
void send_song_select_locked(uint8_t);
void send_byte_event_locked(uint8_t);
MppScoreMain *getCurrTransposeView(void);
QPlainTextEdit *currEditor();
MppScoreMain *currScores();
pthread_mutex_t mtx;
QFont defaultFont;
QFont editFont;
QFont printFont;
QFont showFont;
uint8_t auto_zero_start[0];
struct MppInstr instr[16];
int extended_keys[128][2];
uint32_t convLineStart[MPP_MAX_LINES];
uint32_t convLineEnd[MPP_MAX_LINES];
uint32_t convIndex;
uint32_t lastKeyPress;
uint32_t lastInputEvent;
uint32_t noiseRem;
uint32_t devInputMask[MPP_MAX_DEVS];
uint32_t startPosition;
uint32_t pausePosition;
uint32_t deviceBits;
#define MPP_DEV0_PLAY 0x0001UL
#define MPP_DEV0_RECORD 0x0002UL
uint16_t trackVolume[MPP_MAX_TRACKS];
int16_t masterPitchBend;
uint8_t devSelMap[MPP_MAX_DEVS];
uint8_t muteProgram[MPP_MAX_DEVS];
uint8_t mutePedal[MPP_MAX_DEVS];
uint8_t enableLocalKeys[MPP_MAX_DEVS];
uint8_t disableLocalKeys[MPP_MAX_DEVS];
uint8_t muteAllControl[MPP_MAX_DEVS];
uint8_t muteAllNonChannel[MPP_MAX_DEVS];
uint8_t muteMap[MPP_MAX_DEVS][16];
uint8_t inputEvents[MPP_MAX_QUEUE];
uint8_t numInputEvents;
uint8_t controlEvents[MPP_MAX_QUEUE][4];
uint8_t numControlEvents;
uint8_t cursorUpdate;
uint8_t scoreRecordOn;
uint8_t controlRecordOn;
uint8_t instrUpdated;
uint8_t midiRecordOff;
uint8_t midiPlayOff;
uint8_t midiTriggered;
uint8_t midiPaused;
uint8_t lastViewIndex;
uint8_t keyModeUpdated;
uint8_t doOperation;
#define MPP_OPERATION_PAUSE 0x01
#define MPP_OPERATION_REWIND 0x02
#define MPP_OPERATION_BPM 0x04
uint8_t noteMode;
char *deviceName[MPP_MAX_DEVS];
QGridLayout *main_gl;
MppTabBar *main_tb;
int main_tb_state;
/* main <> */
QPushButton *mwRewind;
QPushButton *mwPlay;
QPushButton *mwReload;
QPushButton *mwPaste;
QPushButton *mwCopy;
QPushButton *mwUndo;
QPushButton *mwRedo;
QPushButton *mwEdit;
QPushButton *mwUpDown;
/* tab <Scores> */
MppScoreMain *scores_main[MPP_MAX_VIEWS];
/* tab <Import> */
MppImportTab *tab_import;
QTimer *watchdog;
/* tab <File> */
MppGridLayout *tab_file_gl;
QPushButton *but_quit;
MppGroupBox *gb_midi_file;
QPushButton *but_midi_file_new;
QPushButton *but_midi_file_open_single;
QPushButton *but_midi_file_open_multi;
QPushButton *but_midi_file_merge_single;
QPushButton *but_midi_file_merge_multi;
QPushButton *but_midi_file_save;
QPushButton *but_midi_file_save_as;
MppButton *but_midi_file_import[MPP_MAX_VIEWS];
MppGroupBox *gb_gpro_file_import;
MppButton *but_gpro_file_import[MPP_MAX_VIEWS];
MppGroupBox *gb_mxml_file_import;
MppButton *but_mxml_file_import[MPP_MAX_VIEWS];
/* tab <Play> */
MppGroupBox *gl_ctrl;
MppGroupBox *gl_time;
MppGroupBox *gl_bpm;
MppGroupBox *gl_synth_play;
MppGroupBox *gl_tuning;
QLCDNumber *lbl_curr_time_val;
QLCDNumber *lbl_bpm_avg_val;
MppGridLayout *tab_play_gl;
MppVolume *spn_tuning;
MppButtonMap *mbm_midi_play;
MppButtonMap *mbm_midi_record;
MppButtonMap *mbm_score_record;
MppButtonMap *mbm_key_mode_a;
MppButtonMap *mbm_key_mode_b;
QPushButton *but_jump[MPP_MAX_LBUTTON];
QPushButton *but_compile;
QPushButton *but_midi_pause;
QPushButton *but_midi_trigger;
QPushButton *but_midi_rewind;
QPushButton *but_bpm;
MppButton *but_mode[MPP_MAX_VIEWS];
MppMode *dlg_mode[MPP_MAX_VIEWS];
MppBpm *dlg_bpm;
/* tab <Chord> */
MppDecodeTab *tab_chord_gl;
/* tab <PianoTab> */
MppPianoTab *tab_pianotab;
/* tab <Configuration> */
MppGridLayout *tab_config_gl;
MppGroupBox *gb_config_device;
MppSettings *mpp_settings;
MppDevSel *but_config_sel[MPP_MAX_DEVS];
MppButton *but_config_dev[MPP_MAX_DEVS];
MppButton *but_config_mm[MPP_MAX_DEVS];
QLineEdit *led_config_dev[MPP_MAX_DEVS];
MppCheckBox *cbx_config_dev[MPP_MAX_DEVS][1 + MPP_MAX_VIEWS];
uint32_t dirty_config_mask;
QTimer *tim_config_apply;
QPushButton *but_config_view_fontsel;
QPushButton *but_config_edit_fontsel;
QPushButton *but_config_print_fontsel;
QString *CurrMidiFileName;
/* tab <Shortcut> */
MppShortcutTab *tab_shortcut;
/* tab <Custom> */
MppCustomTab *tab_custom;
/* tab <Instrument> */
MppInstrumentTab *tab_instrument;
/* tab <Loop> */
MppLoopTab *tab_loop;
/* tab <RePlay> */
MppReplayTab *tab_replay;
/* tab <DataBase> */
MppDataBase *tab_database;
/* tab <Show> */
#ifndef HAVE_NO_SHOW
MppShowControl *tab_show_control;
#endif
/* tab <Help> */
QPlainTextEdit *tab_help;
/* MIDI stuff */
struct mid_data mid_data;
struct umidi20_song *song;
struct umidi20_track *track[MPP_MAX_TRACKS];
uint8_t auto_zero_end[0];
public slots:
void handle_quit();
void handle_jump(int index);
void handle_compile(int force = 0);
void handle_score_record(int);
void handle_midi_record(int);
void handle_midi_pause();
void handle_midi_play(int);
void handle_play_press(int, int);
void handle_play_release(int, int);
void handle_sustain_press(int);
void handle_sustain_release(int);
void handle_watchdog();
void handle_midi_file_new();
void handle_midi_file_merge_single_open();
void handle_midi_file_new_single_open();
void handle_midi_file_merge_multi_open();
void handle_midi_file_new_multi_open();
void handle_midi_file_save();
void handle_midi_file_save_as();
void handle_rewind();
void handle_midi_trigger();
void handle_config_changed();
void handle_config_apply();
void handle_config_local_keys();
void handle_config_reload();
void handle_config_view_fontsel();
void handle_config_edit_fontsel();
void handle_config_print_fontsel();
void handle_midi_file_import(int);
void handle_gpro_file_import(int);
void handle_mxml_file_import(int);
void handle_mute_map(int);
int handle_config_dev(int, int = 0);
void handle_bpm();
void handle_mode(int,int = 1);
void handle_key_mode_a(int);
void handle_key_mode_b(int);
void handle_move_right();
void handle_move_left();
void handle_tab_changed(int force = 0);
void handle_copy();
void handle_paste();
void handle_redo();
void handle_undo();
void handle_edit();
void handle_up_down();
void handle_tuning();
};
#endif /* _MIDIPP_MAINWINDOW_H_ */