Inside3D!
     

A "Sound" Question
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
Junrall



Joined: 21 Sep 2009
Posts: 136
Location: North West Oregon, USA

PostPosted: Sat Feb 27, 2010 2:45 am    Post subject: A "Sound" Question Reply with quote

Is it possible to attach a sound to something like a rocket then have that sound repeated? It would be cool to hear a rocket hiss by as it passes you.
_________________
Good God! You shot my leg off!
Back to top
View user's profile Send private message
Lardarse



Joined: 05 Nov 2005
Posts: 243
Location: Bristol, UK

PostPosted: Sat Feb 27, 2010 4:36 am    Post subject: Reply with quote

It's not possible for sounds to travel as they are ebing played. The only way would be the rocket retriggering the sound as it moves along...
_________________
<ekiM> Son, you're writing data structures your CPU can't cache.
Back to top
View user's profile Send private message
Scrama



Joined: 28 Aug 2009
Posts: 20
Location: Siberia, Omsk

PostPosted: Sat Feb 27, 2010 4:38 am    Post subject: Reply with quote

Code:
void(entity e, float chan, string samp, float vol, float atten) sound = #8;

As you can see, you can play sound at entity (rocket f.e.). Look at the plats.qc/plat_go_* code:
Code:
void() plat_go_down =
{
   sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
   self.state = STATE_DOWN;
   SUB_CalcMove (self.pos2, self.speed, plat_hit_bottom);
};

void() plat_go_up =
{
   sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
   self.state = STATE_UP;
   SUB_CalcMove (self.pos1, self.speed, plat_hit_top);
};

May be you need start and stop markers in wav.
Back to top
View user's profile Send private message
Junrall



Joined: 21 Sep 2009
Posts: 136
Location: North West Oregon, USA

PostPosted: Sat Feb 27, 2010 5:01 am    Post subject: Reply with quote

Lardarse wrote:
It's not possible for sounds to travel as they are ebing played. The only way would be the rocket retriggering the sound as it moves along...


I suppose that immediately after the rocket is spawned I could spawn another entity in front of the rocket. As soon as the rocket touches this entity the rocket's touch function could be triggered and then I could do a sound update in the think function?

This would be similar to Scrama's plat_go_down/plat_go_up idea.
_________________
Good God! You shot my leg off!
Back to top
View user's profile Send private message
ceriux



Joined: 06 Sep 2008
Posts: 969
Location: Florida, USA

PostPosted: Sat Feb 27, 2010 5:13 am    Post subject: Reply with quote

why not spawn an invisible entity which plays the sound and give it a movetype_follow or something?
_________________
QuakeDB - Quake ModDB Group
Back to top
View user's profile Send private message Yahoo Messenger
Junrall



Joined: 21 Sep 2009
Posts: 136
Location: North West Oregon, USA

PostPosted: Sat Feb 27, 2010 5:26 am    Post subject: Reply with quote

ceriux wrote:
why not spawn an invisible entity which plays the sound and give it a movetype_follow or something?


Is movetype_follow a DP movetype?
At the moment I'm focusing on only using standard Quake code.
A part of me wants to stick with the standard stuff as everyone can play a mod using standard QC... the other part of me is starting to lean towards learning to mod for DP.
I'm finding myself torn.
_________________
Good God! You shot my leg off!
Back to top
View user's profile Send private message
Orion



Joined: 12 Jan 2007
Posts: 413
Location: Brazil

PostPosted: Sat Feb 27, 2010 10:46 am    Post subject: Reply with quote

That's only possible on darkplaces, which actually make all sounds follow the entity's origin when played.

On darkplaces you only play the looping sound once, don't need to re-trigger it many times.

You'll need set a think function to your rocket to play the sound, as sound (missile, CHAN_VOICE, "weapons/whatever.wav", 1, ATTN_IDLE); (calling the sound function in W_FireRocket when the missile just spawned) won't work at all.

You can set the rocket's nextthink to something less than 0.1, I recommend just set to time, which will call a function on the next frame.

Also, you'll need to precache and call misc/null.wav on T_MissileTouch(), otherwise when the rocket explodes, the looping sound will still play. Use CHAN_VOICE(or whatever channel you used the looping sound to play, can't be CHAN_AUTO) too, which will make the sound stop, as misc/null.wav on the same channel of the looping sound will override it.

Now on a regular Quake engine, you'll need to create a very short non-looping sound and make the rocket re-trigger it every 0.2 seconds or so(depending on the duration of the sound).
_________________
There's no signature here. Stop looking for one.
Back to top
View user's profile Send private message
Teiman



Joined: 03 Jun 2007
Posts: 309

PostPosted: Sat Feb 27, 2010 3:36 pm    Post subject: Re: A "Sound" Question Reply with quote

Junrall wrote:
Is it possible to attach a sound to something like a rocket then have that sound repeated? It would be cool to hear a rocket hiss by as it passes you.


What you want can be emulated as oposed to simulated:

You can make a think function that calculate distance (from player to the rocket). If the distance is lowering, then do nothing, continue. But If the distance is getting bigger, make a FOOOOOOSH sound, and stop thinking (so only one FOOOSH sound is generated).

This will look like is phisics what are creating the FOOOSH sound, withouth the need to use complicated math, or proper phisics.
Back to top
View user's profile Send private message
goldenboy



Joined: 05 Sep 2008
Posts: 310
Location: Kiel

PostPosted: Sat Feb 27, 2010 4:37 pm    Post subject: Reply with quote

