19 #ifndef SOUND_INTERFACE_H 20 #define SOUND_INTERFACE_H 28 #define logmsg printf ("# "); printf 30 #define logmsg empty_log 48 #define VOLUME_CUTOFF 0.001f 135 virtual void setNCars(
int n_cars) = 0;
140 bool loop =
false,
bool static_pool =
true) = 0;
147 for (
int i=0; i<4; i++) {
225 int n_cars, sgVec3 p_obs, sgVec3 u_obs,
226 sgVec3 c_obs = NULL, sgVec3 a_obs = NULL)
235 fprintf (stderr,
"Warning, gain setting not supported\n");
306 bool loop =
false,
bool static_pool =
true);
342 alGenSources(1, &(
pool[i].source));
343 int error = alGetError();
344 if (error != AL_NO_ERROR) {
345 printf(
"OpenAL error, allocating dynamic source index %d\n", i);
350 printf(
" Dynamic Sources: requested: %d, created: %d\n",
nbsources, this->nbsources);
356 alDeleteSources(1, &(
pool[i].source));
364 if (sound ==
pool[*index].currentOwner) {
376 int i, firstfree = -1;
378 if (
pool[i].in_use ==
false && firstfree < 0) {
399 if (sound ==
pool[*index].currentOwner) {
409 sound ==
pool[*index].currentOwner &&
410 true ==
pool[*index].in_use)
void setBackfireSound(const char *sound_name)
SoundPriState
Current state of sound.
void setRoadRideSound(const char *sound_name)
int n_static_sources_in_use
virtual float getGlobalGain()
virtual ~SharedSourcePool()
virtual void setGlobalGain(float g)
void setSkidSound(const char *sound_name)
static CarSoundData ** car_sound_data
void DopplerShift(SoundChar *sound, float *p_src, float *u_src, float *p, float *u)
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.
TorcsSound * bang_sound
sounds when suspension fully compressed
SharedSourcePool * sourcepool
int curCrashSnd
holds current crash sound used - the sound cycles
void setAxleSound(const char *sound_name)
int sortSndPriority(const void *a, const void *b)
A queue containing mappings between sounds and sound sources.
virtual void muteForMenu()
TorcsSound * bottom_crash_sound
bang when crashing from a great height
QSoundChar CarSoundData::* schar
The calculated sound characteristic.
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.
bool getSource(TorcsSound *sound, ALuint *source, bool *needs_init, int *index)
TorcsSound * curb_ride_sound
rolling on curb
void setBangSound(const char *sound_name)
virtual ~SoundInterface()
Destructor - does nothing.
void DopplerShift(SoundChar *sound, float *p_src, float *u_src, float *p, float *u)
Manages the source sound of each individual car.
static void empty_log(const char *s,...)
void setGrassSkidSound(const char *sound_name)
void setTurboSound(const char *sound_name)
void setBackfireLoopSound(const char *sound_name)
TorcsSound * backfire_loop_sound
exhaust backfire sound
virtual TorcsSound * addSample(const char *filename, int flags=(ACTIVE_VOLUME|ACTIVE_PITCH), bool loop=false, bool static_pool=true)
void setCurbRideSound(const char *sound_name)
TorcsSound * currentOwner
void SetMaxSoundCar(CarSoundData **car_sound_data, QueueSoundMap *smap)
Using the smap->id, get the appropriate entry in car_sound_data and call apprioriate methods for smap...
TorcsSound * grass_skid_sound
skidding on dirt/grass
TorcsSound * turbo_sound
turbo spinning sound
virtual bool getStaticSource(ALuint *source)
virtual TorcsSound * addSample(const char *filename, int flags=(ACTIVE_VOLUME|ACTIVE_PITCH), bool loop=false, bool static_pool=true)
TorcsSound * road_ride_sound
rolling on normal road
void setMetalSkidSound(const char *sound_name)
virtual void update(CarSoundData **car_sound_data, int n_cars, sgVec3 p_obs, sgVec3 u_obs, sgVec3 c_obs, sgVec3 a_obs)
virtual slScheduler * getScheduler()
virtual void update(CarSoundData **car_sound_data, int n_cars, sgVec3 p_obs, sgVec3 u_obs, sgVec3 c_obs=NULL, sgVec3 a_obs=NULL)
QueueSoundMap backfire_loop
static const int OSI_MIN_DYNAMIC_SOURCES
Define this to use the OpenAL Doppler.
struct PlibSoundInterface::SoundChar_ SoundChar
int n_channels
number of channels
TorcsSound * snd
The raw sound.
SoundPri * engpri
the engine priority, used for sorting
virtual void SetMaxSoundCar(CarSoundData **car_sound_data, QueueSoundMap *smap)
struct OpenalSoundInterface::SoundChar_ SoundChar
OpenalSoundInterface(float sampling_rate, int n_channels)
virtual float getGlobalGain()
void SortSingleQueue(CarSoundData **car_sound_data, QueueSoundMap *smap, int n_cars)
Find the max amplitude sound in car_sound_data and put it in smap.
struct SoundPri_ SoundPri
Sound priority, used to sort cars according to amplitude attenuation.
void setBottomCrashSound(const char *sound_name)
TorcsSound * backfire_sound
one-off backfire sound
QueueSoundMap road
The following are mappings for sound prioritisation.
This is the race information structures.
float sampling_rate
sampling rate
std::vector< TorcsSound * > sound_list
keeps track of sounds used
virtual void setGlobalGain(float g)
virtual void setNCars(int n_cars)
TorcsSound * gear_change_sound
sound when changing gears
void setGearChangeSound(const char *sound_name)
struct QueueSoundMap_ QueueSoundMap
A queue containing mappings between sounds and sound sources.
virtual ~OpenalSoundInterface()
virtual void initSharedSourcePool()
initialised the pool of shared sources
void setCrashSound(const char *sound_name, int index)
SharedSourcePool(int nbsources)
virtual void initSharedSourcePool()
int n_engine_sounds
number of simultaneous engines
virtual ~PlibSoundInterface()
virtual SharedSourcePool * getSourcePool(void)
std::vector< TorcsSound * > sound_list
SoundInterface(float sampling_rate, int n_channels)
Make a new sound interface.
TorcsSound * crash_sound[NB_CRASH_SOUND]
list of crash sounds
int OSI_MAX_STATIC_SOURCES
void setGrassRideSound(const char *sound_name)
TorcsSound * metal_skid_sound
metal skidding on metal
TorcsSound * grass_ride_sound
rolling on dirt/grass
virtual float getGlobalGain()
PlibSoundInterface(float sampling_rate, int n_channels)
void SetMaxSoundCar(CarSoundData **car_sound_data, QueueSoundMap *smap)
virtual void setNCars(int n_cars)
bool isSourceActive(TorcsSound *sound, int *index)
virtual void muteForMenu()
virtual void setNCars(int n_cars)=0
Set the number of cars - must be defined in children classes.
virtual void setGlobalGain(float g)
TorcsSound * axle_sound
axle/gear spinning sound
TorcsSound * skid_sound[4]
set of skid sounds, one per tyre
int id
The id of the car producing the sound, used for retrieving doppler effects etc.
bool releaseSource(TorcsSound *sound, int *index)
Sound priority, used to sort cars according to amplitude attenuation.