Re: [linux-audio-user] converting sysEx from my juno-106 into something more useful

From: Clemens Ladisch <clemens@email-addr-hidden>
Date: Fri May 06 2005 - 17:11:08 EEST

Brian Dunn wrote:
> I would like a converter program that would recive my juno's sySex
> and output controler data on whatever controler # and midi channel
> i choose, in realtime.

The program below converts the SysEx commands that are output by
Joost's juno_rose utility (I don't have a Juno). To use a specific
channel, change the "data[3]" to a fixed value.

Clemens

-- 
/* compile with gcc -o junosliders junosliders.c -lasound */
#include <stdio.h>
#include <stdlib.h>
#include <alsa/asoundlib.h>
#define CHECK(cmd) check(cmd, #cmd)
void check(int err, const char *cmd)
{
	if (err < 0) {
		fprintf(stderr, "%s failed: %s\n", cmd, snd_strerror(err));
		exit(EXIT_FAILURE);
	}
}
int main()
{
	snd_seq_t *seq;
	int port;
	snd_seq_event_t *ev;
	CHECK(snd_seq_open(&seq, "default", SND_SEQ_OPEN_DUPLEX, 0));
	CHECK(snd_seq_set_client_name(seq, "Juno SysEx->CC"));
	CHECK(port = snd_seq_create_simple_port(seq, "Juno SysEx->CC",
						SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_WRITE |
						SND_SEQ_PORT_CAP_DUPLEX |
						SND_SEQ_PORT_CAP_SUBS_READ | SND_SEQ_PORT_CAP_SUBS_WRITE,
						SND_SEQ_PORT_TYPE_MIDI_GENERIC));
	while (snd_seq_event_input(seq, &ev) >= 0) {
		if (ev->type == SND_SEQ_EVENT_SYSEX && ev->data.ext.len >= 7) {
			unsigned char *data = ev->data.ext.ptr;
			if (data[0] == 0xf0 && data[1] == 0x41 && data[2] == 0x32) {
				snd_seq_ev_clear(ev);
				snd_seq_ev_set_controller(ev,
							  data[3], /* channel */
							  data[4] + 0x10, /* parameter number */
							  data[5]); /* value */
			}
		}
		snd_seq_ev_set_subs(ev);
		snd_seq_ev_set_source(ev, port);
		snd_seq_ev_set_direct(ev);
		snd_seq_event_output(seq, ev);
		snd_seq_drain_output(seq);
	}
	return 0;
}
Received on Fri May 6 20:15:06 2005

This archive was generated by hypermail 2.1.8 : Fri May 06 2005 - 20:15:06 EEST