TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
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
17typedef struct WheelSoundData_
18{
19 sgVec3 p;
20 sgVec3 u;
23
26protected:
28 sgVec3 position;
29 sgVec3 speed;
32 void calculateAttenuation (tCarElt* car);
33 void calculateEngineSound (tCarElt* car);
35 void calculateTyreSound (tCarElt* car);
38 bool isOffRoadSurface(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
82public:
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 */
struct WheelSoundData_ WheelSoundData
static Point p[4]
Definition Convex.cpp:54
struct QSoundChar_ QSoundChar
struct SoundPri_ SoundPri
Sound priority, used to sort cars according to amplitude attenuation.
struct CarElt tCarElt
Car structure (tCarElt).
float smooth_accel
smoothed acceleration input
bool turbo_on
use turbo sound
QSoundChar grass_skid
void calculateGearChangeSound(tCarElt *car)
QSoundChar engine_backfire
QSoundChar grass
QSoundChar turbo
SoundPri eng_pri
void copyEngPri(SoundPri &epri)
void calculateCollisionSound(tCarElt *car)
void calculateAttenuation(tCarElt *car)
Use inverse distance to calculate attenuation of sounds originating from this car....
float pre_axle
axle related
void setCarSpeed(sgVec3 u)
QSoundChar skid_metal
float turbo_ilag
how fast turbo catches up with engine
float attenuation
global distance attenuation
void getCarSpeed(sgVec3 u)
SoundInterface * sound_interface
float base_frequency
engine base frequency for ~ 6000 rpm
void setListenerPosition(sgVec3 p)
void calculateEngineSound(tCarElt *car)
Calculate characteristics of the engine sound.
void setEngineSound(TorcsSound *engine_sound, float rpm_scale)
void setTurboParameters(bool turbo_on, float turbo_rpm, float turbo_lag)
QSoundChar curb
QSoundChar engine
void handleDirtContribution(tdble dirtContribution, tdble dirtRoughnessFreq, tdble dirtRoughness, tdble wheelSkid, tdble tmpvol, tdble ride)
CarSoundData(int id, SoundInterface *sound_interface)
bool isOffRoadSurface(const tTrackSeg *const seg)
void getDirtRoughnessParams(tCarElt *car, int wheelIndex, bool mainSurfaceIsOffroad, tdble roughnessFreq, tdble otherRoughnessFreq, tdble &dirtRoughnessFreq, tdble &dirtRoughness)
float turbo_rpm
when turbo comes in
TorcsSound * engine_sound
TorcsSound * getEngineSound()
tdble calculateRoughnessFreqency(const tTrackSeg *const seg)
void calculateTyreSound(tCarElt *car)
QSoundChar drag_collision
void handleCurbContribution(tPrivCar *car, bool onOtherSurface, tdble otherSurfaceContribution, tdble curbRoughnessFreq, tdble otherRoughnessFreq, tdble tmpvol, tdble ride, int wheelIndex, tdble wheelReaction)
sgVec3 position
WheelSoundData wheel[4]
QSoundChar axle
void handleRoadContribution(bool mainSurfaceIsOffroad, tdble roadContribution, tdble roughnessFreq, tdble otherRoughnessFreq, tdble tmpvol, tdble ride, int wheelIndex, tdble wheelSkid, tdble wheelSlipAccel, tdble wheelReaction)
void update(tCarElt *car)
sgVec3 listener_position
void setCarPosition(sgVec3 p)
void getCarPosition(sgVec3 p)
void calculateBackfireSound(tCarElt *car)
Calculate the frequency and amplitude of a looped backfiring sound.
QSoundChar road
Sound interface.
A generic TORCS sound.
Definition TorcsSound.h:53
float tdble
Floating point type used in TORCS.
Definition tgf.h:47
struct trackSeg tTrackSeg
Track segment (tTrackSeg) The segments can be straights (type TR_STR): (the track goes from the right...
sgVec3 p
position
sgVec3 u
speed
QSoundChar skid
Data known only by the driver.
Definition car.h:287