25#include <portability.h>
47 const int BUFSIZE = 1024;
50 GfOut(
"-- grInitSound\n");
60 if (!strcmp(optionName, soundDisabledStr)) {
62 }
else if (!strcmp(optionName, soundOpenALStr)) {
64 }
else if (!strcmp(optionName, soundPlibStr)) {
77 }
catch (
const char* err) {
78 GfError(
"Disabling Sound: OpenAL initialisation failed: %s\n", err ? err :
"");
99 for (i = 0; i<ncars; i++) {
100 void* handle = s->
cars[i]->_carHandle;
108 rpm_scale =
GfParmGetNum(handle,
"Sound",
"rpm scale", NULL, 1.0);
109 snprintf (buf, BUFSIZE,
"cars/%s/%s", car->_carName,
param);
110 file = fopen(buf,
"r");
113 snprintf (buf, BUFSIZE,
"data/sound/%s",
param);
125 float default_turbo_rpm = 100.0f;
128 if (!strcmp(
param,
"true")) {
131 if (strcmp(
param,
"false")) {
132 fprintf (stderr,
"expected true or false, found %s\n",
param);
139 car_sound_data[i]->setTurboParameters (turbo_on, turbo_rpm, turbo_lag);
155 snprintf(buf, BUFSIZE,
"data/sound/crash%d.wav", i+1);
174 GfOut(
"-- grShutdownSound\n");
181 for (i = 0; i < ncars; i++) {
195 if (__slPendingError) {
196 GfOut(
"!!! error ignored: %s\n", __slPendingError);
197 __slPendingError = 0;
211 const double UPDATE_DT = 0.01;
227 sgVec3* a_camera = camera->
getUpv();
229 for (i = 0; i<3; i++) {
236 for (i = 0; i < s->_ncars; i++) {
struct CarElt tCarElt
Car structure (tCarElt).
Manages the source sound of each individual car.
sgVec3 * getCenterv(void)
sgVec3 * getWorldPosv(void)
#define GR_ATT_SOUND_STATE_DISABLED
#define GR_ATT_SOUND_VOLUME
#define GR_ATT_SOUND_STATE_OPENAL
#define GR_SOUND_PARM_CFG
#define GR_ATT_SOUND_STATE_PLIB
#define GR_ATT_SOUND_STATE
float tdble
Floating point type used in TORCS.
const char * GfParmGetStr(void *parmHandle, const char *path, const char *key, const char *deflt)
Get a string parameter from the parameter set handle.
tdble GfParmGetNum(void *handle, const char *path, const char *key, const char *unit, tdble deflt)
Get a numerical parameter from the parameter set handle.
void GfParmReleaseHandle(void *parmHandle)
Release given parameter set handle parmHandle.
void * GfParmReadFile(const char *file, int mode)
Read parameter set from file and return handle to parameter set.
static enum SoundMode sound_mode
static SoundInterface * sound_interface
float grRefreshSound(tSituation *s, cGrCamera *camera)
void grInitSound(tSituation *s, int ncars)
static int soundInitialized
static CarSoundData ** car_sound_data
void grShutdownSound(int ncars)
static double lastUpdated
struct Situation tSituation
cars situation used to inform the GUI and the drivers
tCarElt ** cars
list of cars
double currentTime
current time in sec since the beginning of the simulation
Parameter header structure, a parameter can either carry a numeric or a string value,...
#define GFPARM_RMODE_CREAT
Allow an empty in-memory set on file-open failure; does not write a file.
#define GFPARM_RMODE_REREAD
Clear shared cached data and reread the file.