Skip to contentSkip to conversation

envy24control: midi support for mixer

PATCH Dirk Jagdmann 2 participants 3 messages Nov 11, 2004 – Nov 17, 2004 Kbuild

lore
Share & tools
lore
#0 lore raw

Hello devlopers,

I have made the mixer sliders in envy24control react to MIDI controllers. This way the hardware mixer can be controlled from a sequencer program or some external MIDI controller hardware.

envy24control became a standard ALSA sequencer client which you can connect to arbitrary other MIDI sources/sinks.

The patch is attached to this email. Please tell me, if this can be included with the standard alsa-tools sources.

Signature · 3 lines
---> doj / cubic
----> http://cubic.org/~doj
-----> http://llg.cubic.org
Makefile.am +1 -1
diff -u -U 5 -r --new-file -x *~ -X /tmp/diffexclude envy24control.orig/Makefile.am envy24control/Makefile.am
@@ -1,9 +1,9 @@
 AM_CFLAGS = @ENVY24CONTROL_CFLAGS@
 bin_PROGRAMS = envy24control
 man_MANS = envy24control.1
-envy24control_SOURCES = envy24control.c envy24control.h levelmeters.c \
+envy24control_SOURCES = envy24control.c envy24control.h levelmeters.c midi.c \
                         mixer.c patchbay.c hardware.c driverevents.c volume.c \
 			profiles.c profiles.h
 envy24control_LDFLAGS = @ENVY24CONTROL_LIBS@
 EXTRA_DIST = envy24control.1 depcomp configure.in-gtk2 \
 	     strstr_icase_blank.c new_process.c README.profiles
envy24control.1 +30 -27

102 lines not on this page · raw message

envy24control.c +30 -13

159 lines not on this page · raw message

midi.c +188 -0

188 lines not on this page · raw message

midi.h +12 -0
diff -u -U 5 -r --new-file -x *~ -X /tmp/diffexclude envy24control.orig/midi.h envy24control/midi.h
@@ -0,0 +1,12 @@
+#ifndef MIDI__H
+#define MIDI__H
+
+#include <gdk/gdk.h>
+
+int midi_init(char *appname, int channel);
+int midi_close();
+void midi_maxstreams(int);
+int midi_controller(int c, int v);
+void midi_process(gpointer data, gint source, GdkInputCondition condition);
+
+#endif
mixer.c +7 -0
diff -u -U 5 -r --new-file -x *~ -X /tmp/diffexclude envy24control.orig/mixer.c envy24control/mixer.c
@@ -16,10 +16,11 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 ******************************************************************************/
 
 #include "envy24control.h"
+#include "midi.h"
 
 #define	MULTI_PLAYBACK_SWITCH		"Multi Playback Switch"
 #define MULTI_PLAYBACK_VOLUME		"Multi Playback Volume"
 
 #define HW_MULTI_CAPTURE_SWITCH		"H/W Multi Capture Switch"
@@ -60,10 +61,12 @@
 		v[1] = snd_ctl_elem_value_get_integer(vol, 1);
 		if (v[0] != v[1])
 			toggle_set(mixer_stereo_toggle[stream-1], FALSE);
 		gtk_adjustment_set_value(GTK_ADJUSTMENT(mixer_adj[stream-1][0]), 96 - v[0]);
 		gtk_adjustment_set_value(GTK_ADJUSTMENT(mixer_adj[stream-1][1]), 96 - v[1]);
+		midi_controller(stream*2-1, v[0]);
+		midi_controller(stream*2,   v[1]);
 	}
 	if (sw_flag) {
 		snd_ctl_elem_value_t *sw;
 		int v[2];
 		snd_ctl_elem_value_alloca(&sw);
@@ -137,14 +140,16 @@
 	if ((err = snd_ctl_elem_read(ctl, vol)) < 0)
 		g_print("Unable to read multi volume: %s\n", snd_strerror(err));
 	if (left >= 0) {
 		change |= (snd_ctl_elem_value_get_integer(vol, 0) != left);
 		snd_ctl_elem_value_set_integer(vol, 0, left);
+		midi_controller(stream*2-1, left);
 	}
 	if (right >= 0) {
 		change |= (snd_ctl_elem_value_get_integer(vol, 1) != right);
 		snd_ctl_elem_value_set_integer(vol, 1, right);
+		midi_controller(stream*2, right);
 	}
 	if (change) {
 		if ((err = snd_ctl_elem_write(ctl, vol)) < 0 && err != -EBUSY)
 			g_print("Unable to write multi volume: %s\n", snd_strerror(err));
 	}
@@ -173,10 +178,12 @@
 void mixer_init(void)
 {
 	int i;
 	int nb_active_channels;
 	snd_ctl_elem_value_t *val;
+
+	midi_maxstreams(sizeof(stream_is_active)/sizeof(stream_is_active[0]));
 
 	snd_ctl_elem_value_alloca(&val);
 	snd_ctl_elem_value_set_interface(val, SND_CTL_ELEM_IFACE_MIXER);
 	memset (stream_is_active, 0, (MAX_PCM_OUTPUT_CHANNELS + MAX_SPDIF_CHANNELS + MAX_INPUT_CHANNELS + MAX_SPDIF_CHANNELS) * sizeof(int));
 	snd_ctl_elem_value_set_name(val, MULTI_PLAYBACK_SWITCH);
#1 lore raw

At Thu, 11 Nov 2004 21:50:08 +0100,

Quoted 7 lines · Dirk Jagdmann

Hello devlopers,

I have made the mixer sliders in envy24control react to MIDI controllers. This way the hardware mixer can be controlled from a sequencer program or some external MIDI controller hardware.

Quoted 5 lines

envy24control became a standard ALSA sequencer client which you can connect to arbitrary other MIDI sources/sinks.

The patch is attached to this email. Please tell me, if this can be included with the standard alsa-tools sources.

Thanks for the patch.

I committed it to CVS with minor changes. As default, midi_init isn't called unless -m option is given.

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE FREE OODBMS DOWNLOAD - A multidimensional database that combines robust object and relational technologies, making it a perfect match for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8

#2 lore raw
Quoted 3 lines

Thanks for the patch.
I committed it to CVS with minor changes. As default, midi_init isn't called unless -m option is given.

That sound ok, because most user won't use the midi functionality. I can make an "alias" entry in my /etc/profile for my needs :-)

Signature · 10 lines
---> doj / cubic
----> http://cubic.org/~doj
-----> http://llg.cubic.org


-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8