Jump to content

Is there anyway to improve startup speed of this script it takes 5 s which are more like mins


VirtualKitten
 Share

You are about to reply to a thread that has been inactive for 1538 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I have been fiddling with this script is there anyway to speed its initial start up please .Its takes a good amount of time to que up the sound files  ?

SoundOne()
{
    //llOwnerSay("Loading one Song....");
    integer c;
    integer total = llGetListLength(playlist);
    timer_started = FALSE;
    float length = total * 9.0;
    timer_mode_all_by_index = 0;
    last_wave_file_number = total - 1;
  
    for( c = 0; c < total; c ++) {
        preloading_wave_name  =_llGetPlayListItem(PLAYLIST_NAME,  c);
        llSetText(llGetObjectName() + 
                    "\n(preloading " + llGetSubString((string)((total - c)*preload_load_time),0,3) + " secs)"
                        +"\n.", <1,0,0>, set_text_alpha);

            //Attempt to preload first x wave files to local machines cache!                                              
            llTriggerSound(preloading_wave_name, 0.0);
            llPreloadSound(preloading_wave_name);
          
            
            //start play sound timer in 'timer_interval' seconds when we are less than 'timer_interval' seconds from
            // finishing preloading. 
            if ( ((total_wave_files - c) * preload_load_time) < timer_interval && !timer_started) { 
                llSetTimerEvent(timer_interval);
                timer_started = TRUE;
            }
            
            llSleep(preload_load_time);
        }
        i=0; c=0;
      
        llSay(0, "Done! Playing..  (" + (string)llFloor(length) + " secs) Click to stop.");
    
}

Edited by VirtualKitten
Link to comment
Share on other sites

Fenix Preload is set float preload_load_time = 0.2;  Without Preload it doesnt play well.. Its limps along with it too

Timer() {
if( i > last_wave_file_number )
        {
            llSay(0, "finished.");
            sent_to_seat = 0;
            play = FALSE;
            avatarkey=NULL_KEY;
            llSetText(llGetObjectName() + "\n.", <0,1,0>, set_text_alpha);            
            //llResetScript();
            llSetTimerEvent(0);
        } 
        else 
        {
            llSetSoundQueueing(TRUE);
            playing_wave_name = _llGetPlayListItem(PLAYLIST_NAME, i);
            //llWhisper(0, "llPlaySound wav: " + (string)i + " " + (string)llGetInventoryKey(playing_wave_name) );
            llPlaySound(playing_wave_name, 1.0);
            llSetText( /* llGetObjectName() + " - " +*/ llGetSubString(playing_wave_name,0,llStringLength(playing_wave_name)-4) + 
                        "\n(playing " + (string)i +" of "+ (string)last_wave_file_number +")\n."
                            , <0,1,1>, set_text_alpha);
        
            if(i + waves_to_preload <= last_wave_file_number)  
            {
                preloading_wave_name = _llGetPlayListItem(PLAYLIST_NAME,  i + waves_to_preload);
                 llTriggerSound(_llGetPlayListItem(PLAYLIST_NAME,  i + waves_to_preload), 0.0);
                 llPreloadSound(_llGetPlayListItem(PLAYLIST_NAME, i + waves_to_preload));
            }
        }

    i++;     //increment for next wave file in sequence!
}    

 

 

 

Link to comment
Share on other sites

Preloading only applies to viewers currently in range of the emitter, so if somebody arrives on the scene, they will only get the benefit of preloads that occur after they've arrived. So, only preload one sound ahead of the one currently playing instead of trying to preload the entire playlist in advance.

Keep in mind that the llPreloadSound call sleeps the script for a full second, and llSetSoundQueueing only really queues two sounds so the script has to carefully manage the timing of calls to llPlaySound.

 

Link to comment
Share on other sites

If you wish preload sounds faster then you must do it in parallel. Multiple scripts that fire at the same time and all request a different sound be preloaded.

 

Related ... 

For sound events in world, I wrote a dedicated collision based preloader a while back that could be used to set up sounds in advance of them being triggered.

https://wiki.catznip.com/index.php/Sound_Preloader_(LSL)

 

  • Like 1
Link to comment
Share on other sites

There is an issue with llPreloadSound() where it doesn't always cache the requested sound.

I haven't investigated the reason but I have watched calls fail to load sounds in my viewer's cache.

I suspect it mostly has to due with sounds that are greater than 10 seconds (these are still being uploaded today).

The workaround I've had to use is send a link message to a child link that has a script that uses llPlaySound() at 0 volume.

This will save sounds up to 59 seconds long in the viewer's cache.

A child link is used since you can't "preload" sounds with llPlaySound() as a song is playing with one link.

Edited by Lucia Nightfire
  • Like 2
Link to comment
Share on other sites

6 hours ago, Lucia Nightfire said:

The workaround I've had to use is send a link message to a child link that has a script that uses llPlaySound() at 0 volume.

This actually works? llPlaySound ("sound", 0);

6 hours ago, Lucia Nightfire said:

A child link is used since you can't "preload" sounds with llPlaySound() as a song is playing with one link.

Hm... That could explain something to do with my fullperm music sphere. Maybe Sound Queue also caches upcoming sounds?

Link to comment
Share on other sites

12 hours ago, Wulfie Reanimator said:

Maybe Sound Queue also caches upcoming sounds?

llSetSoundQueueing() does cache sounds, but its functionalilty depends on already cached/preloaded sound or it fails if the sound order the viewer receives and caches was not the order you inputted, such as with variable sized sound files despite the same time lengths. You'll see this mostly with the first two sounds you try and play/queue without explicitly preloading.

llSetSoundQueueing() also has a noticeable(to audiophiles) gap between sounds.

Edited by Lucia Nightfire
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1538 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...