mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-12-15 08:56:36 -05:00
Added snd_midi_event_no_status()
This commit is contained in:
parent
fb07cd28e5
commit
f063381430
2 changed files with 37 additions and 15 deletions
|
|
@ -48,6 +48,7 @@ void snd_midi_event_free(snd_midi_event_t *dev);
|
||||||
void snd_midi_event_init(snd_midi_event_t *dev);
|
void snd_midi_event_init(snd_midi_event_t *dev);
|
||||||
void snd_midi_event_reset_encode(snd_midi_event_t *dev);
|
void snd_midi_event_reset_encode(snd_midi_event_t *dev);
|
||||||
void snd_midi_event_reset_decode(snd_midi_event_t *dev);
|
void snd_midi_event_reset_decode(snd_midi_event_t *dev);
|
||||||
|
void snd_midi_event_no_status(snd_midi_event_t *dev, int on);
|
||||||
/* encode from byte stream - return number of written bytes if success */
|
/* encode from byte stream - return number of written bytes if success */
|
||||||
long snd_midi_event_encode(snd_midi_event_t *dev, unsigned char *buf, long count, snd_seq_event_t *ev);
|
long snd_midi_event_encode(snd_midi_event_t *dev, unsigned char *buf, long count, snd_seq_event_t *ev);
|
||||||
int snd_midi_event_encode_byte(snd_midi_event_t *dev, int c, snd_seq_event_t *ev);
|
int snd_midi_event_encode_byte(snd_midi_event_t *dev, int c, snd_seq_event_t *ev);
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ struct snd_midi_event {
|
||||||
size_t read; /* chars read */
|
size_t read; /* chars read */
|
||||||
int type; /* current event type */
|
int type; /* current event type */
|
||||||
unsigned char lastcmd;
|
unsigned char lastcmd;
|
||||||
|
unsigned char nostat;
|
||||||
size_t bufsize;
|
size_t bufsize;
|
||||||
unsigned char *buf; /* input buffer */
|
unsigned char *buf; /* input buffer */
|
||||||
};
|
};
|
||||||
|
|
@ -171,6 +172,11 @@ void snd_midi_event_free(snd_midi_event_t *dev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void snd_midi_event_no_status(snd_midi_event_t *dev, int on)
|
||||||
|
{
|
||||||
|
dev->nostat = on ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* initialize record
|
* initialize record
|
||||||
*/
|
*/
|
||||||
|
|
@ -436,7 +442,7 @@ long snd_midi_event_decode(snd_midi_event_t *dev, unsigned char *buf, long count
|
||||||
} else {
|
} else {
|
||||||
unsigned char xbuf[4];
|
unsigned char xbuf[4];
|
||||||
|
|
||||||
if ((cmd & 0xf0) == 0xf0 || dev->lastcmd != cmd) {
|
if ((cmd & 0xf0) == 0xf0 || dev->lastcmd != cmd || dev->nostat) {
|
||||||
dev->lastcmd = cmd;
|
dev->lastcmd = cmd;
|
||||||
xbuf[0] = cmd;
|
xbuf[0] = cmd;
|
||||||
if (status_event[type].decode)
|
if (status_event[type].decode)
|
||||||
|
|
@ -493,23 +499,38 @@ static void songpos_decode(snd_seq_event_t *ev, unsigned char *buf)
|
||||||
/* decode 14bit control */
|
/* decode 14bit control */
|
||||||
static int extra_decode_ctrl14(snd_midi_event_t *dev, unsigned char *buf, int count, snd_seq_event_t *ev)
|
static int extra_decode_ctrl14(snd_midi_event_t *dev, unsigned char *buf, int count, snd_seq_event_t *ev)
|
||||||
{
|
{
|
||||||
|
unsigned char cmd;
|
||||||
|
int idx = 0;
|
||||||
|
|
||||||
if (ev->data.control.param < 32) {
|
if (ev->data.control.param < 32) {
|
||||||
if (count < 5)
|
if (count < 4)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
buf[0] = MIDI_CMD_CONTROL|(ev->data.control.channel & 0x0f);
|
if (dev->nostat && count < 6)
|
||||||
buf[1] = ev->data.control.param;
|
return -ENOMEM;
|
||||||
buf[2] = (ev->data.control.value >> 7) & 0x7f;
|
cmd = MIDI_CMD_CONTROL|(ev->data.control.channel & 0x0f);
|
||||||
buf[3] = ev->data.control.param + 32;
|
if (cmd != dev->lastcmd || dev->nostat) {
|
||||||
buf[4] = ev->data.control.value & 0x7f;
|
if (count < 5)
|
||||||
dev->lastcmd = buf[0];
|
return -ENOMEM;
|
||||||
return 5;
|
buf[idx++] = dev->lastcmd = cmd;
|
||||||
|
}
|
||||||
|
buf[idx++] = ev->data.control.param;
|
||||||
|
buf[idx++] = (ev->data.control.value >> 7) & 0x7f;
|
||||||
|
if (dev->nostat)
|
||||||
|
buf[idx++] = cmd;
|
||||||
|
buf[idx++] = ev->data.control.param + 32;
|
||||||
|
buf[idx++] = ev->data.control.value & 0x7f;
|
||||||
|
return idx;
|
||||||
} else {
|
} else {
|
||||||
if (count < 3)
|
if (count < 2)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
buf[0] = MIDI_CMD_CONTROL|(ev->data.control.channel & 0x0f);
|
cmd = MIDI_CMD_CONTROL|(ev->data.control.channel & 0x0f);
|
||||||
buf[1] = ev->data.control.param & 0x7f;
|
if (cmd != dev->lastcmd || dev->nostat) {
|
||||||
buf[4] = ev->data.control.value & 0x7f;
|
if (count < 3)
|
||||||
dev->lastcmd = buf[0];
|
return -ENOMEM;
|
||||||
return 3;
|
buf[idx++] = dev->lastcmd = cmd;
|
||||||
|
}
|
||||||
|
buf[idx++] = ev->data.control.param & 0x7f;
|
||||||
|
buf[idx++] = ev->data.control.value & 0x7f;
|
||||||
|
return idx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue