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

From: Shani Hadiyanto Pribadi <shanipribadi@email-addr-hidden>
Date: Wed Nov 21 2012 - 13:54:03 EET

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

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Wed Nov 21 16:15:01 2012

This archive was generated by hypermail 2.1.8 : Wed Nov 21 2012 - 16:15:01 EET