|
How come my 3d sound isn't working correctly?
I've been trying to add 3d sound to the project I'm working on, and it's not working correctly. The sound file plays when I want it to, but it does not sound 3d. No matter where I am it plays at 100% volume, and I can't figure out why. Please help.
R. Jacobs
Matt responds: It sounds like
the problem is with the sound format you are using. This stems from the
attempted use of stereo sounds for 3d audio playback. Mono sounds are
required if you want to use 3d sound playback due to how 3d sound
processing works.
Stereophonic sounds have two or more separate audio channels where the signals have specific levels and relationships to each other. Stereo can simulate the position and perspective of sounds in 3d space. Monophonic sounds' audio signals are mixed together and routed through a single audio channel, resulting in the same product no matter the location of speakers or the listener.
To sum it up, stereo sound contains multiple channels to mimic 3d, and mono sound does not. Since mono sound is simpler, it allows it to be controlled by the software and hardware easier than stereo sound. So if you want 3d sound to work, make sure your sounds are mono.
Linux woes
Torque compiled fine in Linux but when I try to run it hangs and I have to kill the process. What is wrong?
R. Jackson
Guest, Tim Newell responds: You probably are missing a library and it's not loading the graphics. To see if this is the case run the torque demo with the -console argument (./torqueDemo_DEBUG.exe -console) and see if it gives you any errors. Those errors should be clear enough to help you figure out what files you might be missing. Good luck.
FPS for your FPS... or whatever you're making with Torque
How do I get the frame-rate for my game? I'm using Torque, and I can't figure out how.
A. Wilt
Matt responds: Most all of the debugging print functions are located in the client script file "metrics.cs", and it's broken down into 10 different categories: audio, debug, interior, fps, time, terrain, texture, video, vehicle, and water. The category you'll need is "fps", and in order to turn it on you'll need to use the console function:
metrics(fps);
Easy, huh? Well, let's make this even easier, by binding a key that toggles showing the fps. Drop this toggle server command anywhere outside of a function in default.bind.cs which is located in fps\server\scripts\
$ShowFPS = false;
function toggleShowFPS(%client)
{
if (!$ShowFPS)
{
metrics();
$ShowFPS = true;
}
else
{
$ShowFPS = true;
metrics(fps);
$ShowFPS = false;
}
}
And finally, we bind a key (I use F5) to trigger it all. Most keys are bound in config.cs which is located in fps\client\scripts\ so let's go there and put this command in:
moveMap.bind(keyboard, "f5", toggleShowFPS);
Hopefully this is useful for you, and for everyone else who wanted to add a server command, toggle button, or mess with the debug script functions.
What the f???
Sorry, I know this is a really dumb question, but the answer has slipped my mind. What is the significance of the f after some numbers in C++ code? Thanks.
S. Way
Matt responds: The "f" (case doesn't matter in some compilers like MSVC++, but in others it does. I reccomend using "f") is used to tell the compiler that you want that decimal number to be interpreted as a variable of type "float" as opposed to the default "double". As the name would suggest, double is twice as accurate and twice as slow. It's recomended that append an "f" to all constant variables, since you're defining them and it would be a waste to use up any more memory trying to store the value. Well, that and "3.2f" looks so much cooler then just plain 'ol "3.2".
Making a script function in C++
I want to add a c++ function that is accessible by my scripts. Is that hard to do?
K. Weaver
Matt responds: Making the function accessible to scripts only takes a few lines of C++. Making the function itself can vary from cakewalk to dodging traffic blindfolded. Since I don't know what you're going for, I'll just run-down the steps needed to create a C++ function that can be used in scripts.
Step 1: Make sure #include "console/console.h" is included at some point or path in the .cc file you're working in. A handful of other Torque helper files include it, so you don't want to include it more than once. Use this code in your header file to prevent that:
#ifndef _CONSOLE_H_
#include "console/console.h"
#endif
Step 2: Use the ConsoleFunction command to determine the script function's name, return type, maximum input variables, maximum input variables, and usage string.
ConsoleFunction(functionName, void, 2, 2, "functionName(input)")
{
[function code goes here]
}
Step 3: Write the function!
Now one thing that can be confusing are the 3rd and 4th variables that ConsoleFunction accepts. You must remember that it will always be one higher than the actual number of variables entered due to the class name of the object being counted as 1 (even if it isn't used) So if your function accepts 3 variables, your minimum and maximum input variables should be 4.
In order to access the variables sent to the function from scripts, you'll need to use the array argv. Remember, array element 1 is "0" in C++. Since the first element of array argv is always filled (you have no control over it) the first element you'd want to deal with is argv[1]. So to deal with the 4th variable sent from script to this function, you'd refer to argv[4].
Post your questions reguarding this issue here.
|