Midi controller for Ecasound

Justin Rosander <[email protected]>
Newsgroups gmane.comp.audio.ecasound.general
Message-ID <CAOxgbvP1cw7nLqkW0SFCRKJfjW6EZeDauEUcuksGc+AJ4mCV6w@mail.gmail.com>
Hi there,
not sure if this would be an appropriate channel for this, but I am
currently writing a midi controller for the purpose of controlling ecasound
effects in real-time using a GUI.  It is working, but I am running into a
bit of a problem getting ecasound to connect to it automatically without
using aconnect.  I am using Elementary as the widget set from E17 (
enlightenment.org), and have attached the source code to this email.  It
can be built as follows:
gcc main.c -o slider -lasound `pkg-config elementary --cflags --libs`
It currently just sends CC events to channel 1, controller 1.

I am using the following ecasound command:

ecasound -i test.wav -o alsahw -ea:100 -km:1,1,200,1,1
-Md:alsaseq,midicontroller

I am grateful for any thoughts on what I am doing wrong in my code.

Justin

------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb

_______________________________________________
Ecasound-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ecasound-list
main.c (text/x-csrc, 2.2 KB)
#include <Elementary.h>
#include <alsa/asoundlib.h>

static snd_seq_t *seq_handle;
static int out_port;

void midi_open(void)
{
    snd_seq_open(&seq_handle, "default", SND_SEQ_OPEN_OUTPUT, 0);

    snd_seq_set_client_name(seq_handle, "midcontroller");
    out_port = snd_seq_create_simple_port(seq_handle, "out",
                      SND_SEQ_PORT_CAP_READ|SND_SEQ_PORT_CAP_SUBS_READ,
                      SND_SEQ_PORT_TYPE_APPLICATION);
}



static void
on_done(void *data, Evas_Object *obj, void *event_info)
{
	// quit the mainloop (elm_run function will return)
	elm_exit();
}

static void
_changed_cb(void *data, Evas_Object *obj, void *event_info)
{
    double val = elm_slider_value_get(obj);
	snd_seq_event_t ev;
	snd_seq_ev_clear(&ev);
	snd_seq_ev_set_source(&ev, out_port);
	snd_seq_ev_set_subs(&ev);
	
	snd_seq_ev_set_controller(&ev, 1, 1, (int)val);
     snd_seq_ev_set_direct(&ev);
	snd_seq_event_output_direct(seq_handle, &ev);
	snd_seq_drain_output(seq_handle);
}


EAPI_MAIN int
elm_main(int argc, char **argv)
{

	midi_open();

	Evas_Object *win, *box, *sl;

	win = elm_win_util_standard_add("slider", "Slider");
	evas_object_smart_callback_add(win, "delete,request", on_done, NULL);
	

	box = elm_box_add(win);
	elm_box_horizontal_set(box, EINA_TRUE);
	elm_win_resize_object_add(win, box);
	evas_object_show(box);

	//add slider
	sl = elm_slider_add(win);
	elm_slider_horizontal_set(sl, EINA_FALSE);
	//set default text
	elm_object_text_set(sl, "Slide me");
	evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
	evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	//set initial value
	elm_slider_value_set(sl, 0.0);
	//span size of slider
	elm_slider_span_size_set(sl, 200);
	//show units label
	elm_slider_unit_format_set(sl, "%1.0f units");
	//min and max values
	elm_slider_min_max_set(sl, 0, 127);
	//show value on the slider knob
	elm_slider_indicator_format_set(sl, "%1.0f");
	//invert
	elm_slider_inverted_set(sl, EINA_TRUE);
	//pack at the end of the box
	elm_box_pack_end(box, sl);
	evas_object_show(sl);
	//callback to function returning value

	evas_object_smart_callback_add(sl, "changed", _changed_cb, NULL);
	evas_object_show(win);

	elm_run();
	elm_shutdown();
	return 0;

}
ELM_MAIN()
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.