Ener has an idea that she’d like old rusty cannons in Hax Nuit but also a fun handheld watermelon cannon that you carry and shoot watermelons at people. She talks about it in the comments here, helpfully linking to a nice tutorial on a combat system. As I was going through code snippets, thinking about what fun things the cannon could do, I realized we’d need some sound effects, like for the launch of the watermelon and the splat of watermelon impact. Ener may not be fond of sounds (in fact, I usually have sounds off myself), but I bet she will like having her visitors being able to enjoy them if they choose :D
So, I went to freesound.org. I found a nice launching sound rather quickly, but for a good messy splat it took me longer. Finally I found a really gooey banana squelches sound, but its wayyy too long at well over 1 minute.

I’m no pro at sound editing, but I can at least trim down the length of a sound file. I just need a tool to do it with. I’ve known about and used Audacity for years. You can download the latest version from audacity.sourceforge.net. You can use audacity to record as well as edit sound files.
All I need is one really good splat, and there is one right where that red arrow is pointing.

With my mouse, I select the section of sound I want (click and drag). The selected area is a darker grey.

Then, Edit>Copy, File>New, and Edit>Paste gets that sound snippet into a new file.

I like to save edited files first as Audacity project files before exporting to one of the common sound file formats (such as WAV), just in case I decide to tweak it later (File>Save Project).
Exporting sound files is easy, File>Export and then choose the file format. During the export process, you can enter meta data, so I include the URL where I got the file from, the user name of the person that created the file, and indicated that I took a sampling of the file.
When I add that nice splat sound file to the watermelon cannon balls, I’ll also add a little notecard along with the file to indicate where the file came from and who made it.
Files downloadable from freesound.org include licensing information. Some sounds, like the launching sound, are licensed to be freely used without restrictions. Others, like the splat sound file, have restrictions, such as requiring attribution and use only for noncommercial purposes. So while I can use the splat file in Ener’s watermelon gun, I would not use it in an object I planned to sell.
Take care to note licensing requirements before using files, to ensure you will be able to use them in the way that you want.
To trigger a sound in opensim is very simple. The script below preloads the sound and plays the sound when the object is collided with:
default
{
on_rez(integer param)
{
// Preload watermelon squelch from inventory
llPreloadSound("squelch");
}
collision_start(integer num) {
//trigger the sound "squelch" and set the volume (1.0) loud
llTriggerSound("squelch", 1.0);
}
}
To be practical, you’d want to manage collisions so that it only plays upon the first collision, or first three collisions with a given avatar, but the above is a good start. maybe managing collisions would be something for later.







welcome Ohn! i think people will enjoy a little peak inside how you approach scripting (your tidbit about only playing a sound a few times is genius and extremely good user-centric design!)
also cool about free Audacity – Audacity is a great audio editing software that’s been around a long time and is well respected
there is, however, an error in your post – it’s not Ener’s cannon, it’s yours! without you it would just be an oversized paper weight!
i think Torley would approve! =)
Ener Hax
4 Feb 13 at 7:48 am
What a fun thing to build!
Adding audio makes such a difference and is an important part of any movie but we tend to think less of its importance for online endeavors. I would argue that many online “things” are entertainment-based in the respect that they are competing for our attention.
The same is true for OpenSim projects – adding sound can create a more deeply immersive environment – if done properly!
Too many times have I been to a nice build in Second Life only to have it ruined by terrible waves sounds or poorly executed bird chirps!
In Ohn’s post here, she takes that all into consideration much in the same manner a movie production would. Start with a quality sound, be conscious of licensing, edit it down to what is needed, and script it with an eye to the total scene and the user experience.
And extra kudos for the phrase “gooey banana squelches”! :)
David Miller
4 Feb 13 at 3:29 pm
Where do you get your crazy ideas? Too much poutine, and wild dreams?
Keep ‘em coming :)
♥
Dreamy
DreamWalker
4 Feb 13 at 9:08 pm
McDreamy! where have you been!?! i’ve missed you terribly!
Ener Hax
5 Feb 13 at 7:08 am
@Ener, TY for letting me do a post :D
@David, I can only take credit for the “gooey” :)
The funny thing is, I have great speakers, but nearly always have them turned off. If something convinces me that there is great benefit to turning them on, I might try, but not always. Recognizing a repeat pattern in a natural sound bothers my ears. Birds chirping is relaxing sound, but hearing a strong repeat pattern is not.
Good world builders will take this into consideration and add randomness to their sound scripts for the intervals to repeat a sound as well as the volume (and maybe even take the time of day into account). Take a dozen different individual bird calls (rather than one long file), with random intervals and random sound levels, and the recognizable repeat pattern is reduced dramatically.
Ohn Lang
5 Feb 13 at 11:23 am