Re: [gtk-list] Re: Software design question (pthread or special widget)?



>On Thu, 04 Mar 1999 17:15:42 -0500, David J. Topper <topper@virginia.edu>
>wrote:
>
>>I'm writing a front end to a real-time synthesis engine called RTcmix
>>(http://www.music.columbia.edu/cmix).  I already have an application set
>>up to control synthesis parameters via sliders.  But I'd like the
>>ability to read pitch data either from the MIDI port OR from a slider.
>>
>>My two options seem to be:
>>
>>1.  Use pthreads to create a new thread for my MIDI parser
>>2.  Create a special widget to read MIDI data
>>
>>I think I can handle the former, but somehow the idea of the latter is
>>exciting.  Anyone have some ideas / input?  I'm a bit at a loss to go
>>about writing my own widget.

To flesh it out a little bit:

    int midi_fd;
    struct info_needed_to_handle_midi {
        .....
    } my_midi_callback;

    void my_midi_callback (int fd, GdkInputCondition cond, void *arg)
   
    {
            /* read midi data from fd, using arg if necessary */
	    
	    /* get controller/note number values from midi data */

	    /* get the relevant GtkAdjustment ptr, possibly using arg */
	    
	    /* adjust the adjustment */

    }

Then, somewhere do:

    gdk_input_add (midi_fd, GTK_INPUT_READ, my_midi_callback, 
                   (void *) &my_midi_arg);

and you're all set. Every time MIDI data is readable, your callback
will be run, and you'll get a chance to synchronously adjust any of
the relevant GtkAdjustment objects that (presumably) control your
sliders.

Oh, and BTW, check out http://www.op.net/~pbd/quasimodo/ :)

regards,
--p



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]