wip midi
This commit is contained in:
+36
@@ -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);
|
||||
@@ -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 */
|
||||
@@ -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 */
|
||||
Reference in New Issue
Block a user