remove midicat

This commit is contained in:
Alexandre Ratchov 2011-10-18 00:29:58 +02:00
parent 4bbfe303b3
commit 8c514d82b6
14 changed files with 55 additions and 333 deletions

View File

@ -23,15 +23,15 @@ MAN1_DIR = @mandir@/man1
#
# programs to build
#
PROG = aucat midicat
MAN1 = aucat.1 midicat.1
PROG = aucat
MAN1 = aucat.1
all: ${PROG}
install:
mkdir -p ${DESTDIR}${BIN_DIR} ${DESTDIR}${MAN1_DIR}
cp aucat ${DESTDIR}${BIN_DIR}
cd ${DESTDIR}${BIN_DIR} && ln -f aucat midicat
cd ${DESTDIR}${BIN_DIR}
cp ${MAN1} ${DESTDIR}${MAN1_DIR}
uninstall:
@ -51,9 +51,6 @@ wav.o
aucat: ${OBJS}
${CC} ${LDFLAGS} ${LIB} -o aucat ${OBJS} ${LDADD}
midicat: aucat
ln -f aucat midicat
.c.o:
${CC} ${CFLAGS} ${INCLUDE} ${DEFS} -c $<

View File

@ -590,10 +590,10 @@ For instance, the following command will play a file on the
.Va aucat:0.mmc
audio device, and give full control to MIDI software or hardware
connected to the
.Va midithru:0
MIDI device:
.Va aucat:0.thru
MIDI port:
.Bd -literal -offset indent
$ aucat -f aucat:0.mmc -t slave -q midithru:0 -i file.wav
$ aucat -f aucat:0.mmc -t slave -q aucat:0.thru -i file.wav
.Ed
.Pp
At this stage,

View File

