To register and login, use your Google, Twitter, Facebook, LinkedIn, or OpenID credentials.

This is allowing us to stop most spam registrations. We've deleted most of the spam accounts that got through, and we're closely watching for more.

Using externals with libpd

KinKaossKinKaoss Posts: 1
edited November 2012 in Pd Everywhere

Hello,

i want to use freeverb~ with libpd on android. I read the Chapter "Building Externals for Android" in the Book Making Musical Apps and the related links. I tried to compile the freeverb~.c with the Makefile next to under Mac OSX. Here is the command: make NDK_BASE=/path/to/android-ndk-r5 UNAME=ANDROID CFLAGS=-I./ Result: "ld: symbol(s) not found for architecture x86_64" I searched for any switch to set the architecture but didn't find anything. Any ideas?

But anyway i have some problems to understand the whole process. What is the outcome of the makefile? And how does libpd know that i can use the freeverb~ patch from now? Hope, someone enlightened me.

Greetings, KK

Answers

  • pbrinkmannpbrinkmann Posts: 686 ✭✭

    Good news: Building and deploying externals for Android will become much easier once the new OpenSL components are official.

    Bad news: The OpenSL components are not entirely done yet, but I'm hoping to make some progress over the long weekend. Stay tuned!

  • NitroooNitrooo Posts: 21
    edited January 2013

    I'd like to use freeverb~ and other externals with libpd on Android. News about that? I'm totally noob with NDK, JNI... so, I don't know where to start... I've downloaded and installed the NDK, what next? What are the general steps to make an external work with libpd on Android?

  • pbrinkmannpbrinkmann Posts: 686 ✭✭

    Check out the end of this thread for pointers on libpd and Pd extended: http://createdigitalnoise.com/discussion/1341/can-i-use-pd-extended-with-libpd/p1

    Also, you can look at the ScenePlayer sample app in pd-for-android. That one includes some custom externals, along with makefiles that show how to build them.

  • pbrinkmannpbrinkmann Posts: 686 ✭✭

    Oh, and by the way, the OpenSL components of libpd have been official for a few weeks now, so the new, improved way of deploying externals is now in the master branch.

  • NitroooNitrooo Posts: 21
    edited January 2013

    Ok, something weird is going on here.

    I downloaded the freeverb~ 1.2 source and I successfully compiled it with NDK using a modified version of the makefile from ScenePlayer. I moved libfreeverb_tilde.so from the armeabi dir to a dir on my device, and added the proper PdBase.addToSearchPath call to my code. The problem I'm facing is that, while the object seems to be correctly loaded from libpd, since on LogCat I can see pd saying "freeverb~ v1.2", it doesn't seem to work as it should. The input passing through the object looks to be just slightly amplified, but there's no reverb at all.

    This is the patch I'm using, which is working fine on my computer: http://pastebin.com/JZS3eMAM

    Any idea of what could it be?

  • pbrinkmannpbrinkmann Posts: 686 ✭✭

    When you say you moved the binary to a directory on your device, do you mean a directory on the SD card? That won't work because the SD card is mounted with noexec. Also, it's easier if you just leave the binary in the directory where the NDK put it. If you use PdService, it'll automatically set the search path. If you aren't using PdService, you can look at the code of PdService to see how to set the search path.

  • NitroooNitrooo Posts: 21
    edited January 2013

    I refactored my project, so that it follow the structure of the ScenePlayer project. I've noticed that the appropriate libfreeverb_tilde.so file is automatically copied in /data/data/package.name/lib along with the other externals from libpd, at installation time. I'm also importing the externals just like in the PdService class. I don't know if it's related to this refactoring (I don't think so), but now it seems to work..... sometimes! Freeverb~ seems to be always loaded correctly because pd always prints the freeverb~ name and version and even when it doesn't reverberate the input, "something" is working in sense that data passes through the freeverb~ object. Still, sometimes it just amplifies the sound by some factor and at other times it works as expected, producing the reverberated input. One thing I noticed is that generally the first time after uninstalling and reinstalling the app (by launching it from the Run button in Eclipse) tend not to work. Just closing the app and relaunching it from Eclipse generates a correct output. It seems something related to timings or first-time initializations. My code is single-threaded, so there are no race conditions, at first sight. This is puzzling me... any clue?

  • NitroooNitrooo Posts: 21

    Turned out to be my fault. I was calling the libpd setup methods in a wrong order. Now everything is working fine. :)>-

  • pbrinkmannpbrinkmann Posts: 686 ✭✭
    edited January 2013

    Glad to hear it's working. And yes, the fact that appropriate external binaries are now copied to /data/data/package.name/lib at install time is one of the great advantages of the new version of libpd.

  • kapsykapsy Posts: 30

    Apologies if this is a completely stupid question, but when using externals with the new version of libpd, you still need to install the NDK, right?

  • kapsykapsy Posts: 30

    To clarify the above - when compiling externals using an Android.mk file...

  • kapsykapsy Posts: 30

    Ok, I've followed almost the exact same steps as Nitrooo - and I'm getting a very similar problem... freeverb registering but not working, and then working when the app is run for a second time after install. Nitrooo, could you how you fixed the problem with regards to libpd setup?

    Here is the code of my project if anyone would have a look I would greatly appreciate it.

    https://github.com/Kapsy/FreeVerbTest1

    I got your book Peter in hopes of a solution, but now externals are handled differently I couldn't really figure out what I'm doing wrong... but so far looks like there's alot of useful info in there - thankyou!

  • NitroooNitrooo Posts: 21

    Try moving your .openPatch calls after the .initAudio call.

  • kapsykapsy Posts: 30

    Working! Thanks Nitrooo. I've committed the changes to the above GitHub in case anyone has the same issue and wants to have a look :)

  • jrcjrc Posts: 3

    I am using libpd under Windows, and would like to use an external for which source code does not seem to be available. Would it be possible to dynamically link to the dll, and if so, how?

    Thanks very much.

  • EgilSandfeldEgilSandfeld Posts: 4
    jrc I'm not sure that's possible. Did a bit of a search but could not really find an answer to that, meaning it's probably not doable.

    ___

    If I would like to add the OGG Vorbis oggread~ to my android app, I would have to add that external and build with NDK right?

    I made it this far: In the cmd window when running ndk-build it gives me an error with the ogg header file called "os_types.h". The main error is "fatal error: ogg/config.types.h: No such file or directory. Compilation terminated. .... Error 1".

    In my [AndroidAppFolder]\jni\ogg I have a "config_types.h.in" but no .h only. I got Makefile.am, Makefile.in, ogg.h and the os_types.h there as well. How would I make this config_types.h file?

    Alternately can I use Ogg/Vorbis with Android + PD + LibPd without having to import all these Ogg includes, since Android already works with Ogg vorbis?
  • EgilSandfeldEgilSandfeld Posts: 4
    If I outcomment the need for "ogg/config_types.h" which I don't have, then it gives me other errors (probably because there's important stuff in the header file):


    [armeabi] Compile thumb : oggread_tilde <= oggread~.c
    In file included from jni/vorbis/codec.h:26:0,
    from jni/oggread~.c:30:
    jni/ogg/ogg.h:61:3: error: unknown type name 'ogg_int64_t'
    jni/ogg/ogg.h:78:3: error: unknown type name 'ogg_int64_t'
    jni/ogg/ogg.h:83:3: error: unknown type name 'ogg_int64_t'
    jni/ogg/ogg.h:96:3: error: unknown type name 'ogg_int64_t'
    jni/ogg/ogg.h:98:3: error: unknown type name 'ogg_int64_t'
    jni/ogg/ogg.h:160:59: error: unknown type name 'ogg_int64_t'
    jni/ogg/ogg.h:198:1: error: unknown type name 'ogg_int64_t'
    In file included from jni/oggread~.c:30:0:
    jni/vorbis/codec.h:77:3: error: unknown type name 'ogg_int64_t'
    jni/vorbis/codec.h:78:3: error: unknown type name 'ogg_int64_t'
    jni/vorbis/codec.h:80:3: error: unknown type name 'ogg_int64_t'
    jni/vorbis/codec.h:81:3: error: unknown type name 'ogg_int64_t'
    jni/vorbis/codec.h:82:3: error: unknown type name 'ogg_int64_t'
    jni/vorbis/codec.h:83:3: error: unknown type name 'ogg_int64_t'
    jni/vorbis/codec.h:100:3: error: unknown type name 'ogg_int64_t'
    jni/vorbis/codec.h:101:3: error: unknown type name 'ogg_int64_t'
    jni/vorbis/codec.h:180:37: error: unknown type name 'ogg_int64_t'
    In file included from jni/oggread~.c:31:0:
    jni/vorbis/vorbisfile.h:41:43: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:53:42: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:77:20: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:77:49: error: expected '}' before '_ov_header_f
    '
    jni/vorbis/vorbisfile.h:84:20: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:84:49: error: expected '}' before '_ov_header_f
    '
    jni/vorbis/vorbisfile.h:91:20: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:91:49: error: expected '}' before '(' token
    jni/vorbis/vorbisfile.h:98:20: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:98:49: error: expected '}' before '(' token
    jni/vorbis/vorbisfile.h:114:3: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:115:3: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:121:3: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:122:3: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:124:3: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:131:3: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:166:1: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:167:1: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:170:43: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:171:43: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:172:48: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:176:47: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:177:47: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:178:52: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:182:1: error: unknown type name 'ogg_int64_t'
    jni/vorbis/vorbisfile.h:183:1: error: unknown type name 'ogg_int64_t'
    make.exe: *** [obj/local/armeabi/objs/oggread_tilde/oggread~.o] Error 1
Sign In or Register to comment.