.qc (dot qc) - the group for quake c coders of all denominations. If you make quake one mods and write code in quake c, join our group! I'll try to answer any quake c questions - please post your inquiry in the forums...
Posts | ||
---|---|---|
Using audio in Quake C | Locked | |
Thread Options | ||
|
Jun 18 2014 Anchor | |
What is audio? Reference for wave: En.wikipedia.org and ogg: En.wikipedia.org Audio files are uncompressed or compressed digital sound storage. The original quake and glquake used wav files for effects and CD tracks for background music. Advanced engines like darkplaces ( Icculus.org ) support wav and ogg. Additionally ogg tracks can substitute for CD audio by directory and file naming convention: "{quake root}/sound/cdtracks/track{number}.ogg" where "{number}" is the CD track to over lay and such files must be located in "sound/cdtracks". There are 3 major components to using audio in Quake. 1. Record the sound Recording This task I leave to you - for instruction try a search: Ixquick.com Loading To load audio in engines prior to darkplaces you need this function: // in defs.qc This is an engine builtin that can only be called during map load. For map loaded sounds (dynamic or static) this call can be made in the load function. Again, darkplaces and similar engines do not require this function call: Playing You have two function calls to play sound: Sound function 8 emits sound from the specified entity "e" on channel "chan". A sound is referred to with {path}/{audiofilename} - i.e. "sound/ogre/ogdrag.wav " There are some caveats on playing audio that I will track down and append to the article when I find them. Quake C manual ver 3.4 entries for audio: 8.3 Sound emission Function: sound void sound (entity source, float channel, string sample, float volume, float attenuation) source = entity emiting the sound (ex: self) Function: ambientsound void ambientsound(vector position, string sample, float volume, float attenuation) position = position, in 3D space, inside the level sample = name of the sample WAV file (ex: "ogre/ogdrag.wav") 5.2 Values : Sound Channel of entities CHAN_AUTO = 0; // Create a new sound Those values are meant to be used with the function sound. 5.3 Values : Sound Attenuation ATTN_NONE = 0; // full volume everywhere in the level Those functions are used to declare models, sounds and stuff, before the PAK file is built. Just follow this rule: whenever one of your functions makes use of a file that's not defined in Quake, precache this file in a function that will be called by worldspawn(). Then, the QCC compiler can automatically include in the PAK file all the files that you really need to run your programs. And when the level starts running, those precache orders will be executed, so as to attribute a fixed table index to all those files. DO NOT USE those functions in code that will be called after worldspawn() was called. As a matter of fact, that could bomb Quake (restarting the level, without crashing the game). Files can only be precached in spawn functions. Function: precache_file void precache_file(string file) Does nothing during game play. Function: precache_model void precache_model(string file) Does nothing during game play. Must be used in a model's spawn function, to declare the model file. Function: precache_sound void precache_sound(string file) Does nothing during game play. Must be used in a model's spawn function, to declare the sound files. Edited by: numbersix |
||
Jun 18 2014 Anchor | ||
+you can use this in darkplaces or another engin (for your own music player maybe) WriteByte (MSG_ALL, SVC_CDTRACK); |
||
|
Jun 18 2014 Anchor | |
I've decided to make this and using models a full tutorial. I'll include that. -- \|/ |
Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.