-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Receive OSC messages inside lua script #12
Comments
Hi Aris. I can't tell you exactly what is wrong without more code. I suspect it's because your amp() function is a member function and you're not calling the correct instance of your myApp in the lua code so it's returning 0 (null). On Tue, Feb 4, 2014 at 3:02 PM, Aris Bezas notifications@github.com
|
Hi Stewart, my amp() function is part of ofApp class and the wrapper is the following
and the lua script:
Thanks in advance for your help |
You're creating a new instance in Lua as it's calling the constructor of.app(). It dosent refer to the existjf object in c++ but to a new, empty one, which is whynit dosent work. You need a global function binding which returns the already existing app pointer to lua. |
aka you need something like:
Then simply change this:
to this
|
First of all thanks for your reply!
but when I am trying to create the binding:
I am taking an error
deep waters for me... |
Long answer: You need to read up on how C++ compiles source files. Header files (.h) are used to tell the compiler about what classes and functions exist and the .cpp files are where those functions are implemented. Whenever you want to use one of those functions, the compiler needs to know about it which is why at the top of many source files you will see Short answer: You need to put the getApp() function in a place where the compiler can find it in the bindings files. The error is telling you that it doesn't know what "getApp", mainly because it is only written in the ofApp.cpp file. The simplest answer is to put this function in your bindings file, aka at the top of the file where you have the lua bindings (I was trying to imply this in my last answer). |
You have right, I confused with the place that the pointer must be defined. Now my lua bindings file is like that:
And I have to compile errors, but when I run the script:
I taking a console message:
Please help me to close this issue. |
You're almost there, but you didn't update the bindings to reflect how the new function needs to work. "getApp" should be a global function and not a member of your "app" class aka you should be able to use it without having to make a new "app" instance since what we want is to get a reference to the existing "app". Your bindings should look like this:
Then you can use them like:
Make sense? Also, it's very important to note the colon : with app:getAmp(). The colon is used when calling a member function on a class instance while the period . is used when accessing a property (app.amp) or calling a global function in a module (gea.getApp(), where "gea" is the module name). Coming from C++, that still trips me up now and then :D As this is more of a general question about using Luabind with ofxLua and not a problem with the ofxLua source code, in the future can you ask us on the OF forums? Just make sure to include my twitter handle @danomatika in the post so I'll get the notification. |
I didn't manage to receive the amplitude that SuperCollider detecting in my sketch. I' ve create a post in OF forum from scratch. I hope to see you there! |
Good evening,
I am trying to receive arguments from OSC messages inside lua script, for live coding use. I extend wrapper and is working very well, but something strange happen.
Here is a float function that I want to return the amplitude which I receive from an OSC msg.
It's returning a 0 while amplitude is changing.
If I substitute amplitude with ofGetFrameNum() is working fine!
Any help?
Thanks in advance
The text was updated successfully, but these errors were encountered: