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

2012-11-21 Thread Shani Hadiyanto Pribadi
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

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

2012-11-21 Thread Harry van Haaren
On Wed, Nov 21, 2012 at 11:54 AM, Shani Hadiyanto Pribadi shaniprib...@gmx.net wrote: 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); } Extra context

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

2012-11-21 Thread hermann meyer
Am 21.11.2012 13:24, schrieb SxDx: - Original Message - From: Shani Hadiyanto Pribadishaniprib...@gmx.net 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 +

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

2012-11-21 Thread Fons Adriaensen
On Wed, Nov 21, 2012 at 06:54:03PM +0700, Shani Hadiyanto Pribadi wrote: 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); } You should test the return

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

2012-11-21 Thread Shani Hadiyanto Pribadi
That's it. Apparently the cause of segfault is dereferencing the pointer when there's no data. After adding checks for available data the segfault does not happen anymore. It never occured to me that was the cause because on the C version, accessing the pointer when there's no data returns 0x6a

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

2012-11-21 Thread Paul Davis
On Wed, Nov 21, 2012 at 7:49 AM, Shani Hadiyanto Pribadi shaniprib...@gmx.net wrote: That's it. Apparently the cause of segfault is dereferencing the pointer when there's no data. After adding checks for available data the segfault does not happen anymore. It never occured to me that was