electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » ChucK programming language
OSC string to array
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [4 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
sanch



Joined: Mar 23, 2008
Posts: 3
Location: somewhere

PostPosted: Sun Mar 23, 2008 11:23 am    Post subject: OSC string to array
Subject description: how to
Reply with quote  Mark this post and the followings unread

Hi it seams that there is much people here who know about chuck so maybe some of you can help me .
I´m currently using vvvv (vvvv.org) to send data to chuck via osc and it works.
actually i send a string to chuck who is the content of an array :
0,1,0,0,0,1,0,0
chuck (miniaudicle) receive the string and print it

And i would like to just translate it into an array in chuck , i know that there not very much operator and function about string manipulation and on the top of that i´m a newbie .

i would like to use this technique instead of sending 8 different osc message so if anyboday as an answer please tell me.
Back to top
View user's profile Send private message
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Sun Mar 23, 2008 10:03 pm    Post subject: Reply with quote  Mark this post and the followings unread

I still can't think of any way to extract each number from that kind of string and let chuck know each value..

But as I'm looking at the example array you gave: 0,1,0,0,0,1,0,0
If the array contains only 0 or 1, we can translate all the integer into one integer with binary to decimal conversion method:
0x1 + 1x2 + 0x4 + 0x8 + 0x16 + 1x32 + 0x64 + 0x128 .. etc..

Okay.. this is not general, doesn't reply directly to the question,
but if it's exactly the case, I'll choose this way so that I can send only 1 int in string then extract it later in chuck.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Sun Mar 23, 2008 11:28 pm    Post subject: Reply with quote  Mark this post and the followings unread

ChucK lacks string processing and file I/O. For example, I would like to save and reload the state of Guitar Lab and Synth Lab, but ChucK lacks the features. I guess I could fudge it by using SndBuff and packing the numbers into a MATLAB file or something like that, but that's kind of bending over backwards. I suppose the Princeton ChucKists are aware of this and they probably have it on the feature list.

It's another kluge, but you could unpack that string using an external Perl script, or another language like awk or sed. Just use ChucK's string concatenation operator, the plus sign, to put an index value on the front of your string, make a system call to your script passing in the indexed string, and receive that indexed number from the system call. At least I think it would work.
Back to top
View user's profile Send private message Send e-mail
sanch



Joined: Mar 23, 2008
Posts: 3
Location: somewhere

PostPosted: Mon Mar 24, 2008 1:00 pm    Post subject: Reply with quote  Mark this post and the followings unread

thanks for the help but actually i try to find the most direct way to do it so from vvvv i can send any kind of string and feed arrays in chuck.
I´m searching an audio software who could deal with data send from vvvv .
vvvv is a software like max msp but dedicated to graphic , it´s possible to build complex realtime interface and many other things.
My initial project was to build a sequencer , but i can use also array to store data to control many synth at the same time ...

so actually i can send any string from vvvv so the question is what kind of string should i send to be able to grab it in chuck

have try to send
0 1 0 1 0 0 0 1 0
and with the example token.ck i can print each number separatly but it seems to doesn´t work if i try to feed an array instead of the console.
And the fact that i started learning chuck few days ago doesn´t help...

here is "my" code

Code:



fun int[] osc( string adress, string type )
{
"localhost" => string hostName;
// create our OSC receiver
OscRecv recv;
// use port 6449
6394 => recv.port;
// start listening (launch thread)
recv.listen();
// create an address in the receiver, store in new variable
recv.event( adress, type ) @=> OscEvent oe;
// infinite event loop
 while ( true )
 {
    // wait for event to arrive
    oe => now;



    // grab the next message from the queue.
    while ( oe.nextMsg() != 0 )
 
   {
   
   
   
    oe.getString() => string  testt ;
     StringTokenizer tok;
   // set the string
    tok.set( testt );

     // iterate
     
     int Seq[16];
    for( 0 => int i; i <16>Std.atoi => int numb ;
      numb => Seq[i];
     <<< "hello",oe.getString() >>>;
     
     return  Seq ;
   
     }
   
     
   
     }
 
   
   
   
    }
     
   
 }
 
 
 
 
 

while( true )


    {
     
     // do something (debug print)
        <<<osc>>>;
    }
 
   

 
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [4 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use