Kaynağa Gözat

receive midi in zones

master
ebeveyn
işleme
52f0c3700f
1 değiştirilmiş dosya ile 27 ekleme ve 2 silme
  1. +27
    -2
      main.c

+ 27
- 2
main.c Dosyayı Görüntüle

@@ -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

Yükleniyor…
İptal
Kaydet