midi write state
This commit is contained in:
+4
-5
@@ -1,7 +1,6 @@
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <alsa/asoundlib.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "types.h"
|
||||
|
||||
@@ -21,19 +20,19 @@ MidiDevice midi_open(char *name) {
|
||||
return device;
|
||||
}
|
||||
|
||||
void midi_write(MidiDevice device, unsigned char code, float value) {
|
||||
void midi_write(MidiDevice device, unsigned char code, unsigned char value) {
|
||||
unsigned char buffer[3];
|
||||
|
||||
buffer[0] = 0xB0;
|
||||
buffer[1] = code;
|
||||
buffer[2] = (unsigned char)(128 * value);
|
||||
buffer[2] = value;
|
||||
|
||||
snd_rawmidi_write(device.output, buffer, 3);
|
||||
}
|
||||
|
||||
bool midi_background_listen(MidiDevice device, SharedContext *context,
|
||||
void (*event_callback)(unsigned char code,
|
||||
float value)) {
|
||||
unsigned char value)) {
|
||||
pid_t pid;
|
||||
int bytes_read;
|
||||
unsigned char buffer[3];
|
||||
@@ -51,7 +50,7 @@ bool midi_background_listen(MidiDevice device, SharedContext *context,
|
||||
while (!context->stop) {
|
||||
bytes_read = snd_rawmidi_read(device.input, buffer, 3);
|
||||
if (bytes_read == 3) {
|
||||
event_callback(buffer[1], (float)buffer[2] / 256.0);
|
||||
event_callback(buffer[1], buffer[2]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user