本文整理汇总了C++中Sound类的典型用法代码示例。如果您正苦于以下问题:C++ Sound类的具体用法?C++ Sound怎么用?C++ Sound使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Sound类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PlaySound
void Button::PlaySound(int n)
{
Sound* sound = 0;
switch (n) {
default:
case SND_BUTTON: if (button_sound) sound = button_sound->Duplicate(); break;
case SND_CLICK: if (click_sound) sound = click_sound->Duplicate(); break;
case SND_SWISH: if (swish_sound) sound = swish_sound->Duplicate(); break;
case SND_CHIRP: if (chirp_sound) sound = chirp_sound->Duplicate(); break;
case SND_ACCEPT: if (accept_sound) sound = accept_sound->Duplicate(); break;
case SND_REJECT: if (reject_sound) sound = reject_sound->Duplicate(); break;
case SND_CONFIRM: if (confirm_sound) sound = confirm_sound->Duplicate(); break;
case SND_LIST_SELECT: if (list_select_sound) sound = list_select_sound->Duplicate(); break;
case SND_LIST_SCROLL: if (list_scroll_sound) sound = list_scroll_sound->Duplicate(); break;
case SND_LIST_DROP: if (list_drop_sound) sound = list_drop_sound->Duplicate(); break;
case SND_COMBO_OPEN: if (combo_open_sound) sound = combo_open_sound->Duplicate(); break;
case SND_COMBO_CLOSE: if (combo_close_sound) sound = combo_close_sound->Duplicate(); break;
case SND_COMBO_HILITE: if (combo_hilite_sound) sound = combo_hilite_sound->Duplicate(); break;
case SND_COMBO_SELECT: if (combo_select_sound) sound = combo_select_sound->Duplicate(); break;
case SND_MENU_OPEN: if (menu_open_sound) sound = menu_open_sound->Duplicate(); break;
case SND_MENU_CLOSE: if (menu_close_sound) sound = menu_close_sound->Duplicate(); break;
case SND_MENU_SELECT: if (menu_select_sound) sound = menu_select_sound->Duplicate(); break;
case SND_MENU_HILITE: if (menu_hilite_sound) sound = menu_hilite_sound->Duplicate(); break;
}
if (sound) {
sound->SetVolume(gui_volume);
sound->Play();
}
}
示例2: Sound
Sound * Sound::CreateFX(const String & fileName, eType type, int32 priority /*= 0*/)
{
Sound * sound = new Sound(fileName, type, priority);
SoundSystem::Instance()->GroupFX()->AddSound(sound);
sound->Init();
return sound;
}
示例3: fread
size_t yarp::sig::file::soundStreamReader::readBlock(Sound& dest, size_t block_size)
{
int expected_bytes = block_size*(soundInfo.bits/8)*soundInfo.channels;
//this probably works only if soundInfo.bits=16
int expected_words=expected_bytes/(soundInfo.bits/8);
NetInt16 *data = new NetInt16 [expected_words];
int bytes_read = fread(data,1,expected_bytes,fp);
int samples_read = bytes_read/(soundInfo.bits/8)/soundInfo.channels;
dest.resize(samples_read,soundInfo.channels);
dest.setFrequency(soundInfo.freq);
int ct = 0;
for (int i=0; i<samples_read; i++) {
for (int j=0; j<soundInfo.channels; j++) {
dest.set(data[ct],i,j);
ct++;
}
}
index+=samples_read;
delete [] data;
return samples_read;
}
示例4: PlayStreamingSound
Sound* SoundSystem::PlayStreamingSound(SoundID soundID, int loopCount, float volumeLevel)
{
Sound* soundPicked = NULL;
SoundMap ::iterator soundIDIter = m_soundMap.find(soundID);
if(soundIDIter!= m_soundMap.end())
{
//bool playedSound = false;
Sounds& sounds = soundIDIter->second;
for (Sounds::iterator soundIter = sounds.begin(); soundIter != sounds.end(); ++soundIter)
{
Sound* sound = (*soundIter);
if(sound->IsPlaying() &&sound->IsReady())
continue;
sound->Play(loopCount,volumeLevel);
// playedSound = true;
soundPicked = sound;
break;
}
/*
if(soundPicked)
{
}
*/
}
return soundPicked ;
}
示例5: destroy_on_finish
void destroy_on_finish(ga_Handle* in_handle, void* in_context)
{
Sound* sound = (Sound*)in_handle->sound;
sound->m_Count--;
if (sound->m_Count == 0)
sound->stop();
}
示例6: NosuchDebug
std::string
Sound::nextSoundValue(int direction, std::string sound) {
if ( sound == "UNSET" )
sound = SoundBank[0][0][0];
std::map<std::string,Sound>::iterator it = Sounds.find(sound);
if ( it == Sounds.end() ) {
NosuchDebug("Hey! no sound=%s in Sound!? returning same sound",sound.c_str());
return sound;
}
int pnum = Sounds[sound].patchnum();
std::string synth = Sounds[sound].synth();
int npnum = pnum + direction;
if ( npnum < 0 )
npnum = 0;
// Go through the sounds and find the same synth with the new patchnum
it = Sounds.begin();
NosuchDebug("Looking for sound for synth=%s patchnum=%d",synth.c_str(),npnum);
for ( ; it!=Sounds.end(); it++ ) {
std::string soundname = it->first;
Sound s = it->second;
if ( s.synth() == synth && s.patchnum() == npnum ) {
NosuchDebug("Found sound! name=%s",soundname.c_str());
return soundname;
}
}
NosuchErrorOutput("Unable to find next sound dir=%d sound=%s",direction,sound.c_str());
return sound;
}
示例7: DxFont
void TestScene::Init()
{
font = new DxFont();
this->AppendObject(font, 1, true);
this->AppendItemBox("font", font);
tex = new Texture("soccerball.png");
sprite = new Sprite(tex);
this->AppendItemBox("tex", tex);
this->AppendItemBox("sprite", sprite);
r=0.f;
AppendObject(new BGMusic("Kalimba.mp3"), 5, "BGM", true);
AppendItemBox("BGM", FindObject("BGM"));
bgm = dynamic_cast<BGMusic*>(this->FindItemBox("BGM"));
//if(bgm) bgm->Play();
input = (Input*)FindObject("input");
if(input == NULL){
input = new Input();
AppendObject(input, 0, "input", true);
}
sound.Load("missile.wav");
Sound *se = new Sound(*(Sound*)FindItemBox("burst"));
//se->EnableDeleteByEnd();
se->Play();
}
示例8:
Sound*
SoundD3D::Duplicate()
{
Sound* sound = 0;
if (flags & RESOURCE) {
sound = Sound::Create(flags & ~RESOURCE, &wfex);
if (sound && !(flags & STREAMED)) {
sound->SetMinDistance(min_dist);
sound->SetMaxDistance(max_dist);
if (!buffer) {
sound->Load(data_len, data);
}
else {
SoundD3D* s3d = (SoundD3D*) sound;
soundcard->DuplicateSoundBuffer(buffer, &s3d->buffer);
sound->Rewind();
}
}
}
return sound;
}
示例9: WPN_Init
void WPN_Init(TextureManager& textureManager, Sound& sound, Console& console)
{
std::set<Int32> nearestFilterBoom = { 5, 6, 9, 13, 14, 15, 16 };
console.printLine("\n===Weapon initialization===");
for (Weapon& weap : d6WpnDef)
{
const std::string wpnPath = Format("{0}{1,3|0}") << D6_TEXTURE_WPN_PATH << weap.index;
weap.textures.boom = textureManager.load(Format("{0}/boom/") << wpnPath, nearestFilterBoom.find(weap.index) != nearestFilterBoom.end() ? GL_NEAREST : GL_LINEAR, true);
weap.textures.gun = textureManager.load(Format("{0}/gun/") << wpnPath, GL_NEAREST, true);
weap.textures.shot = textureManager.load(Format("{0}/shot/") << wpnPath, GL_NEAREST, true);
if (weap.shotSound)
{
weap.shotSample = sound.loadSample(std::string(D6_FILE_WEAPON_SOUNDS) + weap.shotSound);
}
if (weap.boomSound)
{
weap.boomSample = sound.loadSample(std::string(D6_FILE_WEAPON_SOUNDS) + weap.boomSound);
}
}
Color brownColor(83, 44, 0);
PlayerSkinColors skinColors(brownColor);
brownSkin = std::make_unique<PlayerSkin>("textures/man/", skinColors, textureManager);
}
示例10: QSound
void Sound::play(int name)
{
if (!f_enabled) {
return;
}
Sound* sound = f_sound_objects.value(name);
if (!sound || !sound->isValid()) {
return;
}
QSound* qsound = 0;
QList<QSound*>& sounds = f_sounds[sound->m_id];
int count = sounds.count();
for (int i = 0; i < count; ++i) {
if (sounds.at(i)->isFinished()) {
qsound = sounds.at(i);
break;
}
}
if (qsound == 0) {
qsound = new QSound(sounds.first()->fileName());
sounds.append(qsound);
}
qsound->play();
}
示例11: OnMouseClick
bool Slider::OnMouseClick()
{
if (OnMouseHover() == true)
{
if (MouseManager::GetInstance()->ButtonPressed(eMouseButtons::eLeft) == true)
{
if (myIsDraggingKnob == false)
{
Sound* SoundPtr = SoundFileHandler::GetInstance()->GetSound("ButtonClick");
SoundPtr->SetLooping(false);
SoundPtr->PlaySound();
SoundPtr->SetVolume(0.4f);
}
return true;
}
else
{
return false;
}
}
return false;
}
示例12: OnMouseHover
bool Slider::OnMouseHover()
{
if (MouseManager::GetInstance()->GetPosition().x >= myKnob->GetPosition().x - myKnob->GetSize().x / 2 &&
MouseManager::GetInstance()->GetPosition().x <= myKnob->GetPosition().x + myKnob->GetSize().x / 2)
{
if (MouseManager::GetInstance()->GetPosition().y + 0.010f >= myKnob->GetPosition().y - myKnob->GetSize().y / 2 &&
MouseManager::GetInstance()->GetPosition().y - 0.010f <= myKnob->GetPosition().y + myKnob->GetSize().y / 2)
{
if (myIsHoveringKnob == false)
{
Sound* SoundPtr = SoundFileHandler::GetInstance()->GetSound("ButtonHover");
SoundPtr->SetVolume(0.6f);
SoundPtr->SetLooping(false);
SoundPtr->PlaySound();
}
return true;
}
else
{
return false;
}
}
return false;
}
示例13:
Explosion::Explosion()
{
Sound *s = Client::getSound();
_nbrSprite = 0;
_delete = false;
s->playSound("explosion1");
}
示例14: GetMomentum
/**\brief Update function on every frame.
*/
void Ship::Update( lua_State *L ) {
Sprite::Update( L ); // update momentum and other generic sprite attributes
if( status.isAccelerating == false
&& status.isRotatingLeft == false
&& status.isRotatingRight == false) {
flareAnimation->Reset();
}
flareAnimation->Update();
Coordinate momentum = GetMomentum();
momentum.EnforceMagnitude( shipStats.GetMaxSpeed()*engineBooster );
// Show the hits taken as part of the radar color
if(IsDisabled()) SetRadarColor( GREY );
else SetRadarColor( RED * GetHullIntegrityPct() );
// Ship has taken as much damage as possible...
// It Explodes!
if( status.hullDamage >= (float)shipStats.GetHullStrength() ) {
SpriteManager *sprites = Simulation_Lua::GetSimulation(L)->GetSpriteManager();
Camera* camera = Simulation_Lua::GetSimulation(L)->GetCamera();
// Play explode sound
if(OPTION(int, "options/sound/explosions")) {
Sound *explodesnd = Sound::Get("Resources/Audio/Effects/18384__inferno__largex.wav.ogg");
explodesnd->Play( GetWorldPosition() - camera->GetFocusCoordinate());
}
// Create Explosion
sprites->Add( new Effect( GetWorldPosition(), "Resources/Animations/explosion1.ani", 0) );
// Remove this Sprite from the SpriteManager
sprites->Delete( (Sprite*)this );
}
示例15: InputMaster
void MasterControl::Start()
{
new InputMaster(context_, this);
cache_ = GetSubsystem<ResourceCache>();
graphics_ = GetSubsystem<Graphics>();
renderer_ = GetSubsystem<Renderer>();
CreateSineLookupTable();
// Get default style
defaultStyle_ = cache_->GetResource<XMLFile>("UI/DefaultStyle.xml");
//Create console and debug HUD.
CreateConsoleAndDebugHud();
//Create the scene content
CreateScene();
//Create the UI content
CreateUI();
//Hook up to the frame update and render post-update events
SubscribeToEvents();
Sound* music = cache_->GetResource<Sound>("Resources/Music/Alien Chaos - Disorder.ogg"); //Battle
music->SetLooped(true);
Node* musicNode = world.scene->CreateChild("Music");
SoundSource* musicSource = musicNode->CreateComponent<SoundSource>();
musicSource->SetGain(0.32f);
musicSource->SetSoundType(SOUND_MUSIC);
musicSource->Play(music);
}