Jump to content

how to make sound transitions smooth in a dancer


MissLynnHyun
 Share

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

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

Recommended Posts

Let me first start off by saying that I really do not know how to script. I only have a slight understanding due to learning some programing languages years ago. That being said, I'm trying to make a dancer. I split the song up into 10 second clips, I took a modifiable script from a free dancer I already had, it has some instructions, but apparently not enough.

Now I really don't know if it's a script problem or the way I cut the audio, but I have the first 2 clips inside the dancer just to test it out before I upload the rest and it just doesn't transition smoothly. I'm not entirely sure what i did wrong, I know I split up te song right, at least pretty sure. 

Anywho, I'll just show the script I currently have:

integer ON = 0;                    
string animation = "dance 5 ik"; //Put the Name of the Animation between the "" after adding the animation in the Object
string activationTrigger = "On";//set the activation trigger here
string deactivationTrigger = "Off";//set the deactivation trigger here
integer Max_Sound_Clips = 02;//Put the number of Sound Clips where the 8 is Ex: 20         
integer Sound_Length = 10; //put the sound length 1-10          
integer Last_Sound_Length = 10;  //if the sound lenght is to small for the the LAST clip, change the 2 for 1-10      
integer SoundClipNumber = 0;// DONT CHANGE!!!    
//Dont change anything below!!!!
ResetToDefault()
{
    llStopSound();
    llSetTimerEvent(0.00);
    llStopAnimation(animation);
    ON = 0;
    SoundClipNumber = 0;
}

    
default
{
    state_entry()
    {
        llListen(0, "", "", "");
    }
    
    attach(key id)
    {
        if(id)
        {
            llOwnerSay("To Turn On: " + activationTrigger + " // To Turn Off: " + deactivationTrigger);
            llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION);
        }
        else ResetToDefault();
    }

    timer()
    {
        llPlaySound((string)(++SoundClipNumber),1.0);
        if(ON == 1){llSetTimerEvent(Sound_Length); ON = 2;}
        if(SoundClipNumber == Max_Sound_Clips){llSetTimerEvent(Last_Sound_Length); ON = 1; SoundClipNumber = 0;}
        llPreloadSound((string)(SoundClipNumber+1));
    }
    
    listen(integer channel, string name, key id, string message)
    {
        message = llToLower(message);
        if (ON == 0 && message == llToLower(activationTrigger))
        {
            ON = 1;
            llStartAnimation(animation);
            llSetTimerEvent(0.01);
        }
        else if(message == llToLower(deactivationTrigger)){ResetToDefault();}
    }
}

I hope someone can help me out. It would be greatly appreciated.

Also, sorry for any typos or anything, I had surgery on my hand recently, typing can be a bit of a pain sometimes.

Link to comment
Share on other sites

I haven't tested the script nor studied the logic that carefully, but I don't see llSetSoundQueuing() here and I think you'll want to call that on the prim at some point.

Also, especially the very first time a listener encounters the script, the first sound won't have been preloaded, so it won't start until downloaded, and then the second will likely interrupt it according to the original schedule. Sound queuing will help with that, too.

Also, I just happened to notice that this script has a wide-open listen on PUBLIC_CHANNEL -- which is fine for testing or if you'll only ever use it alone in a skybox but if it's to be used in a chat-heavy environment, you'll want to switch that llListen to specify owner-only (and reset any time the owner may have changed).

Link to comment
Share on other sites

 

Edit for new information

scratch this. diff script below

ok so i have a new script, everything seems to be working so far, but the sound still skips, but it's not too noticable i guess, like if you listen you can just hear a tiny skip. Are dancers normally like this? I listened to a few dancers i have and they skip for longer when they didnt seem to before. idk if im just lagging or what.

I put the llSoundQueueing in myself because it wasnt there before, however i dont know if i did it correctly, I don't get errors and it plays, but there are still tiny little skips.

integer ON = 0; //STATE OF SCRIPT//YOU EDIT THESE PARTS FOR NEW ANIMATIONS, SOUND CLIPS ETC. DO NOT TOUCH THE SCRIPTinteger MaxSoundClips = 9; //AMOUNT OF SONG CLIPS, NAME THEM 1,2,3,4,ETCinteger SoundLength = 10; //FIRST SERIES OF SOUND LENGTHSinteger LastSoundLength = 10; //INCASE LAST SOUND CLIP IS SHORTERinteger SoundClipNumber = 0; //FOR SOUND LOOPinteger AnimCycleTime = 0;integer CurrAnimCycle = 0;integer AnimNumber = 1;integer MaxAnims = 1;string LastAnim = "dance 5 ik";ResetToDefault(){llStopSound();llSetTimerEvent(0.00);llStopAnimation(LastAnim);ON = 0;SoundClipNumber = 0;AnimNumber = 0;}Initialize(){MaxSoundClips = llGetInventoryNumber(INVENTORY_SOUND);MaxAnims = llGetInventoryNumber(INVENTORY_ANIMATION);ResetToDefault();}default{state_entry(){llListen(0, "", "", "");LastAnim = llGetInventoryName(INVENTORY_ANIMATION, 0);Initialize();}attach(key id){if(id){llOwnerSay(" Commands  on or  off");llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION);}else ResetToDefault();}run_time_permissions(integer perm){if(perm & PERMISSION_TRIGGER_ANIMATION){Initialize();}}timer(){llPlaySound((string)(++SoundClipNumber),1.0);if(ON == 1){llSetTimerEvent(SoundLength); ON = 2;}if(SoundClipNumber == MaxSoundClips){llSetTimerEvent(LastSoundLength); ON = 1; SoundClipNumber = 0;}llPreloadSound((string)(SoundClipNumber+1));CurrAnimCycle++;if(CurrAnimCycle >= AnimCycleTime){CurrAnimCycle = 0;AnimNumber++;if(AnimNumber >= MaxAnims){AnimNumber = 0;}string anim = llGetInventoryName(INVENTORY_ANIMATION, AnimNumber);llStopAnimation(LastAnim);llStartAnimation(anim);LastAnim = anim;}}listen(integer channel, string name, key id, string message){    llSetSoundQueueing(TRUE);    llPlaySound("1", 0.5);    llPlaySound("2", 0.5);    llPlaySound("3", 0.5);    llPlaySound("4", 0.5);    llPlaySound("5", 0.5);    llPlaySound("6", 0.5);    llPlaySound("7", 0.5);    llPlaySound("8", 0.5);    llPlaySound("9", 0.5);message = llToLower(message);if (ON == 0 && message == "on"){ON = 1;string anim = llGetInventoryName(INVENTORY_ANIMATION, AnimNumber);llStartAnimation(anim);LastAnim = anim;llSetTimerEvent(0.01);}else if(message == "off"){ResetToDefault();}}}

 

Link to comment
Share on other sites

Ive had my wife test it and a couple friends. All seems fine. Others may have issues with 10s clips but i dont seem to be. The only thing i come across is lag and that cant be helped and sometimes there is small little blips, but i think i only heard them cause im listening for them. When i played it for others they said it was smooth.

 

Now i can play all 3 of my dancers and not even hear any issues anymore. Probably cause i stopped nitpicking.

 

Anyway, multiple people helped me test them and all is good now.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2591 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...