bool Systems::SoundSystem::OnComponentCreated(const Events::ComponentCreated &event) { auto listener = std::dynamic_pointer_cast<Components::Listener>(event.Component); if(listener) { m_Listeners.push_back(listener->Entity); } auto emitter = std::dynamic_pointer_cast<Components::SoundEmitter>(event.Component); if(emitter) { FMOD_CHANNEL* channel; FMOD_SOUND* sound; std::string path = emitter->Path; float volume = emitter->Gain; bool loop = emitter->Loop; float maxDist = emitter->MaxDistance; float minDist = emitter->MinDistance; float pitch = emitter->Pitch; LoadSound(sound, path, maxDist, minDist); m_Channels.insert(std::make_pair(emitter->Entity, channel)); m_Sounds.insert(std::make_pair(emitter->Entity, sound)); } return true; }
void SoundManager::LoadSounds(short *sounds, short count) { for (short i = 0; i < count; i++) { LoadSound(sounds[i]); } }
bool World::LoadSounds() { appSounds.springSummerSound = LoadSound("Data/Sounds/Morning.ogg"); appSounds.springSummerSound->Play(); appSounds.lightningSound = LoadSound("Data/Sounds/lightning.ogg"); appSounds.fireSound = LoadSound("Data/Sounds/fire.ogg"); appSounds.bellsSound = LoadSound("Data/Sounds/sleighbells.ogg"); return appSounds.springSummerSound && appSounds.lightningSound && appSounds.fireSound && appSounds.bellsSound; // !=NULL };
void SoundManager::LPESound(char* fname, int TypePath) { uint16_t lpe=0; if(!(lpe=LoadSound(fname,TypePath))) return; PlaySound(lpe); }
CGeneral::CGeneral() { m_fSndLoaded = false; LoadFonts(); InitCursor(); LoadImages(); LoadSound(); }
ULONG ASMCALL gw_LoadSound( REG(d0, UWORD sound), REG(d1, ULONG type), REG(a0, APTR info), REG(a2, struct AHIPrivAudioCtrl* audioctrl), REG(a6, struct AHIBase* AHIBase) ) { return LoadSound( sound, type, info, audioctrl, AHIBase ); }
void WeaponDef::ParseWeaponSounds(const LuaTable& wdTable) { LoadSound(wdTable, "soundStart", 0, fireSound.sounds); LoadSound(wdTable, "soundHitDry", 0, hitSound.sounds); LoadSound(wdTable, "soundHitWet", 1, hitSound.sounds); // FIXME: do we still want or need any of this? const bool forceSetVolume = (fireSound.getVolume(0) == -1.0f) || (hitSound.getVolume(0) == -1.0f) || (hitSound.getVolume(1) == -1.0f); if (forceSetVolume) { if (damages[0] <= 50.0f) { fireSound.setVolume(0, 5.0f); hitSound.setVolume(0, 5.0f); hitSound.setVolume(1, 5.0f); } else { float fireSoundVolume = math::sqrt(damages[0] * 0.5f); if (type == "LaserCannon") { fireSoundVolume *= 0.5f; } float hitSoundVolume = fireSoundVolume; if ((fireSoundVolume > 100.0f) && ((type == "MissileLauncher") || (type == "StarburstLauncher"))) { fireSoundVolume = 10.0f * math::sqrt(hitSoundVolume); } if (damageAreaOfEffect > 8.0f) { hitSoundVolume *= 2.0f; } if (type == "DGun") { hitSoundVolume *= 0.15f; } if (fireSound.getVolume(0) == -1.0f) { fireSound.setVolume(0, fireSoundVolume); } if (hitSound.getVolume(0) == -1.0f) { hitSound.setVolume(0, hitSoundVolume); } if (hitSound.getVolume(1) == -1.0f) { hitSound.setVolume(1, hitSoundVolume); } } } }
void AddSoundsToEnt(entity_t *ent, char **files, int group) { sound_t *sound; if(!files || !ent) { return; } sound = LoadSound(files, (sound_mixer_group) group); ent->mSounds = sound; }
void plWin32StaticSound::ISetActualTime(double t) { if( !fDSoundBuffer && plgAudioSys::Active()) LoadSound( IsPropertySet( kPropIs3DSound ) ); if( fDSoundBuffer ) { if(!t) fDSoundBuffer->SetTimeOffsetSec((float)t); } }
// \brief Load a window node of the config file (sounds.xml) IAESound* CGUIAudioManager::LoadWindowSound(TiXmlNode* pWindowNode, const std::string& strIdentifier) { if (!pWindowNode) return NULL; TiXmlNode* pFileNode = pWindowNode->FirstChild(strIdentifier); if (pFileNode && pFileNode->FirstChild()) return LoadSound(URIUtils::AddFileToFolder(m_strMediaDir, pFileNode->FirstChild()->Value())); return NULL; }
ULONG gw_LoadSound( void ) { UWORD sound = (UWORD) REG_D0; ULONG type = (ULONG) REG_D1; APTR info = (APTR) REG_A0; struct AHIPrivAudioCtrl* audioctrl = (struct AHIPrivAudioCtrl*) REG_A2; struct AHIBase* AHIBase = (struct AHIBase*) REG_A6; return LoadSound( sound, type, info, audioctrl, AHIBase ); }
ULONG gw_LoadSound( struct _Regs* regs ) { UWORD sound = (UWORD) GET_LONG( regs->d0 ); ULONG type = (ULONG) GET_LONG( regs->d1 ); APTR info = (APTR) GET_LONG( regs->a0 ); struct AHIPrivAudioCtrl* audioctrl = (struct AHIPrivAudioCtrl*) GET_LONG( regs->a2 ); struct AHIBase* AHIBase = (struct AHIBase*) GET_LONG( regs->a6 ); return LoadSound( sound, type, info, audioctrl, AHIBase ); }
static bool LoadResources(SResources& _Res) { _Res.albuf_mono = LoadSound(DResourcesRoot "sonar.wav"); if (_Res.albuf_mono == 0) return false; _Res.albuf_stereo = LoadSound(DResourcesRoot "bark.wav"); if (_Res.albuf_stereo == 0) return false; _Res.albuf_monoloop = LoadSound(DResourcesRoot "mosquitoloop.wav"); if (_Res.albuf_monoloop == 0) return false; _Res.albuf_stereoloop = LoadSound(DResourcesRoot "rainloop.wav"); if (_Res.albuf_stereoloop == 0) return false; return true; }
CGeneral::CGeneral(): m_iPrevGirl(0), m_iPrevGirlColor(0), m_iCurMusic(-1) { LoadImages(); LoadFonts(); LoadMusic(); LoadSound(); InitCursor(); }
RocketLauncher::RocketLauncher(RenderWindow* window, b2World* World, TempObjectHandler* toh, float PositionX, float PositionY, int Ammunition, Snail* user):Weapon(window, World, toh, PositionX, PositionY, Ammunition){ User=user; damage=15; clipsize=1; clip=clipsize; ammunition=Ammunition-clip; firespeed=0.2; CreateBody(PositionX,PositionY, 72.5, 10); LoadImage("contents/rocketluncher2.png", weaponImg, WeaponSp); WeaponSp.SetCenter(weaponshapeDef.vertices[2].x,weaponshapeDef.vertices[2].y+6.5); LoadImage("contents/tt2.png", muzzleImg, MuzzleSp); MuzzleSp.SetCenter(3,87); MuzzleSp.SetScale(0.5,0.5); LoadSound("contents/RocketLauncher.wav", WeaponFireSoundBuffer, WeaponFireSound); LoadSound("contents/flak_reload.wav", WeaponReloadSoundBuffer, WeaponReloadSound); LoadSound("contents/Sound 837 clip out 1.wav", WeaponOutOfAmmoSoundBuffer, WeaponOutOfAmmoSound); jointX=30; jointY=-15; }
//============================================================================================== // ゲームメイン処理 //============================================================================================== void GameMain(void) { TIMECAPS Caps; timeGetDevCaps(&Caps, sizeof(TIMECAPS)); // 性能取得 timeBeginPeriod(Caps.wPeriodMin); // 設定 HDC hDC_Back = CreateEmptyBMP(hDC_Wnd, pWid, pHei); HDC hDC_Wheel = LoadBMPfromFile(hDC_Wnd, TEXT("wheel.bmp")); HDC hDC_Block = LoadBMPfromResourceSTR(hDC_Wnd, hInst, TEXT("IDB_BLOCKIDB_BLOCK")); HDC hDC_org = LoadBMPfromResourceSTR(hDC_Wnd, hInst, TEXT("IDB_ORG")); HDC hDC_Mask = CreateMask(hDC_org, RGB(0, 0, 0)); HANDLE hfile; DWORD file_size, read_byte; mciSendString(_T("close BGM"), NULL, 0, NULL); // (前回ちゃんと閉じられなかったかも…) mciSendString(_T("open SHOOT!.mid type sequencer alias BGM"), NULL, 0, NULL); // 開く TCHAR BGMStatus[256] = { 0 }; mciSendString(_T("status BGM mode"), BGMStatus, 256, NULL); // 状態の取得 if (lstrcmp(BGMStatus, TEXT("stopped")) == 0) { mciSendString(TEXT("play BGM from 0"), NULL, 0, NULL); // 停止中なら演奏 } Sleep(15000); LPCTSTR Sound = LoadSound(_T("notify.wav")); PlaySound(Sound, NULL, SND_ASYNC | SND_MEMORY); //メインループ while (!EndFlag) { const DWORD StartTime = timeGetTime(); //~ ゲーム処理いろいろ ~ //PatBlt(hDC_Back, 0, 0, pWid, pHei, WHITENESS); BitBlt(hDC_Back, 0, 0, 32, 32, hDC_Wheel, 0, 0, SRCCOPY); BitBlt(hDC_Back, 64, 0, 32, 32, hDC_Block, 0, 0, SRCCOPY); //SpriteBlt(hDC_Back, 32, 0, 32, 32, hDC_org, 0, 0, hDC_Mask); BitBlt(hDC_Wnd, 0, 0, pWid, pHei, hDC_Back, 0, 0, SRCCOPY); const DWORD PassTime = timeGetTime() - StartTime; // 経過時間の計算 (1000 / FPS > PassTime) ? Wait(1000 / FPS - PassTime) : Wait(0); // 待つ。 mciSendString(TEXT("status BGM mode"), BGMStatus, 256, NULL); // 状態の取得 if (lstrcmp(BGMStatus, TEXT("stopped")) == 0) { mciSendString(TEXT("play BGM from 0"), NULL, 0, NULL); // 停止中なら演奏 } FPSCount(&fps); // FPS の計測 } timeEndPeriod(Caps.wPeriodMin); // 後処理 HeapFree(GetProcessHeap(), 0, (LPVOID)Sound); // 解放 DeleteDC(hDC_Wheel); DeleteDC(hDC_Block); }
enum ActionMenu StageMain(int *stageState, char *mapName) { static int bgm = - 1; static char name[MAX_PATH]; switch (*stageState) { case 0: map = ReadMap(mapName); #if !MAP_EDIT_MODE GetBgmName(name, mapName); bgm = LoadSound(name); #endif *stageState = 1; break; case 1: { InitMap(map); CreateObject(map); DrawMain = StageDraw; LoopSound(bgm); *stageState = 2; } break; case 2: MoveMap(map); MoveEnemy(map); MoveItem(map); MoveBomb(map); MoveEnemy(map); MovePlayer(map); if (IsPlayerDie()) { SoundPlay(res.sound_die); life--; if (life < 0) { FreeStage(map, stageState, bgm); return MENU_GAMEOVER; } *stageState = 1; } if (IsPlayerClear()) { FreeStage(map, stageState, bgm); return MENU_CLEAR; } break; } return MENU_STAGE; }
void SoundManager::PlaySound(short sound_index, world_location3d *source, short identifier, // NONE is no identifer and the sound is immediately orphaned _fixed pitch) // on top of all existing pitch modifiers { /* donÕt do anything if weÕre not initialized or active, or our sound_code is NONE, or our volume is zero, our we have no sound channels */ if (sound_index!=NONE && active && sound_index < number_of_sound_definitions && parameters.volume > 0 && total_channel_count > 0) { Channel::Variables variables; CalculateInitialSoundVariables(sound_index, source, variables, pitch); /* make sure the sound data is in memory */ if (LoadSound(sound_index)) { Channel *channel = BestChannel(sound_index, variables);; /* get the channel, and free it for our new sound */ if (channel) { /* set the volume and pitch in this channel */ InstantiateSoundVariables(variables, *channel, true); /* initialize the channel */ channel->flags= 0; channel->callback_count= 0; // #MD channel->start_tick= machine_tick_count(); channel->sound_index= sound_index; channel->identifier= identifier; channel->dynamic_source= (identifier==NONE) ? (world_location3d *) NULL : source; MARK_SLOT_AS_USED(channel); /* start the sound playing */ BufferSound(*channel, sound_index, pitch); /* if we have a valid source, copy it, otherwise remember that we donÕt */ if (source) { channel->source= *source; } else { channel->flags|= _sound_is_local; } } } } }
void AudioCache::LoadPlayerResources() { mPlayerSound.insert({ PlayerSound::Collect_Speed, LoadSound("player_collect_speed.wav") }); mPlayerSound.insert({ PlayerSound::Collect_Bombs, LoadSound("player_collect_bombs.wav") }); mPlayerSound.insert({ PlayerSound::Collect_Range, LoadSound("player_collect_range.wav") }); mPlayerSound.insert({ PlayerSound::Collect_InfiniteRange, LoadSound("player_collect_infiniterange.wav") }); mPlayerSound.insert({ PlayerSound::Spawn, LoadSound("player_spawn.wav") }); mPlayerSound.insert({ PlayerSound::Destroy, LoadSound("player_die.wav") }); // mPlayerSound.insert({ PlayerSound::Win, LoadSound("player_.wav") }); }
//初始化· void CGeneralManager::Init() { LoadGameAnim(); LoadHighScore(); LoadSound(); //获取上一次的声音设置 m_bSoundOn = GET_BOOLVALUE("SOUND", true); //清除之前记录的一些数据 SET_INTVALUE("GAME", 0); SET_INTVALUE("SPEED", 0); SET_INTVALUE("LEVEL", 0); }
void AudioEngine::PlaySound(const std::string& filename) { map<std::string, AudioCacheElement>::iterator element = _audio_cache.find(filename); if (element == _audio_cache.end()) { if (LoadSound(filename) == false) { IF_PRINT_WARNING(AUDIO_DEBUG) << "could not play sound from cache because the sound could not be loaded" << endl; return; } else { element = _audio_cache.find(filename); } } element->second.audio->Play(); element->second.last_update_time = SDL_GetTicks(); }
int main() { // Initialization //-------------------------------------------------------------------------------------- int screenWidth = 800; int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib test - ogg audio loading and playing"); InitAudioDevice(); // Initialize audio device Sound fx = LoadSound("resources/audio/0564.ogg"); // Load audio file //-------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- if (IsKeyPressed(KEY_SPACE)) PlaySound(fx); // Play the sound! //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); DrawText("Press SPACE to PLAY the SOUND!", 240, 200, 20, LIGHTGRAY); EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- UnloadSound(fx); // Unload sound data CloseAudioDevice(); // Close audio device CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; }
void Game::Init() { LoadSound(); isGame = false; letra = new Letra(wnd_ancho,wnd_alto,1); zone = new Zone(wnd_ancho,wnd_alto); circulo = new Circulo(wnd_ancho,wnd_alto); vidas = 5; puntos = 0; extra_pnt = 0; count_letras = 0; hud = new Hud(wnd_ancho,wnd_alto); hud->UpdatePuntos(puntos); hud->UpdateVidas(vidas); hud->Enable(true); }
bool SDLPlaySound(const char *filename, bool sfxr) { ResetParams(); bool ok = SDLSoundInit() && LoadSound(filename, sfxr); if (ok) { if (cursnd.sfxr) { ResetSample(false); } else { cursndpos = cursnd.buf; } SDL_PauseAudioDevice(audioid, 0); playing_sample=true; } return ok; }
void SoundManager::DirectPlaySound(short sound_index, angle direction, short volume, _fixed pitch) { /* donÕt do anything if weÕre not initialized or active, or our sound_code is NONE, or our volume is zero, our we have no sound channels */ if (sound_index != NONE && active && sound_index < number_of_sound_definitions && parameters.volume > 0 && total_channel_count > 0) { if (LoadSound(sound_index)) { Channel::Variables variables; Channel *channel = BestChannel(sound_index, variables); if (channel) { world_location3d *listener = _sound_listener_proc(); variables.priority = 0; variables.volume = volume; if (direction = NONE || !listener) { variables.left_volume = variables.right_volume = volume; } else { AngleAndVolumeToStereoVolume(direction - listener->yaw, volume, &variables.right_volume, &variables.left_volume); } InstantiateSoundVariables(variables, *channel, true); /* initialize the channel */ channel->flags = _sound_is_local; // but possibly being played in stereo channel->callback_count = 0; channel->start_tick = machine_tick_count(); channel->sound_index = sound_index; channel->dynamic_source = 0; MARK_SLOT_AS_USED(channel); /* start the sound playing */ BufferSound(*channel, sound_index, pitch); } } } }
void AudioEngine::PlaySound(const std::string &filename) { std::map<std::string, AudioCacheElement>::iterator element = _audio_cache.find(filename); if(element == _audio_cache.end()) { // Don't check the current game mode to prevent the sound unloading in certain cases. // We'll let the audio cache handle it all atm. if(!LoadSound(filename)) { IF_PRINT_WARNING(AUDIO_DEBUG) << "could not play sound from cache because " "the sound could not be loaded" << std::endl; return; } else { element = _audio_cache.find(filename); } } element->second.audio->Play(); element->second.last_update_time = SDL_GetTicks(); }
void digi_load_sounds() { int i, sound_num; if (!digi_initialized) return; if ( RegisterSounds(sound_list, 1) ) digi_close(); // on low memory conditions, we need to release sounds from the registered // set so the memory can be freed. The call to RegisterSounds only registers // them with halestorm. We will use LoadSound to actually load those sounds that // we intend to use. for (i = 0; i < MAX_SOUNDS; i++) { sound_num = digi_xlat_sound(i); if (sound_num != -1) LoadSound(sound_num); // load the sound into memory..hales says this is locked high in heap } }
static void SoundLoadDirImpl( SoundDevice *s, const char *path, const char *prefix) { tinydir_dir dir; if (tinydir_open(&dir, path) == -1) { LOG(LM_MAIN, LL_ERROR, "Cannot open sound dir '%s'", path); goto bail; } for (; dir.has_next; tinydir_next(&dir)) { tinydir_file file; if (tinydir_readfile(&dir, &file) == -1) { LOG(LM_MAIN, LL_ERROR, "Cannot read sound file '%s'", file.path); continue; } char buf[CDOGS_PATH_MAX]; if (prefix != NULL) { sprintf(buf, "%s/%s", prefix, file.name); } else { strcpy(buf, file.name); } if (file.is_reg) { LoadSound(s, buf, file.path); } else if (file.is_dir && file.name[0] != '.') { SoundLoadDirImpl(s, file.path, buf); } } bail: tinydir_close(&dir); }
//////////////////////////////////////////////////////////// /// Point d'entr�e du programme /// /// \return Code d'erreur de l'application /// //////////////////////////////////////////////////////////// int main_lecture(char *fichier) { // Initialisation d'OpenAL InitOpenAL_lecture(NULL); //NULL = device par d�fault // Chargement du fichier audio ALuint Buffer = LoadSound(fichier); if (Buffer == 0) return EXIT_FAILURE; // Cr�ation d'une source ALuint Source; alGenSources(1, &Source); alSourcei(Source, AL_BUFFER, Buffer); // On joue le son alSourcePlay(Source); // On attend qu'il soit termin� ALint Status; do { // R�cup�ration de l'�tat du son alGetSourcei(Source, AL_SOURCE_STATE, &Status); } while (Status == AL_PLAYING); // Destruction du tampon alDeleteBuffers(1, &Buffer); // Destruction de la source alSourcei(Source, AL_BUFFER, 0); alDeleteSources(1, &Source); // Fermeture d'OpenAL ShutdownOpenAL_lecture(); return EXIT_SUCCESS; }
RocketLauncher::RocketLauncher(const dtDAL::ResourceDescriptor& resource) : FrontWeapon(resource) , mCurrentRocketNode(0) { SetName(ROCKET_LAUNCHER_ACTOR_TYPE); SetFiringRate(1.0f); // Load any sounds we have mpFireSound = LoadSound("/sounds/explosion.wav"); mpFireSound->SetGain(0.75f); // Setup launch particles mpLaunchParticles = new dtCore::ParticleSystem; mpLaunchParticles->LoadFile("particles/rocket_launch.osg"); mpLaunchParticles->SetEnabled(false); AddChild(mpLaunchParticles); // Setup our damage mDamage.SetDamageType(SMK::Damage::DAMAGE_BLAST); mDamage.SetAmount(15); mDamage.SetRadius(5.0f); }