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);
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;
224 sgVec3* p_camera = camera->
getPosv();
227 sgVec3* a_camera = camera->
getUpv();
229 for (i = 0; i<3; i++) {
236 for (i = 0; i < s->_ncars; i++) {
void setBackfireSound(const char *sound_name)
void setRoadRideSound(const char *sound_name)
void setListenerPosition(sgVec3 p)
double currentTime
current time in sec since the beginning of the simulation
void * GfParmReadFile(const char *file, int mode)
Read parameter set from file and return handle to parameter set.
cars situation used to inform the GUI and the drivers
void setSkidSound(const char *sound_name)
static CarSoundData ** car_sound_data
virtual void update(CarSoundData **car_sound_data, int n_cars, sgVec3 p_obs, sgVec3 u_obs, sgVec3 c_obs=NULL, sgVec3 a_obs=NULL)
Update sound for a given observer.
tCarElt ** cars
list of cars
void setAxleSound(const char *sound_name)
void GfParmReleaseHandle(void *parmHandle)
Release given parameter set handle parmHandle.
virtual TorcsSound * addSample(const char *filename, int flags=(ACTIVE_VOLUME|ACTIVE_PITCH), bool loop=false, bool static_pool=true)=0
Add a new sample - must be defined in children classes.
void grInitSound(tSituation *s, int ncars)
void grShutdownSound(int ncars)
void setEngineSound(TorcsSound *engine_sound, float rpm_scale)
void setBangSound(const char *sound_name)
Manages the source sound of each individual car.
void setGrassSkidSound(const char *sound_name)
void setTurboSound(const char *sound_name)
void setBackfireLoopSound(const char *sound_name)
void setCurbRideSound(const char *sound_name)
#define GR_ATT_SOUND_STATE_DISABLED
const char * GfParmGetStr(void *parmHandle, const char *path, const char *key, const char *deflt)
Get a string parameter from the parameter set handle.
static double lastUpdated
The Gaming Framework API (client part).
void setMetalSkidSound(const char *sound_name)
float tdble
Floating point type used in TORCS.
#define GR_SOUND_PARM_CFG
#define GFPARM_RMODE_REREAD
reread the parameters from file and release the previous ones
Graphic Module Interface Definition.
float grRefreshSound(tSituation *s, cGrCamera *camera)
#define GR_ATT_SOUND_VOLUME
Parameter header structure, a parameter can either carry a numeric or a string value, numeric value is constraint by min and max, string value by options in within.
void setBottomCrashSound(const char *sound_name)
This is the car structure.
virtual void setGlobalGain(float g)
void setGearChangeSound(const char *sound_name)
virtual void initSharedSourcePool()
initialised the pool of shared sources
void setCrashSound(const char *sound_name, int index)
static SoundInterface * sound_interface
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 setTurboParameters(bool turbo_on, float turbo_rpm, float turbo_lag)
#define GR_ATT_SOUND_STATE_OPENAL
#define GR_ATT_SOUND_STATE
void setGrassRideSound(const char *sound_name)
void update(tCarElt *car)
virtual void muteForMenu()
static int soundInitialized
virtual void setNCars(int n_cars)=0
Set the number of cars - must be defined in children classes.
#define GR_ATT_SOUND_STATE_PLIB
#define GFPARM_RMODE_CREAT
Create the file if doesn't exist.
sgVec3 * getCenterv(void)
static enum SoundMode sound_mode