Closed Ant1r closed 3 years ago
What version of ofxPd? master
or a tag? Also, the multi example is really only experimental...
master
, with some minor fixes like:
pdinstance1 = libpd_free_instance();
-> libpd_free_instance(pdinstance1);
and adapting ofSoundStreamSetup()
to old OF way.
multi example is really only experimental
I know that :-) I would like to see if I could have it running anyway.
libpd/samples/c/pdtest_multi
doesn't crash, so it should be able to (at least) run.
I believe I made most of those changes in a commit yesterday. Did I miss something...
ok maybe i'm not up to date. let me see.
I wasn't... now I am. It compiles fine now, but same crash.
OK, the previous crash is fixed by calling libpd_init()
before the first libpd_new_instance()
.
Now I have another one:
Thread 1 "pdMultiExample_" received signal SIGSEGV, Segmentation fault.
0x0000000000495fdc in sys_lock () at ../../../addons/ofxPd/libs/libpd/pure-data/src/s_inter.c:1641
1641 pthread_mutex_lock(&pd_this->pd_inter->i_mutex);
(gdb) bt
#0 0x0000000000495fdc in sys_lock () at ../../../addons/ofxPd/libs/libpd/pure-data/src/s_inter.c:1641
#1 0x0000000000542313 in libpd_message (recv=0x88c9cc "pd", msg=0x88c9c8 "dsp", argc=1, argv=0xecdf50) at ../../../addons/ofxPd/libs/libpd/libpd_wrapper/z_libpd.c:384
#2 0x0000000000542220 in libpd_finish_message (recv=0x88c9cc "pd", msg=0x88c9c8 "dsp") at ../../../addons/ofxPd/libs/libpd/libpd_wrapper/z_libpd.c:357
#3 0x000000000042c2af in pd::PdBase::PdContext::computeAudio (this=0xecc1f0, state=true) at /home/arsene/Documents/OF/of_v0.9.8_linux64_release/addons/ofxPd/libs/libpd/cpp/PdBase.hpp:1148
#4 0x0000000000435383 in pd::PdBase::computeAudio (this=0xecc0c0, state=true) at /home/arsene/Documents/OF/of_v0.9.8_linux64_release/addons/ofxPd/libs/libpd/cpp/PdBase.hpp:233
#5 0x000000000042e8df in ofxPd::computeAudio (this=0xecc0c0, state=true) at ../../../addons/ofxPd/src/ofxPd.cpp:175
#6 0x000000000042e9ba in ofxPd::start (this=0xecc0c0) at ../../../addons/ofxPd/src/ofxPd.cpp:179
#7 0x000000000042b626 in ofApp::setup (this=0xecc0a0) at /home/arsene/Documents/OF/of_v0.9.8_linux64_release/addons/ofxPd/pdMultiExample/src/ofApp.cpp:88
#8 0x000000000042a1bb in ofBaseApp::setup (this=0xecc0a0, args=...) at ../../../libs/openFrameworks/app/ofBaseApp.h:63
sorry, forget last crash (I had commented out the second libpd_new_instance()
for debugging...).
so it works now!
the only thing is to call libpd_init()
before the first libpd_new_instance()
.
Would you want I make a PR?
Ah ok. I see I need to add the instance flags to the multi example makefile as the PG generated the Xcode project without them, so I wasn't seeing any run time crashes just bad sound as it was single instance.
Yeah, on Linux I add the flags in the config.make
. I don't know if the PG takes it into account; if it does, then it might be useful to add such a config.make
into the multiExample directory.
There's still an issue: both pdinstances need to call pd.init(...)
, which is not the case currently. So the second one, which is not fully configurated, cannot produce sound and cannot measure time.
So I copied pd.init(...)
after libpd_set_instance(pdinstance2)
, and now both instances behave normally!
Right. I was looking at this the other day and it seemed weird then, as compared to the C pdtest_multi
.
I know now the reason was that I wasn't compiling with multi instance enabled. I will add an error check for this and some info in the readme about setting the flags manually for Xcode.
Ok, check latest commits, mainly 4e7597d3e392f3406df1827e8969a60f3e9849a1. The example is working and you should get a mix of 440 and 880 sine tones.
You should be able to build the pdMultiExample with required flags with the makefile by default. For PG projects, uncomment the line in addons_config.mk
.
Great, thanks Dan! btw you didn't add pdMultiExample/config.make, is it on purpose? As it's currently git-ignored, I'm wondering...
Anyway I'm quite happy, as I'm now able to compile ofxPd with the setup I needed:
I was able to verify that audio never stops, even when the first instance is hanging doing a huge job (like calculating log(2) 10 million times....). Still to confirm on mobile devices...
Yeah, I forgot to add config.make as it was ignored. Now there.
Ubuntu 16.04, of_v0.9.8_linux64 gdb backtrace of the Debug build: