/** * @brief Validates the parms and queues the sound up * @param[in] origin if this is @c nullptr, the sound will be dynamically sourced from the entity * @param[in] sample The soundfile to play * @param[in] atten Attenuation of sound to be played (for example, @c fireAttenuation * or @c impactAttenuation from @c fireDef_s). * @param[in] relVolume Max mixer volume factor (0.0 - 1.0) * @sa S_StartLocalSample * @sa S_SetVolume */ void S_PlaySample (const vec3_t origin, s_sample_t* sample, float atten, float relVolume) { s_channel_t* ch; int i; float volume; if (!s_env.initialized) return; if (!sample) return; /* if the last mix of this particular sample is less than half a second ago, skip it */ if (sample->lastPlayed > CL_Milliseconds() - s_env.sampleRepeatRate) return; if ((i = S_AllocChannel()) == -1) return; sample->lastPlayed = CL_Milliseconds(); ch = &s_env.channels[i]; ch->atten = atten; ch->sample = sample; if (origin != nullptr) { VectorCopy(origin, ch->org); S_SpatializeChannel(ch); } volume = snd_volume->value * relVolume * MIX_MAX_VOLUME; Com_DPrintf(DEBUG_SOUND, "%i: Playing sample '%s' at volume %f at channel %i\n", CL_Milliseconds(), sample->name, volume, i); Mix_VolumeChunk(ch->sample->chunk, volume); Mix_PlayChannel(i, ch->sample->chunk, 0); }
void CAudioWave::SpatializeChannel( int volume[4], int master_vol, const Vector& sourceDir, float gain, float dotRight, float dotFront ) { S_SpatializeChannel( volume, master_vol, gain, dotRight ); }