Access files in data folder / Pure Data

Hi,

I'm still trying to run Pure Data and Processing in Android Mode. I was able to make it work in Eclipse following instructions I found elsewhere, but it would be much easier to make it work in Processing alone. When I import org.puredata.processing.PureData it runs fine in Java Mode but it always crashes in Android Mode. (Application stopped working or something like that - my phone is in czech language) I almost gave up but then I found out that the problem was a lot more simple: Pure Data, while in Android Mode, couldn't find the .pd file that was in Data folder.

I found a nice workaround using http://pif.github.io/android-select-file/ from p1ffio. (Thank you! Very handy for so many things.) First, I had to put my .pd file on my sdcard and then it was ok to load Pure Data patch file.

It's not the best solution in this case because when I want to send my app to my friend he would have to copy the .pd file to his sdcard and so on. Is there any way how to access the file in Data folder? What's going on with folder structure when the apk is installed?

Here's just a snippet:

    import org.puredata.processing.PureData;
    PureData pd;

    void setup() {
    pd = new PureData(this, 44100, 0, 2);
    pd.openPatch("test.pd"); //<<<--- I can't reach this file anywhere in Android Mode, it works ok in Java
    pd.start();
    }

Thanks, Martin.

Comments

  • @ daremes::

    not tested!!! but have you tried, working with eclipse + processing to create a "raw" folder with the .pd inside it ??? something like this::

            try {
                                InputStream fileStream = getResources().openRawResource(
                                        R.raw.testpd);
                                int fileLen = fileStream.available();
                                byte[] fileBuffer = new byte[fileLen];
                                fileStream.read(fileBuffer);
                                fileStream.close();
        pd.OpenPatch("test.pd");
               } catch (IOException e) {
    
                    }
    
  • @akenaton: thanks, in eclipse, .pd file is in Raw folder..but i can't make it work using processing in android mode.

    i'm still trying....

  • @daremes== probably "yes" but have you thought to add read & write access for the manifest?

  • edited February 2015

    @akenaton: i set sketch permissions, it doesn't seem to be the problem. :( do you think that processing creates standard file structure during compiling (building?) process - for example that if it puts images from sketch's /data folder to /assets or /res and then it makes .apk file...?

  • @daremes===

    i dont know what P5 does when building apk; that s why in order to be sure i use to work with eclipse for android stuff using external resources not "standard", which have to be put eg in the raw folder (which is not present by default even in eclipse). As for your problem is the file found? (try to put some println or System.out.println when the file is supposed to be read) - Another question: are you sure that the pd library you use is ok for android??? - I know that there are another special libs for pd & android eclipse but i have never tried them. And, last question, what OS are you using? - if osx, i think that the latest version of your lib does not work less than 10.8...

Sign In or Register to comment.