Tuesday, December 02, 2008
USERLOGIN PASSWORD Remember?
You are here » Learning Center ยป Forums

Openlife Forums

 Openlife Grid Forums
Minimize
 
  Openlife Forums  Scripting  Openlife LSL Ex...  Random Sound Player
Previous Previous
 
Next Next
New Post 8/22/2008 1:01 AM
User is offline Haplo
4 posts
Openlife Newbie


Random Sound Player 
Modified By Haplo  on 8/22/2008 3:32:10 PM)

// simple random sound player by Haplo Voss
// currently the 'while' loop causes region memory to overload
// therefore add that later when this is resolved
// for now this will play straight through. if another looping method
// is known for a 'for type' function that is region-safe at the moment
// please feel free to update this script and post your additions by all means!
// enjoy! Hope it helps someone :)


float tune_timer = 10;
integer tune_sample_count;
integer count = 0;
integer random;

default
{
    state_entry()
    {
        tune_sample_count = (llGetInventoryNumber(INVENTORY_SOUND));
    }
    touch_start (integer num)
    {
        for (count = 0; count < tune_sample_count; count++)
        {
            random = (integer) llFrand (tune_sample_count);
            llPlaySound(llGetInventoryName(INVENTORY_SOUND, random), 1);
            llSleep(tune_timer
); //Will be replaced by sound queueing when implemented...
                                                  //For now just set your clip length time in tune_timer.

        }
    }   
}

 
New Post 8/22/2008 4:04 AM
Online now... Professor Merryman
92 posts
professormerryman.com
Openlife Apprentice




Re: Random Sound Player 

HI Haplo!

Thanks so much for putting the time into this. I think it will really make OL a fantastic place if we can have sounds of the ocean, birds, city, crowds and whatever funky sounds we think of in the background.

 

I dropped your script and a few 10 sec sounds in a prim and clicked on the prim. All of the sounds played at the same time and then quit.

 

Too bad about the looping, that's a crucial part of this. But this is a great start. Thank you again.

 

:)

 

PS: Can I change touch_start to on_rez?


Join me in Petrona region.
Petrona Teaching Center
Learn about teaching in multiple virtual worlds.
Meet us Thursdays at 12:00 PM GMT
 
New Post 8/22/2008 4:20 AM
Online now... Professor Merryman
92 posts
professormerryman.com
Openlife Apprentice




Re: Random Sound Player 
Modified By Professor Merryman  on 8/22/2008 4:22:23 AM)

The first time I tried it I had only uploaded three sounds. It was actually only playing one of the sounds at that time, not all of them at once (kinda stupid to think it would do that anyway). Then I uploaded a total of five clips (<10 sec each). It played three of them. Am I seeing a pattern? But it is pretty much doing what you said. The randomness gets better with the more files you include.

 

I think what you said about hard coding a list would be best and then loop the list. I could split up a 1:20 of a sample in to 12 10 sec clips that wouldn't sound like it's repeating because they would be placed in four or five areas around the region.

 

Your thoughts?

 

Cheers

 

 


Join me in Petrona region.
Petrona Teaching Center
Learn about teaching in multiple virtual worlds.
Meet us Thursdays at 12:00 PM GMT
 
New Post 8/22/2008 3:23 PM
User is offline Haplo
4 posts
Openlife Newbie


Re: Random Sound Player 

well, for only a few sounds I think a manual list would be fine... I am gonig to test this again though - I have this exact script running in a test prim... and the number of sounds in the prim should be the number of "times" it plays a random selection from that pool of sounds.

 

Ok just in case There were any issues I may have missed in pasting the script originally I am updating the first script in a moment from this one.

Take care,

- Hap

 

 

 
New Post 8/25/2008 5:37 AM
Online now... Professor Merryman
92 posts
professormerryman.com
Openlife Apprentice




Re: Random Sound Player 

I may have found a script here http://www.thinkerer.org/LODScriptMod/LODScrSimpleSounder.htm that does the trick. More testing, but so far so good.

 

Thanks Thinkerer Melville! I've even spoken to him in SL. I'll to IM him and thank him. Also ask if I can post the script here.

 


Join me in Petrona region.
Petrona Teaching Center
Learn about teaching in multiple virtual worlds.
Meet us Thursdays at 12:00 PM GMT
 
Previous Previous
 
Next Next
  Openlife Forums  Scripting  Openlife LSL Ex...  Random Sound Player
Privacy Statement | Terms Of UseAll Rights Reserved 2007,2008 3DX - Openlifegrid.com