-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathmidi2.c
executable file
·98 lines (74 loc) · 2.21 KB
/
midi2.c
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <alsa/asoundlib.h>
#include <alsa/seq_event.h>
int main(){
snd_seq_client_info_t *cinfo;
snd_seq_port_info_t *pinfo;
int client;
int myport;
int ret;
int queue;
snd_seq_t *seq;
int lokke;
snd_seq_client_info_alloca(&cinfo);
snd_seq_client_info_set_client(cinfo, -1);
snd_seq_open(&seq,"default",SND_SEQ_OPEN_DUPLEX,0);
//snd_seq_open(&toseq,"hw",SND_SEQ_OPEN_DUPLEX,0);
queue = snd_seq_alloc_queue(seq);
myport = snd_seq_create_simple_port(seq,
"radium out",
SND_SEQ_PORT_CAP_NO_EXPORT |
SND_SEQ_PORT_CAP_READ,
SND_SEQ_PORT_TYPE_MIDI_GENERIC |
SND_SEQ_PORT_TYPE_APPLICATION );
snd_seq_start_queue( seq, queue, NULL );
while (snd_seq_query_next_client(seq, cinfo) >= 0){
client = snd_seq_client_info_get_client(cinfo);
snd_seq_port_info_alloca(&pinfo);
snd_seq_port_info_set_client(pinfo, client);
snd_seq_port_info_set_port(pinfo, -1);
if(client==0) continue;
//if (client == m_client || client == 0) continue;
printf("Name: %s\n",snd_seq_client_info_get_name(cinfo));
if(!strcmp("Hydrogen",snd_seq_client_info_get_name(cinfo))){
while (snd_seq_query_next_port(seq, pinfo) >= 0 ){
int cap = snd_seq_port_info_get_capability(pinfo);
if ( snd_seq_port_info_get_client(pinfo) != 0 ){
if ( (cap & SND_SEQ_PORT_CAP_SUBS_WRITE) != 0){
printf("gakk %s\n", snd_seq_port_info_get_name(pinfo));
break;
}
}
}
break;
}
}
ret = snd_seq_connect_to(
seq,
myport,
snd_seq_port_info_get_client(pinfo),
snd_seq_port_info_get_port(pinfo)
);
printf("myport: %d, connectret: %d\n",myport,ret);
for(lokke=0;lokke<0x7f;lokke++){
unsigned char buffer[3]={0x90,lokke,0x70};
snd_seq_event_t ev;
snd_midi_event_t *midi_ev;
snd_midi_event_new( 10, &midi_ev );
snd_seq_ev_clear( &ev );
snd_midi_event_encode(midi_ev,
buffer,
3,
&ev);
snd_midi_event_free( midi_ev );
snd_seq_ev_set_source(&ev,myport);
snd_seq_ev_set_subs(&ev);
snd_seq_ev_schedule_tick( &ev, queue, 1, 1);
snd_seq_event_output(seq, &ev);
snd_seq_drain_output(seq);
}
{
char temp[500];
gets(&temp);
}
return 0;
}