Ofxpd how to read and store values from [ r exampleValue ] in ofxpd

#1

Hi all and thank you for this forum.

I have created something very simple as a test to see how I can get values from my pd patch into my code. A simple [metro] object counts up and stores the values in a [ s exampleValue ] object and then I receive this value from [ r exampleValue ].
In my code I have set a receiver, subscribed “exampleValue” and I am trying to store the values of the [ r exampleValue ] into a variable. Can you please show me how? Im would expect something like
receiveFloat(“exampleValue”, myDeclaredValue); where it just reads the numbers from [ r exampleValue ] and stores them into myDeclaredValue. Thank you.

#2

are you receiving the values at all in openFrameworks?

#3

In theory I should. But I don’t know how to read them and thus store them.

#4

what platform/ IDE are you building for?
Are you using the example project?

#5

xcode 10.1 and yes I’m using the example. Ok I want to explain the problem better. I get only one value of [ r exampleValue ] which is the initial after [loadbang]. As [metro] updates the values in PD and stores them in [s exampleValue] ( 1,2,3,4…etc.), Ofx does not invoke void ofApp::receiveFloat( const std::string& dest, float value); And I need it to invoke this every time a value changes in [r exampleValue].

#6

the [s exampleValue] is just a send, so it doesn’t really store any value. can you provide a screenshot of your PD patch

#7

#8

So I would expect that the void ofApp::receiveFloat( const std::string& dest, float value); would be invoked every time a value increments. But it stops after the first time.

#9

The problem might be that the [metro 20] expects a toggle rather than just the bang it’s getting from loadbang. try it like this:
19

#10

Same problem. I tried adding 2 different bang objects that bang the [float] object and I got the first 3 values on ofx 07

#11

sorry for the picture format above. Anyway, it appears that in order to invoke the void ofApp::receiveFloat( const std::string& dest, float value); I need to keep adding bang objects for as many values I want to receive.

#12

So here I would expect to invoke it 5 times ( counting the loadbang )

#13

25

And indeed it invoked it 5 times. These are the console prints above.

Can I invoke void ofApp::receiveFloat( const std::string& dest, float value); every time a value changes ???

#14

So yeah I want this to be invoked every time a value increments in PD

#15

can you share your ofApp code. seems like it might not be updating

#16

Hi Miles, I just tested it. It doesn’t work. It calls void ofApp::receiveFloat( const std::string& dest, float value) {

cout << "OF: float " << dest << ": " << value << endl;

}

Once at the beginning and never again. It’s very simple what needs to happen. Every time a value is changed in Pure Data… Call the above function and receive the new value. Or call it constantly regardless of what Pure Data is doing.

#17

Ok, there’s a lot of stuff that is unnecessary here that you probably want to remove, you’re using a different patch, so what might be happening is that some of the calls to the old patch are messing things up. I’ve stripped some bits out in the attached files that you can switch out and change to load up your patchslimmed ofxPd iOS Example.zip (4.7 KB)
I haven’t tested this, so you might need to remove a couple of references if it doesn’t compile

#18

Hi Miles, I just tested it. It doesn’t work. It calls void ofApp::receiveFloat( const std::string& dest, float value) {

cout << "OF: float " << dest << ": " << value << endl;

}

Once at the beginning and never again. It’s very simple what needs to happen. Every time a value is changed in Pure Data… Call the above function and receive the new value. Or call it constantly regardless of what Pure Data is doing. I think it receives float only when the patch is initialised and that’s it. Never again.

#19

One thing to make sure about is that you have “Legacy Build System” is set in File>Project Settings (it can cause issues where updates in the code dont get represented in the build

Slimmed PD.zip (51.7 KB)
)
I’ve attached src and pd that works my side, let me know if that works

#20

Hi Miles,

Yes I have Legacy Build System. I am literally copying your code and pasting. But I can’t get Receive Float to update.
I have removed any #import <AVFoundation/AVFoundation.h> and include “ofxiOS.h”

#include “ofxiOSExtras.h” but it shouldn’t make a difference. It builds. It runs. Not updating the function. Can you send me a picture of your console ? Does it print values until you press stop ?

Thank you Miles.