[PD] Pduino sysex vs. OSC advice

Rick Snow ricksnow at gmail.com
Fri Jun 17 18:07:39 CEST 2016


Thank you for spending so much time looking at this!  Being new to this
side of arduino I am learning a great deal.

I'm testing your ...._korr2.ino sketch.  Viewing the serial monitor shows
me the expected input from the faders in the pd patch.  However, I get no
response from the led strip.  I commented out your original Serial.println
(fad[0]); here:

 char pattern[] = "/fad/0"; // "/fad/N" is better OSC style than "/fadN"

    for (int i = 0; i < 9; ++i){
      // change the number in the address to the current index.
      // if you want it to work with numbers that have more than a single
digit you have to adapt the code
      pattern[5] = i + '0';
      if (msg.fullMatch(pattern, 0)){
        // then check if first item is an integer
        if (msg.isInt(0)){
          // use the integer argument for controlling the led 0
          fad[0] = (msg.getInt(0));
        }
        //Serial.println (fad[0]);
        break; // jump out of for-loop
      }
    }

Then tried to print from within:

{
  if (fad[2] >= 1){
    for (int i = 0; i < 30; i += 2){
      leds[i] = CHSV( fad[1], fad[0], fad[2]);
    }
    Serial.println (fad[1]);
    Serial.println (fad[2]);
  }

in order to test whether the values are passing to this point in the code.
Nothing prints to the serial monitor when sending values from pd in this
configuration.  I don't know exactly how to test whether the sketch is
passing the values to the strip.  Any ideas?

I will work on adapting/testing some of the other sketches now as well.

Thanks again!
Rick





On Thu, Jun 16, 2016 at 7:01 PM, Christof Ressi <christof.ressi at gmx.at>
wrote:

> Arghhh, please ignore my last arduino sketches. I had too little sleep and
> I got confused by all the braces (was too lazy to copy the code into a
> decent editor).
>
> You actually did your matching inside the right while loop
> ("while(SLIPSerial.available())"). But writing to the LEDs should happen
> outside because there's no need to update the LEDs for every OSC message.
> Better do it after all messages have been read. Attached is a 'corrected'
> and optimized version. Again, not tested.
>
> Are you sending all faders simultanously all the time? In that case it
> makes more sense to send a single OSC message, containing all the fader
> values as a list. Then you can dispatch every value via its index with
> getInt(INDEX)
>
>
> Gesendet: Freitag, 17. Juni 2016 um 01:28 Uhr
> Von: "Christof Ressi" <christof.ressi at gmx.at>
> An: Pd-List <pd-list at lists.iem.at>, "Rick Snow" <ricksnow at gmail.com>
> Betreff: Re: [PD] Pduino sysex vs. OSC advice
>
> Hi, I think there was a problem in your arduino code:
>
> you did the testing against the address outside the while loop, so you
> will only have access to the latest message. The point of the while loop is
> that it will keep reading new OSC messages till the buffer is empty. So do
> your matching *inside* the while loop, right after a new message has been
> filled. Also, since your if clauses are mutually exclusive, you should do
> 'else if', so it will stop testing once you got 'true'. I attached a
> corrected version. You can try it and see if it works now. Unfortunately I
> couldn't test it myself.
>
> I also did an optimized version, where I made an array fad[0] which gives
> you more flexibility and lets you do the matching with a simple for loop
> instead of chained if clauses. Again, not tested.
>
> For this kind of application, you probably wouldn't need OSC. The question
> how to handle the bitshifting in a MIDI style protocol has already been
> answered in this thread ;-)
> https://lists.puredata.info/pipermail/pd-list/2016-06/115160.html
>
> Chris
> ​tof​
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20160617/cfc4723a/attachment.html>


More information about the Pd-list mailing list