Brilliant!  Thanks for the help :)

On Sat, Feb 16, 2013 at 4:41 PM, Arvind R <arvin...@gmail.com> wrote:

> On Sat, Feb 16, 2013 at 8:42 PM, Justin Rosander
> <justinrosan...@gmail.com> wrote:
> > Thanks for the replies.  Taking Arvind's suggestion on a structure, I put
> > the following together, but I'm getting an error:
> > slidermult.c: In function ‘_changed_cb’:
> > slidermult.c:38: error: request for member ‘ch’ in something not a
> > structure or union
> >
> > I've googled and googled, but can't really seem to be getting anywhere
> > closer to understanding what I'm doing wrong, here.
> >
> > code follows:
> > #include <Elementary.h>
> > #include <alsa/asoundlib.h>
> >
> > #define CHN 12 //define # of channels
> >
> > static snd_seq_t *seq_handle;
> > static int out_port;
> >
> > typedef struct{
> >     int ch;
> >     int mid_ch; //sticking with midi channel 1 for now
> >     int mid_CC;     //I'm wanting CC# to be assigned per widget
> >     Evas_Object *sl; //Not sure if declaring this in the structure works,
> > but we'll give it a shot.  The point here is to have the object
> associated
> > with bank[x].{ch,mid_ch,mid_CC}, and so on.
> >     }mixer;
> >
> > 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)
> > {
> mixer *mix = data;
>
> >     double val = elm_slider_value_get(obj);
> >      printf("Changed to %1.0f\n", val);
> >      printf("slider is %d", data.ch);
> printf("slider is %d\n", mix->ch);
>
> >     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, 0, 0, (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;
> >     int x;
> >
> >     mixer *ptr; //pointer to structure
> >     mixer bank[CHN]; //declare array of structures
> >     ptr = bank; //pointer to first struct
> >     ptr->mid_ch; //sticking with midi channel 1 for now
> >
> >     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);
> >
> > //set up an array of sliders
> > for(x = 0; x < CHN; x++) {
> >     //set ch and CC
> >     ptr->ch = x;
> >     ptr->mid_CC = x;
> >     //add slider
> >     ptr->sl = elm_slider_add(win);
> >
> >     elm_slider_horizontal_set(ptr->sl, EINA_FALSE);
> >     //pack at the end of the box
> >     elm_box_pack_end(box, ptr->sl);
> >     evas_object_show(ptr->sl);
> >     //callback to function returning value
> >     evas_object_smart_callback_add(ptr->sl, "changed", _changed_cb, ptr);
> >     ptr++;
> > }
> >     evas_object_show(win);
> >
> >     elm_run();
> >     elm_shutdown();
> >     return 0;
> >
> > }
> > ELM_MAIN()
> >
> >
> > On Fri, Feb 15, 2013 at 7:24 AM, Arvind R <arvin...@gmail.com> wrote:
> >
> >> On Thu, Feb 14, 2013 at 6:44 PM, Justin Rosander
> >> <justinrosan...@gmail.com> wrote:
> >> > Thanks for the reply, Arvind.  Okay, so I have that working, and I
> >> > understand by passing the addresses of the array to my callback, I am
> >> > interacting with specific sliders.  If the type is void, then how
> would I
> >> > specify that the values of a specific slider is supposed to be related
> >> to a
> >> > specific integer?  In dealing with the callback, my understanding is
> I am
> >> > passing on the address of the array, but I cannot increment the array
> >> > directly in the callback like in a for loop:
> >> >
> >> > static void
> >> > _changed_cb(void *data, Evas_Object *obj, void *event_info)
> >> > {
> >> Generally, data is your private struct. initialised with references to
> >> all your operational data. obj would be the source of the event. You
> >> should be able to do anything you want here.
> >> >     double val = elm_slider_value_get(obj);
> >> >      printf("Changed to %1.0f\n", val);
> >> >      printf("slider is %d", *(int*)data); //test what is passed to
> *data
> >> >     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, 0, 0, (int)val);  //second and
> third
> >> > args need to relate to the specific widget that is being interacted
> with,
> >> > i.e. "1" for "slider 1"
> >> >
> >> >      snd_seq_ev_set_direct(&ev);
> >> >     snd_seq_event_output_direct(seq_handle, &ev);
> >> >     snd_seq_drain_output(seq_handle);
> >> > }
> >> >
> >> > My goal here is to have the specific slider relate to specific
> integers
> >> > such as in the second and third arguments of
> >> > snd_seq_ev_set_controller(&ev, 0, 0, (int)val);
> >> > so that when the specific slider is interacted with, I can pass to
> >> another
> >> > function that I am dealing with a specific channel number or
> controller
> >> > number.
> >> >
> >> >
> >> > On Wed, Feb 13, 2013 at 8:51 PM, Arvind R <arvin...@gmail.com> wrote:
> >> >
> >> >> On Thu, Feb 14, 2013 at 6:51 AM, Justin Rosander
> >> >> <justinrosan...@gmail.com> wrote:
> >> >> > Hi there,
> >> >> >
> >> >> > I'm trying to put together a midi controller featuring faders that
> >> would
> >> >> be
> >> >> > assigned to different channels.  In exploring the use of an array
> to
> >> >> make a
> >> >> > window full of sliders, I put the following together:
> >> >> >
> >> >> > for(x = 0; x < 12; x++) {
> >> >> >
> >> >> >     //add slider
> >> >> >     sl[x] = elm_slider_add(win);
> >> >> >
> >> >> >     elm_slider_horizontal_set(sl[x], EINA_FALSE);
> >> >> >     //pack at the end of the box
> >> >> >     elm_box_pack_end(box, sl[x]);
> >> >> >     evas_object_show(sl[x]);
> >> >> >     //callback to function returning value
> >> >> >     evas_object_smart_callback_add(sl[x], "changed", _changed_cb,
> >> NULL);
> >> >> > }
> >> >> Replace the NULL in the callback_add with a pointer to data. It will
> >> >> be available as the first argument in the callback funcion as a void
> *
> >> >> . If you don't need to reference any other data in the cb, you can
> >> >> pass &sl[x]. Also, the second arg. in the cb is the first arg. in the
> >> >> callback_add().
> >> >> >
> >> >> > What I'm trying to figure out is how I would differentiate one
> slider
> >> >> from
> >> >> > another in a callback function?  For instance, when I move, say,
> >> "slider
> >> >> 1"
> >> >> > as opposed to "slider 2".
> >> >> >
> >> >> > Any input is appreciated.
> >> >> >
> >> >> > 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
> >> >> > _______________________________________________
> >> >> > enlightenment-users mailing list
> >> >> > enlightenment-users@lists.sourceforge.net
> >> >> > https://lists.sourceforge.net/lists/listinfo/enlightenment-users
> >> >>
> >> >>
> >> >>
> >>
> ------------------------------------------------------------------------------
> >> >> 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
> >> >> _______________________________________________
> >> >> enlightenment-users mailing list
> >> >> enlightenment-users@lists.sourceforge.net
> >> >> https://lists.sourceforge.net/lists/listinfo/enlightenment-users
> >> >>
> >> >
> >>
> ------------------------------------------------------------------------------
> >> > 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
> >> > _______________________________________________
> >> > enlightenment-users mailing list
> >> > enlightenment-users@lists.sourceforge.net
> >> > https://lists.sourceforge.net/lists/listinfo/enlightenment-users
> >>
> >>
> >>
> ------------------------------------------------------------------------------
> >> 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
> >> _______________________________________________
> >> enlightenment-users mailing list
> >> enlightenment-users@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/enlightenment-users
> >>
> >
> ------------------------------------------------------------------------------
> > The Go Parallel Website, sponsored by Intel - in partnership with
> Geeknet,
> > is your hub for all things parallel software development, from weekly
> thought
> > leadership blogs to news, videos, case studies, tutorials, tech docs,
> > whitepapers, evaluation guides, and opinion stories. Check out the most
> > recent posts - join the conversation now.
> http://goparallel.sourceforge.net/
> > _______________________________________________
> > enlightenment-users mailing list
> > enlightenment-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/enlightenment-users
>
>
> ------------------------------------------------------------------------------
> The Go Parallel Website, sponsored by Intel - in partnership with Geeknet,
> is your hub for all things parallel software development, from weekly
> thought
> leadership blogs to news, videos, case studies, tutorials, tech docs,
> whitepapers, evaluation guides, and opinion stories. Check out the most
> recent posts - join the conversation now.
> http://goparallel.sourceforge.net/
> _______________________________________________
> enlightenment-users mailing list
> enlightenment-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-users
>
------------------------------------------------------------------------------
The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, 
is your hub for all things parallel software development, from weekly thought 
leadership blogs to news, videos, case studies, tutorials, tech docs, 
whitepapers, evaluation guides, and opinion stories. Check out the most 
recent posts - join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
enlightenment-users mailing list
enlightenment-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-users

Reply via email to