Re: [LAD] help with RtMidi and gtkmm

From: Harry van Haaren <harryhaaren@email-addr-hidden>
Date: Sat Feb 04 2012 - 20:34:36 EET

Hi Alessandro!

You'll need to learn a bit about threading in C++, either Mutexs or Lock
Free Ringbuffers.
I'll advise Ringbuffers because it scales up, while mutexs is slightly
easier to learn, but you'll
want to learn ringbuffers soon thereafter anyway!

One option is to use the Gtk::timeout functions to update the values
regardless of if they've changed: bit of a hack but it works :)
http://developer.gnome.org/gtkmm-tutorial/3.0/sec-timeouts.html.en

Another option is to attach a "idle" function when a MIDI message is
recieved in the MIDI IN callback: which tells the UI to update.

Problem with both of these options: you need to tell the parameters what
value to update to: this involves either mutexs or a ringbuffer.

I've not looked at your code, this is all just C++ threading theory RE
RtMidi & Gtkmm. Same applies for JACK & Gtkmm, or any "callback" api, and a
"blocking" api like Gtkmm.

Good luck! -Harry

PS: I've written a blog post on Gtkmm & signal handling:
http://harryhaaren.blogspot.com/2009/12/tut-5-callbacks-with-gtkmm.html
Its *not* thread safe, but it explains callbacks a little..

On Sat, Feb 4, 2012 at 5:57 PM, alessandro filippo <
alessandro.filippo@email-addr-hidden> wrote:

> Hi, I'm learning to write simple audio/midi applications in C++ with
> RtMidi and gtkmm libraries (version 2.4).
>
> This is the application I'm working on:
>
> http://www.eclepticbox.altervista.org/index.php/download/finish/2-audio-midi/8-sawlidsyngui
>
>
> I got some issues with RtMidi IN (Callback). I followed the RtMidi
> tutorial and the VMPK example (however this is written with Qt), but the
> problem is that the GUI freezes when I send some MIDI data and it
> doesn't refresh the widgets values.
>
> Midi Out works properly.
>
> I think the problem is in the Midi Callback and in the event/signal
> managing.
> I tried some function in order to refresh the gui but they didn't work.
>
> This is the smallest extract of code that has the issue (only a
> spinbutton sending / receiving MIDI Program Change):
>
>
> http://www.eclepticbox.altervista.org/index.php/download/finish/2-audio-midi/9-sawlidsyngui-test
>
> The sources are in the src folder, see:
>
> sawlidsyngui.cpp
> sawlidsyngui.h
>
> Any help is appreciated....
>
> Thanks ...
> Alessandro
>
>
>
> _______________________________________________
> Linux-audio-dev mailing list
> Linux-audio-dev@email-addr-hidden
> http://lists.linuxaudio.org/listinfo/linux-audio-dev
>

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Sat Feb 4 20:15:02 2012

This archive was generated by hypermail 2.1.8 : Sat Feb 04 2012 - 20:15:02 EET