summaryrefslogtreecommitdiff
path: root/midi-sdl.c
blob: a45852853f33dcb1ff60e7daec828db708180a53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>

#include "midi.h"
#include "main.h"

int  midi_init() {
        return 0;
}

void midi_playnote( int channel, int note, int octave_offset, int velocity ) {
        char out[32];
        int b = sprintf(out,"M%02X0020\nM%02X%02X%02X\n", 0xe0 | channel, 0x90 | channel, note + 12 * octave_offset, velocity&127);
        if (g_harfe_connected && (g_harfe_fd != -1))
                write(g_harfe_fd, out, b);
}

void midi_silencenote( int channel, int note, int octave_offset ) {
        char out[10];
        int b = sprintf(out,"M%02X%02X%02X\n", 0x80 | channel, note + 12 * octave_offset, 0);
        if (g_harfe_connected && (g_harfe_fd != -1))
                write(g_harfe_fd, out, b);
}

void midi_pitchbend( int channel, int pitch ) {
        char out[10];
        pitch += 8192;
        if (pitch < 0)
                pitch = 0;
        if (pitch > 16383)
                pitch = 16383;
        int b = sprintf(out,"M%02X%02X%02X\n", 0xe0 | channel, 0x7f & pitch, 0x7f & (pitch>>7));
        if (g_harfe_connected && (g_harfe_fd != -1))
                write(g_harfe_fd, out, b);
}

//void midi_controller_event( int saite, int value );