OXYGENHUB
◆ main x16-emulator / src / midi.h
1.2 KiB · Objective-C · last changed chore(): initial commit 15 days ago source blame history raw
1
// Commander X16 Emulator
2
// Copyright (c) 2024 MooingLemur
3
// All rights reserved. License: 2-clause BSD
4
5
#pragma once
6
7
#ifdef HAS_FLUIDSYNTH
8
#include <fluidsynth.h>
9
#endif
10
11
#define MIDI_UART_OSC_RATE_MHZ 16.0f
12
#define MIDI_UART_PRIMARY_DIVIDER 16
13
14
#define FS_MIDI_TEXT 0x01
15
#define FS_NOTE_OFF 0x80
16
#define FS_NOTE_ON 0x90
17
#define FS_KEY_PRESSURE 0xa0
18
#define FS_CONTROL_CHANGE 0xb0
19
#define FS_PROGRAM_CHANGE 0xc0
20
#define FS_CHANNEL_PRESSURE 0xd0
21
#define FS_PITCH_BEND 0xe0
22
#define FS_MIDI_SYSEX 0xf0
23
#define FS_MIDI_TIME_CODE 0xf1
24
#define FS_MIDI_SONG_POSITION 0xf2
25
#define FS_MIDI_SONG_SELECT 0xf3
26
#define FS_MIDI_TUNE_REQUEST 0xf6
27
#define FS_MIDI_EOX 0xf7
28
#define FS_MIDI_SYNC 0xf8
29
#define FS_MIDI_TICK 0xf9
30
#define FS_MIDI_START 0xfa
31
#define FS_MIDI_CONTINUE 0xfb
32
#define FS_MIDI_STOP 0xfc
33
#define FS_MIDI_ACTIVE_SENSING 0xfe
34
#define FS_MIDI_SYSTEM_RESET 0xff
35
36
#define FL_DEFAULT_GAIN 0.2f
37
38
void midi_init(void);
39
void midi_serial_init(void);
40
void midi_serial_step(int clocks);
41
uint8_t midi_serial_read(uint8_t reg, bool debugOn);
42
void midi_serial_write(uint8_t reg, uint8_t val);
43
void midi_load_sf2(uint8_t* filename);
44
void midi_synth_render(int16_t* buf, int len);
45
bool midi_serial_irq(void);
46
47
extern bool fs_midi_in_connect;