Inside3D!
     

Help With Sound?
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
MikeWoodham



Joined: 22 Nov 2006
Posts: 4

PostPosted: Wed Nov 22, 2006 3:56 pm    Post subject: Help With Sound? Reply with quote

In Quake1SP I have a sound file that plays at a constant volume. In-game I want to adjust the volume level of that sound file according to player action but I do not want to use another sound file.

If I adjust the volume and play the sound again then the sound file will simply play from the begining at the new volume level, and although this is easy to achieve, it is not the effect I am looking for.

Is it possible to affect the volume using qc whilst the sound is playing?

I am only trying to affect the volume of the one selected sound file that is playing, not the overall sound level of the game.
Back to top
View user's profile Send private message
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Wed Nov 22, 2006 6:48 pm    Post subject: Reply with quote

once a sound is started, there is no way for the gamecode to refer to that sound. You can overwrite the sound by starting a new one (possibly silent) on the same entity and channel.

Of course, because each sound is attached to an entity, by moving the entity you can change the volume of the sound.
Unfortunatly this will be rather awkward. Firstly, it'll only work properly with a single player on the server. Secondly, if the entity enters into a wall then the sound volume will be left unchanged. Thirdly, you will end up with different volumes in left/right speakers depending on the player's angles and direction of sound. Or I might be muddled and it won't work at all.
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
Urre



Joined: 05 Nov 2004
Posts: 1073
Location: Sweden

PostPosted: Wed Nov 22, 2006 8:03 pm    Post subject: Reply with quote

Other than the problems you just presented, that's actually a pretty cool idea for music fading in and out Spike. It would work great in a top/down game/mod, if you just move the entity playing the music on a forward axis so that stereo isn't bothered. Cool stuff mate.
_________________
Look out for Twigboy
Back to top
View user's profile Send private message Visit poster's website
FrikaC
Site Admin


Joined: 08 Oct 2004
Posts: 947

PostPosted: Wed Nov 22, 2006 10:17 pm    Post subject: Reply with quote

Spike wrote:
once a sound is started, there is no way for the gamecode to refer to that sound. You can overwrite the sound by starting a new one (possibly silent) on the same entity and channel.

Of course, because each sound is attached to an entity, by moving the entity you can change the volume of the sound.
Unfortunatly this will be rather awkward. Firstly, it'll only work properly with a single player on the server. Secondly, if the entity enters into a wall then the sound volume will be left unchanged. Thirdly, you will end up with different volumes in left/right speakers depending on the player's angles and direction of sound. Or I might be muddled and it won't work at all.


Obviously would require a custom engine because in standard Quake the sound is sent to a client with simply a vector location, it is not attached to an entity in any way, thus moving an entity has no effect on a playing sound. The only thing that could be done is to move the listener (the client) but that would also be changing the view.
Back to top
View user's profile Send private message Send e-mail
scar3crow
Inside3D Staff


Joined: 18 Jan 2005
Posts: 837
Location: Las Vegas, NV

PostPosted: Wed Nov 22, 2006 10:33 pm    Post subject: Reply with quote

Quote:
Obviously would require a custom engine


Yeah thats what I was about to say. IIRC doesnt Darkplaces have a decently more advanced sound system in it ? I believe it can crossfade and such, dont know about changing volume of an entity midgame, but I guess we could poke LordHavoc about it.
Back to top
View user's profile Send private message AIM Address
LordHavoc



Joined: 05 Nov 2004
Posts: 243
Location: western Oregon, USA

PostPosted: Wed Nov 22, 2006 11:03 pm    Post subject: Reply with quote

scar3crow wrote:
Yeah thats what I was about to say. IIRC doesnt Darkplaces have a decently more advanced sound system in it ? I believe it can crossfade and such, dont know about changing volume of an entity midgame, but I guess we could poke LordHavoc about it.


I wish it had a more advanced sound system Razz

