瀏覽代碼

receive midi in zones

master
父節點
當前提交
52f0c3700f
共有 1 個檔案被更改,包括 27 行新增2 行删除
  1. +27
    -2
      main.c

+ 27
- 2
main.c 查看文件

@@ -12,10 +12,13 @@
// function declarations:
void alsa_error (const char *format, ...);
void* midiinfunction (void * arg);
void midi_in_dispatch (void * arg, unsigned char * m);


typedef struct {
snd_rawmidi_t* midiin;
snd_rawmidi_t* midiout;
unsigned char hui_in_zone;
} housicIO;

int main(int argc, char *argv[]) {
@@ -23,7 +26,7 @@ int main(int argc, char *argv[]) {
int mode = SND_RAWMIDI_SYNC;
pthread_t midiinthread;

housicIO IOs = {NULL,NULL};
housicIO IOs = {NULL,NULL,0};
// snd_rawmidi_t* midiin = NULL;
const char* portname = "virtual";
@@ -69,12 +72,34 @@ void *midiinfunction(void *arg) {
message[3-i] = (unsigned char) buffer[status-i];
}

printf("%d: %x %x %x\n", status, message[0], message[1], message[2]);
midi_in_dispatch(IOs,message);

fflush(stdout);
}
}



//////////////////////////////
//
// midi_in_dispatch -- Thread function which waits around until a MIDI
// input byte arrives and then react correspondingly
//

void midi_in_dispatch(void *arg, unsigned char *m) {
housicIO* IOs = (housicIO*)arg;

if (m[0] == 0xb0) {
// received a CC message on MIDIchannel 1
if (m[1] == 0x0f) {
// received a zone select
IOs->hui_in_zone = m[2];
}

}
}


//////////////////////////////
//
// error -- print error message

Loading…
取消
儲存