CSQC can do moving sound (which is one reason I really, really want it).
_________________
ReMakeQuake
The Realm of Blog Magic
Back to top
View user's profile Send private message
Lardarse



Joined: 05 Nov 2005
Posts: 243
Location: Bristol, UK

PostPosted: Sat Feb 27, 2010 7:44 pm    Post subject: Reply with quote

Junrall wrote:
Lardarse wrote:
It's not possible for sounds to travel as they are ebing played. The only way would be the rocket retriggering the sound as it moves along...

I suppose that immediately after the rocket is spawned I could spawn another entity in front of the rocket. As soon as the rocket touches this entity the rocket's touch function could be triggered and then I could do a sound update in the think function?

Even easier: have the rocket think every 0.2 seconds or so (a lot depends on the sound being used), and in that think function, check how how long the rocket has been flying for (I think it's something like 5 seconds before it's removed), and if it isn't time for it to disappear then play the sound again.
_________________
<ekiM> Son, you're writing data structures your CPU can't cache.
Back to top
View user's profile Send private message
ceriux



Joined: 06 Sep 2008
Posts: 969
Location: Florida, USA

PostPosted: Sat Feb 27, 2010 8:24 pm    Post subject: Reply with quote

couldnt you call a seperate trace that shoots out the x cordinants and if it hits the player play your wizzz sound? or w.e?
_________________
QuakeDB - Quake ModDB Group
Back to top
View user's profile Send private message Yahoo Messenger
Junrall



Joined: 21 Sep 2009
Posts: 136
Location: North West Oregon, USA

PostPosted: Sat Feb 27, 2010 10:04 pm    Post subject: Reply with quote

Alright, I've got it to work... very easy as Lardarse said it was.
Code:
void() RocketThink =
{
   if (self.attack_finished < time)
   {
      remove(self);
      return;
   }

   sound (self, CHAN_VOICE, "weapons/ricofly.wav",1, ATTN_IDLE);

   self.nextthink = time + 0.48;
};

And as Lardarse mentioned...
Quote:
(a lot depends on the sound being used)

If your sound is short or long you'll have to adjust self.nextthink accordingly. If you don't, you'll hear sputtering/warbling which could mean thet self.nextthink is too short for the sound's play length... or you may hear sound, a pause, then sound again which means self.nextthink is too long for the sound's play length.
Also, if the sound file fades in or out, you'll hear weird things as well.
The sound file I'm using is about one second long. I clipped the start and end parts off as one was fading in and the other was fading out. Now I just have to find a better sound clip... one that has a slight hiss and buzz sound... should be great for those spikes!
_________________
Good God! You shot my leg off!
Back to top
View user's profile Send private message
Lardarse



Joined: 05 Nov 2005
Posts: 243
Location: Bristol, UK

PostPosted: Sun Feb 28, 2010 10:55 pm    Post subject: Reply with quote

Something you could try is have the rocket play the sound on a different channel each time. This would make the sounds overlap a little but, and then you'd also avoid the horrible noise of the sound being retriggered.
_________________
<ekiM> Son, you're writing data structures your CPU can't cache.
Back to top
View user's profile Send private message
Junrall



Joined: 21 Sep 2009
Posts: 136
Location: North West Oregon, USA

PostPosted: Sun Feb 28, 2010 11:06 pm    Post subject: Reply with quote

Lardarse wrote:
Something you could try is have the rocket play the sound on a different channel each time. This would make the sounds overlap a little but, and then you'd also avoid the horrible noise of the sound being retriggered.

I was wondering about that. Smile

I also figured out that the sounds I was using would only work in DP and not standard Quake. Turns out that the sounds were stereo and not mono... easy fix... deleted one channel and converted the other channel to mono.
This tells me that DP has revamped sound code (What hasn't been revamped in DP!? I really need to read DP's documentation!).
Does DP make use of the stereo output?
_________________
Good God! You shot my leg off!
Back to top
View user's profile Send private message
Team Xlink



Joined: 25 Jun 2009
Posts: 320

PostPosted: Sun Feb 28, 2010 11:59 pm    Post subject: Reply with quote

Orion wrote:
That's only possible on darkplaces, which actually make all sounds follow the entity's origin when played.

On darkplaces you only play the looping sound once, don't need to re-trigger it many times.

You'll need set a think function to your rocket to play the sound, as sound (missile, CHAN_VOICE, "weapons/whatever.wav", 1, ATTN_IDLE); (calling the sound function in W_FireRocket when the missile just spawned) won't work at all.

You can set the rocket's nextthink to something less than 0.1, I recommend just set to time, which will call a function on the next frame.

Also, you'll need to precache and call misc/null.wav on T_MissileTouch(), otherwise when the rocket explodes, the looping sound will still play. Use CHAN_VOICE(or whatever channel you used the looping sound to play, can't be CHAN_AUTO) too, which will make the sound stop, as misc/null.wav on the same channel of the looping sound will override it.

Now on a regular Quake engine, you'll need to create a very short non-looping sound and make the rocket re-trigger it every 0.2 seconds or so(depending on the duration of the sound).


MOVETYPE_FOLLOW isn't a DarkPlaces only feature, it is in more engines such as TomazQuake and is very easy to implement from TomazQuake into other engines, everything in TomazQuake is commented very well.

I suppose you could do it like this:

Find all players x units away from where the rocket was aimed and then play the sound for them.
_________________
Anonymous wrote:
if it works, it works. if it doesn't, HAHAHA!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group