/usr/share/doc/HOWTO/ja-html/MIDI-HOWTO-9.html is in doc-linux-ja-html 2006.05.25-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.21">
<TITLE>The Linux MIDI-HOWTO : MIDI $B$r07$&%W%m%0%i%`$N3+H/(B</TITLE>
<LINK HREF="MIDI-HOWTO-10.html" REL=next>
<LINK HREF="MIDI-HOWTO-8.html" REL=previous>
<LINK HREF="MIDI-HOWTO.html#toc9" REL=contents>
</HEAD>
<BODY>
<A HREF="MIDI-HOWTO-10.html">$B<!$N%Z!<%8(B</A>
<A HREF="MIDI-HOWTO-8.html">$BA0$N%Z!<%8(B</A>
<A HREF="MIDI-HOWTO.html#toc9">$BL\<!$X(B</A>
<HR>
<H2><A NAME="s9">9.</A> <A HREF="MIDI-HOWTO.html#toc9">MIDI $B$r07$&%W%m%0%i%`$N3+H/(B</A></H2>
<P>MIDI $B%"%W%j%1!<%7%g%s$N3+H/;VK><T$K$H$C$F!"3+H/$KCe<j$9$k$?$a$KNI$$%W%m%0%i%`Nc$,(B
$BI,MW$H$J$k$3$H$O$"$j$,$A$G$9!#(B</P>
<P>$B<!$K5s$2$kNc$O!"(BLAD $B%a!<%j%s%0%j%9%H$N!"%W%m%0%i%`Nc$HJ8=q!&%A%e!<%H%j%"%k(B
$B$K$D$$$F$N%9%l%C%I$KEj9F$5$l$^$7$?!#(B</P>
<H2><A NAME="ss9.1">9.1</A> <A HREF="MIDI-HOWTO.html#toc9.1">$BNc(B 1</A>
</H2>
<P>$B0J2<$N%W%m%0%i%`$O(B Dr. Matthias Nagorni $B$K$h$k!"$A$g$C$H$7$?%7!<%1%s%5$N(B
$B%k!<%A%s$G$9!#%j%s%/=8$K%j%9%H%"%C%W$5$l$F$$$k(B Matthias $B$N%5%$%H$+$i(B
$B$5$i$KB?$/$NNc$,F~<j$G$-$^$9!#(B</P>
<P>$B$3$N$h$&$K%3%s%Q%$%k$7$^$9(B:</P>
<P>
<HR>
<PRE>
[phil@beatbox] $ gcc seqdemo.c -o seqdemo -lasound
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <alsa/asoundlib.h>
snd_seq_t *open_seq();
void midi_action(snd_seq_t *seq_handle);
snd_seq_t *open_seq() {
snd_seq_t *seq_handle;
int portid;
if (snd_seq_open(&seq_handle, "hw", SND_SEQ_OPEN_DUPLEX, 0) < 0) {
fprintf(stderr, "Error opening ALSA sequencer.\n");
exit(1);
}
snd_seq_set_client_name(seq_handle, "ALSA Sequencer Demo");
if ((portid = snd_seq_create_simple_port(seq_handle, "ALSA Sequencer Demo",
SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE,
SND_SEQ_PORT_TYPE_APPLICATION)) < 0) {
fprintf(stderr, "Error creating sequencer port.\n");
exit(1);
}
return(seq_handle);
}
void midi_action(snd_seq_t *seq_handle) {
snd_seq_event_t *ev;
do {
snd_seq_event_input(seq_handle, &ev);
switch (ev->type) {
case SND_SEQ_EVENT_CONTROLLER:
fprintf(stderr, "Control event on Channel %2d: %5d \r",
ev->data.control.channel, ev->data.control.value);
break;
case SND_SEQ_EVENT_PITCHBEND:
fprintf(stderr, "Pitchbender event on Channel %2d: %5d \r",
ev->data.control.channel, ev->data.control.value);
break;
case SND_SEQ_EVENT_NOTEON:
fprintf(stderr, "Note On event on Channel %2d: %5d \r",
ev->data.control.channel, ev->data.note.note);
break;
case SND_SEQ_EVENT_NOTEOFF:
fprintf(stderr, "Note Off event on Channel %2d: %5d \r",
ev->data.control.channel, ev->data.note.note);
break;
}
snd_seq_free_event(ev);
} while (snd_seq_event_input_pending(seq_handle, 0) > 0);
}
int main(int argc, char *argv[]) {
snd_seq_t *seq_handle;
int npfd;
struct pollfd *pfd;
seq_handle = open_seq();
npfd = snd_seq_poll_descriptors_count(seq_handle, POLLIN);
pfd = (struct pollfd *)alloca(npfd * sizeof(struct pollfd));
snd_seq_poll_descriptors(seq_handle, pfd, npfd, POLLIN);
while (1) {
if (poll(pfd, npfd, 100000) > 0) {
midi_action(seq_handle);
}
}
}
</PRE>
<HR>
</P>
<H2><A NAME="ss9.2">9.2</A> <A HREF="MIDI-HOWTO.html#toc9.2">$BNc(B 2</A>
</H2>
<P>$B0J2<$O(B Nick Dowell $B:n$N(B ALSA 0.9 $BBP1~(B MIDI $B%j%@%$%l%/%?$G$9!#(B</P>
<P>
<HR>
<PRE>
/* ALSA Sequencer MIDI redirector.
Redirects the input to outputs determined by the MIDI channel
(as requested by Nathaniel Virgo on Linux-Audio-Dev ;-)
based on Dr. Matthias Nagorni's ALSA seq example
Nick Dowell <nixx@nixx.org.uk>
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <alsa/asoundlib.h>
int
main()
{
snd_seq_t *seq_handle;
snd_seq_event_t *ev;
int i;
int portid; /* input port */
int oportid[16]; /* output ports */
int npfd;
struct pollfd *pfd;
char txt[20];
if (snd_seq_open(&seq_handle, "hw", SND_SEQ_OPEN_DUPLEX, 0) < 0) {
fprintf(stderr, "Error opening ALSA sequencer.\n");
exit(1);
}
snd_seq_set_client_name(seq_handle, "MIDI Redirect");
/* open one input port */
if ((portid = snd_seq_create_simple_port
(seq_handle, "Input",
SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE,
SND_SEQ_PORT_TYPE_APPLICATION)) < 0) {
fprintf(stderr, "fatal error: could not open input port.\n");
exit(1);
}
/* open 16 output ports for the MIDI channels */
for (i=0; i<16; i++){
sprintf( txt, "MIDI Channel %d", i );
if ((oportid[i] = snd_seq_create_simple_port
(seq_handle, txt,
SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ,
SND_SEQ_PORT_TYPE_APPLICATION)) < 0) {
fprintf(stderr, "fatal error: could not open output port.\n");
exit(1);
}
}
npfd = snd_seq_poll_descriptors_count(seq_handle, POLLIN);
pfd = (struct pollfd *)alloca(npfd * sizeof(struct pollfd));
snd_seq_poll_descriptors(seq_handle, pfd, npfd, POLLIN);
while (1) /* main loop */
if (poll(pfd, npfd, 1000000) > 0){
do {
snd_seq_event_input(seq_handle, &ev);
snd_seq_ev_set_source( ev, oportid[ev->data.control.channel] );
snd_seq_ev_set_subs( ev );
snd_seq_ev_set_direct( ev );
snd_seq_event_output_direct( seq_handle, ev );
snd_seq_free_event(ev);
} while (snd_seq_event_input_pending(seq_handle, 0) > 0);
}
return 0;
}
</PRE>
<HR>
</P>
<H2><A NAME="ss9.3">9.3</A> <A HREF="MIDI-HOWTO.html#toc9.3">$BNc(B 3</A>
</H2>
<P>$B0J2<$O(B Craig Stuart Sapp $B$K$h$k!"(BOSS $B$N(B /dev/midi $B%$%s%?%U%'!<%9$K(B
$B%G!<%?$r=q$-9~$`Nc$G$9!#(B</P>
<P>$B%j%s%/$N@a$K%j%9%H%"%C%W$5$l$F$$$k(B Craig $B$N%5%$%H$K$O!"$5$i$KB?$/$N(B
$BNc$,$"$j$^$9!#(B</P>
<P>
<HR>
<PRE>
//
// Programmer: Craig Stuart Sapp [craig@ccrma.stanford.edu]
// Creation Date: Mon Dec 21 18:00:42 PST 1998
// Last Modified: Mon Dec 21 18:00:42 PST 1998
// Filename: ...linuxmidi/output/method1.c
// Syntax: C
// $Smake: gcc -O -o devmidiout devmidiout.c && strip devmidiout
//
#include <linux/soundcard.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
int main(void) {
char* device = "/dev/midi" ;
unsigned char data[3] = {0x90, 60, 127};
// step 1: open the OSS device for writing
int fd = open(device, O_WRONLY, 0);
if (fd < 0) {
printf("Error: cannot open %s\n", device);
exit(1);
}
// step 2: write the MIDI information to the OSS device
write(fd, data, sizeof(data));
// step 3: (optional) close the OSS device
close(fd);
return 0;
}
</PRE>
<HR>
</P>
<HR>
<A HREF="MIDI-HOWTO-10.html">$B<!$N%Z!<%8(B</A>
<A HREF="MIDI-HOWTO-8.html">$BA0$N%Z!<%8(B</A>
<A HREF="MIDI-HOWTO.html#toc9">$BL\<!$X(B</A>
</BODY>
</HTML>
|