TORCS  1.3.9
The Open Racing Car Simulator
CarSoundData.h
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 /***************************************************************************
3  file : CarSoundData.h
4  created : Tue Apr 5 19:57:35 CEST 2005
5  copyright : (C) 2005-2024 Christos Dimitrakakis, Bernhard Wymann
6  email : berniw@bluewin.ch
7 
8  ***************************************************************************/
9 
10 #ifndef CAR_SOUND_DATA_H
11 #define CAR_SOUND_DATA_H
12 
13 #include <vector>
14 
15 #include "QSoundChar.h"
16 
17 typedef struct WheelSoundData_
18 {
19  sgVec3 p;
20  sgVec3 u;
23 
25 class CarSoundData {
26 protected:
28  sgVec3 position;
29  sgVec3 speed;
32  void calculateAttenuation (tCarElt* car);
33  void calculateEngineSound (tCarElt* car);
34  void calculateBackfireSound (tCarElt* car);
35  void calculateTyreSound (tCarElt* car);
37  void calculateCollisionSound (tCarElt* car);
38  bool isOffRoadSurface(const tTrackSeg* const seg);
39  tdble calculateRoughnessFreqency(const tTrackSeg* const seg);
41  tCarElt* car,
42  int wheelIndex,
43  bool mainSurfaceIsOffroad,
44  tdble roughnessFreq,
45  tdble otherRoughnessFreq,
46  tdble& dirtRoughnessFreq,
47  tdble& dirtRoughness
48  );
50  tdble dirtContribution,
51  tdble dirtRoughnessFreq,
52  tdble dirtRoughness,
53  tdble wheelSkid,
54  tdble tmpvol,
55  tdble ride
56  );
58  bool mainSurfaceIsOffroad,
59  tdble roadContribution,
60  tdble roughnessFreq,
61  tdble otherRoughnessFreq,
62  tdble tmpvol,
63  tdble ride,
64  int wheelIndex,
65  tdble wheelSkid,
66  tdble wheelSlipAccel,
67  tdble wheelReaction
68  );
70  tPrivCar* car,
71  bool onOtherSurface,
72  tdble otherSurfaceContribution,
73  tdble curbRoughnessFreq,
74  tdble otherRoughnessFreq,
75  tdble tmpvol,
76  tdble ride,
77  int wheelIndex,
78  tdble wheelReaction
79  );
80 
81 
82 public:
85  float attenuation;
87  float smooth_accel;
88  float pre_axle;
89  bool turbo_on;
90  float turbo_rpm;
91  float turbo_ilag;
103 
105  void setEngineSound (TorcsSound* engine_sound, float rpm_scale);
106  void setTurboParameters (bool turbo_on, float turbo_rpm, float turbo_lag);
108  void copyEngPri (SoundPri& epri) {epri = eng_pri;}
109  void setCarPosition (sgVec3 p)
110  {
111  for (int i=0; i<3; i++) {
112  position[i] = p[i];
113  }
114  }
115  void setCarSpeed (sgVec3 u)
116  {
117  for (int i=0; i<3; i++) {
118  speed[i] = u[i];
119  }
120  }
121  void getCarPosition (sgVec3 p)
122  {
123  for (int i=0; i<3; i++) {
124  p[i] = position[i];
125  }
126  }
127  void getCarSpeed (sgVec3 u)
128  {
129  for (int i=0; i<3; i++) {
130  u[i] = speed[i];
131  }
132  }
133  void setListenerPosition (sgVec3 p)
134  {
135  for (int i=0; i<3; i++) {
136  listener_position[i] = p[i];
137  }
138  }
139  void update (tCarElt* car);
142  bool bang;
143  bool crash;
144 };
145 
146 #endif /* CAR_SOUND_DATA_H */
QSoundChar road
Definition: CarSoundData.h:100
struct WheelSoundData_ WheelSoundData
void setListenerPosition(sgVec3 p)
Definition: CarSoundData.h:133
QSoundChar engine_backfire
Definition: CarSoundData.h:96
CarSoundData(int id, SoundInterface *sound_interface)
QSoundChar axle
Definition: CarSoundData.h:95
void handleDirtContribution(tdble dirtContribution, tdble dirtRoughnessFreq, tdble dirtRoughness, tdble wheelSkid, tdble tmpvol, tdble ride)
float turbo_rpm
when turbo comes in
Definition: CarSoundData.h:90
TorcsSound * getEngineSound()
Definition: CarSoundData.h:107
SoundPri eng_pri
Definition: CarSoundData.h:83
QSoundChar turbo
Definition: CarSoundData.h:94
Car structure (tCarElt).
Definition: car.h:455
sgVec3 position
Definition: CarSoundData.h:28
void setEngineSound(TorcsSound *engine_sound, float rpm_scale)
void setCarPosition(sgVec3 p)
Definition: CarSoundData.h:109
Manages the source sound of each individual car.
Definition: CarSoundData.h:25
QSoundChar skid
Definition: CarSoundData.h:21
WheelSoundData wheel[4]
Definition: CarSoundData.h:84
QSoundChar grass
Definition: CarSoundData.h:99
TorcsSound * engine_sound
Definition: CarSoundData.h:30
bool turbo_on
use turbo sound
Definition: CarSoundData.h:89
void setCarSpeed(sgVec3 u)
Definition: CarSoundData.h:115
float base_frequency
engine base frequency for ~ 6000 rpm
Definition: CarSoundData.h:86
void calculateBackfireSound(tCarElt *car)
Calculate the frequency and amplitude of a looped backfiring sound.
void calculateCollisionSound(tCarElt *car)
void calculateEngineSound(tCarElt *car)
Calculate characteristics of the engine sound.
void calculateTyreSound(tCarElt *car)
float attenuation
global distance attenuation
Definition: CarSoundData.h:85
bool gear_changing
Definition: CarSoundData.h:140
float tdble
Floating point type used in TORCS.
Definition: tgf.h:48
bool isOffRoadSurface(const tTrackSeg *const seg)
static Point p[4]
Definition: Convex.cpp:54
QSoundChar drag_collision
Definition: CarSoundData.h:93
tdble calculateRoughnessFreqency(const tTrackSeg *const seg)
QSoundChar engine
Definition: CarSoundData.h:92
QSoundChar curb
Definition: CarSoundData.h:98
void getCarPosition(sgVec3 p)
Definition: CarSoundData.h:121
sgVec3 speed
Definition: CarSoundData.h:29
void handleRoadContribution(bool mainSurfaceIsOffroad, tdble roadContribution, tdble roughnessFreq, tdble otherRoughnessFreq, tdble tmpvol, tdble ride, int wheelIndex, tdble wheelSkid, tdble wheelSlipAccel, tdble wheelReaction)
void setTurboParameters(bool turbo_on, float turbo_rpm, float turbo_lag)
Track segment (tTrackSeg) The segments can be straights (type TR_STR): (the track goes from the right...
Definition: track.h:276
Sound interface.
void getCarSpeed(sgVec3 u)
Definition: CarSoundData.h:127
void copyEngPri(SoundPri &epri)
Definition: CarSoundData.h:108
void calculateGearChangeSound(tCarElt *car)
QSoundChar skid_metal
Definition: CarSoundData.h:101
void handleCurbContribution(tPrivCar *car, bool onOtherSurface, tdble otherSurfaceContribution, tdble curbRoughnessFreq, tdble otherRoughnessFreq, tdble tmpvol, tdble ride, int wheelIndex, tdble wheelReaction)
float smooth_accel
smoothed acceleration input
Definition: CarSoundData.h:87
sgVec3 listener_position
Definition: CarSoundData.h:27
void update(tCarElt *car)
QSoundChar grass_skid
Definition: CarSoundData.h:97
Data known only by the driver.
Definition: car.h:285
sgVec3 u
speed
Definition: CarSoundData.h:20
sgVec3 p
position
Definition: CarSoundData.h:19
void getDirtRoughnessParams(tCarElt *car, int wheelIndex, bool mainSurfaceIsOffroad, tdble roughnessFreq, tdble otherRoughnessFreq, tdble &dirtRoughnessFreq, tdble &dirtRoughness)
float pre_axle
axle related
Definition: CarSoundData.h:88
A generic TORCS sound.
Definition: TorcsSound.h:53
void calculateAttenuation(tCarElt *car)
Use inverse distance to calculate attenuation of sounds originating from this car. Useful for prioritisation of sounds.
SoundInterface * sound_interface
Definition: CarSoundData.h:31
Sound priority, used to sort cars according to amplitude attenuation.
float turbo_ilag
how fast turbo catches up with engine
Definition: CarSoundData.h:91