Browse Source

receive midi in zones

master
parent
commit
52f0c3700f
1 changed files with 27 additions and 2 deletions
  1. +27
    -2
      main.c

+ 27
- 2
main.c View File

// function declarations: // function declarations:
void alsa_error (const char *format, ...); void alsa_error (const char *format, ...);
void* midiinfunction (void * arg); void* midiinfunction (void * arg);
void midi_in_dispatch (void * arg, unsigned char * m);



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


int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
int mode = SND_RAWMIDI_SYNC; int mode = SND_RAWMIDI_SYNC;
pthread_t midiinthread; pthread_t midiinthread;


housicIO IOs = {NULL,NULL};
housicIO IOs = {NULL,NULL,0};
// snd_rawmidi_t* midiin = NULL; // snd_rawmidi_t* midiin = NULL;
const char* portname = "virtual"; const char* portname = "virtual";
message[3-i] = (unsigned char) buffer[status-i]; 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); 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 // error -- print error message

Loading…
Cancel
Save