hydrogen 1.2.6
SMFEvent.h
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2025 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY, without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see https://www.gnu.org/licenses
20 *
21 */
22
23#ifndef SMF_EVENT_H
24#define SMF_EVENT_H
25
26#include <QByteArray>
27#include <QString>
28#include <core/Object.h>
29
30namespace H2Core
31{
32
34class SMFBuffer : public H2Core::Object<SMFBuffer>
35{
37public:
38 QByteArray getBuffer() {
39 return m_buffer;
40 }
41
42 void writeByte( char nByte );
43 void writeWord( int nVal );
44 void writeDWord( long nVal );
45 void writeString( const QString& sMsg );
46 void writeVarLen( long nVal );
47
48 QByteArray m_buffer;
49
50 SMFBuffer();
51};
52
53
54
56 NOTE_OFF = 128,
57 NOTE_ON = 144
58};
59
60
61
76
77
80{
81public:
82 virtual ~SMFBase() {}
83 virtual QByteArray getBuffer() const = 0;
84 virtual QString toQString() const = 0;
85};
86
87
88
90class SMFEvent : public SMFBase, public H2Core::Object<SMFEvent>
91{
93public:
94 SMFEvent(unsigned nTicks );
95 virtual ~SMFEvent();
96
97 virtual QString toQString() const override;
100};
101
102
103
105class SMFTrackNameMetaEvent : public SMFEvent, public H2Core::Object<SMFTrackNameMetaEvent>
106{
108public:
109 SMFTrackNameMetaEvent( const QString& sTrackName, unsigned nDeltaTime );
110 virtual QByteArray getBuffer() const override;
111
112private:
114
115};
116
117
118
120class SMFSetTempoMetaEvent : public SMFEvent, public H2Core::Object<SMFSetTempoMetaEvent>
121{
123public:
124 SMFSetTempoMetaEvent( float fBPM, unsigned nDeltaTime );
125 virtual QByteArray getBuffer() const override;
126
127private:
128 unsigned m_fBPM;
129
130};
131
132
133
135class SMFCopyRightNoticeMetaEvent : public SMFEvent, public H2Core::Object<SMFCopyRightNoticeMetaEvent>
136{
138public:
139 SMFCopyRightNoticeMetaEvent( const QString& sAuthor, unsigned nDeltaTime );
140 virtual QByteArray getBuffer() const override;
141
142private:
143 QString m_sAuthor;
144
145};
146
147
148
150class SMFTimeSignatureMetaEvent : public SMFEvent, public H2Core::Object<SMFTimeSignatureMetaEvent>
151{
153public:
154 SMFTimeSignatureMetaEvent( unsigned nBeats, unsigned nNote , unsigned nMTPMC , unsigned nTSNP24 , unsigned nTicks );
155 virtual QByteArray getBuffer() const override;
156 // MTPMC = MIDI ticks per metronome click
157 // TSNP24 = Thirty Second Notes Per 24 MIDI Ticks.
158private:
160};
161
162
163
165class SMFNoteOnEvent : public SMFEvent, public H2Core::Object<SMFNoteOnEvent>
166{
168public:
169 SMFNoteOnEvent( unsigned nTicks, int nChannel, int nPitch, int nVelocity );
170
171 virtual QByteArray getBuffer() const override;
172
173protected:
174 unsigned m_nChannel;
175 unsigned m_nPitch;
176 unsigned m_nVelocity;
177};
178
179
180
182class SMFNoteOffEvent : public SMFEvent, public H2Core::Object<SMFNoteOffEvent>
183{
185public:
186 SMFNoteOffEvent( unsigned nTicks, int nChannel, int nPitch, int nVelocity );
187
188 virtual QByteArray getBuffer() const override;
189
190protected:
191 unsigned m_nChannel;
192 unsigned m_nPitch;
193 unsigned m_nVelocity;
194
195};
196
197};
198
199#endif
200
#define H2_OBJECT(name)
Definition Object.h:227
virtual QByteArray getBuffer() const =0
virtual QString toQString() const =0
virtual ~SMFBase()
Definition SMFEvent.h:82
QByteArray m_buffer
Definition SMFEvent.h:48
QByteArray getBuffer()
Definition SMFEvent.h:38
void writeVarLen(long nVal)
Definition SMFEvent.cpp:61
void writeString(const QString &sMsg)
Definition SMFEvent.cpp:53
void writeDWord(long nVal)
Definition SMFEvent.cpp:44
void writeWord(int nVal)
Definition SMFEvent.cpp:37
void writeByte(char nByte)
Definition SMFEvent.cpp:31
virtual QByteArray getBuffer() const override
Definition SMFEvent.cpp:146
SMFCopyRightNoticeMetaEvent(const QString &sAuthor, unsigned nDeltaTime)
Definition SMFEvent.cpp:137
virtual ~SMFEvent()
Definition SMFEvent.cpp:217
virtual QString toQString() const override
Definition SMFEvent.cpp:222
SMFEvent(unsigned nTicks)
Definition SMFEvent.cpp:207
virtual QByteArray getBuffer() const override
Definition SMFEvent.cpp:270
SMFNoteOffEvent(unsigned nTicks, int nChannel, int nPitch, int nVelocity)
Definition SMFEvent.cpp:257
virtual QByteArray getBuffer() const override
Definition SMFEvent.cpp:242
SMFNoteOnEvent(unsigned nTicks, int nChannel, int nPitch, int nVelocity)
Definition SMFEvent.cpp:229
virtual QByteArray getBuffer() const override
Definition SMFEvent.cpp:116
SMFSetTempoMetaEvent(float fBPM, unsigned nDeltaTime)
Definition SMFEvent.cpp:107
SMFTimeSignatureMetaEvent(unsigned nBeats, unsigned nNote, unsigned nMTPMC, unsigned nTSNP24, unsigned nTicks)
Definition SMFEvent.cpp:170
virtual QByteArray getBuffer() const override
Definition SMFEvent.cpp:184
SMFTrackNameMetaEvent(const QString &sTrackName, unsigned nDeltaTime)
Definition SMFEvent.cpp:85
virtual QByteArray getBuffer() const override
Definition SMFEvent.cpp:94
SMFEventType
Definition SMFEvent.h:55
@ NOTE_ON
Definition SMFEvent.h:57
@ NOTE_OFF
Definition SMFEvent.h:56
SMFMetaEventType
Definition SMFEvent.h:62
@ TIME_SIGNATURE
Definition SMFEvent.h:73
@ SEQUENCE_NUMBER
Definition SMFEvent.h:63
@ KEY_SIGNATURE
Definition SMFEvent.h:74
@ LYRIC
Definition SMFEvent.h:68
@ MARKER
Definition SMFEvent.h:69
@ CUE_POINT
Definition SMFEvent.h:70
@ TEXT_EVENT
Definition SMFEvent.h:64
@ SET_TEMPO
Definition SMFEvent.h:72
@ INSTRUMENT_NAME
Definition SMFEvent.h:67
@ COPYRIGHT_NOTICE
Definition SMFEvent.h:65
@ TRACK_NAME
Definition SMFEvent.h:66
@ END_OF_TRACK
Definition SMFEvent.h:71