hydrogen 1.2.6
EventQueue.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 EVENT_QUEUE_H
24#define EVENT_QUEUE_H
25
26#include <core/Object.h>
27#include <core/Basics/Note.h>
28#include <cassert>
29#include <mutex>
30
33#define MAX_EVENTS 1024
34
35namespace H2Core
36{
37
180
185class Event
186{
187public:
193 int value;
194};
195
210class EventQueue : public H2Core::Object<EventQueue>
211{
213public:
219 static void create_instance();
224 static EventQueue* get_instance() { assert(__instance); return __instance; }
225 ~EventQueue();
226
245 void push_event( const EventType type, const int nValue );
261
263 int m_column; //position
264 int m_row; //instrument row
265 int m_pattern; // pattern number
268 float f_pan;
273 };
274 std::vector<AddMidiNoteVector> m_addMidiNoteVector;
275
276 bool getSilent() const;
277 void setSilent( bool bSilent );
278
279private:
287 EventQueue();
294
301 volatile unsigned int __read_index;
308 volatile unsigned int __write_index;
316
320 std::mutex m_mutex;
321
324};
325
326inline bool EventQueue::getSilent() const {
327 return m_bSilent;
328}
329inline void EventQueue::setSilent( bool bSilent ) {
330 m_bSilent = bSilent;
331}
332
333};
334
335#endif
#define MAX_EVENTS
Maximum number of events to be stored in the H2Core::EventQueue::__events_buffer.
Definition EventQueue.h:33
#define H2_OBJECT(name)
Definition Object.h:227
volatile unsigned int __write_index
Continuously growing number indexing the event, which has been written to the EventQueue most recentl...
Definition EventQueue.h:308
static EventQueue * get_instance()
Returns a pointer to the current EventQueue singleton stored in __instance.
Definition EventQueue.h:224
EventQueue()
Constructor of the EventQueue class.
void push_event(const EventType type, const int nValue)
Queues the next event into the EventQueue.
void setSilent(bool bSilent)
Definition EventQueue.h:329
std::mutex m_mutex
Mutex to lock access to queue.
Definition EventQueue.h:320
static void create_instance()
If __instance equals 0, a new EventQueue singleton will be created and stored in it.
bool getSilent() const
Definition EventQueue.h:326
static EventQueue * __instance
Object holding the current EventQueue singleton.
Definition EventQueue.h:293
Event __events_buffer[MAX_EVENTS]
Array of all events contained in the EventQueue.
Definition EventQueue.h:315
std::vector< AddMidiNoteVector > m_addMidiNoteVector
Definition EventQueue.h:274
bool m_bSilent
Whether or not to push log messages.
Definition EventQueue.h:323
Event pop_event()
Reads out the next event of the EventQueue.
volatile unsigned int __read_index
Continuously growing number indexing the event, which has been read from the EventQueue most recently...
Definition EventQueue.h:301
Basic building block for the communication between the core of Hydrogen and its GUI.
Definition EventQueue.h:186
EventType type
Specifies the context the event is create in and which function should be triggered to handle it.
Definition EventQueue.h:190
int value
Additional information to describe the actual context of the engine.
Definition EventQueue.h:193
Key
possible keys
Definition Note.h:105
Octave
possible octaves
Definition Note.h:109
EventType
Basic types of communication between the core part of Hydrogen and its GUI.
Definition EventQueue.h:40
@ EVENT_COLUMN_CHANGED
Triggered when transport is moved into a different column (either during playback or when relocated b...
Definition EventQueue.h:156
@ EVENT_RELOCATION
Triggered in case there is a relocation of the transport position while trasnsport is not rolling.
Definition EventQueue.h:166
@ EVENT_XRUN
Definition EventQueue.h:85
@ EVENT_PLAYBACK_TRACK_CHANGED
Definition EventQueue.h:175
@ EVENT_INSTRUMENT_PARAMETERS_CHANGED
Some parameters of an instrument have been changed.
Definition EventQueue.h:83
@ EVENT_METRONOME
Triggered when a metronome note is passed to the H2Core::Sampler.
Definition EventQueue.h:97
@ EVENT_UNDO_REDO
Definition EventQueue.h:101
@ EVENT_PLAYLIST_LOADSONG
Definition EventQueue.h:100
@ EVENT_DRUMKIT_LOADED
A the current drumkit was replaced by a new one.
Definition EventQueue.h:158
@ EVENT_STATE
Definition EventQueue.h:43
@ EVENT_JACK_TRANSPORT_ACTIVATION
Toggles the button indicating the usage JACK transport.
Definition EventQueue.h:141
@ EVENT_PLAYING_PATTERNS_CHANGED
The list of currently played patterns (AudioEngine::getPlayingPatterns()) did change.
Definition EventQueue.h:57
@ EVENT_TEMPO_CHANGED
Definition EventQueue.h:103
@ EVENT_ACTION_MODE_CHANGE
Switches between select mode (0) and draw mode (1) in the *SongEditor.
Definition EventQueue.h:152
@ EVENT_SELECTED_INSTRUMENT_CHANGED
Definition EventQueue.h:77
@ EVENT_PATTERN_MODIFIED
A pattern was added, deleted, or modified.
Definition EventQueue.h:68
@ EVENT_TIMELINE_ACTIVATION
Enables/disables the usage of the Timeline.
Definition EventQueue.h:136
@ EVENT_SOUND_LIBRARY_CHANGED
Definition EventQueue.h:176
@ EVENT_TIMELINE_UPDATE
Tells the GUI some parts of the Timeline (tempo markers or tags) were modified.
Definition EventQueue.h:139
@ EVENT_NEXT_SHOT
Definition EventQueue.h:177
@ EVENT_SONG_SIZE_CHANGED
Definition EventQueue.h:173
@ EVENT_UPDATE_SONG
Event triggering HydrogenApp::updateSongEvent() whenever the Song was changed outside of the GUI,...
Definition EventQueue.h:128
@ EVENT_BBT_CHANGED
The coarse grained transport position in beats and bars did change.
Definition EventQueue.h:172
@ EVENT_LOOP_MODE_ACTIVATION
Toggles the button indicating the usage loop mode.
Definition EventQueue.h:150
@ EVENT_NOTEON
Definition EventQueue.h:86
@ EVENT_MIDI_ACTIVITY
Definition EventQueue.h:84
@ EVENT_MIDI_MAP_CHANGED
Definition EventQueue.h:178
@ EVENT_GRID_CELL_TOGGLED
Definition EventQueue.h:153
@ EVENT_NONE
Fallback event.
Definition EventQueue.h:42
@ EVENT_NEXT_PATTERNS_CHANGED
Used in Song::PatternMode::Stacked to indicate that a either AudioEngine::getNextPatterns() did chang...
Definition EventQueue.h:64
@ EVENT_SONG_MODIFIED
Definition EventQueue.h:102
@ EVENT_QUIT
Triggering HydrogenApp::quitEvent() and enables a shutdown of the entire application via the command ...
Definition EventQueue.h:133
@ EVENT_PROGRESS
Definition EventQueue.h:98
@ EVENT_ERROR
Definition EventQueue.h:87
@ EVENT_UPDATE_PREFERENCES
Event triggering the loading or saving of the H2Core::Preferences whenever they were changed outside ...
Definition EventQueue.h:116
@ EVENT_JACK_TIMEBASE_STATE_CHANGED
Toggles the button indicating the usage JACK Timebase control and informs the GUI about a state chang...
Definition EventQueue.h:144
@ EVENT_PATTERN_EDITOR_LOCKED
Locks the PatternEditor on the pattern currently played back.
Definition EventQueue.h:160
@ EVENT_JACK_SESSION
Definition EventQueue.h:99
@ EVENT_SONG_MODE_ACTIVATION
Definition EventQueue.h:145
@ EVENT_SELECTED_PATTERN_CHANGED
Another pattern was selected via MIDI or the GUI without affecting the audio transport.
Definition EventQueue.h:76
@ EVENT_DRIVER_CHANGED
Definition EventQueue.h:174
@ EVENT_STACKED_MODE_ACTIVATION
Song::PatternMode::Stacked (0) or Song::PatternMode::Selected (1) was activated.
Definition EventQueue.h:148