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.

How do we use readArray() & writeArray()..?

SpiroZSpiroZ Posts: 16
edited November 2012 in Pd Everywhere

The task is to input from the pd patch the array of the sound (written there with either tabwrite~ or tabsend~) in order to process it in Processing using the pdlib for processing, (get an instance of the waveform or continuously update the waveform) So how do i use them because whatever i've tried ended up with some error exception. Any example would be delightful. Thanx


  • SpiroZSpiroZ Posts: 16

    Figured it out! Just an example: processing: PureDataP5Jack pd = new PureDataP5Jack(this, 1,2, "system", "system"); int pdBlockSize = 64; // unless you change it in the pd patch.. float[] myArray = new float[pdBlockSize];

    pd.readArray(myArray, 0, "pd_array", 0, pdBlockSize); // pd_array is the one hosting the for (int i =0; i< pdBlockSize-1; i++) // block with the waveform line ( i, myArray[i], i+1, myarray[i+1] );

    pureData: [osc~] | [*~ 0.5] | [tabsend~ pd_array] // pd_array --> put > array > name:pd_array / size:64

  • SpiroZSpiroZ Posts: 16

    The question is how to do this with multiple oscillators?

    the processing draws error: "not enough ports to autoconnect to" and it counts till 3 output ports.. How to set extra ports?

  • pbrinkmannpbrinkmann Posts: 685 ✭✭

    Sounds like you're using an old version of the puredatap5. Please pull the latest version from GitHub and see how it works for you.

    About your work with arrays, I'm not entirely sure what you're trying to accomplish. A little more context would be good.

  • I have a similar question, so maybe I can guess at what he is looking for. I would like to send an array created in an andrioid app to a patch to modulate a sine wave.

    I have been seeking out examples of this for a day or two, with no luck. Essentially, say I have an array of float n[] with length 100, what does the write array method look like on the java end, and what does the receiver look like on the Pd end. (Assume I've got everything else together and have been able to build a functional app using your book, pbrinkmann (digirattle on play, if you are curious). And this would be for the next project) Thanks for writing the book by the way. Very clear for me with no prior Pd experience, reasonable Java skills and just beginning on Android. Maybe I should go write something like that on Amazon?

  • pbrinkmannpbrinkmann Posts: 685 ✭✭

    Yes, a review on Amazon would be much appreciated!

    Each array in Pd has a name. That's what you use to specify an array in your patch, and you use the same name when you're accessing the array with libpd. The array access methods of libpd copy samples back and forth between arrays in Pd and arrays in your code. They read or write slices of arrays at a time; a slice is defined by its offset (relative to the beginning of the array) and length.

    In the simplest case, the array in Pd and the array in your code are the same size and you read or write all of it. In that case, the offsets are zero and the number of samples is the size of the array. Does this make sense?

  • Much simpler than I was thinking. I was thinking you needed some kind of special indicator to make it writable. I have to admit, I skimmed a bit to get to example code. Guess I just need to reread the bit in the floss manuals about modulation and get to tinkering. I'm going back and forth between your book and a gaming in android book at the moment... though I keep coming back to audio-visual. Off to Amazon!

Sign In or Register to comment.