Leoplod Posted April 5, 2019 Share Posted April 5, 2019 I have little scripting experience, so please bear with me - I also searced the forums for a couple hours, but without result I try to use a simple loop sound script, but it doesn't make any difference in sound volume whether I set "float vol" to 0.1 or 1.0 Can someone please help me with this? I need to make the faint fountain sound louder - it makes no difference whether I have the sound in the prim with the script or use the UUID Thanks... float min = 1; float max = 30; float vol = 0.5; // Sound to play. key sound = "Fountain"; default { state_entry() { llLoopSound(sound, vol); } } Link to comment Share on other sites More sharing options...
Qie Niangao Posted April 5, 2019 Share Posted April 5, 2019 What happens if you llStopSound() first, before starting to loop it again? Also, be sure the sound is loud enough when you play it directly from inventory. Imported sounds tend to sound quieter in-world than they seem in, say, Audacity. 1 Link to comment Share on other sites More sharing options...
steph Arnott Posted April 5, 2019 Share Posted April 5, 2019 Should work. BTW this is not a key it is a string. key sound = "Fountain"; Should be string sound = "Fountain"; Link to comment Share on other sites More sharing options...
steph Arnott Posted April 5, 2019 Share Posted April 5, 2019 (edited) 7 minutes ago, Qie Niangao said: What happens if you llStopSound() first, before starting to loop it again? Also, be sure the sound is loud enough when you play it directly from inventory. Imported sounds tend to sound quieter in-world than they seem in, say, Audacity. When SL compress the sound file on download it reduces the vol to about 50% of Audacity. At a guess i would say SL converts the file to mono. Edited April 5, 2019 by steph Arnott Link to comment Share on other sites More sharing options...
Wulfie Reanimator Posted April 5, 2019 Share Posted April 5, 2019 (edited) Like Qie guessed, you have to first stop the sound before you can play it again with a different volume. (I think this is because playing a looping sound that is already playing is ignored.) Though, fun fact; there's a function called llAdjustSoundVolume which can change the volume of a looping sound without restarting it. It's not particularly helpful here, but maybe elsewhere. Edited April 5, 2019 by Wulfie Reanimator 1 Link to comment Share on other sites More sharing options...
Leoplod Posted April 5, 2019 Author Share Posted April 5, 2019 2 hours ago, Qie Niangao said: What happens if you llStopSound() first, before starting to loop it again? Also, be sure the sound is loud enough when you play it directly from inventory. Imported sounds tend to sound quieter in-world than they seem in, say, Audacity. Thanks for the replies to all... where in the script do I insert "llStopSound()"? I don't have experience in scripting and get "syntax error" whatever I try (I changed key sound = "Fountain"; to string sound = "Fountain"; ) float min = 1; float max = 30; float vol = 0.5; // Sound to play. string sound = "Fountain"; default { state_entry() { llLoopSound(sound, vol); } } Link to comment Share on other sites More sharing options...
steph Arnott Posted April 5, 2019 Share Posted April 5, 2019 (edited) 7 minutes ago, Leoplod said: float vol = 0.5; string sound = "Fountain"; default { state_entry() { } touch_start(integer total_number) { llLoopSound(sound, vol); } } This needs the sound in the object inventory. If you use the UUID key for the asset then add the "this is the uuid key" and use that. It does not have to be in object if you use the key Edited April 5, 2019 by steph Arnott Link to comment Share on other sites More sharing options...
Rolig Loon Posted April 5, 2019 Share Posted April 5, 2019 1 minute ago, Leoplod said: where in the script do I insert "llStopSound()"? Wherever you want to stop it. Depending on what you want the trigger to be, you might want touch_start( integer num ) { llStopSound(); } or timer() { llStopSound(); } or listen (integer channel, string name, key id, string message) { if (message == "Stop") { llStopSound(); } } or sensor(integer num ) { llStopSound(); } Each of those assumes that you have set up the event properly with llSetTimerEvent() or llListen() or llSensor(). Another question, which you haven't addressed, is how to turn the sound back on again. The quickest (and clumsiest) way to do it is simply to restart the script. It's not at all elegant, but it works. If you are learning, though, it might be a good idea to search for examples of code that switches ON/OFF. Link to comment Share on other sites More sharing options...
Fenix Eldritch Posted April 5, 2019 Share Posted April 5, 2019 For a quick fix of stopping the currently playing sound and restarting it with a new volume, Placing llStopSound(); on the line before the llLoopSound command in your state_entry event should work. Make sure you don't forget to add a semicolon ( ; ) after the command - otherwise you'll get a syntax error. Link to comment Share on other sites More sharing options...
steph Arnott Posted April 5, 2019 Share Posted April 5, 2019 2 minutes ago, Fenix Eldritch said: For a quick fix of stopping the currently playing sound and restarting it with a new volume, Placing llStopSound(); on the line before the llLoopSound command in your state_entry event should work. Make sure you don't forget to add a semicolon ( ; ) after the command - otherwise you'll get a syntax error. The OP was on about sound volume, not stopping a loop. Link to comment Share on other sites More sharing options...
Fenix Eldritch Posted April 5, 2019 Share Posted April 5, 2019 Why are you so confrontational? I was responding to OP's most recent reply - in which they were asking where to place the llStopSound command in their sample script. Link to comment Share on other sites More sharing options...
steph Arnott Posted April 5, 2019 Share Posted April 5, 2019 3 minutes ago, Fenix Eldritch said: Why are you so confrontational? I was responding to OP's most recent reply - in which they were asking where to place the llStopSound command in their sample script. Not confrontational at all. The issue is the sound volume. Link to comment Share on other sites More sharing options...
Leoplod Posted April 5, 2019 Author Share Posted April 5, 2019 16 minutes ago, Fenix Eldritch said: For a quick fix of stopping the currently playing sound and restarting it with a new volume, Placing llStopSound(); on the line before the llLoopSound command in your state_entry event should work. Make sure you don't forget to add a semicolon ( ; ) after the command - otherwise you'll get a syntax error. Thank you Fenix... I can now control the volume And thanks for reminding me about the semicolon, that's what had me beaten Thanks again to all for helping Link to comment Share on other sites More sharing options...
steph Arnott Posted April 5, 2019 Share Posted April 5, 2019 34 minutes ago, Leoplod said: Thank you Fenix... I can now control the volume And thanks for reminding me about the semicolon, that's what had me beaten Thanks again to all for helping float min = 1; float max = 30; float vol = 0.5; // Sound to play. key sound = "Fountain";//this is a string default { state_entry() { llLoopSound(sound, vol); } } So your script here is not the one used inworld. Which does clear up the fact that there is nothing wrong with this. Link to comment Share on other sites More sharing options...
Leoplod Posted April 5, 2019 Author Share Posted April 5, 2019 2 minutes ago, steph Arnott said: float min = 1; float max = 30; float vol = 0.5; // Sound to play. key sound = "Fountain";//this is a string default { state_entry() { llLoopSound(sound, vol); } } So your script here is not the one used inworld. Which does clear up the fact that there is nothing wrong with this. That is the script with which you couldn't control the volume - otherwise it workes, as long as you are happy with the preset volume Below is the modified script with the stop command that let's me control the volume and raise it to 1.0 Thanks again float min = 1; float max = 30; float vol = 1.0; // Sound to play. string sound = "bcb6dd68-1d01-5a32-9036-612c797373f9"; default { state_entry() { llStopSound(); llLoopSound(sound, vol); } } Link to comment Share on other sites More sharing options...
steph Arnott Posted April 5, 2019 Share Posted April 5, 2019 (edited) 7 minutes ago, Leoplod said: llStopSound(); This is because once you call the sound file it is not adjustable on volume when it loops. You have to stop it and update the value. Edited April 5, 2019 by steph Arnott Link to comment Share on other sites More sharing options...
Wulfie Reanimator Posted April 5, 2019 Share Posted April 5, 2019 2 hours ago, steph Arnott said: This is because once you call the sound file it is not adjustable on volume when it loops. You have to stop it and update the value. http://wiki.secondlife.com/wiki/LlAdjustSoundVolume 🙄 Link to comment Share on other sites More sharing options...
steph Arnott Posted April 6, 2019 Share Posted April 6, 2019 8 minutes ago, Wulfie Reanimator said: http://wiki.secondlife.com/wiki/LlAdjustSoundVolume 🙄 It just turns off the one running and restarts with the new value. It has a 0.1 time penalty which loopSound and stopSound does not. No one uses it because it is totally pointless. 1 Link to comment Share on other sites More sharing options...
steph Arnott Posted April 6, 2019 Share Posted April 6, 2019 (edited) 2 hours ago, Wulfie Reanimator said: http://wiki.secondlife.com/wiki/LlAdjustSoundVolume 🙄 Funny that you have no idea what the function actually does. Guess you are laughing at yourself. It is utterly pointless for a loop. Edited April 6, 2019 by steph Arnott Link to comment Share on other sites More sharing options...
ItHadToComeToThis Posted April 6, 2019 Share Posted April 6, 2019 Random funny thing to note. If you use the depreciated llSound function you can play multiple sounds from the same prim at the same time. Even though its depreciated it works fine and gets right around the one sound per prim restriction. Link to comment Share on other sites More sharing options...
Qie Niangao Posted April 6, 2019 Share Posted April 6, 2019 That's interesting. I wonder why llSound was deprecated, inasmuch as it seems to have almost all the functionality of the current suite of (attached) sound functions, so I wonder why they went to all the trouble of replacing it. The one current behavior the old function lacks is to silently do nothing if called while a sound is playing and llSetSoundQueuing is turned off; rather, at least as documented, llSound would either interrupt the current sound or queue the new one for after the first completes, depending on its queue parameter. (So now I'm wondering how one calls it in a way that makes it play multiple sounds; maybe that's the non-queuing behavior if the previous sound was looped? Can't really test that at the moment.) Link to comment Share on other sites More sharing options...
steph Arnott Posted April 6, 2019 Share Posted April 6, 2019 (edited) 5 hours ago, Qie Niangao said: I tried it and could not get it to run two sounds at the same time even with two scripts. Maybe it is viewer side set. Maybe it is sim server side. IDK. Edited April 6, 2019 by steph Arnott Link to comment Share on other sites More sharing options...
Rachel1206 Posted April 6, 2019 Share Posted April 6, 2019 Here is how do it. Notice; do not use the deprecated function llSound() - instead use the new sound functions. // Example of using the deprecated llSound function default { state_entry() { // Stop sound(s) after 30 seconds llSetTimerEvent(30.0); // Play "master" sound llSound("f7ab57e1-299e-7828-3aa5-0a37f5ec19db",1.0,TRUE,TRUE); llSay(0, "Click me for a SNEEZE! - all sounds stop after 30 seconds"); } touch_start(integer total_number) { // Play "child" sound llSound("1bf70184-e383-1493-4e7f-25ff1155f953",1.0,FALSE,FALSE); } timer() { // We are done llSetTimerEvent(0.0); llStopSound(); } } 1 1 Link to comment Share on other sites More sharing options...
Fenix Eldritch Posted April 6, 2019 Share Posted April 6, 2019 (edited) Qie, I spent some time messing with the old llSound on the beta grid and here are my findings: llSound seems to only loop if both the queue and loop parameters are TRUE. Calling llSound with the loop parameter set to FALSE will not interrupt an already playing attached sound (looping or not) set by llLoopSound llPlaySound, or a previous llSound call. The queue parameter doesn't seem to have any effect (that I could see) when loop is FALSE. Calling llSound with queue=FALSE and loop=TRUE will interrupt any currently playing/looping attached sound similar to llPlaySound's behavior. Calling llSound from a HUD will result in the sound emanating from the avatar's in-world position instead of the worn HUD. As a side note, I did a little digging and discovered that llSound has been deprecated since early 2004 - and possibly earlier. That's astoundingly early... I'm really curious what happened back then to make them switch. Edited April 6, 2019 by Fenix Eldritch 1 1 Link to comment Share on other sites More sharing options...
steph Arnott Posted April 6, 2019 Share Posted April 6, 2019 1 hour ago, Fenix Eldritch said: It was replaced because llSound plays untill the end and can not be stopped, where as llPlaySound can be stopped at any point. Link to comment Share on other sites More sharing options...
Recommended Posts
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