Page 8 of 11

Re: Railgun.oxp v 1.2 now available

Posted: Tue May 10, 2011 8:05 am
by DaddyHoggy
Commander McLane wrote:
pagroove wrote:
I like the railgun! Good work and very original. It only need one thing more and that is: sound.
Its a bit silent.
... and therefore doesn't fit the Space Is Noisy-trope. :wink:

But seriously, I'd love to have a sound effect, perhaps two sound effects: one for firing, and one for hitting. You're the man for sounds, would you like to provide some?

(And while you're at it, I'd also love to have a sound effect for the fireworks from fireworks.oxp.)
You should still hear the firing mechanism reverberating through the hull of the ship though, should you?

Re: Railgun.oxp v 1.2 now available

Posted: Tue May 10, 2011 8:39 am
by Commander McLane
As I have never worked with sound effects or music before, how would I script the use of a sound effect let's say in railgun-firing.js? Is it enough to insert

Code: Select all

Sound.playMusic("laser.ogg");
somewhere? If I type this into the console, nothing happens.

Re: Railgun.oxp v 1.2 now available

Posted: Tue May 10, 2011 10:17 am
by Svengali
As it is a sound that is used inflight and not only one or two times...

Put the sound in customsounds.plist, e.g.

Code: Select all

"[railgun_fire]" = "railgun_fire.ogg";
and in the script

Code: Select all

this.bang = new SoundSource;
this.bang.sound = "[railgun_fire]";
this.bang.play();
or

Code: Select all

var bang = new SoundSource;
bang.sound = "[railgun_fire]";
bang.play();

Re: Railgun.oxp v 1.2 now available

Posted: Tue May 10, 2011 10:46 am
by Cody
A nice sound effect for the railgun would be very cool.

Re: Railgun.oxp v 1.2 now available

Posted: Tue May 10, 2011 11:00 am
by Smivs
Phut!

Re: Railgun.oxp v 1.2 now available

Posted: Tue May 10, 2011 12:01 pm
by Disembodied
There are some Creative Commons sound-effect libraries out there ... something like this might be good:

http://www.freesound.org/samplesViewSingle.php?id=39023

Re: Railgun.oxp v 1.2 now available

Posted: Tue May 10, 2011 12:02 pm
by Commander McLane
Smivs wrote:
Phut!
Now if you would be so kind and send it to me as an OGG. :D

Re: Railgun.oxp v 1.2 now available

Posted: Tue May 10, 2011 12:04 pm
by Commander McLane
@ Svengali: thanks! :D

(And as it turns out, I should've consulted the SoundSource documentation, not the Sound documentation. D'oh! :oops: )

Re: Railgun.oxp v 1.2 now available

Posted: Tue May 10, 2011 12:41 pm
by Smivs
Commander McLane wrote:
Smivs wrote:
Phut!
Now if you would be so kind and send it to me as an OGG. :D
My pleasure. Here you are :lol:

Re: Railgun.oxp v 1.2 now available

Posted: Tue May 10, 2011 1:23 pm
by Commander McLane
Smivs wrote:
Commander McLane wrote:
Smivs wrote:
Phut!
Now if you would be so kind and send it to me as an OGG. :D
My pleasure. Here you are :lol:
Nothing personal, but I'm not quite convinced yet. :P

But seriously: I am imagining something not completely unlike the missile launching sound, but shorter, and more 'electric'.

Re: Railgun.oxp v 1.2 now available

Posted: Tue May 10, 2011 2:11 pm
by Smivs
Hehe, only kidding.

On a serious note (excuse the pun) this might be more suitable.

If it's any help to anyone, I found these here, available as .wav or mp3 files, and used the free online mp3 to ogg converter here.

Re: Railgun.oxp v 1.2 now available

Posted: Tue May 10, 2011 2:36 pm
by Commander McLane
Smivs wrote:
Hehe, only kidding.

On a serious note (excuse the pun) this might be more suitable.

If it's any help to anyone, I found these here, available as .wav or mp3 files, and used the free online mp3 to ogg converter here.
Oh, shiny! Nice sound effects. I'll dig through those. :D

Re: Railgun.oxp v 1.2 now available

Posted: Tue May 10, 2011 3:58 pm
by Commander McLane
Svengali wrote:
As it is a sound that is used inflight and not only one or two times...

Put the sound in customsounds.plist, e.g.

Code: Select all

"[railgun_fire]" = "railgun_fire.ogg";
and in the script

Code: Select all

this.bang = new SoundSource;
this.bang.sound = "[railgun_fire]";
this.bang.play();
or

Code: Select all

var bang = new SoundSource;
bang.sound = "[railgun_fire]";
bang.play();
Another question: is it safe and sound to put this into the activated handler?

I have done this with the second version, and at least I don't get errors about a re-defined var bang. I am not sure about the nature of the activated handler. Does it create a new instance of the script each time (so it seems with the lack of an error message), or could I declare the soundSource somewhere else and only once, and then only use the play() in the activated handler?

Re: Railgun.oxp v 1.2 now available

Posted: Tue May 10, 2011 4:45 pm
by JensAyton
A variable declared with var inside a function exists for the duration of that activation of the function. It ceases to exist when the function returns.

The sound source itself continues to exist until it is garbage collected, which can’t happen while it’s playing (i.e., the game code protects it; this is different from timers, which can randomly stop if you don’t keep a reference to them). In fact, sound sources will keep going even after the game resets (Bug #18108).

In general, it’s better style to set up one sound source, or a small pool, and reuse it. However, the behaviour of equipment scripts is somewhat weird and I don’t actually know if the script is reused or you’re getting a new instance each time (Kaks implemented this stuff).

Re: Railgun.oxp v 1.2 now available

Posted: Tue May 10, 2011 6:14 pm
by Svengali
In the eq script for Cabal_Common_Comms I'm using

Code: Select all

this.activated = function()
{
  if(!this.beep){
    this.beep = new SoundSource;
    this.beep.sound = "[cabal_common_commbeep]";
  }
  // Other stuff
  this.beep.play();
}
Ahruman wrote:
In fact, sound sources will keep going even after the game resets (Bug #18108).
Yep. Gave me some headaches for BGS when the player loads or reloads a savedgame, because BGS uses looped sounds.