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
limit on number of OSC addresses you can listen to?
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [16 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
bens



Joined: Dec 21, 2013
Posts: 9
Location: Massachusetts

PostPosted: Thu Aug 21, 2014 10:23 am    Post subject: limit on number of OSC addresses you can listen to? Reply with quote  Mark this post and the followings unread

I am working on some ChucK code using an Illucia dtr -- in short, I'm listening to six knobs, four buttons, and four toggle switches using OSC. I know the hardware is good, since I can get input from all 14 inputs using Max/MSP. My simple ChucK program only gets input from the first 12 addresses added, though -- is it possible there's a hard limit in the language?

Here's the code:

Code:
spork ~ inputs("Continuous", [1, 2, 3, 4, 5, 6]);
spork ~ inputs("Digital", [1, 2, 3, 4, 5, 6, 7, 8]);

while ( true ) {
    1::second => now;
}

fun void inputs(string type, int inputs[]) {
    OscIn oin;
    OscMsg msg;
    12001 => oin.port;
    for ( 0 => int i ; i < inputs.cap() ; i++ ) {
        <<< "/dtr/" + type + "/" + inputs[i] + ", f" >>>;
        oin.addAddress("/dtr/" + type + "/" + inputs[i] + ", f");
    }
    float val;
    while (true) {
        oin => now;
        while ( oin.recv(msg) != 0 )
        {
            msg.getFloat(0) => val;
            <<< type, val >>>;
        }
        5::ms => now;
    }
}


When I run the above code, I get data from knobs 1-6 and buttons/switches 1-6, but not switches 7 and 8. If I reverse the order of the sporks, I get data from buttons/switches 1-8 and knobs 1-4, but not knobs 5 and 6.

(By the way, I'm sporking only two instances of the function because I wondered if the problem were too many sporked functions. It would be better to spork a function for each input, so that I can identify which input is the source of a given OSC message.)

I'm fairly confident this doesn't have anything to do with the device; however, I think I'll try to write some test code that doesn't use it at all.
Back to top
View user's profile Send private message
bens



Joined: Dec 21, 2013
Posts: 9
Location: Massachusetts

PostPosted: Fri Aug 22, 2014 6:49 am    Post subject: Reply with quote  Mark this post and the followings unread

OK, here's more information. The following code starts 16 OSC transmitters and 16 receivers. When you run it, you can see that transmitters 0-15 all transmit, but only receivers 0-11 receive.

Code:
for ( 0 => int i ; i < 16 ; i++ ) {
    spork ~ output(i);
    spork ~ input(i);
}

while ( true ) {
    1::second => now;
}

fun void output(int number) {
    12008 => int port;
    "localhost" => string hostname;
    OscOut xmit;
    xmit.dest(hostname, port);
    while (true) {
        Math.random2f(5.5, 8.5) => float wait;
        wait::second => now;
        xmit.start("/tester/what/" + number);
        Math.random2f(0.0, 1.0) => float temp => xmit.add;
        xmit.send();
        <<< "sent", number, temp >>>;
    }
}

fun void input(int number) {
    OscIn oin;
    OscMsg msg;
    12008 => oin.port;
    oin.addAddress("/tester/what/" + number + ", f");
    float val;
    while (true) {
        oin => now;
        while ( oin.recv(msg) != 0 )
        {
            msg.getFloat(0) => val;
            <<< "received", number, val >>>;
        }
        5::ms => now;
    }
}


By the way, should I be posting this to the chuck-users mailing list instead or in addition?
Back to top
View user's profile Send private message
bens



Joined: Dec 21, 2013
Posts: 9
Location: Massachusetts

PostPosted: Fri Aug 22, 2014 7:07 am    Post subject: Reply with quote  Mark this post and the followings unread

Weird. I just ran the code from my second post again, and all listeners were operating. And then again, and the last four weren't. And then again, and all worked. And then again, and the last four didn't work. This is in miniAudicle.

Running "chuck --loop" and then adding this code seems to consistently produce the result of 16 transmitters and only 12 receivers.
Back to top
View user's profile Send private message
Antimon



Joined: Jan 18, 2005
Posts: 4145
Location: Sweden
Audio files: 371
G2 patch files: 100

PostPosted: Fri Aug 22, 2014 9:17 am    Post subject: Reply with quote  Mark this post and the followings unread

I can't really help you with your issue (I don't have any device that sends on so many different OSC addresses), but I'm curious about the OscIn class that you are using. I've always used OscRecv myself, and that's what's used in the examples. Where can I find information about OscIn?

Also, it might (or might not) help to know what OS you are on.

Edit: sorry I quickly realize that all you have to do is write another program that sends, and that you have done just that. Will check it out.

_________________
Antimon's Window
@soundcloud @Flattr home - you can't explain music
Back to top
View user's profile Send private message Visit poster's website
bens



Joined: Dec 21, 2013
Posts: 9
Location: Massachusetts

PostPosted: Fri Aug 22, 2014 9:26 am    Post subject: Reply with quote  Mark this post and the followings unread

Thanks, Antimon. I'm running ChucK 1.3.4.0 and miniAudicle 1.3.2 on Mavericks.

I'd noticed the different names for the OSC objects, too. I took my lead from the examples in the distribution, under File... Open Example... in miniAudicle.
Back to top
View user's profile Send private message
Antimon



Joined: Jan 18, 2005
Posts: 4145
Location: Sweden
Audio files: 371
G2 patch files: 100

PostPosted: Fri Aug 22, 2014 9:30 am    Post subject: Reply with quote  Mark this post and the followings unread

Ok, apparently I hadn't updated my ChucK installation Embarassed I updated and ran you second example and I am getting the faulty result you describe: no receive messages after sending on 11 and above:

Code:
sent 5 0.239300
received 5 0.239300
sent 15 0.954485
sent 4 0.022245
received 4 0.022245
sent 13 0.960307
sent 10 0.606250
received 10 0.606250
sent 6 0.249211
received 6 0.249211
sent 3 0.747775
received 3 0.747775
sent 9 0.320291
received 9 0.320291
sent 12 0.867480
sent 8 0.643842
sent 7 0.233511
received 8 0.643842
received 7 0.233511
sent 11 0.522583
received 11 0.522583
sent 0 0.223917
received 0 0.223917
sent 2 0.163471
received 2 0.163471


I wondered what the 5 ms wait was doing at the end of the receive loop, but removing it didn't help.

_________________
Antimon's Window
@soundcloud @Flattr home - you can't explain music
Back to top
View user's profile Send private message Visit poster's website
Antimon



Joined: Jan 18, 2005
Posts: 4145
Location: Sweden
Audio files: 371
G2 patch files: 100

PostPosted: Fri Aug 22, 2014 9:47 am    Post subject: Reply with quote  Mark this post and the followings unread

I'm thinking that there may be a bug in the new OscIn class. Googling around I found stuff like this:

https://lists.cs.princeton.edu/pipermail/chuck-users/2014-May/007609.html

Spencer Salazar is a guy working with implementing the language I think. If you want, you can report this as a bug to the ChucK mailing list:

https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

Lately the developers have been fairly quick to notice bug reports there, and fix them.

In the meantime, you could try creating new instances of OscIn for each message you want to listen to (i.e. never call .addAddress() more than once for each OscIn instance). Not sure if that will help but it's worth a try.

Alternatively try to use the old OscRev class - luckily the exampes on the web page haven't yet been updated, so you can find them here:

http://chuck.cs.princeton.edu/doc/examples/

(the OSC examples are close to the bottom).

_________________
Antimon's Window
@soundcloud @Flattr home - you can't explain music
Back to top
View user's profile Send private message Visit poster's website
Antimon



Joined: Jan 18, 2005
Posts: 4145
Location: Sweden
Audio files: 371
G2 patch files: 100

PostPosted: Fri Aug 22, 2014 9:49 am    Post subject: Reply with quote  Mark this post and the followings unread

Incidentally, it took me a bit longer than I wanted to respond to this, because I got derailed looking at the Illucia dtr. A very interesting project!
_________________
Antimon's Window
@soundcloud @Flattr home - you can't explain music
Back to top
View user's profile Send private message Visit poster's website
bens



Joined: Dec 21, 2013
Posts: 9
Location: Massachusetts

PostPosted: Fri Aug 22, 2014 10:10 am    Post subject: Reply with quote  Mark this post and the followings unread

Yeah, isn't illucia cool?

Those are all good ideas -- thanks. I was wondering whether this or the mailing list would be the better place to ask -- I'll post over there, too.
Back to top
View user's profile Send private message
jwmatthys



Joined: May 24, 2011
Posts: 7
Location: Cincinnati OH

PostPosted: Fri Aug 22, 2014 11:53 am    Post subject: Reply with quote  Mark this post and the followings unread

I posted a reply on the chuck list, but I'll comment here too. It appears that the limit of 12 is hard-coded into chuck. One of the devs may be willing to raise that number--I can see the value of allowing more than 12 listeners.

Just out of curiousity, have you tried with the older OscRecv methods?
Back to top
View user's profile Send private message
bens



Joined: Dec 21, 2013
Posts: 9
Location: Massachusetts

PostPosted: Fri Aug 22, 2014 11:58 am    Post subject: Reply with quote  Mark this post and the followings unread

Thanks for the response both here and there. I'm going to experiment with OscRecv next -- stay tuned.
Back to top
View user's profile Send private message
bens



Joined: Dec 21, 2013
Posts: 9
Location: Massachusetts

PostPosted: Fri Aug 22, 2014 12:10 pm    Post subject: Reply with quote  Mark this post and the followings unread

The problem does not occur with OscRecv. All 16 listeners work when you replace the input() function with this one:

Code:
fun void input(int number) {
    OscRecv recv;
    12008 => recv.port;
    recv.listen();
    recv.event("/tester/what/" + number + ", f") @=> OscEvent oe;
    float val;
    while (true) {
        oe => now;
        while ( oe.nextMsg() != 0 )
        {
            oe.getFloat() => val;
            <<< "received", number, val >>>;
        }
        5::ms => now;
    }
}
Back to top
View user's profile Send private message
bens



Joined: Dec 21, 2013
Posts: 9
Location: Massachusetts

PostPosted: Fri Aug 22, 2014 1:53 pm    Post subject: Reply with quote  Mark this post and the followings unread

Another approach I just found in Ajay Kapur, Perry Cook, Spencer Salazar & Ge Wang, Programming for Musicians and Digital Artists is

Code:
OscIn oin;
6449 => oin.port;
oin.listenAll();


I haven't tested this yet. (Now I have. It works fine.)
Back to top
View user's profile Send private message
Antimon



Joined: Jan 18, 2005
Posts: 4145
Location: Sweden
Audio files: 371
G2 patch files: 100

PostPosted: Sat Aug 23, 2014 1:44 am    Post subject: Reply with quote  Mark this post and the followings unread

Nice to see that there is progress. Smile
_________________
Antimon's Window
@soundcloud @Flattr home - you can't explain music
Back to top
View user's profile Send private message Visit poster's website
Antimon



Joined: Jan 18, 2005
Posts: 4145
Location: Sweden
Audio files: 371
G2 patch files: 100

PostPosted: Sat Oct 04, 2014 2:40 pm    Post subject: Reply with quote  Mark this post and the followings unread

I became inspired by you bens and got me an illucia of my own! :D Here's my first little test program that just allows you to connect jacks 12-15 to 0-3 (I get uneasy with 1-based indexes) and have them flash the leds. In this solution I could reuse the OscSend and OscRecv objects, meaning I don't open up lots of ports.

It would be interesting to see more of what you're using this fun little gadget for. :)

Code:

OscSend xmit;
xmit.setHost("localhost", 12000);

OscRecv orec;
12001 => orec.port;
orec.listen();

int i;

class ValueEvent extends Event {
   float value;
}

fun void sendToThing(string thing, int index, float state) {
   xmit.startMsg("/dtr/" + thing + "/" + (index+1), "f");
   state => xmit.addFloat;
}

fun void listenOnThing(string thing, int index, ValueEvent@ valueEvent) {
   orec.event("/dtr/" + thing + "/" + (index+1) + ",f") @=> OscEvent jackEvent;
   while (true) {
      jackEvent => now;
      <<< "Hup! ", index>>>;
      while (jackEvent.nextMsg() != 0) {
         jackEvent.getFloat() => valueEvent.value;
         valueEvent.signal();
      }
   }
}

fun void listenOnJack(int index) {
   new ValueEvent @=> ValueEvent @valueEvent;
   spork ~ listenOnThing("InputJack", index, valueEvent);
   while (true) {
      valueEvent => now;
      sendToThing("LED", index, valueEvent.value);
   }
}

for (0 => i; i < 4; i++) {
   spork ~ listenOnJack(i);
}

fun void pulseJack(int index, dur on, dur off) {
   while (true) {
      sendToThing("OutputJack", index, 1.0);
      on => now;
      sendToThing("OutputJack", index, 0.0);
      off => now;
   }
}

spork ~ pulseJack(12, 100::ms, 100::ms);
spork ~ pulseJack(13, 100::ms, 300::ms);
spork ~ pulseJack(14, 200::ms, 200::ms);
spork ~ pulseJack(15, 300::ms, 100::ms);

sendToThing("LED", 0, 1);
sendToThing("LED", 1, 0.8);
sendToThing("LED", 2, 0.4);
sendToThing("LED", 3, 0.2);


while (true) {
   1:: week => now;
}

_________________
Antimon's Window
@soundcloud @Flattr home - you can't explain music
Back to top
View user's profile Send private message Visit poster's website
bens



Joined: Dec 21, 2013
Posts: 9
Location: Massachusetts

PostPosted: Sun Oct 05, 2014 7:50 am    Post subject: Reply with quote  Mark this post and the followings unread

Excellent! Congratulations! And thanks for the code.

I'd show you something new, except this project has taken a backseat to the modular obsession. What I'm planning for the Illucia and ChucK is a sonification of web and possibly other logs. At the moment, I think I'm going to set up the patchbay in Max; ChucK will handle the audio.
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 [16 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