|
- #ifndef IZ_MIDI_H
- #define IZ_MIDI_H
-
- #include <SDL_stdinc.h>
- #include <string.h>
-
- #ifndef PORTMIDI_INCLUDED
- #define PORTMIDI_INCLUDED
- #include <portmidi.h>
- #endif
-
- #include <minIni.h>
- #include "IZ_action.h"
- #include "../util/IZ_midi.h"
-
- #define MIDI_EVENT_BUFFER_SIZE 1024
-
- typedef u8 IZ_MIDINote;
-
- static const u8 IZ_MIDI_NOTE_ON = 0x90u;
-
- static const u8 IZ_MIDI_NOTE_OFF = 0x80u;
-
- typedef struct {
- PmDeviceID device_id;
- u8 channel;
- IZ_MIDINote control_mapping[CONTROLS];
- } IZ_MIDIInputConfig;
-
- typedef struct {
- IZ_MIDIInputConfig config;
- const PmDeviceInfo* device_info;
- PmStream* stream;
- PmEvent event_buffer[MIDI_EVENT_BUFFER_SIZE];
- i32 midi_events_count;
- } IZ_MIDIInputState;
-
- static const IZ_MIDIInputState IZ_MIDI_INPUT_DEFAULT_STATE[IZ_PLAYERS] = {
- {
- .config = {
- .control_mapping = {
- 70,
- 72,
- 71,
- 69,
- 65,
- 64,
- 48,
- 49,
- 50,
- 51,
- 52,
- 53,
- 54,
- 55,
- 56,
- 57,
- },
- .device_id = 0,
- .channel = 0,
- },
- .event_buffer = {},
- .stream = NULL,
- .device_info = NULL,
- },
- {
- .config = {
- .control_mapping = {
- 70,
- 72,
- 71,
- 69,
- 65,
- 64,
- 48,
- 49,
- 50,
- 51,
- 52,
- 53,
- 54,
- 55,
- 56,
- 57,
- },
- .device_id = 1,
- .channel = 1,
- },
- .event_buffer = {},
- .stream = NULL,
- .device_info = NULL,
- },
- };
-
- IZ_ProcedureResult IZ_MIDIInputSaveConfig(IZ_MIDIInputState(*)[IZ_PLAYERS], const char*);
-
- void IZ_MIDIInputHandleEvents(IZ_MIDIInputState(*)[IZ_PLAYERS], IZ_Action(*)[IZ_PLAYERS], PmEvent);
-
- IZ_ProcedureResult IZ_MIDIInputInitialize(IZ_MIDIInputState(*)[IZ_PLAYERS], const char*, u8, const char**);
-
- void IZ_MIDIInputTeardown(IZ_MIDIInputState(*)[IZ_PLAYERS]);
-
- #endif
|