hi karl! karl petermichl wrote:
Thanks to all who helped so far, I fiddled around for 6 hours now, and I am "almost" giving up..---))) After reading all the different tipps, I tried the following:
1) downloading WireShark to analyse which strings JAVAOSC is transmitting Result: Zero, as after a lot of googling I found out that under WINDOWS, Wireshark can not listen to localhost....-))) So I gave up on JAVAOSC for the moment...
2) following this very interesting project in the Princeton WIKI: JucK (this is just what we need....) http://wiki.cs.princeton.edu/index.php/JucK_Doc Result: Zero, as I could not find the Compilation: javac Juck.java online anywhere
3) finding, installing and trying out the following very interesting links (maybe this helps somebody): http://www.grahamwakefield.net/MAT-F04/233/index.html http://www.auditorium-project.org.uk/documentation/gettingstarted/ http://www2.realizedsound.net:8080/downloads/vst2osc/ http://www.sciss.de/swingOSC/ http://sourceforge.net/projects/meloncillo/ Result: Zero, as none of those wonderful applications gave me any insight into which strings they are transmitting...
4) coming back to PYTHON, installing python_2.5 with TKINTER and SIMPLEOSC: I pasted ALTERN´s basic code in a python script, debugged it with IDLE (right click with mouse-->run module) --> found out that it is important that the folder "osc" is in the path c:\Python2.X\Lib\site-packages (thanks ALTERN!) --> otherwise IDLE reports "module osc not found" Result: Yppieeee!!! as a first success, python was running the simpleosc script and showing me a nice little GUI fader!!!
From the python script I got my first transmitted string name: "/slider1" And I got the transmission port: 9000
5) back to ChucK, reading the EVENT section over and over, comparing with the OSCEVENT example: Result: not really a success. My ChucK shred still cannot read the fader value from SIMPLEOSC. Somehow I feel lost in the relationship between an OSCRECV and an OSCEVENT, and how to read out the OSC.event data... here is my shred (and yes, I DID TURN OFF MY FIREWALL!!!):
OscRecv orec; 9000 => orec.port; int data; orec.listen(); function void get_osc_data() { orec.event("/slider1,int") @=> OscEvent oscdata; while ( true ) { oscdata => now; while( oscdata.nextMsg() != 0 ) {oscdata.getInt()=> data;} } } while (true) { get_osc_data; <<<data>>>; .1::second=>now; }
Result: shred prints out "0" constantly, ignoring me moving the python fader desperately.... Help? PLEASE!
ok, I have been dealing with OSC in ChucK recently and many times when the data doesnt arrive but the code seems ok there is usually a problem with the type of the data. Sometimes you think you are sending an int 1 and actually is a float 1.0 etc... And this is a similar case. I checked your code and it looked ok. So i went back to python and did print type(value) before sending it and python said that value variable is a string. So Tkinter values coming from sliders seem to be strings. Weird, but problem solved, we just need to listen for strings in Chuck. However, you are very unlikely to need a string but rather an int or a float to chuck it into some frequency or amplitude. I dont think it is possible to casting strings into ints or floats in ChucK (correct me if i am wrong!), string support is yet basic but it seems to be coming soon. So you need to cast your value to the right type in python with int(value) or float(value). Something like this: osc.sendMsg('/slider1', [int(value)], "127.0.0.1", 9000) However, on top of all this there was an error on your code, you did recv.event( "/slider1, int" ) @=> OscEvent oe; but the right code would be recv.event( "/slider1, i" ) @=> OscEvent oe; Say you send several values from python like this osc.sendMsg('/slider1', [1, 0.3, 'hello'], "127.0.0.1", 9000) you would listen to it this way recv.event( "/slider1, i f s" ) @=> OscEvent oe; and this is all the chuck code to listen to your slider, i changed a couple of things on top of the i to make it more clear OscRecv recv; 9000 => recv.port; recv.listen(); recv.event( "/slider1, int" ) @=> OscEvent oe; while( true ) { oe => now; while( oe.nextMsg() ){ oe.getInt() => int i; <<< "got (via OSC):", i>>>; 1::ms=>now; } } Note that one problem with the sliders in tkinter (same is true for wxpython not sure about other libraries) is that it is difficult (impossible?) to get them to operate with float numbers, if you want to get 0 to 1 values they stick to binary 0 or 1. I am not sure if this can be configured somehow in python (maybe extending the class) but the simple trick would be to set it to display 0 to 100 and divide the value /100 before sending it or after receiving it. Note that it would still display 0 to 100 on the gui having more than one slider in the interface you are likely to have to spork one shred from each of them to listen for incoming messages . Check the documentation about shreds and if you have problems with this ask in the list. enrike
Exhausted greetings, Karl.
-----Ursprüngliche Nachricht----- Von: chuck-users-bounces@lists.cs.princeton.edu [mailto:chuck-users-bounces@lists.cs.princeton.edu] Im Auftrag von altern Gesendet: Dienstag, 16. Januar 2007 21:41 An: ChucK Users Mailing List Betreff: Re: [chuck-users] ChuK control via OSC
Tom Lieber wrote:
On 1/16/07, altern
wrote: the easiest way to send/receive OSC i know is using python. It gets as simple as this: import osc osc.init() osc.sendMsg('/blah', [6.9999])
For this you need to install python www.python.org and SimpleOSC library for python http://www.ixi-software.net/content/download/simpleosc0.2.3.zip To install simpleosc you can use the setup.py from command line or just uncompress the zip and copy the osc folder into c:\Python2.x\Lib\site-packages check readme.txt file and app.py example for detailes on how to use. When I try
import osc osc.init()
from the Python console in Windows, it works. When I put it in a file then run "python mine.py" it fails with the message that "init" is not defined. What could the difference be?
thats weird, did you put the osc module (the osc folder) in the right place? (c:\Python2.X\Lib\site-packages)
do you trigger "python mine.py" from command line in the windows terminal? and the python console you mean the interactive python shortcut from the python menu? It could be that you have two different versions on python installed but this should not be a problem on windows as far as i remember.
otherwise try doing print dir(osc) in both the python console and the mine.py, just after importing osc module before the osc.init(). The init function should be listed in the dictionary you get printed into the output window.
beware that there is an OSC.py file inside the osc module. you might have copied only the OSC.py file and not the osc folder with all the files included?
another option is that you have another module called osc and there is a naming conflict. Or maybe there is a folder called osc inside the folder where the mine.py is located? try to move the mine.py file somewhere else.
let me know if you get it working
enrike _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.16.12/630 - Release Date: 15.01.2007 20:28