On Thu, 13 Feb 2020 08:46:18 +0100
Kjetil Matheussen <k.s.matheussen(a)gmail.com> wrote:
On Wed, Feb 12, 2020 at 5:49 PM Andre Osku Schmidt
<andre(a)osku.de> wrote:
Hello JACKies,
i tinkered this thing
https://github.com/oskude/jackplot that plots jack audio data with
opengl in real-time (and am a really happy puppy :D). but as i'm a c, jack and opengl
noob, i was hoping to get some help here. (at least for the jack part)
so i set the jack data (pointer) to a global variable
https://github.com/oskude/jackplot/blob/bcac59813b01b3bf7c2ebebd4988b22f5bf…
and read that data in opengl draw function (when ever its ready to draw)
https://github.com/oskude/jackplot/blob/bcac59813b01b3bf7c2ebebd4988b22f5bf…
(ignoring the function i read it in, am i even reading the jack data correctly?)
i'm suprised that it works, and hasn't crashed!
but i have the feeling that this is a bad/unsafe way to do it...
any thoughts? tips? links?
You could look at example_clients/capture_client.c in the jack2 repository.
ah, gotta check capture_client.c in detail later, thanks!
but for the data reading part, i guess the tip is a ring-buffer[0]?
i guess that is benefitical for writing a "backup" to disk.
but do i really need/want it for real-time plotting?
hmm, i'll try to understand the basics first.
/me quickly "learns" c pointers
https://www.youtube.com/watch?v=mw1qsMieK5c
(cool-side-note: pointer++ automagically advances the right amount of bits!)
so i did (in jackplot code):
```
in = jack_port_get_buffer(input_port, nframes);
printf("%x\n", in);
```
and it gives:
```
efe54820
efe54820
efe54820
efe54820
efe54820
efe54820
efe54820
efe54820
efe54820
efe54820
```
does that mean jack writes here always to the same (starting) position in memory?
overwriting the old data?
if yes, this means when reading it somewhere else, we might get "wrong" data?
BUT, as we are only reading it, elsewhere, nothing technically bad can happen?
i guess the question is then, can the reader ever get "wrong" data?
(as the goal is to get the latest data;)
so "wrong" data could only be if:
- writer writes data faster than reader reads? (and overtakes reader)
- reader reads data faster than writer writes? (and overtakes writer)
hmmm, now i'm really curious, can we somehow "see" when/if that happens?
/me sends a sine wave through jackplot, for the first time... *facepalm*
(side-note: puredata ftw!)
hmm, haven't seen a miss placed point/"pixel" while staring a 93.75 osc~ for
a while...
WAIT! that is a bad test, the waveform doesnt move on my screen, so the data is always the
same... *facepalm*
lets try different frequencies...
hmm, cant be sure i see any "wrong" points..
now i want a programmatic/automatic test for reading-"wrong"-data, any tips?
Cheers,
Andre Osku Schmidt
ps. i would also like to know where exactly - including technical terms - does the jack
process callback run? (trying to understand why it cant call opengl functions. not that i
want to run them there anymore though)
pps. but maybe i first need to concentrate on the drawing part, atm its even reading more
often than jack is writing...
[0]
https://en.wikipedia.org/wiki/Circular_buffer