本文整理汇总了C++中PlaySample函数的典型用法代码示例。如果您正苦于以下问题:C++ PlaySample函数的具体用法?C++ PlaySample怎么用?C++ PlaySample使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PlaySample函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetPosition
void MAS::SpinBox::HandleEvent(Widget& obj, int msg, intptr_t arg1, intptr_t arg2) {
if (msg == MSG_ACTIVATE) {
if (obj == bUp) {
double oldpos = pos;
SetPosition(editBox.GetDouble());
Increment();
if (oldpos != pos) {
PlaySample(Skin::SAMPLE_SCROLL);
GetParent()->HandleEvent(*this, MSG_SCROLL, (intptr_t)GetIncrement());
}
}
else if (obj == bDown) {
double oldpos = pos;
SetPosition(editBox.GetDouble());
Decrement();
if (oldpos != pos) {
PlaySample(Skin::SAMPLE_SCROLL);
GetParent()->HandleEvent(*this, MSG_SCROLL, -(intptr_t)GetIncrement());
}
}
else {
GetParent()->HandleEvent(*this, callbackID >= 0 ? callbackID : MSG_ACTIVATE);
}
}
else if (msg == MSG_UCHAR && obj == editBox) {
if (integerMode) {
SetPosition(editBox.GetInt());
}
else {
ScrollObject::SetPosition(editBox.GetDouble());
}
}
}
示例2: Minimize
void MAS::Window::HandleEvent(MAS::Widget &obj, int msg, intptr_t arg1, intptr_t arg2) {
Dialog::HandleEvent(obj, msg, arg1, arg2);
if (msg == MSG_ACTIVATE) {
if (obj == iconMin) {
Minimize();
}
else if (obj == iconMax) {
Maximize();
}
}
else if (msg == MSG_DCLICK) {
if (obj == bGrip || obj == textBack || obj == title) {
if (TestFlag(D_RESIZABLE)) {
if (extraFlags & W_MAXIMIZED) {
PlaySample(Skin::SAMPLE_CLOSE);
}
else {
PlaySample(Skin::SAMPLE_OPEN);
}
Maximize();
}
}
}
else if (msg == MSG_CLOSE && obj == *clientArea) {
Close();
}
}
示例3: ASSERTPTR
void CSoundPlayer::PlayPosSample(enum TIngameSoundEffect aEffect,float aVolume, CCoord<int> aPos)
{
ASSERTPTR( iDynData );
if (aEffect==ESoundEffectNoSound) return;
if (iObserver)
iObserver->SoundHeard(aEffect,aVolume,aPos);
if (!iInitialized)
return;
if (iDynData->LocalPlayers().size()!=1)
{
PlaySample(iDynData->LevelRuntime()->IngameData()->SoundFX(aEffect),aVolume,PAN_MIDDLE);
return;
}
int chan=Mix_PlayChannel(-1,iDynData->LevelRuntime()->IngameData()->SoundFX(aEffect),0);
Mix_Volume(chan,(int)(aVolume*iFXVolume*127.0));
int left, right;
StereoShaper( iDynData->LocalPlayers()[0]->Location(),aPos, left, right );
Mix_SetPanning(chan, left, right );
}
示例4: PlaySample
void COpenALSound::PlaySample(int id, float volume)
{
if (!camera) {
return;
}
PlaySample(id, float3(0, 0, 0), volume, true);
}
示例5: ResetParams
void generator::GenerateBasicPowerUp(void)
{
ResetParams();
if(rnd(1)) {
wave_type=1;
} else {
p_duty=frnd(0.6f);
}
if(rnd(1)) {
p_base_freq=0.2f+frnd(0.3f);
p_freq_ramp=0.1f+frnd(0.4f);
p_repeat_speed=0.4f+frnd(0.4f);
} else {
p_base_freq=0.2f+frnd(0.3f);
p_freq_ramp=0.05f+frnd(0.2f);
if(rnd(1)) {
p_vib_strength=frnd(0.7f);
p_vib_speed=frnd(0.6f);
}
}
p_env_attack=0.0f;
p_env_sustain=frnd(0.4f);
p_env_decay=0.1f+frnd(0.4f);
PlaySample();
}
示例6: RandomLocal
int JukeBox::Play(const std::string& category, const std::string& sample,
const int loop)
{
if (!Config::GetInstance()->GetSoundEffects() || !m_init) return -1;
uint nb_sounds= m_soundsamples.count(category+ "/" +sample);
if (nb_sounds) {
std::pair<sample_iterator, sample_iterator> p =
m_soundsamples.equal_range(category+ "/" +sample);
sample_iterator it = p.first;
// Choose a random sound sample
if (nb_sounds > 1) {
uint selection = RandomLocal().GetUint(0, nb_sounds);
if (selection == nb_sounds) --selection ;
it = p.first ;
for (uint i=0; i<selection && it!=p.second; ++i) it++ ;
}
// Play the sound
Mix_Chunk * sampleChunk = m_cache.LoadSound(it->second.filename.c_str());
MSG_DEBUG("jukebox.play", "Playing sample %s/%s",
category.c_str(), sample.c_str());
return PlaySample(sampleChunk, it->second.level, loop);
} else if (category != "default") {
return Play("default", sample, loop) ; // try with default profile
}
std::cerr << "Sound error: No sound found for sample" << category.c_str()
<< "/" << sample.c_str() << std::endl;
return -1;
}
示例7: PlayUnitSound
/**
** Ask to the sound server to play a sound attached to a unit. The
** sound server may discard the sound if needed (e.g., when the same
** unit is already speaking).
**
** @param unit Sound initiator, unit speaking
** @param voice Type of sound wanted (Ready,Die,Yes,...)
*/
void PlayUnitSound(const CUnit &unit, UnitVoiceGroup voice)
{
CSound *sound = ChooseUnitVoiceSound(unit, voice);
if (!sound) {
return;
}
bool selection = (voice == VoiceSelected || voice == VoiceBuilding);
Origin source = {&unit, unsigned(UnitNumber(unit))};
//Wyrmgus start
// if (UnitSoundIsPlaying(&source)) {
if (UnitSoundIsPlaying(&source) && voice != VoiceHit && voice != VoiceMiss && voice != VoiceStep) {
//Wyrmgus end
return;
}
int channel = PlaySample(ChooseSample(sound, selection, source), &source);
if (channel == -1) {
return;
}
//Wyrmgus start
// SetChannelVolume(channel, CalculateVolume(false, ViewPointDistanceToUnit(unit), sound->Range));
SetChannelVolume(channel, CalculateVolume(false, ViewPointDistanceToUnit(unit), sound->Range) * sound->VolumePercent / 100);
//Wyrmgus end
SetChannelStereo(channel, CalculateStereo(unit));
//Wyrmgus start
SetChannelVoiceGroup(channel, voice);
//Wyrmgus end
}
示例8: PlayMissileSound
/**
** Ask the sound server to play a sound for a missile.
**
** @param missile Sound initiator, missile exploding
** @param sound Sound to be generated
*/
void PlayMissileSound(const Missile &missile, CSound *sound)
{
if (!sound) {
return;
}
int stereo = ((missile.position.x + (missile.Type->G ? missile.Type->G->Width / 2 : 0) +
UI.SelectedViewport->MapPos.x * PixelTileSize.x) * 256 /
((UI.SelectedViewport->MapWidth - 1) * PixelTileSize.x)) - 128;
clamp(&stereo, -128, 127);
Origin source = {NULL, 0};
//Wyrmgus start
// unsigned char volume = CalculateVolume(false, ViewPointDistanceToMissile(missile), sound->Range);
unsigned char volume = CalculateVolume(false, ViewPointDistanceToMissile(missile), sound->Range) * sound->VolumePercent / 100;
//Wyrmgus end
if (volume == 0) {
return;
}
int channel = PlaySample(ChooseSample(sound, false, source));
if (channel == -1) {
return;
}
SetChannelVolume(channel, volume);
SetChannelStereo(channel, stereo);
}
示例9: ResetParams
void sfxr::PowerupButtonPressed()
{
ResetParams();
if(rnd(1))
wave_type=1;
else
p_duty=frnd(0.6f);
if(rnd(1))
{
p_base_freq=0.2f+frnd(0.3f);
p_freq_ramp=0.1f+frnd(0.4f);
p_repeat_speed=0.4f+frnd(0.4f);
}
else
{
p_base_freq=0.2f+frnd(0.3f);
p_freq_ramp=0.05f+frnd(0.2f);
if(rnd(1))
{
p_vib_strength=frnd(0.7f);
p_vib_speed=frnd(0.6f);
}
}
p_env_attack=0.0f;
p_env_sustain=frnd(0.4f);
p_env_decay=0.1f+frnd(0.4f);
PlaySample();
}
示例10: PlaySample
void sfxr::MutateButtonPressed()
{
if(rnd(1)) p_base_freq+=frnd(0.1f)-0.05f;
//if(rnd(1)) p_freq_limit+=frnd(0.1f)-0.05f;
if(rnd(1)) p_freq_ramp+=frnd(0.1f)-0.05f;
if(rnd(1)) p_freq_dramp+=frnd(0.1f)-0.05f;
if(rnd(1)) p_duty+=frnd(0.1f)-0.05f;
if(rnd(1)) p_duty_ramp+=frnd(0.1f)-0.05f;
if(rnd(1)) p_vib_strength+=frnd(0.1f)-0.05f;
if(rnd(1)) p_vib_speed+=frnd(0.1f)-0.05f;
if(rnd(1)) p_vib_delay+=frnd(0.1f)-0.05f;
if(rnd(1)) p_env_attack+=frnd(0.1f)-0.05f;
if(rnd(1)) p_env_sustain+=frnd(0.1f)-0.05f;
if(rnd(1)) p_env_decay+=frnd(0.1f)-0.05f;
if(rnd(1)) p_env_punch+=frnd(0.1f)-0.05f;
if(rnd(1)) p_lpf_resonance+=frnd(0.1f)-0.05f;
if(rnd(1)) p_lpf_freq+=frnd(0.1f)-0.05f;
if(rnd(1)) p_lpf_ramp+=frnd(0.1f)-0.05f;
if(rnd(1)) p_hpf_freq+=frnd(0.1f)-0.05f;
if(rnd(1)) p_hpf_ramp+=frnd(0.1f)-0.05f;
if(rnd(1)) p_pha_offset+=frnd(0.1f)-0.05f;
if(rnd(1)) p_pha_ramp+=frnd(0.1f)-0.05f;
if(rnd(1)) p_repeat_speed+=frnd(0.1f)-0.05f;
if(rnd(1)) p_arp_speed+=frnd(0.1f)-0.05f;
if(rnd(1)) p_arp_mod+=frnd(0.1f)-0.05f;
PlaySample();
}
示例11: HideHelpers
void TThor::GoOverground(int over)
{
int i;
if (over == IsOverground) return;
if (TimeUnits < 30) {
if (ID < BADLIFE) Message(MSG_OUT_OF_TIME);
return;
}
TimeUnits -= 30;
IsOverground = over;
HideHelpers();
if (GetField(X, Y)->Visib == 2) {
if (over) PlaySample(GetUnitSound(6), 6, EffectsVolume, GetFieldPanning(X, Y));
else PlaySample(GetUnitSound(7), 6, EffectsVolume, GetFieldPanning(X, Y));
}
if (over) {
for (i = 9; i < 16; i++) {
ActualSprite = i;
PaintUnit();
SDL_Delay(iniAnimDelay2);
}
Orient = 3; ActualSprite = 3;
Weapons[0]->Ammo = 8;
TotalRockets -= 8;
if (TotalRockets < 0) {
Weapons[0]->Ammo += TotalRockets;
TotalRockets = 0;
}
Defense[0] = -utTH_DND0, Defense[1] -= utTH_DND1, Defense[2] -= utTH_DND2;
}
else {
Rotate(3);
for (i = 15; i > 8; i--) {
ActualSprite = i;
PaintUnit();
SDL_Delay(iniAnimDelay2);
}
ActualSprite = 8;
TotalRockets += Weapons[0]->Ammo;
Weapons[0]->Ammo = 0;
Defense[0] += utTH_DND0, Defense[1] += utTH_DND1, Defense[2] += utTH_DND2;
}
ShowHelpers();
PaintUnit();
}
示例12: PlaySoundFile
/**
** Play a sound file
**
** @param name Filename of a sound to play
**
** @return Channel number the sound is playing on, -1 for error
*/
int PlaySoundFile(const std::string &name)
{
CSample *sample = LoadSample(name);
if (sample) {
return PlaySample(sample);
}
return -1;
}
示例13: ExportWAV
bool ExportWAV(char* filename)
{
FILE* foutput=fopen(filename, "wb");
if(!foutput)
return false;
// write wav header
char string[32];
unsigned int dword=0;
unsigned short word=0;
fwrite("RIFF", 4, 1, foutput); // "RIFF"
dword=0;
fwrite(&dword, 1, 4, foutput); // remaining file size
fwrite("WAVE", 4, 1, foutput); // "WAVE"
fwrite("fmt ", 4, 1, foutput); // "fmt "
dword=16;
fwrite(&dword, 1, 4, foutput); // chunk size
word=1;
fwrite(&word, 1, 2, foutput); // compression code
word=1;
fwrite(&word, 1, 2, foutput); // channels
dword=wav_freq;
fwrite(&dword, 1, 4, foutput); // sample rate
dword=wav_freq*wav_bits/8;
fwrite(&dword, 1, 4, foutput); // bytes/sec
word=wav_bits/8;
fwrite(&word, 1, 2, foutput); // block align
word=wav_bits;
fwrite(&word, 1, 2, foutput); // bits per sample
fwrite("data", 4, 1, foutput); // "data"
dword=0;
int foutstream_datasize=ftell(foutput);
fwrite(&dword, 1, 4, foutput); // chunk size
// write sample data
mute_stream=true;
file_sampleswritten=0;
filesample=0.0f;
fileacc=0;
PlaySample();
while(playing_sample)
SynthSample(256, NULL, foutput);
mute_stream=false;
// seek back to header and write size info
fseek(foutput, 4, SEEK_SET);
dword=0;
dword=foutstream_datasize-4+file_sampleswritten*wav_bits/8;
fwrite(&dword, 1, 4, foutput); // remaining file size
fseek(foutput, foutstream_datasize, SEEK_SET);
dword=file_sampleswritten*wav_bits/8;
fwrite(&dword, 1, 4, foutput); // chunk size (data)
fclose(foutput);
return true;
}
示例14: OnPickup
void Pickup::OnCollision(Entity *e)
{
if(e == game.player)
{
OnPickup();
alive = false;
PlaySample((SAMPLE *) game.GetData("snd_pickup"));
}
}
示例15: PlayGameSound
/**
** Play a game sound
**
** @param sound Sound to play
** @param volume Volume level to play the sound
*/
void PlayGameSound(CSound *sound, unsigned char volume)
{
Origin source = {NULL, 0};
int channel = PlaySample(ChooseSample(sound, false, source));
if (channel == -1) {
return;
}
SetChannelVolume(channel, CalculateVolume(true, volume, sound->Range));
}