Changing the pitch of a sound through QC?

Discuss programming in the QuakeC language.
Post Reply
DusterdooSmock
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Changing the pitch of a sound through QC?

Post by DusterdooSmock »

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.
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: Changing the pitch of a sound through QC?

Post by Cobalt »

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.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Changing the pitch of a sound through QC?

Post by Spike »

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.
leileilol
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Re: Changing the pitch of a sound through QC?

Post by leileilol »

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
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: Changing the pitch of a sound through QC?

Post by Cobalt »

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?
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Changing the pitch of a sound through QC?

Post by Spike »

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.
DusterdooSmock
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Re: Changing the pitch of a sound through QC?

Post by DusterdooSmock »

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
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: Changing the pitch of a sound through QC?

Post by Cobalt »

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.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Changing the pitch of a sound through QC?

Post by Spike »

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.
Cobalt
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA
Contact:

Re: Changing the pitch of a sound through QC?

Post by Cobalt »

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.
Post Reply