This commit is contained in:
2025-09-28 15:56:19 +02:00
parent 12cc9040d8
commit b12fb43654
9 changed files with 77 additions and 17 deletions
+36
View File
@@ -0,0 +1,36 @@
#include <GLFW/glfw3.h>
#include <alsa/asoundlib.h>
#include "log.h"
#include "types.h"
void midi_close(MidiDevice device) {
if (device.input != NULL) {
snd_rawmidi_close(device.input);
}
if (device.output != NULL) {
snd_rawmidi_close(device.input);
}
}
MidiDevice midi_open(char *name) {
MidiDevice device;
device.input = NULL;
device.output = NULL;
snd_rawmidi_open(&device.input, &device.output, name, 0);
device.error = device.input == NULL || device.output == NULL;
if (device.error) {
midi_close(device);
}
log_debug("(%s) MIDI open", name);
return device;
}
// int bytes_read = snd_rawmidi_read(input, input_buffer, sizeof(input_buffer));
// snd_rawmidi_write(output, buffer, 3);
+9
View File
@@ -0,0 +1,9 @@
#include "types.h"
#ifndef MIDI_H
#define MIDI_H
MidiDevice midi_open(char *name);
void midi_close(MidiDevice device);
#endif /* MIDI_H */
+7
View File
@@ -1,4 +1,5 @@
#include <GLFW/glfw3.h>
#include <alsa/asoundlib.h>
#include <glad/egl.h>
#include <glad/gl.h>
#include <hashmap.h>
@@ -148,4 +149,10 @@ typedef struct ConfigFileItem {
char value[2048];
} ConfigFileItem;
typedef struct MidiDevice {
bool error;
snd_rawmidi_t *input;
snd_rawmidi_t *output;
} MidiDevice;
#endif /* TYPES_H */