Apologies for spam; we've changed our policy by requiring approval for accounts, and deleted all existing spam and user - thanks for your help flagging content. We continue to test our forums and Vanilla software, aiming for release early in 2013. If you need to give us feedback outside the forum, contact us via http://createdigitalmusic.com/contact/ or on Facebook
Using expr~ in LibPd
  • Hello!
    I was trying to play around with the "phaser~.pd" effect patch in the pd-starter-kit package. It uses expr~ which is not included in the pd-core. So I added the extra/expr~ folder in XCode and it gets compiled successfully. Unfortunately, I still receive "expr~ ... couldn't create" messages.
    Is there something else I have to do to set up my project using expr~ than compiling it? Do I have to call some kind of setup()-function for expr~? I couldn't find any in the source-code, though...

    Thanks,
    Markus
  • Every external has a setup function. The one for expr~ is called expr_setup() and you need to call it right after you call libpd_init().
  • Okay, this seems to do the trick... But unfortunately it only compiles for i386 architecture, i. e. Simulator, not for the iPad:

    Undefined symbols for architecture armv7:
    "_finite", referenced from:
    _ex_finite in libLibPd.a(vexp_fun.o)
    "_drem", referenced from:
    _ex_drem in libLibPd.a(vexp_fun.o)
    ld: symbol(s) not found for architecture armv7
  • This looks like a problem with the settings in xcode, but I can't tell for sure because I don't do iOS development. Maybe someone else can shed some light on this...?
  • The manpage for drem says the drem() function is deprecated, use the C99 function remainder() instead.

    finite() function should still be in math.h, but apparently not in the arm version. Don't know what's up with that. 

    Maybe make a simple stub that calls remainder() for drem() and isfinite() for finite().
  • e.g.

    #include
    #if !( TARGET_IPHONE_SIMULATOR)
    int finite(double x){ return isfinite( x);}

    double drem (double x, double y){ return remainder(x, y);}
    #endif
  • That was supposed to say include math.h, but it got filtered out by the text input widget.
  • Hi there, did anyone find workaround for this?
    I'm having the same problem with my expr objects (control and audio) not working on the device. 

    I'm going to see if I can refactor and get away with not using expr, but if someone already had a working solution it would be much appreciated!
  • I hate to be the license troll here, but just a little reminder: if you are thinking of putting your app into the Apple App Store, you cannot include GPL sources in it, like expr~. The Apple App Store is incompatible with the GPL. You are of course free to distribute iOS apps with GPL code in any other way, like direct download, etc. That's what VLC does.
  • But then the problem of needing to statically link libraries arises.. apple prohibits any form of binary plugins.

    For iOS projects, you might as well just write your own externals to replace whatever instances of [expr] that you are using.  Or just rewrite with pd primitives.
  • I think that's what I'm going to end up doing. I was using Pd-extended on os x instead of vanilla. I might just have to write my own externals as you just said. Not a big deal! :D
  • If someone could write a replacement for expr~ and put it under the BSD license (or similar), it'd be a huge, huge contribution to Pd. :)
  • IMHO, rewriting any GPL code as BSD would be a big waste of time.  Instead spend that time lobbying sticks in the mud like Apple to remove their needless onerous restrictions.  Remember: GPL software is totally fine on iOS, so jailbreak your phone and install any GPL software!  It is Apple's restrictions in their App Store that are the problem.
  • Yeah seriously. I need to jailbreak again since I no longer have a credit card, and for some reason it isn't acceptable (in Canada) for me to specify "None" as my credit card option. It's a huge hassle. Apple is not the same company that it was in the 90's. 

  • I think lobbying Apple to removing the conditions of their TOS that interfere with distribution of GPL-licensed software is also a big waste of time.   

    The question becomes which path can be certain of eventual success, and the answer is rewrite.

    Alternatively, direct your energy towards tools and platforms where you aren't tilting at windmills, and in doing so you indirectly create pressure for Apple to change their policies.
  • Yes, I totally agree switching away from restrictive platforms, is a great idea.  Android hardware manufacturers still have a lot to learn about how to make good media devices tho.  I think lobbying them could be more productive. On that note, Chris McCormick is working on an app to test latency.  Then we can go to mobile phone stores, install and test away, and get a good catalog of the good devices, and shame the bad ones.  I guess we should frame it in terms of games or Smule-like apps, since that's where the money seems to be.
  • Hi all,

    Well, I really want to get expr~ working in iOS. As of right now, I still get the same errors that Internaut Mako was geting over a year ago:

    Undefined symbols for architecture armv7:
    “_finite”, referenced from:
    _ex_finite in libLibPd.a(vexp_fun.o)
    “_drem”, referenced from:
    _ex_drem in libLibPd.a(vexp_fun.o)
    ld: symbol(s) not found for architecture armv7

    I'm a C noob, so implementing the solution suggested by Richard Lawler is not trivial for me. 

    Not unexpectedly, I've found some information that complicates things:

    http://stackoverflow.com/questions/617554/override-a-function-call-in-c

    and 

    http://www.cs.umd.edu/Library/TRs/CS-TR-4585/CS-TR-4585.pdf

    Seems like the platform and compiler in use make a big difference in how to approach this.

    Can anyone provide any guidance? As it now appears that we can use expr~ on iOS because its license has changed, it would be very useful to actually be able to use it without major headaches! 

    Apologies if this is indeed trivial - I just don't know how to do it and it doesn't Google well!

    Thanks...
  • For anyone seeking to do this in the future, it turns out to be shockingly easy (when you know how!). The following is for usage in xCode only. I can only verify that it worked for me... Again, it's been years since I've written any C.

    - Define a .h and .c file in the same xcode group as your main app source files.
    - While you'll find much info about the need to link files using compiler args in C, XCode seems to do this for you automatically.
    - .c file looks like this:



    //
    //  ExprOverrides.c
    //

    #import "ExprOverrides.h"

    #include <stdio.h>
    #include <math.h>
    #include "TargetConditionals.h" //Allows compiler target conditionals to work, see http://bit.ly/tWarEW

    #if !(TARGET_IPHONE_SIMULATOR)
    int finite(double x){ return isfinite( x);}
    double drem (double x, double y){return remainder(x, y);}
    #endif


  • Hey shmimpie I just tried all of the things you've said and I got it to run on my device... But the sound is still not working... I am receiving messages from pd and the pdpatch opens but no sound on the device. I also checked the 'other c flags', making sure the Build Active Architecture Only was set to yes. Anything else I should try?