Re: [Vala] Void*, how to deal with it



I've used get_buffer only for MIDI, so far, so I'm not sure how it'd
work on raw audio ports.

With MIDI ports, you use it like this:

        void *port_buffer = midi_in.get_buffer(nframes);
        NFrames count = Midi.get_event_count(port_buffer); 

        for (NFrames i=0; i<count; ++i)
        {
            Midi.Event e;
            Midi.Event.get(out e, port_buffer, i);
            ...

I guess, for audio, you'd have to cast void* get_buffer to
DefaultAudioSample, something like this (untested!):

DefaultAudioSample* buffer =
(DefaultAudioSample*)master_l.get_buffer(nframes);

Let me know if it works.
alb


On Wed, 2010-06-30 at 14:26 +0100, Harry Van Haaren wrote:
Hey All,

I've got a function in the JACK.vapi binding, that returns a buffer. Now it
doesnt "physically"
return the buffer, but returns a  void*  to the buffer.

I checked the Vala tutorial for any references to void*, and didnt find
anything...

This is the function (to be called on a Port object):
public void* get_buffer(NFrames nframes);         // nframes is a uint32..
not that it matters

And this is what I tried (master_l is of Port type):
var buffer = master_l.get_buffer(nframes);

And what I want to do with this buffer is the following:
    for(int i = 0; i < (uint32) nframes; i++)
    {
        buffer[i] = array[i];   // have an array of samples, need to write
them to this void* buffer.
    }

Any suggestions..? Thanks for reading, -Harry
_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list





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