Forum

Changing the pitch of a sound through QC?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Changing the pitch of a sound through QC?

Postby DusterdooSmock » Sun Oct 02, 2011 1:25 am

Is there a way to change the pitch of a sound that is being played through qc?
Sort of like the voicepitch for bots in CS:S, but I had another use in mind for it.
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Re: Changing the pitch of a sound through QC?

Postby Cobalt » Sun Oct 02, 2011 1:29 am

Not that I am aware of. I thought about it as well , but I guess you would need to port over a sound editing utility to the engine, and make up new paramaters for the sound commands in quake to modify them in game. I would imagine that it would soak up some decent CPU resources to convert sounds on the fly like that during the game.
User avatar
Cobalt
 
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA

Re: Changing the pitch of a sound through QC?

Postby Spike » Sun Oct 02, 2011 2:16 am

void(entity e, float chan, string samp, float vol, float atten, float speedpct) soundpitch = #8;

identical to existing sound builtin. using random(80,120) or so gives a reasonable range to stop sounds from being quite so monotonous. and because its the same builtin number, its generally safe to call even if the engine doesn't support the extension, you'll just loose any randomised pitches, so its great for sound effects.
Works in FTE, and from what I hear also DP now, though you'll need a fairly recent build.

specifically, the added argument is a speed percentage. passing a value of 50 will make the sound play at half the speed and thus give it a lower pitch. exercise caution when using it for voice samples due to the duration changes.

Disclaimer: old versions of DP will explode due to not expecting the extra arg, no other engine will.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Changing the pitch of a sound through QC?

Postby leileilol » Sun Oct 02, 2011 10:17 am

Darkplaces just added the ability to not too long ago. I also meant to add the ability to Engoo last year but the pitch value seemed to get lost in translation so I never did a release with it working

but when I do, i'll model it over DP's builtin
i should not be here
leileilol
 
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Re: Changing the pitch of a sound through QC?

Postby Cobalt » Mon Oct 03, 2011 4:06 am

Wow, didnt know that !

#8 seems to be the regular sound command in my qc. Just substitute that in place, and I guess alter all the regular sound calls to meet the new one?
User avatar
Cobalt
 
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA

Re: Changing the pitch of a sound through QC?

Postby Spike » Mon Oct 03, 2011 5:02 am

coder's choice. you can just have two separate #8 builtins defined, or use ... in the prototype so the qcc won't care if its there or not.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Changing the pitch of a sound through QC?

Postby DusterdooSmock » Mon Oct 03, 2011 8:08 pm

Spike wrote:void(entity e, float chan, string samp, float vol, float atten, float speedpct) soundpitch = #8;

identical to existing sound builtin. using random(80,120) or so gives a reasonable range to stop sounds from being quite so monotonous. and because its the same builtin number, its generally safe to call even if the engine doesn't support the extension, you'll just loose any randomised pitches, so its great for sound effects.
Works in FTE, and from what I hear also DP now, though you'll need a fairly recent build.

specifically, the added argument is a speed percentage. passing a value of 50 will make the sound play at half the speed and thus give it a lower pitch. exercise caution when using it for voice samples due to the duration changes.

Disclaimer: old versions of DP will explode due to not expecting the extra arg, no other engine will.


Great! Thank you. :D
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Re: Changing the pitch of a sound through QC?

Postby Cobalt » Tue Oct 04, 2011 5:42 am

Hmm, tried just having a duplicate #8, compiled ok. Tried a test using the itembk sound, value of 100, didnt seem to make a difference. After changing that value around, (dedicated server) I get a parse server illegable message with the snd_svc. Had this before when LH built a release for me to get items2 to work, he said it was soundpitch happening on every water splash noise...but I didnt have the soundpitch used at all in the qc. Still not sure why that happened....or how to get this to work.


Spike wrote:coder's choice. you can just have two separate #8 builtins defined, or use ... in the prototype so the qcc won't care if its there or not.
User avatar
Cobalt
 
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA

Re: Changing the pitch of a sound through QC?

Postby Spike » Tue Oct 04, 2011 5:55 am

sounds like your dp client+server are not compatible with it and thus each other, specifically that the server supports it while the client does not.

a value of 100 is normal speed. you'll hear no difference from normal if the value is 100. the further away from 100 that it is, the greater the speed/pitch change.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Changing the pitch of a sound through QC?

Postby Cobalt » Tue Oct 04, 2011 7:47 pm

Could be. That was what LH said when I was testing the new build to get items2 working. The client is darkplaces64 bit, the server is the 32 bit....not sure why that would matter.

Also, I just tried using the same engine build to connect with as the server is running, and at first, the client crashed saying that libjpeg-8.dll
was not available, while the file was there. I suspected its probably the 64 bit version of the file, copied the other one over from the folder I had the server running from , and connected.

Still, cant seem to hear any difference in the pitch sound though....no matter what value I put in.

Spike wrote:sounds like your dp client+server are not compatible with it and thus each other, specifically that the server supports it while the client does not.

a value of 100 is normal speed. you'll hear no difference from normal if the value is 100. the further away from 100 that it is, the greater the speed/pitch change.
User avatar
Cobalt
 
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest