mirror of
https://github.com/ericonr/sndio.git
synced 2024-02-18 04:45:21 -06:00
reuse midi-control code to implement midi thru boxes and remove
the old midithru implementation; less code, less bugs. As a side effect, midi output doesn't implement running status "compression" any more
This commit is contained in:
parent
a3955999b1
commit
37f7cba0f8
@ -169,11 +169,9 @@ struct aproc {
|
|||||||
int bnext; /* to reach the next byte */
|
int bnext; /* to reach the next byte */
|
||||||
int snext; /* to reach the next sample */
|
int snext; /* to reach the next sample */
|
||||||
} conv;
|
} conv;
|
||||||
struct {
|
|
||||||
struct timo timo; /* timout for throtteling */
|
|
||||||
} thru;
|
|
||||||
struct {
|
struct {
|
||||||
struct dev *dev; /* controlled device */
|
struct dev *dev; /* controlled device */
|
||||||
|
struct timo timo; /* timout for throtteling */
|
||||||
unsigned fps; /* MTC frames per second */
|
unsigned fps; /* MTC frames per second */
|
||||||
#define MTC_FPS_24 0
|
#define MTC_FPS_24 0
|
||||||
#define MTC_FPS_25 1
|
#define MTC_FPS_25 1
|
||||||
@ -185,7 +183,7 @@ struct aproc {
|
|||||||
unsigned fr; /* MTC frames */
|
unsigned fr; /* MTC frames */
|
||||||
unsigned qfr; /* MTC quarter frames */
|
unsigned qfr; /* MTC quarter frames */
|
||||||
int delta; /* rel. to the last MTC tick */
|
int delta; /* rel. to the last MTC tick */
|
||||||
} ctl;
|
} midi;
|
||||||
} u;
|
} u;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -532,7 +532,7 @@ main(int argc, char **argv)
|
|||||||
mkdev("loopback", MODE_LOOP, bufsz, round, 1, autovol);
|
mkdev("loopback", MODE_LOOP, bufsz, round, 1, autovol);
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
mkdev("midithru", MODE_THRU, 0, 0, 1, 0);
|
mkdev("midithru", MODE_THRU, 0, 0, hold, 0);
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
background = 1;
|
background = 1;
|
||||||
@ -609,7 +609,7 @@ main(int argc, char **argv)
|
|||||||
dnext = d->next;
|
dnext = d->next;
|
||||||
if (!dev_run(d))
|
if (!dev_run(d))
|
||||||
goto fatal;
|
goto fatal;
|
||||||
if (!dev_idle(d))
|
if (d->refcnt > 0)
|
||||||
active = 1;
|
active = 1;
|
||||||
}
|
}
|
||||||
if (dev_list == NULL)
|
if (dev_list == NULL)
|
||||||
|
56
aucat/dev.c
56
aucat/dev.c
@ -141,6 +141,7 @@ dev_new(char *path, unsigned mode,
|
|||||||
d->hold = hold;
|
d->hold = hold;
|
||||||
d->autovol = autovol;
|
d->autovol = autovol;
|
||||||
d->autostart = 0;
|
d->autostart = 0;
|
||||||
|
d->refcnt = 0;
|
||||||
d->pstate = DEV_CLOSED;
|
d->pstate = DEV_CLOSED;
|
||||||
d->serial = 0;
|
d->serial = 0;
|
||||||
for (i = 0; i < CTL_NSLOT; i++) {
|
for (i = 0; i < CTL_NSLOT; i++) {
|
||||||
@ -395,8 +396,7 @@ dev_open(struct dev *d)
|
|||||||
* if there's no device
|
* if there's no device
|
||||||
*/
|
*/
|
||||||
if (d->mode & MODE_MIDIMASK) {
|
if (d->mode & MODE_MIDIMASK) {
|
||||||
d->midi = (d->mode & MODE_THRU) ?
|
d->midi = midi_new("midi", (d->mode & MODE_THRU) ? NULL : d);
|
||||||
thru_new("thru") : ctl_new("ctl", d);
|
|
||||||
d->midi->refs++;
|
d->midi->refs++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1450,8 +1450,9 @@ dev_slotnew(struct dev *d, char *who, struct ctl_ops *ops, void *arg, int mmc)
|
|||||||
s->ops->vol(s->arg, s->vol);
|
s->ops->vol(s->arg, s->vol);
|
||||||
|
|
||||||
if (APROC_OK(d->midi)) {
|
if (APROC_OK(d->midi)) {
|
||||||
ctl_slot(d->midi, slot);
|
midi_send_slot(d->midi, slot);
|
||||||
ctl_vol(d->midi, slot, s->vol);
|
midi_send_vol(d->midi, slot, s->vol);
|
||||||
|
midi_flush(d->midi);
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (debug_level >= 2) {
|
if (debug_level >= 2) {
|
||||||
@ -1495,38 +1496,10 @@ dev_slotvol(struct dev *d, int slot, unsigned vol)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
d->slot[slot].vol = vol;
|
d->slot[slot].vol = vol;
|
||||||
if (APROC_OK(d->midi))
|
if (APROC_OK(d->midi)) {
|
||||||
ctl_vol(d->midi, slot, vol);
|
midi_send_vol(d->midi, slot, vol);
|
||||||
}
|
midi_flush(d->midi);
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* check if there are controlled streams
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
dev_idle(struct dev *d)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
struct ctl_slot *s;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XXX: this conditions breaks -aoff for thru boxes
|
|
||||||
*/
|
|
||||||
if (d->mode & MODE_THRU)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (d->pstate != DEV_CLOSED)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XXX: if the device is closed, we're sure there are no
|
|
||||||
* slots in use, so the following test is useless
|
|
||||||
*/
|
|
||||||
for (i = 0, s = d->slot; i < CTL_NSLOT; i++, s++) {
|
|
||||||
if (s->ops)
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1578,8 +1551,11 @@ dev_try(struct dev *d, int slot)
|
|||||||
if (slot >= 0)
|
if (slot >= 0)
|
||||||
d->slot[slot].tstate = CTL_RUN;
|
d->slot[slot].tstate = CTL_RUN;
|
||||||
d->tstate = CTL_RUN;
|
d->tstate = CTL_RUN;
|
||||||
if (APROC_OK(d->midi))
|
if (APROC_OK(d->midi)) {
|
||||||
ctl_full(d->midi, d->origin, d->rate, d->round, dev_getpos(d));
|
midi_send_full(d->midi,
|
||||||
|
d->origin, d->rate, d->round, dev_getpos(d));
|
||||||
|
midi_flush(d->midi);
|
||||||
|
}
|
||||||
dev_wakeup(d);
|
dev_wakeup(d);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1726,6 +1702,8 @@ dev_onmove(void *arg, int delta)
|
|||||||
*/
|
*/
|
||||||
if (d->tstate != CTL_RUN)
|
if (d->tstate != CTL_RUN)
|
||||||
return;
|
return;
|
||||||
if (APROC_OK(d->midi))
|
if (APROC_OK(d->midi)) {
|
||||||
ctl_qfr(d->midi, d->rate, delta);
|
midi_send_qfr(d->midi, d->rate, delta);
|
||||||
|
midi_flush(d->midi);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,6 @@ struct dev {
|
|||||||
struct aparams reqipar, reqopar; /* parameters */
|
struct aparams reqipar, reqopar; /* parameters */
|
||||||
unsigned reqbufsz; /* buffer size */
|
unsigned reqbufsz; /* buffer size */
|
||||||
unsigned reqround; /* block size */
|
unsigned reqround; /* block size */
|
||||||
unsigned reqrate; /* sample rate */
|
|
||||||
unsigned hold; /* hold the device open ? */
|
unsigned hold; /* hold the device open ? */
|
||||||
unsigned autovol; /* auto adjust playvol ? */
|
unsigned autovol; /* auto adjust playvol ? */
|
||||||
unsigned autostart; /* don't wait for MMC start */
|
unsigned autostart; /* don't wait for MMC start */
|
||||||
@ -120,6 +119,5 @@ void dev_slotstop(struct dev *, int);
|
|||||||
void dev_mmcstart(struct dev *);
|
void dev_mmcstart(struct dev *);
|
||||||
void dev_mmcstop(struct dev *);
|
void dev_mmcstop(struct dev *);
|
||||||
void dev_loc(struct dev *, unsigned);
|
void dev_loc(struct dev *, unsigned);
|
||||||
int dev_idle(struct dev *);
|
|
||||||
|
|
||||||
#endif /* !define(DEV_H) */
|
#endif /* !define(DEV_H) */
|
||||||
|
835
aucat/midi.c
835
aucat/midi.c
File diff suppressed because it is too large
Load Diff
14
aucat/midi.h
14
aucat/midi.h
@ -19,13 +19,13 @@
|
|||||||
|
|
||||||
struct dev;
|
struct dev;
|
||||||
|
|
||||||
struct aproc *thru_new(char *);
|
struct aproc *midi_new(char *, struct dev *);
|
||||||
struct aproc *ctl_new(char *, struct dev *);
|
|
||||||
|
|
||||||
void ctl_ontick(struct aproc *, int);
|
void midi_ontick(struct aproc *, int);
|
||||||
void ctl_slot(struct aproc *, int);
|
void midi_send_slot(struct aproc *, int);
|
||||||
void ctl_vol(struct aproc *, int, unsigned);
|
void midi_send_vol(struct aproc *, int, unsigned);
|
||||||
void ctl_full(struct aproc *, unsigned, unsigned, unsigned, unsigned);
|
void midi_send_full(struct aproc *, unsigned, unsigned, unsigned, unsigned);
|
||||||
void ctl_qfr(struct aproc *, unsigned, int);
|
void midi_send_qfr(struct aproc *, unsigned, int);
|
||||||
|
void midi_flush(struct aproc *);
|
||||||
|
|
||||||
#endif /* !defined(MIDI_H) */
|
#endif /* !defined(MIDI_H) */
|
||||||
|
Loading…
Reference in New Issue
Block a user