[LAD] Segfault when trying to dereference __midi_event.buffer (c++ newbie question)

Shani Hadiyanto Pribadi shanipribadi at gmx.net
Wed Nov 21 11:54:03 UTC 2012


Hello there!

I am trying to write a real time pitch shifter using C++.
The pitch shifter uses resampling and WSOLA for time-scaling.
I have written a jack client that already works using C, but I would like
to try using zita-resampler as the resampler library for my program.
That is why I am rewriting my program using C++ (it would also be a
learning experience for me).
I looked to Rui's synthv1 and zita-ajbridge for example of writing jack
client using C++.

The problem I am having relates to Jack MIDI.
My program keeps having a segfault when it is trying to read from the MIDI
buffer,
specifically when it tries to dereference the buffer pointer inside the
event structure.

jack_midi_event_get(&in_event, midi_buf, event_index);
if ((*(in_event.buffer) & 0xf0) == 0x90) // Segfault happens here, on
boolean mask operation
{
    _note = *(in_event.buffer + 1);
}

So I tried to print the buffer's content but it also segfaults.
std::cout << std::hex << static_cast<unsigned int> (*(in_event.buffer)) <<
std::endl;

My understanding that in_event.buffer is a pointer-to-char,
so that *(in_event.buffer) should be an unsigned char.

I don't understand where I am doing wrong,
I would be very grateful if someone could point out my error.

Oh, my computer is Archlinux 64 bit using jack2-git 20120718.
I have put up a git repo of the code on
https://github.com/shanipribadi/pitch-segfault.git

Thanks.

Shani Pribadi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxaudio.org/pipermail/linux-audio-dev/attachments/20121121/44ebecd0/attachment.html>


More information about the Linux-audio-dev mailing list