drumstick 1.1.3
qwrk.h
Go to the documentation of this file.
1/*
2 WRK File component
3 Copyright (C) 2010-2019, Pedro Lopez-Cabanillas <plcl@users.sf.net>
4
5 This library is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef DRUMSTICK_QWRK_H
20#define DRUMSTICK_QWRK_H
21
22#include "macros.h"
23#include <QObject>
24
25class QDataStream;
26
34namespace drumstick {
35
71
72const QByteArray HEADER("CAKEWALK");
73
80class DRUMSTICK_EXPORT QWrk : public QObject
81{
82 Q_OBJECT
83
84public:
85 QWrk(QObject * parent = 0);
86 virtual ~QWrk();
87
88 void readFromStream(QDataStream *stream);
89 void readFromFile(const QString& fileName);
90 QTextCodec* getTextCodec();
91 void setTextCodec(QTextCodec *codec);
92 long getFilePos();
93
94 int getNow() const;
95 int getFrom() const;
96 int getThru() const;
97 int getKeySig() const;
98 int getClock() const;
99 int getAutoSave() const;
100 int getPlayDelay() const;
101 bool getZeroCtrls() const;
102 bool getSendSPP() const;
103 bool getSendCont() const;
104 bool getPatchSearch() const;
105 bool getAutoStop() const;
106 unsigned int getStopTime() const;
107 bool getAutoRewind() const;
108 int getRewindTime() const;
109 bool getMetroPlay() const;
110 bool getMetroRecord() const;
111 bool getMetroAccent() const;
112 int getCountIn() const;
113 bool getThruOn() const;
114 bool getAutoRestart() const;
115 int getCurTempoOfs() const;
116 int getTempoOfs1() const;
117 int getTempoOfs2() const;
118 int getTempoOfs3() const;
119 bool getPunchEnabled() const;
120 int getPunchInTime() const;
121 int getPunchOutTime() const;
122 int getEndAllTime() const;
123
124 QByteArray getLastChunkRawData() const;
125 double getRealTime(long ticks) const;
126
127Q_SIGNALS:
128
134 void signalWRKError(const QString& errorStr);
135
142 void signalWRKUnknownChunk(int type, const QByteArray& data);
143
150 void signalWRKHeader(int verh, int verl);
151
156
160 void signalWRKStreamEnd(long time);
161
172 void signalWRKNote(int track, long time, int chan, int pitch, int vol, int dur);
173
183 void signalWRKKeyPress(int track, long time, int chan, int pitch, int press);
184
194 void signalWRKCtlChange(int track, long time, int chan, int ctl, int value);
195
204 void signalWRKPitchBend(int track, long time, int chan, int value);
205
214 void signalWRKProgram(int track, long time, int chan, int patch);
215
224 void signalWRKChanPress(int track, long time, int chan, int press);
225
233 void signalWRKSysexEvent(int track, long time, int bank);
234
244 void signalWRKSysex(int bank, const QString& name, bool autosend, int port, const QByteArray& data);
245
254 void signalWRKText(int track, long time, int type, const QString& data);
255
263 void signalWRKTimeSig(int bar, int num, int den);
264
271 void signalWRKKeySig(int bar, int alt);
272
282 void signalWRKTempo(long time, int tempo);
283
298 void signalWRKTrack(const QString& name1,
299 const QString& name2,
300 int trackno, int channel, int pitch,
301 int velocity, int port,
302 bool selected, bool muted, bool loop );
303
309 void signalWRKTimeBase(int timebase);
310
320
335 void signalWRKThru(int mode, int port, int channel, int keyPlus, int velPlus, int localPort);
336
343 void signalWRKTrackOffset(int track, int offset);
344
351 void signalWRKTrackReps(int track, int reps);
352
359 void signalWRKTrackPatch(int track, int patch);
360
367 void signalWRKTrackBank(int track, int bank);
368
375 void signalWRKTimeFormat(int frames, int offset);
376
382 void signalWRKComments(const QString& data);
383
391 void signalWRKVariableRecord(const QString& name, const QByteArray& data);
392
399 void signalWRKTrackVol(int track, int vol);
400
414 void signalWRKNewTrack( const QString& name,
415 int trackno, int channel, int pitch,
416 int velocity, int port,
417 bool selected, bool muted, bool loop );
418
424 void signalWRKSoftVer(const QString& version);
425
432 void signalWRKTrackName(int track, const QString& name);
433
439 void signalWRKStringTable(const QStringList& strs);
440
448 void signalWRKSegment(int track, long time, const QString& name);
449
458 void signalWRKChord(int track, long time, const QString& name, const QByteArray& data);
459
468 void signalWRKExpression(int track, long time, int code, const QString& text);
469
478 void signalWRKHairpin(int track, long time, int code, int dur);
479
480private:
481 quint8 readByte();
482 quint16 to16bit(quint8 c1, quint8 c2);
483 quint32 to32bit(quint8 c1, quint8 c2, quint8 c3, quint8 c4);
484 quint16 read16bit();
485 quint32 read24bit();
486 quint32 read32bit();
487 QString readString(int len);
488 QString readVarString();
489 void readRawData(int size);
490 void readGap(int size);
491 bool atEnd();
492 void seek(qint64 pos);
493
494 int readChunk();
495 void processTrackChunk();
496 void processVarsChunk();
497 void processTimebaseChunk();
498 void processNoteArray(int track, int events);
499 void processStreamChunk();
500 void processMeterChunk();
501 void processTempoChunk(int factor = 1);
502 void processSysexChunk();
503 void processSysex2Chunk();
504 void processNewSysexChunk();
505 void processThruChunk();
506 void processTrackOffset();
507 void processTrackReps();
508 void processTrackPatch();
509 void processTrackBank();
510 void processTimeFormat();
511 void processComments();
512 void processVariableRecord(int max);
513 void processNewTrack();
514 void processSoftVer();
515 void processTrackName();
516 void processStringTable();
517 void processLyricsStream();
518 void processTrackVol();
519 void processNewTrackOffset();
520 void processMeterKeyChunk();
521 void processSegmentChunk();
522 void processNewStream();
523 void processUnknown(int id);
524 void processEndChunk();
525 void wrkRead();
526
527 struct RecTempo {
528 long time;
529 double tempo;
530 double seconds;
531 };
532
533 class QWrkPrivate;
534 QWrkPrivate *d;
535};
536
537} // namespace drumstick;
538
541#endif // DRUMSTICK_QWRK_H
The QObject class is the base class of all Qt objects.
Cakewalk WRK file format (input only)
Definition qwrk.h:81
void signalWRKTrackPatch(int track, int patch)
Emitted after reading a track patch chunk.
void signalWRKText(int track, long time, int type, const QString &data)
Emitted after reading a text message.
void signalWRKTrack(const QString &name1, const QString &name2, int trackno, int channel, int pitch, int velocity, int port, bool selected, bool muted, bool loop)
Emitted after reading a track prefix chunk.
void signalWRKProgram(int track, long time, int chan, int patch)
Emitted after reading a Program change message.
void signalWRKChord(int track, long time, const QString &name, const QByteArray &data)
Emitted after reading a chord diagram chunk.
void signalWRKHeader(int verh, int verl)
Emitted after reading a WRK header.
void signalWRKSysexEvent(int track, long time, int bank)
Emitted after reading a System Exclusive event.
void signalWRKGlobalVars()
Emitted after reading the global variables chunk.
void signalWRKSoftVer(const QString &version)
Emitted after reading a software version chunk.
void signalWRKComments(const QString &data)
Emitted after reading a comments chunk.
void signalWRKTrackOffset(int track, int offset)
Emitted after reading a track offset chunk.
void signalWRKChanPress(int track, long time, int chan, int press)
Emitted after reading a Channel Aftertouch message.
void signalWRKStreamEnd(long time)
Emitted after reading the last event of a event stream.
void signalWRKKeyPress(int track, long time, int chan, int pitch, int press)
Emitted after reading a Polyphonic Aftertouch message.
void signalWRKVariableRecord(const QString &name, const QByteArray &data)
Emitted after reading a variable chunk.
void signalWRKTrackVol(int track, int vol)
Emitted after reading a track volume chunk.
void signalWRKStringTable(const QStringList &strs)
Emitted after reading a string event types chunk.
void signalWRKError(const QString &errorStr)
Emitted for a WRK file read error.
void signalWRKSegment(int track, long time, const QString &name)
Emitted after reading a segment prefix chunk.
void signalWRKTempo(long time, int tempo)
Emitted after reading a Tempo Change message.
void signalWRKExpression(int track, long time, int code, const QString &text)
Emitted after reading an expression indication (notation) chunk.
void signalWRKTimeSig(int bar, int num, int den)
Emitted after reading a WRK Time signature.
void signalWRKHairpin(int track, long time, int code, int dur)
Emitted after reading a hairpin symbol (notation) chunk.
void signalWRKPitchBend(int track, long time, int chan, int value)
Emitted after reading a Bender message.
void signalWRKEnd()
Emitted after reading the last chunk of a WRK file.
void signalWRKThru(int mode, int port, int channel, int keyPlus, int velPlus, int localPort)
Emitted after reading an Extended Thru parameters chunk.
void signalWRKNote(int track, long time, int chan, int pitch, int vol, int dur)
Emitted after reading a Note message.
void signalWRKUnknownChunk(int type, const QByteArray &data)
Emitted after reading an unknown chunk.
void signalWRKTrackBank(int track, int bank)
Emitted after reading a track bank chunk.
void signalWRKTrackName(int track, const QString &name)
Emitted after reading a track name chunk.
void signalWRKTimeBase(int timebase)
Emitted after reading the timebase chunk.
void signalWRKTimeFormat(int frames, int offset)
Emitted after reading a SMPTE time format chunk.
void signalWRKSysex(int bank, const QString &name, bool autosend, int port, const QByteArray &data)
Emitted after reading a System Exclusive Bank.
void signalWRKCtlChange(int track, long time, int chan, int ctl, int value)
Emitted after reading a Control Change message.
void signalWRKTrackReps(int track, int reps)
Emitted after reading a track offset chunk.
void signalWRKNewTrack(const QString &name, int trackno, int channel, int pitch, int velocity, int port, bool selected, bool muted, bool loop)
Emitted after reading a new track prefix.
void signalWRKKeySig(int bar, int alt)
Emitted after reading a WRK Key Signature.
Drumstick visibility macros.
const QByteArray HEADER("CAKEWALK")
Cakewalk WRK File header id.
WrkChunkType
Record types within a WRK file.
Definition qwrk.h:39
@ NTRKOFS_CHUNK
Track offset.
Definition qwrk.h:62
@ NTRACK_CHUNK
Track prefix.
Definition qwrk.h:64
@ TRKPATCH_CHUNK
Track patch.
Definition qwrk.h:52
@ STRTAB_CHUNK
Table of text event types.
Definition qwrk.h:58
@ NTEMPO_CHUNK
New Tempo map.
Definition qwrk.h:53
@ VARS_CHUNK
Global variables.
Definition qwrk.h:42
@ TRKBANK_CHUNK
Track bank.
Definition qwrk.h:63
@ COMMENTS_CHUNK
Comments.
Definition qwrk.h:47
@ SGMNT_CHUNK
Segment prefix.
Definition qwrk.h:67
@ SOFTVER_CHUNK
Software version which saved the file.
Definition qwrk.h:68
@ TRKNAME_CHUNK
Track name.
Definition qwrk.h:60
@ TIMEFMT_CHUNK
SMPTE time format.
Definition qwrk.h:50
@ END_CHUNK
Last chunk, end of file.
Definition qwrk.h:69
@ STREAM_CHUNK
Events stream.
Definition qwrk.h:41
@ TRACK_CHUNK
Track prefix.
Definition qwrk.h:40
@ TIMEBASE_CHUNK
Timebase. If present is the first chunk in the file.
Definition qwrk.h:49
@ TRKOFFS_CHUNK
Track offset.
Definition qwrk.h:48
@ NSYSEX_CHUNK
System exclusive bank.
Definition qwrk.h:65
@ THRU_CHUNK
Extended thru parameters.
Definition qwrk.h:54
@ SYSEX2_CHUNK
System exclusive bank.
Definition qwrk.h:57
@ NSTREAM_CHUNK
Events stream.
Definition qwrk.h:66
@ TEMPO_CHUNK
Tempo map.
Definition qwrk.h:43
@ VARIABLE_CHUNK
Variable record chunk.
Definition qwrk.h:61
@ METER_CHUNK
Meter map.
Definition qwrk.h:44
@ METERKEY_CHUNK
Meter/Key map.
Definition qwrk.h:59
@ MEMRGN_CHUNK
Memory region.
Definition qwrk.h:46
@ TRKREPS_CHUNK
Track repetitions.
Definition qwrk.h:51
@ TRKVOL_CHUNK
Track volume.
Definition qwrk.h:56
@ SYSEX_CHUNK
System exclusive bank.
Definition qwrk.h:45
@ LYRICS_CHUNK
Events stream with lyrics.
Definition qwrk.h:55