electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
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
[SOLVED] Advancing time and with sporked shreds.
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [6 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
agkbill



Joined: Feb 15, 2007
Posts: 11
Location: Uppsala Sweden

PostPosted: Sun Dec 19, 2010 1:29 pm    Post subject: [SOLVED] Advancing time and with sporked shreds. Reply with quote  Mark this post and the followings unread

I have a code that look like this:

Code:
fun void flash()
{
    while( true )
    {
      1 => f_led;
      for( 0 => int i; i < 3; i++ )
   {
     for( 0 => int j; j < 3; j++ )
     {
       if( p_led_flash[i][j] == 1 )
       {
         xmit.startMsg("/sleep/led", "iii");
         i => xmit.addInt;
         j => xmit.addInt;
         f_led => xmit.addInt;
       }      
     }
   }
   1000::ms => now;
   


   0 => f_led;
   for( 0 => int i; i < 3; i++ )
   {
     for( 0 => int j; j < 3; j++ )
     {
       if( p_led_flash[i][j] == 1 )
       {
         xmit.startMsg("/sleep/led", "iii");
         i => xmit.addInt;
         j => xmit.addInt;
         f_led => xmit.addInt;
       }      
     }
   }
   1000::ms => now;

      <<<"¤¤¤¤">>>;
      <<<"x-flash" , x>>>;
      <<<"y-flash" , y>>>;
      <<<"f_led-flash" , f_led>>>;
    }
   
}


spork~ flash();


[ [0, 0, 0], [0, 2, 0], [0, 0, 0] ] @=> int p_led_s[][];



while( true )
{
   
  //zero matrix
  for( 0 => int i; i < 3; i++ )
  {
    for( 0 => int j; j < 3; j++ )
    {
      0 => p_led_flash[i][j];
      0 => p_led_on[i][j];
      0 => p_led_off[i][j];
    }
   }
     
  for( 0 => int i; i < 3; i++ )
  {
    for( 0 => int j; j < 3; j++ )
    {
      if( p_led_s[i][j] == 2 )
      {
   // add into flash led matrix
   1 => p_led_flash[i][j];
      }
      if( p_led_s[i][j] ==  1)
   {
   // add into normal led matrix
   1 => p_led_on[i][j];
      }
      if( p_led_s[i][j] == 0 )   
      {
   1 => p_led_off[i][j];
      }
    }
  }
c
<<<" ------------------------------------------------- NEXT ---------------">>>;
}




But what causing me problem is the time deley I put in, for example
Code:
2000::ms => now;
and
Code:
1000::ms => now;


It is when I have it in both places, main code and the sporked part. If I delete from one of the places the code run but with it in both places everything halts.

I guess I missed something in how => now; is working.

I need the time delay in the sporked part because I making a led to flash in that way.
I also need it in main part to control progress there.

Any ide on how to deal with this?

All input most appreciated.


Best regards,
/Christer

Last edited by agkbill on Mon Dec 20, 2010 1:18 pm; edited 1 time in total
Back to top
View user's profile Send private message
vrachnasormora



Joined: Mar 22, 2007
Posts: 42
Location: Preveza,Greece

PostPosted: Sun Dec 19, 2010 5:52 pm    Post subject: Reply with quote  Mark this post and the followings unread

Hi Christer,
your code works fine for me.I can't find anything weird into it.I tried to reconstruct your code with the missing variables and added the "2000::ms => now" part at the end of the main loop ( I guess you replaced it with the "c" character in the code you posted ) and it just runs.This is it:

Code:
int f_led;
[ [ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ] ] @=> int p_led_flash[][];
[ [ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ] ] @=> int p_led_on[][];
[ [ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ] ] @=> int p_led_off[][];

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

fun void flash()
{
    while( true )
    {
        1 => f_led;
        for( 0 => int i; i < 3; i++ )
        {
            for( 0 => int j; j < 3; j++ )
            {
                if( p_led_flash[i][j] == 1 )
                {
                    xmit.startMsg("/sleep/led", "iii");
                    i => xmit.addInt;
                    j => xmit.addInt;
                    f_led => xmit.addInt;
                }      
            }
        }
        1000::ms => now;
       
       
       
        0 => f_led;
        for( 0 => int i; i < 3; i++ )
        {
            for( 0 => int j; j < 3; j++ )
            {
                if( p_led_flash[i][j] == 1 )
                {
                    xmit.startMsg("/sleep/led", "iii");
                    i => xmit.addInt;
                    j => xmit.addInt;
                    f_led => xmit.addInt;
                }      
            }
        }
        1000::ms => now;
       
        //<<<"¤¤¤¤">>>;
        //<<<"x-flash" , x>>>;
        //<<<"y-flash" , y>>>;
        //<<<"f_led-flash" , f_led>>>;
    }
   
}


spork~ flash();


[ [0, 0, 0], [0, 2, 0], [0, 0, 0] ] @=> int p_led_s[][];



while( true )
{
   
    //zero matrix
    for( 0 => int i; i < 3; i++ )
    {
        for( 0 => int j; j < 3; j++ )
        {
            0 => p_led_flash[i][j];
            0 => p_led_on[i][j];
            0 => p_led_off[i][j];
        }
    }
   
    for( 0 => int i; i < 3; i++ )
    {
        for( 0 => int j; j < 3; j++ )
        {
            if( p_led_s[i][j] == 2 )
            {
                // add into flash led matrix
                1 => p_led_flash[i][j];
            }
            if( p_led_s[i][j] ==  1)
            {
                // add into normal led matrix
                1 => p_led_on[i][j];
            }
            if( p_led_s[i][j] == 0 )   
            {
                1 => p_led_off[i][j];
            }
        }
    }
    2000::ms => now;
    <<<" ------------------------------------------------- NEXT ---------------">>>;
}


Maybe you should search elsewhere for the source of your problem.
Hope it helps

Cheers,
Andreas
Back to top
View user's profile Send private message
agkbill



Joined: Feb 15, 2007
Posts: 11
Location: Uppsala Sweden

PostPosted: Mon Dec 20, 2010 5:53 am    Post subject: Reply with quote  Mark this post and the followings unread

Thank you vrachnasormora,


Ok, the problem is not that I have several
Code:
2000::ms => now;
instructions in both main code and spork~ processes.

I am glad to sort that out. Now I just have to keep on looking for what cause the unwanted behavior.

All the best!
/Christer
Back to top
View user's profile Send private message
Antimon



Joined: Jan 18, 2005
Posts: 3371
Location: Sweden
Audio files: 211
G2 patch files: 92

PostPosted: Mon Dec 20, 2010 6:54 am    Post subject: Reply with quote  Mark this post and the followings unread

I don't know if you tested with a monome, vrachnasormora, but anyway I tried your version, and I got the second row second column led flashing on my monome.

I had to change the port to 8080 to match my old default setting in monomeserial, and ChucK doesn't give any error even though you transmit to a port where no one is listening. Have you double-checked that the ports match, Christer?

/Stefan

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



Joined: Mar 22, 2007
Posts: 42
Location: Preveza,Greece

PostPosted: Mon Dec 20, 2010 11:58 am    Post subject: Reply with quote  Mark this post and the followings unread

Quote:
I don't know if you tested with a monome

No, Stefan, I don't have a monome.I just completed the code Christer sent with the variables and their values missing in order to check how it runs.The choice of the port number was random.

Andreas
Back to top
View user's profile Send private message
agkbill



Joined: Feb 15, 2007
Posts: 11
Location: Uppsala Sweden

PostPosted: Mon Dec 20, 2010 1:12 pm    Post subject: Reply with quote  Mark this post and the followings unread

Thanks for the comments,

I have managed to find the problem. It was not in the chucK code but rather in the way monome handle OSC I would believe.

I noticed that when I added the code:
Code:
fun void on()
{
    while( write_out == 1 )
    {
      for( 0 => int i; i < 3; i++ )
      {
   for( 0 => int j; j < 3; j++ )
   {
     if( p_led_on[i][j] == 1 )
     {
         xmit.startMsg("/sleep/led", "iii");
         i => xmit.addInt;
         j => xmit.addInt;
         1 => xmit.addInt;
         <<<"¤¤on¤¤">>>;
      }      
    }
   }
      }
}


spork~ on();


That is the function to layout the layer of no flash led on the monome, it all freeze up.

It seems to be when to much data is sent to the monome, it get to much and it stop to respond.



Code:
fun void on()
{
    while( write_out == 1 )
    {
      for( 0 => int i; i < 3; i++ )
      {
   for( 0 => int j; j < 3; j++ )
   {
     if( p_led_on[i][j] == 1 )
     {
         xmit.startMsg("/sleep/led", "iii");
         i => xmit.addInt;
         j => xmit.addInt;
         1 => xmit.addInt;
         <<<"¤¤on¤¤">>>;
      }      
    }
   }
      step_time => now;
      }
}


spork~ on();


So I put the time for each step in the main loop and put it in a "dur" that I called step_time and then used that one to delay the loop until next step. In that way I only send data each step and not all the time.

it looks like it working.


Thank you for all input!

All the best!

/Christer
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 [6 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
Niio1

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


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