hydrogen 1.2.3
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-2024 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 <vector>
27#include <core/Object.h>
28
29namespace H2Core
30{
31
33class SMFBuffer : public H2Core::Object<SMFBuffer>
34{
36public:
37 std::vector<char> getBuffer() {
38 return m_buffer;
39 }
40
41 void writeByte( short int nByte );
42 void writeWord( int nVal );
43 void writeDWord( long nVal );
44 void writeString( const QString& sMsg );
45 void writeVarLen( long nVal );
46
47 std::vector<char> m_buffer;
48
49 SMFBuffer();
50};
51
52
53
55 NOTE_OFF = 128,
56 NOTE_ON = 144
57};
58
59
60
75
76
79{
80public:
81 virtual ~SMFBase() {}
82 virtual std::vector<char> getBuffer() = 0;
83};
84
85
86
88class SMFEvent : public SMFBase, public H2Core::Object<SMFEvent>
89{
91public:
92 SMFEvent(unsigned nTicks );
93 virtual ~SMFEvent();
94
97};
98
99
100
102class SMFTrackNameMetaEvent : public SMFEvent, public H2Core::Object<SMFTrackNameMetaEvent>
103{
105public:
106 SMFTrackNameMetaEvent( const QString& sTrackName, unsigned nDeltaTime );
107 virtual std::vector<char> getBuffer() override;
108
109private:
111
112};
113
114
115
117class SMFSetTempoMetaEvent : public SMFEvent, public H2Core::Object<SMFSetTempoMetaEvent>
118{
120public:
121 SMFSetTempoMetaEvent( float fBPM, unsigned nDeltaTime );
122 virtual std::vector<char> getBuffer() override;
123
124private:
125 unsigned m_fBPM;
126
127};
128
129
130
132class SMFCopyRightNoticeMetaEvent : public SMFEvent, public H2Core::Object<SMFCopyRightNoticeMetaEvent>
133{
135public:
136 SMFCopyRightNoticeMetaEvent( const QString& sAuthor, unsigned nDeltaTime );
137 virtual std::vector<char> getBuffer() override;
138
139private:
140 QString m_sAuthor;
141
142};
143
144
145
147class SMFTimeSignatureMetaEvent : public SMFEvent, public H2Core::Object<SMFTimeSignatureMetaEvent>
148{
150public:
151 SMFTimeSignatureMetaEvent( unsigned nBeats, unsigned nNote , unsigned nMTPMC , unsigned nTSNP24 , unsigned nTicks );
152 virtual std::vector<char> getBuffer() override;
153 // MTPMC = MIDI ticks per metronome click
154 // TSNP24 = Thirty Second Notes Per 24 MIDI Ticks.
155private:
157};
158
159
160
162class SMFNoteOnEvent : public SMFEvent, public H2Core::Object<SMFNoteOnEvent>
163{
165public:
166 SMFNoteOnEvent( unsigned nTicks, int nChannel, int nPitch, int nVelocity );
167
168 virtual std::vector<char> getBuffer() override;
169
170protected:
171 unsigned m_nChannel;
172 unsigned m_nPitch;
173 unsigned m_nVelocity;
174};
175
176
177
179class SMFNoteOffEvent : public SMFEvent, public H2Core::Object<SMFNoteOffEvent>
180{
182public:
183 SMFNoteOffEvent( unsigned nTicks, int nChannel, int nPitch, int nVelocity );
184
185 virtual std::vector<char> getBuffer() override;
186
187protected:
188 unsigned m_nChannel;
189 unsigned m_nPitch;
190 unsigned m_nVelocity;
191
192};
193
194};
195
196#endif
197
#define H2_OBJECT(name)
Definition Object.h:224
virtual std::vector< char > getBuffer()=0
virtual ~SMFBase()
Definition SMFEvent.h:81
std::vector< char > getBuffer()
Definition SMFEvent.h:37
void writeByte(short int nByte)
Definition SmfEvent.cpp:31
std::vector< char > m_buffer
Definition SMFEvent.h:47
void writeVarLen(long nVal)
Definition SmfEvent.cpp:70
void writeString(const QString &sMsg)
Definition SmfEvent.cpp:58
void writeDWord(long nVal)
Definition SmfEvent.cpp:48
void writeWord(int nVal)
Definition SmfEvent.cpp:39
virtual std::vector< char > getBuffer() override
Definition SmfEvent.cpp:157
SMFCopyRightNoticeMetaEvent(const QString &sAuthor, unsigned nDeltaTime)
Definition SmfEvent.cpp:148
virtual ~SMFEvent()
Definition SmfEvent.cpp:228
SMFEvent(unsigned nTicks)
Definition SmfEvent.cpp:218
virtual std::vector< char > getBuffer() override
Definition SmfEvent.cpp:277
SMFNoteOffEvent(unsigned nTicks, int nChannel, int nPitch, int nVelocity)
Definition SmfEvent.cpp:264
virtual std::vector< char > getBuffer() override
Definition SmfEvent.cpp:249
SMFNoteOnEvent(unsigned nTicks, int nChannel, int nPitch, int nVelocity)
Definition SmfEvent.cpp:236
virtual std::vector< char > getBuffer() override
Definition SmfEvent.cpp:127
SMFSetTempoMetaEvent(float fBPM, unsigned nDeltaTime)
Definition SmfEvent.cpp:118
SMFTimeSignatureMetaEvent(unsigned nBeats, unsigned nNote, unsigned nMTPMC, unsigned nTSNP24, unsigned nTicks)
Definition SmfEvent.cpp:181
virtual std::vector< char > getBuffer() override
Definition SmfEvent.cpp:195
SMFTrackNameMetaEvent(const QString &sTrackName, unsigned nDeltaTime)
Definition SmfEvent.cpp:96
virtual std::vector< char > getBuffer() override
Definition SmfEvent.cpp:105
SMFEventType
Definition SMFEvent.h:54
@ NOTE_ON
Definition SMFEvent.h:56
@ NOTE_OFF
Definition SMFEvent.h:55
SMFMetaEventType
Definition SMFEvent.h:61
@ TIME_SIGNATURE
Definition SMFEvent.h:72
@ SEQUENCE_NUMBER
Definition SMFEvent.h:62
@ KEY_SIGNATURE
Definition SMFEvent.h:73
@ LYRIC
Definition SMFEvent.h:67
@ MARKER
Definition SMFEvent.h:68
@ CUE_POINT
Definition SMFEvent.h:69
@ TEXT_EVENT
Definition SMFEvent.h:63
@ SET_TEMPO
Definition SMFEvent.h:71
@ INSTRUMENT_NAME
Definition SMFEvent.h:66
@ COPYRIGHT_NOTICE
Definition SMFEvent.h:64
@ TRACK_NAME
Definition SMFEvent.h:65
@ END_OF_TRACK
Definition SMFEvent.h:70