Lines Matching refs:ev

59 typedef void (*event_encode_t)(snd_midi_event_t *dev, snd_seq_event_t *ev);
60 typedef void (*event_decode_t)(const snd_seq_event_t *ev, unsigned char *buf);
67 static void note_event(snd_midi_event_t *dev, snd_seq_event_t *ev);
68 static void one_param_ctrl_event(snd_midi_event_t *dev, snd_seq_event_t *ev);
69 static void pitchbend_ctrl_event(snd_midi_event_t *dev, snd_seq_event_t *ev);
70 static void two_param_ctrl_event(snd_midi_event_t *dev, snd_seq_event_t *ev);
71 static void one_param_event(snd_midi_event_t *dev, snd_seq_event_t *ev);
72 static void songpos_event(snd_midi_event_t *dev, snd_seq_event_t *ev);
73 static void note_decode(const snd_seq_event_t *ev, unsigned char *buf);
74 static void one_param_decode(const snd_seq_event_t *ev, unsigned char *buf);
75 static void pitchbend_decode(const snd_seq_event_t *ev, unsigned char *buf);
76 static void two_param_decode(const snd_seq_event_t *ev, unsigned char *buf);
77 static void songpos_decode(const snd_seq_event_t *ev, unsigned char *buf);
118 static int extra_decode_ctrl14(snd_midi_event_t *dev, unsigned char *buf, int len, const snd_seq_event_t *ev);
119 static int extra_decode_xrpn(snd_midi_event_t *dev, unsigned char *buf, int count, const snd_seq_event_t *ev);
123 int (*decode)(snd_midi_event_t *dev, unsigned char *buf, int len, const snd_seq_event_t *ev);
304 * \param[out] ev Sequencer event.
309 * encoded, the sequencer event is written to \a ev; otherwise, \a ev->type is
321 * When this function returns a system exclusive sequencer event (\a ev->type
322 * is #SND_SEQ_EVENT_SYSEX), the data pointer (\a ev->data.ext.ptr) points into
362 long snd_midi_event_encode(snd_midi_event_t *dev, const unsigned char *buf, long count, snd_seq_event_t *ev)
367 ev->type = SND_SEQ_EVENT_NONE;
370 rc = snd_midi_event_encode_byte(dev, *buf++, ev);
385 * \param[out] ev Sequencer event.
391 * \a ev; otherwise, further bytes are required to complete a message.
400 int snd_midi_event_encode_byte(snd_midi_event_t *dev, int c, snd_seq_event_t *ev)
408 ev->type = status_event[ST_SPECIAL + c - 0xf0].event;
409 ev->flags &= ~SND_SEQ_EVENT_LENGTH_MASK;
410 ev->flags |= SND_SEQ_EVENT_LENGTH_FIXED;
411 return ev->type != SND_SEQ_EVENT_NONE;
438 ev->type = status_event[dev->type].event;
439 ev->flags &= ~SND_SEQ_EVENT_LENGTH_MASK;
440 ev->flags |= SND_SEQ_EVENT_LENGTH_FIXED;
442 status_event[dev->type].encode(dev, ev);
449 ev->flags &= ~SND_SEQ_EVENT_LENGTH_MASK;
450 ev->flags |= SND_SEQ_EVENT_LENGTH_VARIABLE;
451 ev->type = SND_SEQ_EVENT_SYSEX;
452 ev->data.ext.len = dev->read;
453 ev->data.ext.ptr = dev->buf;
466 static void note_event(snd_midi_event_t *dev, snd_seq_event_t *ev)
468 ev->data.note.channel = dev->buf[0] & 0x0f;
469 ev->data.note.note = dev->buf[1];
470 ev->data.note.velocity = dev->buf[2];
474 static void one_param_ctrl_event(snd_midi_event_t *dev, snd_seq_event_t *ev)
476 ev->data.control.channel = dev->buf[0] & 0x0f;
477 ev->data.control.value = dev->buf[1];
481 static void pitchbend_ctrl_event(snd_midi_event_t *dev, snd_seq_event_t *ev)
483 ev->data.control.channel = dev->buf[0] & 0x0f;
484 ev->data.control.value = (int)dev->buf[2] * 128 + (int)dev->buf[1] - 8192;
488 static void two_param_ctrl_event(snd_midi_event_t *dev, snd_seq_event_t *ev)
490 ev->data.control.channel = dev->buf[0] & 0x0f;
491 ev->data.control.param = dev->buf[1];
492 ev->data.control.value = dev->buf[2];
496 static void one_param_event(snd_midi_event_t *dev, snd_seq_event_t *ev)
498 ev->data.control.value = dev->buf[1];
502 static void songpos_event(snd_midi_event_t *dev, snd_seq_event_t *ev)
504 ev->data.control.value = (int)dev->buf[2] * 128 + (int)dev->buf[1];
512 * \param[in] ev The sequencer event to decode.
522 * for System Exclusive events (\a ev->type == #SND_SEQ_EVENT_SYSEX) which can
523 * have any length (as specified by \a ev->data.ext.len).
550 * <dt>-EINVAL<dd>\a ev is not a valid sequencer event.
559 long snd_midi_event_decode(snd_midi_event_t *dev, unsigned char *buf, long count, const snd_seq_event_t *ev)
565 if (ev->type == SND_SEQ_EVENT_NONE)
569 if (ev->type == status_event[type].event)
573 if (ev->type == extra_event[type].event)
574 return extra_event[type].decode(dev, buf, count, ev);
583 cmd = 0x80 | (type << 4) | (ev->data.note.channel & 0x0f);
588 qlen = ev->data.ext.len;
591 switch (ev->flags & SND_SEQ_EVENT_LENGTH_MASK) {
595 memcpy(buf, ev->data.ext.ptr, qlen);
604 status_event[type].decode(ev, xbuf + 1);
608 status_event[type].decode(ev, xbuf + 0);
622 static void note_decode(const snd_seq_event_t *ev, unsigned char *buf)
624 buf[0] = ev->data.note.note & 0x7f;
625 buf[1] = ev->data.note.velocity & 0x7f;
629 static void one_param_decode(const snd_seq_event_t *ev, unsigned char *buf)
631 buf[0] = ev->data.control.value & 0x7f;
635 static void pitchbend_decode(const snd_seq_event_t *ev, unsigned char *buf)
637 int value = ev->data.control.value + 8192;
643 static void two_param_decode(const snd_seq_event_t *ev, unsigned char *buf)
645 buf[0] = ev->data.control.param & 0x7f;
646 buf[1] = ev->data.control.value & 0x7f;
650 static void songpos_decode(const snd_seq_event_t *ev, unsigned char *buf)
652 buf[0] = ev->data.control.value & 0x7f;
653 buf[1] = (ev->data.control.value >> 7) & 0x7f;
657 static int extra_decode_ctrl14(snd_midi_event_t *dev, unsigned char *buf, int count, const snd_seq_event_t *ev)
662 cmd = MIDI_CMD_CONTROL|(ev->data.control.channel & 0x0f);
663 if (ev->data.control.param < 32) {
673 buf[idx++] = ev->data.control.param;
674 buf[idx++] = (ev->data.control.value >> 7) & 0x7f;
677 buf[idx++] = ev->data.control.param + 32;
678 buf[idx++] = ev->data.control.value & 0x7f;
687 buf[idx++] = ev->data.control.param & 0x7f;
688 buf[idx++] = ev->data.control.value & 0x7f;
694 static int extra_decode_xrpn(snd_midi_event_t *dev, unsigned char *buf, int count, const snd_seq_event_t *ev)
713 cmd = MIDI_CMD_CONTROL|(ev->data.control.channel & 0x0f);
714 bytes[0] = (ev->data.control.param & 0x3f80) >> 7;
715 bytes[1] = ev->data.control.param & 0x007f;
716 bytes[2] = (ev->data.control.value & 0x3f80) >> 7;
717 bytes[3] = ev->data.control.value & 0x007f;
723 cbytes = ev->type == SND_SEQ_EVENT_NONREGPARAM ? cbytes_nrpn : cbytes_rpn;