mirror of
https://github.com/dwhinham/mt32-pi.git
synced 2026-07-09 10:17:46 +00:00
Previously, the LCD code needed to be aware of each synthesizer to know how to draw their respective displays, which wasn't very maintainable. Introduce a UI class where generic drawing utility functions and "system" drawing code can be implemented, and move synth-specific drawing to the synth classes themselves. This simplifies the LCD/OLED drivers to just being interfaces to the hardware. Also introduce a "MIDI monitor" class which tracks the state of all MIDI activity per-synth for level meter drawing purposes. This ensures we never miss a note; previously we were simply polling each synth engine for its note velocities per LCD update, which was prone to missing fast notes and also didn't account for channel volume or expression pedal. Finally, enable support for 16-character wide displays (closes #58).
99 lines
1.8 KiB
C++
99 lines
1.8 KiB
C++
//
|
|
// event.h
|
|
//
|
|
// mt32-pi - A baremetal MIDI synthesizer for Raspberry Pi
|
|
// Copyright (C) 2020-2021 Dale Whinham <daleyo@gmail.com>
|
|
//
|
|
// This file is part of mt32-pi.
|
|
//
|
|
// mt32-pi is free software: you can redistribute it and/or modify it under the
|
|
// terms of the GNU General Public License as published by the Free Software
|
|
// Foundation, either version 3 of the License, or (at your option) any later
|
|
// version.
|
|
//
|
|
// mt32-pi is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
// details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License along with
|
|
// mt32-pi. If not, see <http://www.gnu.org/licenses/>.
|
|
//
|
|
|
|
#ifndef _event_h
|
|
#define _event_h
|
|
|
|
#include "control/button.h"
|
|
#include "lcd/images.h"
|
|
#include "ringbuffer.h"
|
|
#include "synth/mt32romset.h"
|
|
#include "synth/synth.h"
|
|
|
|
struct TButtonEvent
|
|
{
|
|
TButton Button;
|
|
bool bPressed;
|
|
};
|
|
|
|
struct TEncoderEvent
|
|
{
|
|
s8 nDelta;
|
|
};
|
|
|
|
struct TSwitchSynthEvent
|
|
{
|
|
TSynth Synth;
|
|
};
|
|
|
|
struct TSwitchMT32ROMSetEvent
|
|
{
|
|
TMT32ROMSet ROMSet;
|
|
};
|
|
|
|
struct TSwitchSoundFontEvent
|
|
{
|
|
size_t Index;
|
|
};
|
|
|
|
struct TAllSoundOffEvent
|
|
{
|
|
// No payload
|
|
};
|
|
|
|
struct TDisplayImageEvent
|
|
{
|
|
TImage Image;
|
|
};
|
|
|
|
enum class TEventType
|
|
{
|
|
Button,
|
|
Encoder,
|
|
SwitchSynth,
|
|
SwitchMT32ROMSet,
|
|
SwitchSoundFont,
|
|
AllSoundOff,
|
|
DisplayImage,
|
|
};
|
|
|
|
struct TEvent
|
|
{
|
|
TEventType Type;
|
|
|
|
union
|
|
{
|
|
TButtonEvent Button;
|
|
TEncoderEvent Encoder;
|
|
TSwitchSynthEvent SwitchSynth;
|
|
TSwitchMT32ROMSetEvent SwitchMT32ROMSet;
|
|
TSwitchSoundFontEvent SwitchSoundFont;
|
|
TAllSoundOffEvent AllSoundOff;
|
|
TDisplayImageEvent DisplayImage;
|
|
};
|
|
};
|
|
|
|
constexpr size_t EventQueueSize = 32;
|
|
using TEventQueue = CRingBuffer<TEvent, EventQueueSize>;
|
|
|
|
#endif
|