@ -57,7 +57,6 @@
#define SNDIO_PRIO (-20)
#define PROG_AUCAT "aucat"
#define PROG_MIDICAT "midicat"
/*
* sample rate if no ``-r'' is used
@ -85,10 +84,6 @@ char aucat_usage[] = "usage: " PROG_AUCAT " [-dlMn] [-a flag] [-b nframes] "
"[-q port] [-r rate] [-s name] [-t mode] [-U unit] [-v volume]\n\t"
"[-w flag] [-x policy] [-z nframes]\n";
char midicat_usage[] = "usage: " PROG_MIDICAT " [-dlM] [-a flag] "
"[-i file] [-L addr] [-o file] [-q port]\n\t"
"[-s name] [-U unit]\n";
/*
* SIGINT handler, it raises the quit flag. If the flag is already set,
* that means that the last SIGINT was not handled, because the process
@ -368,8 +363,8 @@ mkopt(char *path, struct dev *d, struct aparams *rpar, struct aparams *ppar,
int
main(int argc, char **argv)
{
char *prog, *un_path, *optstr, *usagestr;
int c, background, unit, server, tcp_port, active;
char *prog, *optstr, *usagestr;
int c, background, unit, server, active;
char base[PATH_MAX], path[PATH_MAX];
unsigned mode, hdr, xrun, rate, join, mmc, vol;
unsigned hold, autovol, bufsz, round;
@ -410,21 +405,11 @@ main(int argc, char **argv)
mode = MODE_MIDIMASK | MODE_PLAY | MODE_REC;
optstr = "a:b:c:C:de:f:h:i:j:lL:m:Mno:q:r:s:t:U:v:w:x:z:t:j:z:";
usagestr = aucat_usage;
un_path = AUCAT_PATH;
tcp_port = AUCAT_PORT;
} else if (strcmp(prog, PROG_MIDICAT) == 0) {
mode = MODE_MIDIMASK | MODE_THRU;
optstr = "a:di:lL:Mo:q:s:U:";
usagestr = midicat_usage;
un_path = MIDICAT_PATH;
tcp_port = MIDICAT_PORT;
mkdev("midithru", MODE_THRU, 0, 0, 1, 0);
} else {
fprintf(stderr, "%s: can't determine program to run\n", prog);
return 1;
}
while ((c = getopt(argc, argv, optstr)) != -1) {
switch (c) {
case 'd':
@ -442,7 +427,7 @@ main(int argc, char **argv)
server = 1;
break;
case 'L':
listen_new_tcp(optarg, tcp_port + unit);
listen_new_tcp(optarg, AUCAT_PORT + unit);
server = 1;
break;
case 'm':
@ -568,7 +553,7 @@ main(int argc, char **argv)
}
if (server) {
getbasepath(base, sizeof(base));
snprintf(path, PATH_MAX, "%s/%s%u", base, un_path, unit);
snprintf(path, PATH_MAX, "%s/%s%u", base, AUCAT_PATH, unit);
listen_new_un(path);
if (geteuid() == 0)
privdrop();

View File

@ -1,215 +0,0 @@
.\" $OpenBSD$
.\"
.\" Copyright (c) 2006 Alexandre Ratchov <alex@caoua.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate$
.Dt MIDICAT 1
.Os
.Sh NAME
.Nm midicat
.Nd MIDI server and manipulation tool
.Sh SYNOPSIS
.Nm midicat
.Op Fl dlM
.Op Fl a Ar flag
.Op Fl i Ar file
.Op Fl L Ar addr
.Op Fl o Ar file
.Op Fl q Ar port
.Op Fl s Ar name
.Op Fl U Ar unit
.Sh DESCRIPTION
The
.Nm
utility can merge any number of MIDI inputs and broadcast the result
to any number of MIDI outputs, similarly to a hardware MIDI thru box.
MIDI streams are typically MIDI ports or plain files containing raw MIDI
data.
.Pp
The
.Nm
utility can also act as a MIDI server in which case MIDI streams
correspond to client connections.
The server capability
allows any MIDI-capable application to send MIDI messages to
MIDI hardware or to another application in a uniform way.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl a Ar flag
Control whether
.Nm
opens MIDI ports connected to the thru box only when needed
or keeps them open all the time.
If the flag is
.Va on
then MIDI ports are kept open all the time, ensuring no other program can
steal any of them.
If the flag is
.Va off ,
then they are automatically closed, allowing other programs to have direct
access to MIDI ports, or the corresponding hardware to be disconnected.
The default is
.Va on .
.It Fl d
Increase log verbosity.
.Nm
logs on
.Em stderr
until it daemonizes.
.It Fl i Ar file
Read data to send from this file.
If the option argument is
.Sq -
then standard input will be used.
.It Fl L Ar addr
Specify a local network address to listen on in server mode.
.Nm
will listen on TCP port 11041+n, where n is the unit number
specified with
.Fl U .
Without this option,
.Nm
listens on the
.Ux Ns -domain
socket only, and is not reachable from any network.
If the option argument is
.Sq -
then
.Nm
will accept connections from any address.
.It Fl M
Create a MIDI thru box.
It merges any number of MIDI inputs and broadcasts the result
to any number of MIDI outputs, similarly to a hardware MIDI thru box.
Any MIDI ports
.Pq Fl q
or MIDI files
.Pq Fl io
specified after this option will be subscribed to this thru box.
If sub-devices are exposed
.Pq Fl s
they behave like software MIDI ports,
allowing any MIDI-capable application to send MIDI messages to
MIDI hardware or to another application in a uniform way.
.It Fl l
Detach and become a daemon.
.It Fl s Ar name
Expose a MIDI thru box to which MIDI programs
can connect.
The given
.Ar name
corresponds to the
.Dq option
part of the
.Xr sndio 7
device name string.
.It Fl o Ar file
Write received data into this file.
If the option argument is
.Sq -
then standard output will be used.
.It Fl q Ar port
Send and receive data from this
.Xr sndio 7
MIDI port.
.It Fl U Ar unit
Unit number to use when running in server mode.
Each
.Nm
server instance has a unique unit number,
used in
.Xr sndio 7
device names.
The default is 0.
The unit number must be set before any server-specific
options are used
.Pq Fl Ls .
.El
.Pp
If files
.Pq Fl io
are specified but no ports
.Pq Fl q
are specified, the default
.Xr sndio 7
port is used.
If no streams
.Pq Fl ioq
are specified, server mode is assumed and a thru box is created
as if
.Fl s Ar default
was used as the last argument.
.Pp
Generally MIDI applications are real-time.
To reduce jitter, especially on busy machines,
the server can be started by the super-user,
in which case it will run with higher priority.
Any user will still be able to connect to it,
but for privacy reasons only one user may have connections to
it at a given time.
.Pp
If
.Nm
is sent
.Dv SIGHUP ,
.Dv SIGINT
or
.Dv SIGTERM ,
then processing terminates.
.Sh EXAMPLES
The following dumps MIDI data received from the default port:
.Bd -literal -offset indent
$ midicat -o - | hexdump -e '1/1 "%x"'
.Ed
.Pp
The following sends raw MIDI data to the
.Pa rmidi:5
port:
.Bd -literal -offset indent
$ midicat -i sysexfile -q rmidi:5
.Ed
.Pp
The following connects
.Pa rmidi:5
and
.Pa rmidi:6
ports:
.Bd -literal -offset indent
$ midicat -q rmidi:5 -q rmidi:6
.Ed
.Pp
The following creates a MIDI thru box and daemonizes,
allowing MIDI programs to send data to each other instead of
using hardware MIDI ports:
.Bd -literal -offset indent
$ midicat -l
.Ed
.Pp
The following creates a MIDI thru box and subscribes the
.Pa rmidi:5
port, allowing multiple MIDI programs to use the port
simultaneously:
.Bd -literal -offset indent
$ midicat -q rmidi:5
.Ed
.Sh SEE ALSO
.Xr aucat 1 ,
.Xr midi 4 ,
.Xr sndio 7
.Sh BUGS
The ability to merge multiple inputs is provided to allow multiple
applications producing MIDI data to keep their connection open while
idling; it does not replace a fully featured MIDI merger.

View File

@ -24,8 +24,6 @@
*/
#define AUCAT_PATH "aucat"
#define AUCAT_PORT 11025
#define MIDICAT_PATH "midicat"
#define MIDICAT_PORT 11041
#define DEFAULT_OPT "default"
/*

View File

@ -322,7 +322,7 @@ bad_gen:
}
int
aucat_connect_tcp(struct aucat *hdl, char *host, char *unit, int isaudio)
aucat_connect_tcp(struct aucat *hdl, char *host, char *unit)
{
int s, error, opt;
struct addrinfo *ailist, *ai, aihints;
@ -333,11 +333,7 @@ aucat_connect_tcp(struct aucat *hdl, char *host, char *unit, int isaudio)
DPRINTF("%s: bad unit number\n", unit);
return 0;
}
if (isaudio)
port += AUCAT_PORT;
else
port += MIDICAT_PORT;
snprintf(serv, sizeof(serv), "%u", port);
snprintf(serv, sizeof(serv), "%u", port + AUCAT_PORT);
memset(&aihints, 0, sizeof(struct addrinfo));
aihints.ai_socktype = SOCK_STREAM;
aihints.ai_protocol = IPPROTO_TCP;
@ -378,18 +374,16 @@ aucat_connect_tcp(struct aucat *hdl, char *host, char *unit, int isaudio)
}
int
aucat_connect_un(struct aucat *hdl, char *unit, int isaudio)
aucat_connect_un(struct aucat *hdl, char *unit)
{
struct sockaddr_un ca;
socklen_t len = sizeof(struct sockaddr_un);
char *sock;
uid_t uid;
int s;
uid = geteuid();
sock = isaudio ? AUCAT_PATH : MIDICAT_PATH;
snprintf(ca.sun_path, sizeof(ca.sun_path),
"/tmp/aucat-%u/%s%s", uid, sock, unit);
"/tmp/aucat-%u/%s%s", uid, AUCAT_PATH, unit);
ca.sun_family = AF_UNIX;
s = socket(AF_UNIX, SOCK_STREAM, 0);
if (s < 0)
@ -400,7 +394,7 @@ aucat_connect_un(struct aucat *hdl, char *unit, int isaudio)
DPERROR(ca.sun_path);
/* try shared server */
snprintf(ca.sun_path, sizeof(ca.sun_path),
"/tmp/aucat/%s%s", sock, unit);
"/tmp/aucat/%s%s", AUCAT_PATH, unit);
while (connect(s, (struct sockaddr *)&ca, len) < 0) {
if (errno == EINTR)
continue;
@ -415,7 +409,7 @@ aucat_connect_un(struct aucat *hdl, char *unit, int isaudio)
}
int
aucat_open(struct aucat *hdl, const char *str, unsigned mode, int isaudio)
aucat_open(struct aucat *hdl, const char *str, unsigned mode)
{
extern char *__progname;
int eof, hashost;
@ -451,10 +445,10 @@ aucat_open(struct aucat *hdl, const char *str, unsigned mode, int isaudio)
}
DPRINTF("aucat_init: trying %s -> %s.%s\n", str, unit, opt);
if (hashost) {
if (!aucat_connect_tcp(hdl, host, unit, isaudio))
if (!aucat_connect_tcp(hdl, host, unit))
return 0;
} else {
if (!aucat_connect_un(hdl, unit, isaudio))
if (!aucat_connect_un(hdl, unit))
return 0;
}
if (fcntl(hdl->fd, F_SETFD, FD_CLOEXEC) < 0) {

View File

@ -20,7 +20,7 @@ int aucat_rmsg(struct aucat *, int *);
int aucat_wmsg(struct aucat *, int *);
size_t aucat_rdata(struct aucat *, void *, size_t, int *);
size_t aucat_wdata(struct aucat *, const void *, size_t, unsigned, int *);
int aucat_open(struct aucat *, const char *, unsigned, int);
int aucat_open(struct aucat *, const char *, unsigned);
void aucat_close(struct aucat *, int);
int aucat_pollfd(struct aucat *, struct pollfd *, int);
int aucat_revents(struct aucat *, struct pollfd *);

View File

@ -50,7 +50,7 @@ mio_open(const char *str, unsigned mode, int nbio)
if (str == NULL && !issetugid())
str = getenv("MIDIDEVICE");
if (str == NULL) {
hdl = mio_midithru_open("0", mode, nbio);
hdl = mio_aucat_open("0", mode, nbio);
if (hdl != NULL)
return hdl;
return mio_rmidi_open("0", mode, nbio);
@ -63,7 +63,7 @@ mio_open(const char *str, unsigned mode, int nbio)
len = sep - str;
if (len == (sizeof(prefix_midithru) - 1) &&
memcmp(str, prefix_midithru, len) == 0)
return mio_midithru_open(sep + 1, mode, nbio);
return mio_aucat_open(sep + 1, mode, nbio);
if (len == (sizeof(prefix_aucat) - 1) &&
memcmp(str, prefix_aucat, len) == 0)
return mio_aucat_open(sep + 1, mode, nbio);

View File

@ -52,15 +52,15 @@ static struct mio_ops mio_aucat_ops = {
mio_aucat_revents,
};
static struct mio_hdl *
mio_xxx_open(const char *str, unsigned mode, int nbio, int isaudio)
struct mio_hdl *
mio_aucat_open(const char *str, unsigned mode, int nbio)
{
struct mio_aucat_hdl *hdl;
hdl = malloc(sizeof(struct mio_aucat_hdl));
if (hdl == NULL)
return NULL;
if (!aucat_open(&hdl->aucat, str, mode, isaudio))
if (!aucat_open(&hdl->aucat, str, mode))
goto bad;
mio_create(&hdl->mio, &mio_aucat_ops, mode, nbio);
if (!aucat_setfl(&hdl->aucat, nbio, &hdl->mio.eof))
@ -71,18 +71,6 @@ bad:
return NULL;
}
struct mio_hdl *
mio_midithru_open(const char *str, unsigned mode, int nbio)
{
return mio_xxx_open(str, mode, nbio, 0);
}
struct mio_hdl *
mio_aucat_open(const char *str, unsigned mode, int nbio)
{
return mio_xxx_open(str, mode, nbio, 1);
}
static void
mio_aucat_close(struct mio_hdl *sh)
{

View File

@ -51,8 +51,8 @@ The
library allows user processes to access
.Xr midi 4
hardware and
.Xr midicat 1
MIDI thru boxes in a uniform way.
.Xr aucat 1
MIDI thru boxes and control ports in a uniform way.
.Ss Opening and closing an MIDI stream
First the application must call the
.Fn mio_open
@ -63,10 +63,10 @@ argument of most other functions.
The
.Fn mio_open
function tries to connect to the
.Xr midicat 1
software MIDI thru box or to use the
.Xr aucat 1
MIDI thru box or to use the
.Xr midi 4
hardware device.
hardware port.
The
.Ar name
parameter gives the device string discussed in
@ -232,22 +232,22 @@ and
.Fn mio_write
functions return the number of bytes transferred.
.Sh ENVIRONMENT
.Bl -tag -width "MIO_DEBUGXXX" -compact
.Bl -tag -width "SNDIO_DEBUGXXX" -compact
.It Ev SNDIO_DEBUG
The debug level:
may be a value between 0 and 2.
.El
.Sh FILES
.Bl -tag -width "/tmp/aucat-<uid>/midithru0" -compact
.It Pa /tmp/aucat-<uid>/midithru0
.Bl -tag -width "/tmp/aucat-<uid>/aucat0" -compact
.It Pa /tmp/aucat-<uid>/aucat0
Default path to
.Xr midicat 1
.Xr aucat 1
socket to connect to.
.It Pa /dev/rmidiX
.Xr midi 4
devices.
.El
.Sh SEE ALSO
.Xr midicat 1 ,
.Xr aucat 1 ,
.Xr midi 4 ,
.Xr sndio 7

View File

@ -42,7 +42,6 @@ struct mio_ops {
};
struct mio_hdl *mio_rmidi_open(const char *, unsigned, int);
struct mio_hdl *mio_midithru_open(const char *, unsigned, int);
struct mio_hdl *mio_aucat_open(const char *, unsigned, int);
void mio_create(struct mio_hdl *, struct mio_ops *, unsigned, int);
void mio_destroy(struct mio_hdl *);

View File

@ -157,7 +157,7 @@ sio_aucat_open(const char *str, unsigned mode, int nbio)
hdl = malloc(sizeof(struct sio_aucat_hdl));
if (hdl == NULL)
return NULL;
if (!aucat_open(&hdl->aucat, str, mode, 1)) {
if (!aucat_open(&hdl->aucat, str, mode)) {
free(hdl);
return NULL;
}

View File

@ -722,7 +722,7 @@ and
.Fn sio_write
functions return the number of bytes transferred.
.Sh ENVIRONMENT
.Bl -tag -width "AUDIODEVICEXXX" -compact
.Bl -tag -width "SNDIO_DEBUGXXX" -compact
.It Ev AUDIODEVICE
Device to use if
.Fn sio_open
@ -734,8 +734,8 @@ The debug level:
may be a value between 0 and 2.
.El
.Sh FILES
.Bl -tag -width "/tmp/aucat-<uid>/softaudio0" -compact
.It Pa /tmp/aucat-<uid>/softaudio0
.Bl -tag -width "/tmp/aucat-<uid>/aucat0" -compact
.It Pa /tmp/aucat-<uid>/aucat0
Default path to
.Xr aucat 1
socket to connect to.

View File

@ -25,9 +25,7 @@ The
.Nm sndio
audio and MIDI system provides access to audio and MIDI hardware and
to services provided by
.Xr aucat 1
and
.Xr midicat 1 ,
.Xr aucat 1 ,
summarized below.
.Pp
Hardware
@ -59,27 +57,25 @@ Software MIDI thru boxes allow one application to send MIDI data to other
applications connected to the thru box (for instance a software sequencer
can send events to multiple software synthesizers).
There's no hardware involved: thru boxes are created by
.Xr midicat 1 .
.Xr aucat 1 .
.Pp
Additionally,
.Xr aucat 1
exposes a MIDI device used to control and monitor audio streams
exposes a MIDI port used to control and monitor audio streams
in real time using MIDI.
.Sh DEVICE NAMES
From the user's perspective every audio interface, MIDI port,
.Xr aucat 1
or
.Xr midicat 1
service has a name of the form:
.Bd -literal -offset center
type:[hostname/]unit[.option]
.Ed
.Pp
This information is used by audio and MIDI applications to determine
how to access the audio or MIDI device or service.
how to access the audio device or MIDI port.
.Bl -tag -width "option"
.It Pa type
The type of the audio or MIDI device.
The type of the audio device or MIDI port.
Possible values for audio devices are
.Pa aucat
and
@ -89,31 +85,24 @@ corresponding to
sockets and hardware
.Xr audio 4
devices.
Possible values for MIDI devices are
.Pa midithru ,
.Pa rmidi ,
and
Possible values for MIDI ports are
.Pa aucat
and
.Pa rmidi
corresponding to
.Xr midicat 1
software MIDI thru boxes, hardware
.Xr midi 4
ports and
.Xr aucat 1
control through MIDI respectively.
software MIDI thru boxes or control ports and hardware
.Xr midi 4
ports respectively.
.It Pa hostname
The hostname where the remote
.Xr aucat 1
or
.Xr midicat 1
server to connect to is running.
.It Pa unit
For hardware audio or MIDI devices, this corresponds to
For hardware audio or MIDI ports, this corresponds to
the character device minor number.
For audio or MIDI devices created with
For audio devices or MIDI ports created with
.Xr aucat 1
or
.Xr midicat 1
it corresponds to the server
.Em unit
number, typically 0.
@ -121,13 +110,9 @@ number, typically 0.
Corresponds to the profile string registered using the
.Fl s
option of
.Xr aucat 1
or
.Xr midicat 1 .
.Xr aucat 1 .
Only meaningful for
.Pa aucat
and
.Pa midithru
device types.
.El
.Pp
@ -148,19 +133,13 @@ device registered with
.Fl s Fa rear .
.It Pa rmidi:5
Hardware MIDI port number 5.
.It Pa midithru:0
First software MIDI thru box created with
.Xr midicat 1 .
.It Pa aucat:0
MIDI port controlling the first
.Xr aucat 1
audio server.
First software MIDI thru box or control port created with
.Xr aucat 1 .
.El
.Sh AUTHENTICATION
If a shared
.Xr aucat 1
or
.Xr midicat 1
server is running, for privacy reasons only one user may have
connections to it at a given time
(though the same user could have multiple connections to it).
@ -179,9 +158,7 @@ can connect to the server using the same cookie.
.It AUCAT_COOKIE
Path to file containing the session cookie to be used
when connecting to
.Xr aucat
or
.Xr midicat .
.Xr aucat .
.It Ev AUDIODEVICE
Audio device to use if the application provides
no device chooser.
@ -201,7 +178,6 @@ MIDI ports.
.El
.Sh SEE ALSO
.Xr aucat 1 ,
.Xr midicat 1 ,
.Xr mio_open 3 ,
.Xr sio_open 3 ,
.Xr audio 4 ,