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

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-audio-dev@...>
Date: Wednesday, November 21, 2012 - 11:54 am

--001636c928a9c9a06204cf00019e
Content-Type: text/plain; charset=UTF-8

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 (*(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

--001636c928a9c9a06204cf00019e
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

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 ha=
ve 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.Tha=
t is why I am rewriting my program using C++ (it would also be a learning e=
xperience for me).I looked to Rui's synthv1 and zita-ajbridge for e=
xample of writing jack client using C++.
The problem I am having relates to Jack MIDI.My program keeps havin=
g a segfault when it is trying to read from the MIDI buffer,specificall=
y when it tries to dereference the buffer pointer inside the event structur=
e.
jack_midi_event_get(&in_event, midi_buf, event_index);if ((*(in=
_event.buffer) & 0xf0) =3D=3D 0x90) // Segfault happens here, on boolea=
n mask operation{=C2=A0=C2=A0=C2=A0 _note =3D *(in_event.buffer + 1=
);}So I tried to print the buffer's content but it also seg=
faults.
std::cout << std::hex << static_cast<unsigned int> (*(in_=
event.buffer)) << std::endl;My understanding that in_event.bu=
ffer is a pointer-to-char,so that *(in_event.buffer) should be an unsig=
ned char.
I don't understand where I am doing wrong,I would be very grate=
ful if someone could point out my error.Oh, my computer is Archlinu=
x 64 bit using jack2-git 20120718.I have put up a git repo of the code =
on https://g=
ithub.com/shanipribadi/pitch-segfault.git

Thanks.Shani Pribadi

--001636c928a9c9a06204cf00019e--

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[LAD] Segfault when trying to dereference __midi_event.buffe..., Shani Hadiyanto Pribadi, (Wed Nov 21, 11:54 am)
Re: [LAD] Segfault when trying to dereference __midi_event.b..., Shani Hadiyanto Pribadi, (Wed Nov 21, 12:49 pm)
Re: [LAD] Segfault when trying to dereference __midi_event.b..., Harry van Haaren, (Wed Nov 21, 12:14 pm)