Dear ChuKees, I am particularely interested in the wonderful feature which allows me to calculate EVERY SINGLE AUDIO SAMPLE prior to outputting it to the dac via the impulse ugen. Is there a rough estimation just how much calucaltion can go on between each sample at 44100hz? Does this depend on the cpu type and speed, or is there an inherent ChuK limit? I want to create some amazing sounds by making extremly complicated computations for each sample, as in theory one could just create about any sound in the world this way (including semi-talented clarinet players just having been woken up from a deep alpha-cycle..---)) Thanks and cheers, Karl.
On 01/15/2007 03:17:49 PM, karl.petermichl@orf.at wrote:
(including semi-talented clarinet players just having been woken up from a deep alpha-cycle..---))
please bear in mind that any such function will require a severely large quantity of irrational numbers. .pltk.
Hi list, Today I've noticed something unexpected while using BlitSquare. What happens is that I understand the freq() method as to set the fundamental frequency of the oscillator, however this is not true, and somehow the frequency being set is way below the specified one (subharmonic). The following code may be more explanatory. First, I use BlitSquare to create a band limited square waveform with fundamental frequency = 200 Hz and 4 harmonics. Secondly, I try to reproduce the same sound while using a sum of sinusoids which frequencies are related by 1, 3, 5, 7, etc... (odd harmonics) and their gains are 1, 1/3, 1/5, 1/7 etc. However I must start with a fundamental frequency of 50Hz in order to obtain the same sound as a 200Hz BlitSquare. // using BlitSquare BlitSquare b => gain g=> WvOut audio => dac; audio.wavFilename( "blitSqr.wav" ); 0.9 => g.gain; 4 => int n; // number of harmonics 200. => float fund_freq; b.harmonics( n ); b.freq( fund_freq ); now => time end; 1::second +=> end; while( now < end ) 1::second => now; b =< g; // "hand made" band limited square wave sinosc s[n]; 50 => fund_freq; // note that fund_freq must be set to 50 Hz in order to yield same // results as a 200Hz BlitSquare for( 0=> int i; i < n; i++ ) { s[i].freq( fund_freq*(2*i+1) ); s[i].gain( 1./((2*i+1)) ); s[i] => g; } 0.5 => g.gain; 1::second +=> end; while( now < end ) { 1::second => now; } Am I understanding BlitSquare wrongly? Thanks in advance, eduard
Hi Eduard!
Today I've noticed something unexpected while using BlitSquare. What happens is that I understand the freq() method as to set the fundamental frequency of the oscillator, however this is not true, and somehow the frequency being set is way below the specified one (subharmonic).
Sorry for the delayed reply. Indeed this was a bug in BlitSquare. The fundamental seems to be low by a factor of 4. It has been fixed in STK and we have now applied the same fix to the chuckian STK BlitSquare. Changes are in CVS and will be in 1.2.0.8. Thanks for your email and the careful testing and example! Best, Ge!
On 1/15/07, karl.petermichl@orf.at
Dear ChuKees,
Hi, Karl! I am particularely interested in the wonderful feature which allows me
to calculate EVERY SINGLE AUDIO SAMPLE prior to outputting it to the dac via the impulse ugen. Is there a rough estimation just how much calucaltion can go on between each sample at 44100hz?
Generally somewhere inbetween "a fair amount" and "too much for comfort". It's realy quite expensive to ChucK that way but still very possible. Does this depend
on the cpu type and speed, or is there an inherent ChuK limit?
It's all in the CPU but it also heavily depends on the sample rate set. As far as I know there is no real limit nor should there be. I want to create some amazing sounds by making extremly complicated
computations for each sample, as in theory one could just create about any sound in the world this way (including semi-talented clarinet players just having been woken up from a deep alpha-cycle..---))
I'd like to point out there is a Clarinet model ready made in Chuck already. This particular model, because of it's name, is very well suited for more jokes in dubious taste should one be so inclined. Somewhere about a year ago or so there was a fair amount of talk on the list about using arrays of floats to record to, then chuck the values in them to Impulse or Step once per sample. That might be a interesting place to start, you could do some variations on Karplus-Strong using that. You could also implement anything found in texts on DSP or your own concoctions doing it this way but be prepared to spend a lot of time optimising. Do use Gain in it's various modes for all multiplications at sample-rate; this realy saves a lot of cpu time at the expense of some readablity. In my experience you can create very interesting little instruments that way that will still run in realtime but ti would be pushing it a bit too far to try to do a whole piece that way. That's refering to my own Pentium4 2GHz under a tuned version of XP. Your processor and taste in experiments will likely give different results but I'd save this menthod for things you can't get in any other way or for moments when this method sounds like real fun. Kas.
Somewhere about a year ago or so there was a fair amount of talk on the
Thank you, Kas, for the insights: list about using arrays of floats to record to,
then chuck values in them to Impulse or Step once per sample. That might be a interesting place to start, you could do some variations on Karplus-Strong using that. You could also implement anything found in texts on DSP or your own concoctions doing it this way but be prepared to spend a lot of time optimising. Do use Gain in it's various modes for all multiplications at sample-rate; this realy saves a lot of cpu time at the expense of some readablity.
ok, I will search the archives. However, DSP code fragments is exactely what I thought to do. Some 15 years ago I coded on DSP level, but since than lost track of all those new chip types, developement kits etc... also, compiling and uploading code to a chip (I had to burn EPROMS for every little change in those days) is not as efficient as klicking on "Replace Shred" in the Mini..--))) Question: would it be possible to give rough numbers of processing "costs" for each operation of ChucK? (not right now, but in some later revision of the manual). I remember in those very thick books about the DSP assembler language they always gave some kind of DSP cycles per operation, helping us to optimize code and maybe use 100 "dumb" instructions instead of 1 elegant, but enormousely DSP intensive...
for moments when this method sounds like real fun.
YES! -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.16.10/626 - Release Date: 14.01.2007 20:29
Sorry to flood the list with so many questions, but I have to get ChuK and myself ready for the first date in public together (read: live gig) quite soon. The only funcionality which I am lacking for this first gig is some kind of graphic fader for adjusting variables on the fly. I know it is all about live coding, but I really would like to feed my sound generators with some "fluid floats" (or ints). I got into OSC, and I do understand the sending and receiving OSC examples. I also found the OSC commands within JAVA, and a nice little application called JAVAOSC. Those four faders would be all that I need, I just cannot figure out which OSC codesc JAVAOSC is transmitting to the localhost. I searched for an OSC-Analyser, but the only one I could find exists for MAC and LINUX exclusively, and I am running XP (ok, sorry, way uncool, I know, but I really needed the harddisc space for audio samples, so I had to erase my ReiserFS partition...). So does anyone of you know which codes JAVAOSC is transmitting by default? Are there other simple ways of transmitting OSC commands to ChuK? I tried the software PROCESSING and TAPSTREAM, but in both cases it was obvious to me how to assign OSC commands to faders. Thank you again for your advice, karl. -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.16.10/626 - Release Date: 14.01.2007 20:29
On 1/15/07, karl petermichl
but I have to get ChuK and myself ready for the first date in public together (read: live gig) quite soon. The only funcionality which I am lacking for this first gig is some kind of graphic fader for adjusting variables on the fly. I know it is all about live coding, but I really would like to feed my sound generators with some "fluid floats" (or ints). I got into OSC, and I do understand the sending and receiving OSC examples.
I also found the OSC commands within JAVA, and a nice little application called JAVAOSC. Those four faders would be all that I need, I just cannot figure out which OSC codesc JAVAOSC is transmitting to the localhost. I searched for an OSC-Analyser, but the only one I could find exists for MAC and LINUX exclusively, and I am running XP (ok, sorry, way uncool, I know, but I really needed the harddisc space for audio samples, so I had to erase my ReiserFS partition...).
So does anyone of you know which codes JAVAOSC is transmitting by default? Are there other simple ways of transmitting OSC commands to ChuK? I tried the software PROCESSING and TAPSTREAM, but in both cases it was obvious to me how to assign OSC commands to faders.
I found that with a packet sniffer like Wireshark, you can read the OSC packets and fairly easily read out the ASCII bits. Looking at the source of JavaOSC, I see a lot of: - /s_new int, int, string ("freq"), float - /n_set int, string ("freq"), float - /n_free int So I'd listen for those.
Thank you again for your advice, karl.
Sincerely, Tom Lieber http://AllTom.com/ http://GadgetLife.org/
Hey Karl,
When you do get it all working, I'd love for you to post your solution
to the list. Your setup sounds very similar to the one I'm planning
for my application (Chuck, JavaOSC, etc).
There is a mode in Processing in which you can use pure-Java. In that
mode I don't see why you can't use the JavaOSC classes. Let us know
how you fair.
Cheers,
Mike
On 1/15/07, karl petermichl
Sorry to flood the list with so many questions,
but I have to get ChuK and myself ready for the first date in public together (read: live gig) quite soon. The only funcionality which I am lacking for this first gig is some kind of graphic fader for adjusting variables on the fly. I know it is all about live coding, but I really would like to feed my sound generators with some "fluid floats" (or ints). I got into OSC, and I do understand the sending and receiving OSC examples.
I also found the OSC commands within JAVA, and a nice little application called JAVAOSC. Those four faders would be all that I need, I just cannot figure out which OSC codesc JAVAOSC is transmitting to the localhost. I searched for an OSC-Analyser, but the only one I could find exists for MAC and LINUX exclusively, and I am running XP (ok, sorry, way uncool, I know, but I really needed the harddisc space for audio samples, so I had to erase my ReiserFS partition...).
So does anyone of you know which codes JAVAOSC is transmitting by default? Are there other simple ways of transmitting OSC commands to ChuK? I tried the software PROCESSING and TAPSTREAM, but in both cases it was obvious to me how to assign OSC commands to faders.
Thank you again for your advice, karl.
-- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.16.10/626 - Release Date: 14.01.2007 20:29
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- http://clembie.livejournal.com http://shadowofaculture.blogspot.com http://deadlylittlepills.com
hi karl karl petermichl wrote:
* Sorry to flood the list with so many questions, *
i do it all the time as well ;)
but I have to get ChuK and myself ready for the first date in public together (read: live gig) quite soon. The only funcionality which I am lacking for this first gig is some kind of graphic fader for adjusting variables on the fly. I know it is all about live coding, but I really would like to feed my sound generators with some "fluid floats" (or ints). I got into OSC, and I do understand the sending and receiving OSC examples.
I also found the OSC commands within JAVA, and a nice little application called JAVAOSC. Those four faders would be all that I need, I just cannot figure out which OSC codesc JAVAOSC is transmitting to the localhost. I searched for an OSC-Analyser, but the only one I could find exists for MAC and LINUX exclusively, and I am running XP (ok, sorry, way uncool, I know, but I really needed the harddisc space for audio samples, so I had to erase my ReiserFS partition...).
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. To create a GUI with faders you could use few python libraries, being TKinter (GUI toolkit by default included Python) the easiest, others candidates would be FLTK, WXPython, GTK, QT ... this is the tkinter reference for that Range widget (fader) http://infohost.nmt.edu/tcc/help/pubs/tkinter/scale.html This is an example of one fader sending osc to localhost on port 9000 (comments start with #) from Tkinter import * import osc osc.init() # start osc library # this function will be called every time the slider changes value def sendValue(value) : osc.sendMsg('/slider1', [value], "127.0.0.1", 9000) window = Tk() # create window # create slider and bind it to sendValue function h = Scale(window, from_=0, to=200, orient=HORIZONTAL, command=sendValue) h.pack() # put slider in the window mainloop() # enter main loop you can copy this code and paste it into notepad then save it as myslider.py, to run the scripts under windows just doubleclick it. Again if you want a crossplatform GUI that sends automatically OSC you could check something i did just couple of weeks ago. http://ixi-software.net/content/body_backyard_python.html It is called zombi, and it is kind of usable. Very primitive yet. It is done with python and wxpython but it can be used from ChucK so you dont have to do a single line of python if you dont want to. On a different direction there is a java based GUI server called swingOSC, this is done for supercollider but i guess it could be used with chuck as well. good luck enrike
So does anyone of you know which codes JAVAOSC is transmitting by default? Are there other simple ways of transmitting OSC commands to ChuK? I tried the software PROCESSING and TAPSTREAM, but in both cases it was obvious to me how to assign OSC commands to faders.
Thank you again for your advice, karl.
-- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.16.10/626 - Release Date: 14.01.2007 20:29
------------------------------------------------------------------------
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
On 1/16/07, altern
simple as this: import osc osc.init() osc.sendMsg('/blah', [6.9999])
I wish more explanations and manuals would be like your mail here. Looks like some serious fun and very acessible; I think I'm going to have to tinker with this. Thanks a lot! Kas.
Kassen wrote:
On 1/16/07, *altern*
mailto:altern2@gmail.com> 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])
I wish more explanations and manuals would be like your mail here. Looks like some serious fun and very acessible; I think I'm going to have to tinker with this.
Thanks a lot!
pleasure is mine ;)
Is this the corrct list to ask about Audical or the MiniAudical that is used with Chuck? I am having compile problems but I will hold back on the info until I find the proper list... Thanks in advance vince
Howdy Vince, There is a separate audicle list (audicle@lists.cs.princeton.edu) which was created to handle audicle-related issues, so that might be the best place for those questions. With regards to the miniAudicle, it has no dedicated list of its own, but a question to either the chuck-users or audicle list is likely reach the right ears, though in the past questions about it have generally gone to chuck-users. hopefully we can resolve your problem! spencer On Jan 16, 2007, at 4:40 PM, Vince Werber wrote:
Is this the corrct list to ask about Audical or the MiniAudical that is used with Chuck?
I am having compile problems but I will hold back on the info until I find the proper list...
Thanks in advance
vince
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Thanks for the info... I must have missed it during one of my late night web sessions <heh> thanks again vince On Tue, 16 Jan 2007, Spencer Salazar wrote:
Howdy Vince, There is a separate audicle list (audicle@lists.cs.princeton.edu) which was created to handle audicle-related issues, so that might be the best place for those questions. With regards to the miniAudicle, it has no dedicated list of its own, but a question to either the chuck-users or audicle list is likely reach the right ears, though in the past questions about it have generally gone to chuck-users. hopefully we can resolve your problem!
spencer
On Jan 16, 2007, at 4:40 PM, Vince Werber wrote:
Is this the corrct list to ask about Audical or the MiniAudical that is used with Chuck?
I am having compile problems but I will hold back on the info until I find the proper list...
Thanks in advance
vince
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
On 1/16/07, altern
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?
good luck
enrike
Sincerely, Tom Lieber http://AllTom.com/ http://GadgetLife.org/
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
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! 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 -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.16.12/630 - Release Date: 15.01.2007 20:28
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
OK, I just could not wait! Although in a hurry, I had to try out the suggestions from enrike..---)) And Yes, SUCCESS!!! ChucK finally does receive OSC commands!! The only small change I had to make in enrikes code was my initial fault (which he spotted but copied over into his example). The type declaration for the OSC data must read "i" for integer, not "int": recv.event( "/slider1, i" ) @=> OscEvent oe; Proudly presenting (with a lot of help from enrike) my first shred which actually creates sound controlled by a python-fader sending an OSC-command: SinOsc sinus =>dac; OscRecv recv; 9000 => recv.port; recv.listen(); recv.event( "/slider1, i" ) @=> OscEvent oe; while( true ) { oe => now; while( oe.nextMsg() ){ oe.getInt() => int i; <<< "got (via OSC):", i>>>; i*5+50=>sinus.freq; 1::ms=>now; } } This is the python code: from Tkinter import * import osc osc.init() def sendValue(value) : osc.sendMsg('/slider1', [int(value)], "127.0.0.1", 9000) window = Tk() h = Scale(window, from_=0, to=200, orient=HORIZONTAL, command=sendValue) h.pack() mainloop() Thank you enrike, without you this would not have been possible!!! Karl. -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.16.13/632 - Release Date: 16.01.2007 16:36
great ;) no problem. i help you and somebody else helps me somewhere else. enrike karl petermichl wrote:
OK, I just could not wait!
Although in a hurry, I had to try out the suggestions from enrike..---)) And Yes, SUCCESS!!! ChucK finally does receive OSC commands!!
The only small change I had to make in enrikes code was my initial fault (which he spotted but copied over into his example). The type declaration for the OSC data must read "i" for integer, not "int": recv.event( "/slider1, i" ) @=> OscEvent oe;
Proudly presenting (with a lot of help from enrike) my first shred which actually creates sound controlled by a python-fader sending an OSC-command:
SinOsc sinus =>dac; OscRecv recv; 9000 => recv.port; recv.listen(); recv.event( "/slider1, i" ) @=> OscEvent oe; while( true ) { oe => now; while( oe.nextMsg() ){ oe.getInt() => int i; <<< "got (via OSC):", i>>>; i*5+50=>sinus.freq; 1::ms=>now; } }
This is the python code:
from Tkinter import * import osc osc.init() def sendValue(value) : osc.sendMsg('/slider1', [int(value)], "127.0.0.1", 9000) window = Tk() h = Scale(window, from_=0, to=200, orient=HORIZONTAL, command=sendValue) h.pack() mainloop()
Thank you enrike, without you this would not have been possible!!! Karl.
------------------------------------------------------------------------
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Hi enrike, Thank you SO MUCH for the concrete, to-the-point clarifications! Yes, I do not need strings, i want integers, so I will change the python code. It is good to know that floats are not so easy in python, I will ue your divide-by-workaround in cae I need floats. I will try, test and use all this later tomorrow, I will let you know if it was a success and post some uasble code here. Thank you again, 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: Mittwoch, 17. Januar 2007 10:09 An: ChucK Users Mailing List Betreff: Re: [chuck-users] ChuK control via OSC hi karl! 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 -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.16.13/632 - Release Date: 16.01.2007 16:36
It is good to know that floats are not so easy in python, I will ue your divide-by-workaround in cae I need floats.
ooopps! i checked more properly and it is possible to use floats if you check here http://infohost.nmt.edu/tcc/help/pubs/tkinter/scale.html you will see that there is an argument called resolution. So we can say h = Scale(window, from_=0, to=100, orient=HORIZONTAL, command=sendValue, resolution=0.1) and there we are we get float numbers. Note that still they are strings so you will need to translate them into floats like this osc.sendMsg('/slider1', [float(value)], "127.0.0.1", 9000) there are many other interesting arguments that can be passed as well. enrike
Ok, thanks for the additional information! Now that I mastered the very basics I really hope to "pass other interesting arguments"..--))) -----Ursprüngliche Nachricht----- Von: chuck-users-bounces@lists.cs.princeton.edu [mailto:chuck-users-bounces@lists.cs.princeton.edu] Im Auftrag von altern Gesendet: Mittwoch, 17. Januar 2007 14:32 An: ChucK Users Mailing List Betreff: Re: [chuck-users] ChuK control via OSC
It is good to know that floats are not so easy in python, I will ue your divide-by-workaround in cae I need floats.
ooopps! i checked more properly and it is possible to use floats if you check here http://infohost.nmt.edu/tcc/help/pubs/tkinter/scale.html you will see that there is an argument called resolution. So we can say h = Scale(window, from_=0, to=100, orient=HORIZONTAL, command=sendValue, resolution=0.1) and there we are we get float numbers. Note that still they are strings so you will need to translate them into floats like this osc.sendMsg('/slider1', [float(value)], "127.0.0.1", 9000) there are many other interesting arguments that can be passed as well. 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.13/632 - Release Date: 16.01.2007 16:36 -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.16.13/632 - Release Date: 16.01.2007 16:36
On 1/16/07, altern
Tom Lieber wrote:
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.
Thanks, I had an osc.py in the same directory!
let me know if you get it working
enrike
Sincerely, Tom Lieber http://AllTom.com/ http://GadgetLife.org/
participants (11)
-
altern
-
eduard
-
Ge Wang
-
karl petermichl
-
karl.petermichl@orf.at
-
Kassen
-
mike clemow
-
plutek
-
Spencer Salazar
-
Tom Lieber
-
Vince Werber