1 //Copyright (c) 2002-2003 Nasca Octavian Paul
19 snd_seq_open(&midi_in,"default",SND_SEQ_OPEN_INPUT,0);
20 snd_seq_open(&midi_out,"default",SND_SEQ_OPEN_OUTPUT,0);
22 char portname[50];sprintf(portname,"Spliter IN");
23 int alsaport = snd_seq_create_simple_port(midi_in,portname
24 ,SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE
25 ,SND_SEQ_PORT_TYPE_SYNTH);
26 sprintf(portname,"Spliter OUT");
27 alsaport = snd_seq_create_simple_port(midi_out,portname
28 ,SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ
29 ,SND_SEQ_PORT_TYPE_SYNTH);
35 snd_seq_close(midi_in);
36 snd_seq_close(midi_out);
39 // This splits the Midi events from one channel to another two channels
40 void Spliter::midievents(){
41 snd_seq_event_t *midievent;
43 snd_seq_event_input(midi_in,&midievent);
45 if (midievent==NULL) return;
46 if ((midievent->type==SND_SEQ_EVENT_NOTEON)||(midievent->type==SND_SEQ_EVENT_NOTEOFF)){
47 int cmdchan=midievent->data.note.channel;
49 snd_seq_ev_set_subs(midievent);
50 snd_seq_ev_set_direct(midievent);
51 if (midievent->data.note.note<Psplitpoint) {
52 midievent->data.note.channel=Pchout1;
53 int tmp=midievent->data.note.note;
54 tmp+=Poct1*12;if (tmp>127) tmp=127;if (tmp<0) tmp=0;
55 midievent->data.note.note=tmp;
57 midievent->data.note.channel=Pchout2;
58 int tmp=midievent->data.note.note;
59 tmp+=Poct2*12;if (tmp>127) tmp=127;if (tmp<0) tmp=0;
60 midievent->data.note.note=tmp;
62 snd_seq_event_output_direct(midi_out,midievent);
64 snd_seq_ev_set_subs(midievent);
65 snd_seq_ev_set_direct(midievent);
66 snd_seq_event_output_direct(midi_out,midievent);
70 snd_seq_free_event(midievent);