Seriously though, the sound system in DP has a few fixes and changes in it, but no cross-fading (isn't that only useful for music?).

Someone ought to write up an EXT_SND_SOUNDVOLUME or something to add a builtin and svc_ to change volume of a playing sound, wouldn't hurt to add a EXT_SND_SOUNDSTOP extension as well.

Regarding the ability to change properties of a playing sound - anything on a specific channel (not CHAN_AUTO) can be found easily if you know the entity and the entity channel value that was used to play it; CHAN_VOICE, CHAN_BODY, etc, are just qc constants that correspond to one of 7 specific sound channels per entity, there can be only one sound per channel, except that there can be any number of sounds on CHAN_AUTO for each entity.
Back to top
View user's profile Send private message Visit poster's website
FrikaC
Site Admin


Joined: 08 Oct 2004
Posts: 947

PostPosted: Thu Nov 23, 2006 2:39 pm    Post subject: Reply with quote

LordHavoc wrote:
scar3crow wrote:
Yeah thats what I was about to say. IIRC doesnt Darkplaces have a decently more advanced sound system in it ? I believe it can crossfade and such, dont know about changing volume of an entity midgame, but I guess we could poke LordHavoc about it.


I wish it had a more advanced sound system Razz

Seriously though, the sound system in DP has a few fixes and changes in it, but no cross-fading (isn't that only useful for music?).

Someone ought to write up an EXT_SND_SOUNDVOLUME or something to add a builtin and svc_ to change volume of a playing sound, wouldn't hurt to add a EXT_SND_SOUNDSTOP extension as well.

Regarding the ability to change properties of a playing sound - anything on a specific channel (not CHAN_AUTO) can be found easily if you know the entity and the entity channel value that was used to play it; CHAN_VOICE, CHAN_BODY, etc, are just qc constants that correspond to one of 7 specific sound channels per entity, there can be only one sound per channel, except that there can be any number of sounds on CHAN_AUTO for each entity.


Obviously would require a custom engine.
Back to top
View user's profile Send private message Send e-mail
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Thu Nov 23, 2006 7:55 pm    Post subject: Reply with quote

FrikaC wrote:
Spike wrote:
once a sound is started, there is no way for the gamecode to refer to that sound. You can overwrite the sound by starting a new one (possibly silent) on the same entity and channel.

Of course, because each sound is attached to an entity, by moving the entity you can change the volume of the sound.
Unfortunatly this will be rather awkward. Firstly, it'll only work properly with a single player on the server. Secondly, if the entity enters into a wall then the sound volume will be left unchanged. Thirdly, you will end up with different volumes in left/right speakers depending on the player's angles and direction of sound. Or I might be muddled and it won't work at all.


Obviously would require a custom engine because in standard Quake the sound is sent to a client with simply a vector location, it is not attached to an entity in any way, thus moving an entity has no effect on a playing sound. The only thing that could be done is to move the listener (the client) but that would also be changing the view.


Hrm...

So what's wrong with moving absolutly everything? :p

MWAA HA HA!!!


Yeah, quakeworld doesn't work quite the same way, instead it grabs the sound's origin from the entity that it's attached to. Probably still doesn't update it though. Damn, I should be able to remember this stuff.

LordHavoc: Maybe a flag to attach a sound to the entity, allowing audiable rockets, q3 style. But personally I'd only allow changing the volume in csqc, other stuff would be too clunky to work effectivly. Gives people motivation to use it. :p
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
MikeWoodham



Joined: 22 Nov 2006
Posts: 4

PostPosted: Thu Nov 23, 2006 9:13 pm    Post subject: Reply with quote

OK, thanks for your replies: it is for a music fade.

Although I can stop the music easily enough, an abrupt stop at a random point in the music is a bit naff and a fade can imply s-o-m-e-t-h-i-n-g i-s a-b-o-u-t t-o h-a-p-p-e-n b-u-t y-o-u d-o-n-t k-n-o-w w-h-e-n.

I'll just have to stop the music and trigger the event at the same time.
Back to top
View user's profile Send private message
HeadThump



Joined: 14 May 2006
Posts: 74
Location: Zin

PostPosted: Fri Nov 24, 2006 8:57 am    Post subject: Reply with quote

hey Mike,

I suspect you have good reasons not to add another sound file, but I'll ask just in case -- why not use the custent entity ambient_bgm (bgm is for back ground music). There is a good example in the custent test maps of background music where three wav files are 'spliced' together with an intro, body and fade out where the entity is used to organize the timing. I suspect you could trigger two of these events in seperate channels simultaneously, have one of these at a 'loud' volume and another at a soft -- have the loud end early and the soft one contain the fade out.

I would have to experiment to be certain -- its been a long time since I've used this QC set, but you may have to use the play_sound_triggered entity instead because it contains a key that allows you to specify the channel that is playing the sound.
Back to top
View user's profile Send private message
MikeWoodham



Joined: 22 Nov 2006
Posts: 4

PostPosted: Fri Nov 24, 2006 3:27 pm    Post subject: Headthump Reply with quote

I've had a quick look at Custents and although it could be used to fade the sound, it is not quite right.

To fade the music at the appropriate time means at any time during the music loop. It will be determined by the player's position in the map e.g. the player arrives at a 'battle' area after an unknown number of minutes. Therefore, I cannot know in advance where we will be in the music loop.

If I play another sound file (the one that fades) on the same channel, it will stop the original music loop but I cannot guarantee the fade will commence at the right place - I hope that reads OK, I know what I mean but I'm not sure if I am explaining it well.

The actual effect I am going for is: play music; just before an event determined unwittingly by the player, fade this tune; a couple of seconds later just as the event occurs, play the new music.

I can play the music, and I can stop one tune and start a new one. I just don't like the abruptness of stopping the first tune in the middle of a bar. I could wait untill the end of the loop and then change the tune but the player could have been long-gone (like turkey through the corn) and so spoil the (high drama) effect.

I am probably just trying to be too clever in a game that is too old Sad
Back to top
View user's profile Send private message
Dr. Shadowborg
Inside3D Staff


Joined: 16 Oct 2004
Posts: 726

PostPosted: Fri Nov 24, 2006 7:40 pm    Post subject: Re: Headthump Reply with quote

MikeWoodham wrote:
I am probably just trying to be too clever in a game that is too old Sad


It's probably not so much that, as it is that while the sound system was perfectly adequate back in the olden days, it's pretty much ass today. It's probably the least touched (unfortunatly) bit in the entire history of the engine since it became open source. :/
_________________
"Roboto suggests Plasma Bazooka."
Back to top
View user's profile Send private message
scar3crow
Inside3D Staff


Joined: 18 Jan 2005
Posts: 837
Location: Las Vegas, NV

PostPosted: Sat Nov 25, 2006 2:43 am    Post subject: Reply with quote

Honestly, sound is probably the least touched bit in games period. Of course you have exceptions such as Thief and Blood and apparently Doom3, but on the whole, sound is just something to please the audiocard manufacturers to some companies.
Back to top
View user's profile Send private message AIM Address
Entar



Joined: 05 Nov 2004
Posts: 422
Location: At my computer

PostPosted: Sat Nov 25, 2006 3:00 am    Post subject: Reply with quote

Yeah. Code-wise, there's not a whole lot you can do with sound - sure you can do fades, volume, 3D sound etc, but at some point you just run out of things to do. The coolest effects are those that you record in the first place.
_________________
woh... feelin woozy... too much cider...
http://entar.quakedev.com
games fascination - My Game Development Blog/Journal
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
FrikaC
Site Admin


Joined: 08 Oct 2004
Posts: 947

PostPosted: Sat Nov 25, 2006 6:28 am    Post subject: Reply with quote

I personally would like to see the ability to do DSP style effects on the sound in certain areas of the map (e.g. make a cave all echo-y).
Back to top
View user's profile Send private message Send e-mail
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