diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2012-03-23 11:59:55 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2012-03-23 11:59:55 +0000 |
commit | 90a2ff4fa5831ade67656fe7f50121e98c95190e (patch) | |
tree | 6332abf4d6cc52b04b97b798059407e06df630af /usr.bin | |
parent | f60831a71f3f91a36f54623acb8a91a113a5d169 (diff) |
add a MIDI-controlled master volume knob to adjust the mix of
all playback stream, discussed with armani@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/aucat/aproc.c | 8 | ||||
-rw-r--r-- | usr.bin/aucat/aproc.h | 5 | ||||
-rw-r--r-- | usr.bin/aucat/aucat.1 | 7 | ||||
-rw-r--r-- | usr.bin/aucat/dev.c | 28 | ||||
-rw-r--r-- | usr.bin/aucat/dev.h | 4 | ||||
-rw-r--r-- | usr.bin/aucat/midi.c | 33 | ||||
-rw-r--r-- | usr.bin/aucat/midi.h | 3 | ||||
-rw-r--r-- | usr.bin/aucat/sysex.h | 9 |
8 files changed, 84 insertions, 13 deletions
diff --git a/usr.bin/aucat/aproc.c b/usr.bin/aucat/aproc.c index 9bdf74eaf37..3d689848d93 100644 --- a/usr.bin/aucat/aproc.c +++ b/usr.bin/aucat/aproc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aproc.c,v 1.69 2012/01/10 08:10:21 ratchov Exp $ */ +/* $OpenBSD: aproc.c,v 1.70 2012/03/23 11:59:54 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -1021,7 +1021,8 @@ struct aproc_ops mix_ops = { }; struct aproc * -mix_new(char *name, int maxlat, unsigned round, unsigned autovol) +mix_new(char *name, int maxlat, unsigned round, + unsigned autovol, unsigned master) { struct aproc *p; @@ -1032,6 +1033,7 @@ mix_new(char *name, int maxlat, unsigned round, unsigned autovol) p->u.mix.maxlat = maxlat; p->u.mix.mon = NULL; p->u.mix.autovol = autovol; + p->u.mix.master = master; return p; } @@ -1061,7 +1063,7 @@ mix_setmaster(struct aproc *p) } if (weight > i->r.mix.maxweight) weight = i->r.mix.maxweight; - i->r.mix.weight = weight; + i->r.mix.weight = ADATA_MUL(weight, p->u.mix.master); #ifdef DEBUG if (debug_level >= 3) { abuf_dbg(i); diff --git a/usr.bin/aucat/aproc.h b/usr.bin/aucat/aproc.h index 5def8a99f7f..c374a6c9ef2 100644 --- a/usr.bin/aucat/aproc.h +++ b/usr.bin/aucat/aproc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: aproc.h,v 1.42 2011/12/02 10:34:50 ratchov Exp $ */ +/* $OpenBSD: aproc.h,v 1.43 2012/03/23 11:59:54 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -140,6 +140,7 @@ struct aproc { unsigned abspos; /* frames produced */ struct aproc *mon; /* snoop output */ unsigned autovol; /* adjust volume dynamically */ + int master; /* master attenuation */ } mix; struct { unsigned idle; /* frames since idleing */ @@ -211,7 +212,7 @@ void aproc_opos(struct aproc *, struct abuf *, int); struct aproc *rfile_new(struct file *); struct aproc *wfile_new(struct file *); -struct aproc *mix_new(char *, int, unsigned, unsigned); +struct aproc *mix_new(char *, int, unsigned, unsigned, unsigned); struct aproc *sub_new(char *, int, unsigned); struct aproc *resamp_new(char *, unsigned, unsigned); struct aproc *enc_new(char *, struct aparams *); diff --git a/usr.bin/aucat/aucat.1 b/usr.bin/aucat/aucat.1 index 36317e2cd39..c85776ebace 100644 --- a/usr.bin/aucat/aucat.1 +++ b/usr.bin/aucat/aucat.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: aucat.1,v 1.97 2012/02/09 18:33:36 ratchov Exp $ +.\" $OpenBSD: aucat.1,v 1.98 2012/03/23 11:59:54 ratchov Exp $ .\" .\" Copyright (c) 2006 Alexandre Ratchov <alex@caoua.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: February 9 2012 $ +.Dd $Mdocdate: March 23 2012 $ .Dt AUCAT 1 .Os .Sh NAME @@ -535,6 +535,9 @@ the same MIDI controller message is sent out; it can be used for instance for monitoring or as feedback for motorized faders. .Pp +The master volume can be changed using the standard master volume +system exclusive message. +.Pp Streams created with the .Fl t option are controlled by the following MMC messages: diff --git a/usr.bin/aucat/dev.c b/usr.bin/aucat/dev.c index 67866f15ffb..a8cdb9ea05c 100644 --- a/usr.bin/aucat/dev.c +++ b/usr.bin/aucat/dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.c,v 1.76 2012/01/26 09:07:03 ratchov Exp $ */ +/* $OpenBSD: dev.c,v 1.77 2012/03/23 11:59:54 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -152,6 +152,7 @@ dev_new(char *path, unsigned mode, d->slot[i].serial = d->serial++; d->slot[i].name[0] = '\0'; } + d->master = MIDI_MAXCTL; d->origin = 0; d->tstate = CTL_STOP; d->next = dev_list; @@ -404,7 +405,8 @@ dev_open(struct dev *d) * Create mixer, demuxer and monitor */ if (d->mode & MODE_PLAY) { - d->mix = mix_new("play", d->bufsz, d->round, d->autovol); + d->mix = mix_new("play", d->bufsz, d->round, + d->autovol, MIDI_TO_ADATA(d->master)); d->mix->refs++; } if (d->mode & MODE_REC) { @@ -1703,3 +1705,25 @@ dev_onmove(void *arg, int delta) midi_flush(d->midi); } } + +void +dev_master(struct dev *d, unsigned master) +{ +#ifdef DEBUG + if (debug_level >= 3) { + dev_dbg(d); + dbg_puts(": changing master volume to "); + dbg_putu(master); + dbg_puts("\n"); + } +#endif + d->master = master; + if (APROC_OK(d->mix)) { + d->mix->u.mix.master = MIDI_TO_ADATA(master); + mix_setmaster(d->mix); + } + if (APROC_OK(d->midi)) { + midi_send_master(d->midi); + midi_flush(d->midi); + } +} diff --git a/usr.bin/aucat/dev.h b/usr.bin/aucat/dev.h index 22a81222ac7..68d5cda2887 100644 --- a/usr.bin/aucat/dev.h +++ b/usr.bin/aucat/dev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.h,v 1.34 2011/12/02 10:34:50 ratchov Exp $ */ +/* $OpenBSD: dev.h,v 1.35 2012/03/23 11:59:54 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -85,6 +85,7 @@ struct dev { #define CTL_RUN 3 /* started */ unsigned tstate; /* one of above */ unsigned origin; /* MTC start time */ + unsigned master; /* master volume controller */ }; extern struct dev *dev_list; @@ -119,5 +120,6 @@ void dev_slotstop(struct dev *, int); void dev_mmcstart(struct dev *); void dev_mmcstop(struct dev *); void dev_loc(struct dev *, unsigned); +void dev_master(struct dev *, unsigned); #endif /* !define(DEV_H) */ diff --git a/usr.bin/aucat/midi.c b/usr.bin/aucat/midi.c index 66514ad4308..1d8979044a2 100644 --- a/usr.bin/aucat/midi.c +++ b/usr.bin/aucat/midi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: midi.c,v 1.40 2011/12/02 10:34:50 ratchov Exp $ */ +/* $OpenBSD: midi.c,v 1.41 2012/03/23 11:59:54 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -125,6 +125,21 @@ midi_msg_vol(struct aproc *p, int slot, char *msg) msg[2] = s->vol; } +void +midi_msg_master(struct aproc *p, char *msg) +{ + struct sysex *x = (struct sysex *)msg; + + memset(x, 0, sizeof(struct sysex)); + x->start = SYSEX_START; + x->type = SYSEX_TYPE_RT; + x->id0 = SYSEX_CONTROL; + x->id1 = SYSEX_MASTER; + x->u.master.fine = 0; + x->u.master.coarse = p->u.midi.dev->master; + x->u.master.end = SYSEX_END; +} + /* * send a message to the given output */ @@ -330,6 +345,8 @@ midi_copy_dump(struct aproc *p, struct abuf *obuf) unsigned char msg[sizeof(struct sysex)]; struct ctl_slot *s; + midi_msg_master(p, msg); + midi_copy(NULL, obuf, msg, SYSEX_SIZE(master)); for (i = 0, s = p->u.midi.dev->slot; i < CTL_NSLOT; i++, s++) { midi_msg_info(p, i, msg); midi_copy(NULL, obuf, msg, SYSEX_SIZE(mixinfo)); @@ -360,6 +377,15 @@ midi_send_vol(struct aproc *p, int slot, unsigned vol) } void +midi_send_master(struct aproc *p) +{ + unsigned char msg[sizeof(struct sysex)]; + + midi_msg_master(p, msg); + midi_send(p, NULL, msg, SYSEX_SIZE(master)); +} + +void midi_send_slot(struct aproc *p, int slot) { unsigned char msg[sizeof(struct sysex)]; @@ -431,6 +457,11 @@ midi_onsysex(struct aproc *p, struct abuf *ibuf) return; switch (x->type) { case SYSEX_TYPE_RT: + if (x->id0 == SYSEX_CONTROL && x->id1 == SYSEX_MASTER) { + if (len == SYSEX_SIZE(master)) + dev_master(p->u.midi.dev, x->u.master.coarse); + return; + } if (x->id0 != SYSEX_MMC) return; switch (x->id1) { diff --git a/usr.bin/aucat/midi.h b/usr.bin/aucat/midi.h index 5c91349a2fb..0b409406c94 100644 --- a/usr.bin/aucat/midi.h +++ b/usr.bin/aucat/midi.h @@ -1,4 +1,4 @@ -/* $OpenBSD: midi.h,v 1.11 2011/12/02 10:34:50 ratchov Exp $ */ +/* $OpenBSD: midi.h,v 1.12 2012/03/23 11:59:54 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -24,6 +24,7 @@ struct aproc *midi_new(char *, struct dev *); void midi_ontick(struct aproc *, int); void midi_send_slot(struct aproc *, int); void midi_send_vol(struct aproc *, int, unsigned); +void midi_send_master(struct aproc *); void midi_send_full(struct aproc *, unsigned, unsigned, unsigned, unsigned); void midi_send_qfr(struct aproc *, unsigned, int); void midi_flush(struct aproc *); diff --git a/usr.bin/aucat/sysex.h b/usr.bin/aucat/sysex.h index ea32558d690..d4c6a43f6bb 100644 --- a/usr.bin/aucat/sysex.h +++ b/usr.bin/aucat/sysex.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysex.h,v 1.2 2011/06/27 07:17:44 ratchov Exp $ */ +/* $OpenBSD: sysex.h,v 1.3 2012/03/23 11:59:54 ratchov Exp $ */ /* * Copyright (c) 2011 Alexandre Ratchov <alex@caoua.org> * @@ -36,6 +36,8 @@ */ #define SYSEX_MTC 0x01 /* mtc messages */ #define SYSEX_MTC_FULL 0x01 /* mtc full frame message */ +#define SYSEX_CONTROL 0x04 +#define SYSEX_MASTER 0x01 #define SYSEX_MMC 0x06 #define SYSEX_MMC_STOP 0x01 #define SYSEX_MMC_START 0x02 @@ -71,6 +73,11 @@ struct sysex { struct sysex_empty { uint8_t end; } empty; + struct sysex_master { + uint8_t fine; + uint8_t coarse; + uint8_t end; + } master; struct sysex_start { uint8_t end; } start; |