void StreamData(int streamNum, const void* data, int numSamples, int rate, int width, int channels, float volume, int entityNum) { if (not initialized or (streamNum < 0 or streamNum >= N_STREAMS)) { return; } if (not streams[streamNum]) { streams[streamNum] = std::make_shared<StreamingSound>(); if (IsValidEntity(entityNum)) { AddSound(GetEmitterForEntity(entityNum), streams[streamNum], 1); } else { AddSound(GetLocalEmitter(), streams[streamNum], 1); } } streams[streamNum]->SetGain(volume); AudioData audioData(rate, width, channels, (width * numSamples * channels), reinterpret_cast<const char*>(data)); AL::Buffer buffer; int feedError = buffer.Feed(audioData); if (not feedError) { streams[streamNum]->AppendBuffer(std::move(buffer)); } }
void CDrumMachine::Init(const int Index,void* MainWindow) { m_Name=devicename; IDevice::Init(Index,MainWindow); AddJack("Out",IJack::Wave,IJack::Out,0); AddParameter(ParameterType::Numeric,"Tempo","BPM",20,300,0,"",100); AddParameter(ParameterType::dB,"Volume","dB",0,200,0,"",100); BeatInterval=0; PatternLength=0; SamplesPerTick=0; Playing=false; PatternType* DefaultPattern=new PatternType("Default",16,DrumMachine::SoundCount,100,0,0); Patterns.append(DefaultPattern); PatternListType* DefaultList=new PatternListType(); DefaultList->Pattern=DefaultPattern; DefaultList->Repeats=4; PatternsInList.append(DefaultList); AddSound("kick02.wav","Kick",&WG[0],&ST[0]); AddSound("snr01.wav","Snare",&WG[1],&ST[1]); AddSound("hat01.wav","Hi-Hat",&WG[2],&ST[2]); AddSound("hat19.wav","Open Hi-Hat",&WG[3],&ST[3]); AddSound("cym01.wav","Cymbal",&WG[4],&ST[4]); AddSound("tom01.wav","Tom 1",&WG[5],&ST[5]); AddSound("tom02.wav","Tom 2",&WG[6],&ST[6]); Reset(); CalcParams(); m_Form=new CDrumMachineForm(this,(QWidget*)MainWindow); }
Sound* SoundCardD3D::CreateSound(DWORD flags, LPWAVEFORMATEX format) { if (!soundcard) return 0; Sound* result = new(__FILE__,__LINE__) SoundD3D(soundcard, flags, format); if (result) AddSound(result); return result; }
void ResourceManager::LoadAllResources() { SetStartScene( new World ); AddTexture("Blaster", "blaster.png"); AddTexture("Mushroom", "mushroom.png"); AddTexture("Bullets", "bullet.png"); AddTexture("Centipede Head","centipede_head.png"); AddTexture("Centipede Body","centipede_body.png"); AddTexture("Scorpion", "scorpion.png"); AddTexture("Flea", "flea.png"); AddTexture("Spider", "spider.png"); AddTexture("Death", "spawn.png"); AddTexture("PlayerExplosion", "death.png"); AddTexture("300", "three.png"); AddTexture("600", "six.png"); AddTexture("900", "nine.png"); AddTexture("CentipedeFont", "FONT.bmp"); AddSound("BulletSnd", "fire2.wav"); AddSound("DeathSnd", "death.wav"); AddSound("KillSnd", "kill.wav"); AddSound("SpiderSnd", "spider_new.wav"); AddSound("ScorpionSnd", "scorpion_new.wav"); AddSound("CentipedeSnd", "beat.wav"); }
Sound* SoundCardD3D::CreateSound(DWORD flags, LPWAVEFORMATEX format, DWORD len, LPBYTE data) { if (!soundcard) return 0; Sound* result = new(__FILE__,__LINE__) SoundD3D(soundcard, flags, format, len, data); if (flags & (Sound::STREAMED | Sound::OGGVORBIS)) { if (result) AddSound(result); } return result; }
void Sound::CacheSounds() { //cache sound files std::ifstream myFile ("./media/sounds/soundcache.txt", std::ios::in); std::string str; while (std::getline(myFile, str)) { AddSound(str); } myFile.close(); //cache music files for(int x=1; x<7; x++) { std::stringstream strMusic; strMusic << "music" << x << ".mp3"; AddSound(strMusic.str(), true, true); } }
void Module::LoadKit(std::string file, Kit& kit) { const char* fileName = file.c_str(); //xmlInitParser(); xmlDoc* doc = xmlReadFile(fileName, NULL, 0); xmlNode* rootElement = xmlDocGetRootElement(doc); xmlNode* node = rootElement->children; xmlNode* kitName = node->next; kit.kitName = std::string((char*) kitName->children->content); xmlNode* kitFolder = kitName->next->next; kit.kitFolder = std::string((char*) kitFolder->children->content); xmlNode* kitParams = kitFolder->next->next; xmlNode* drumName = kitParams->children->next; bool getSound = true; while(getSound) { size_t drumId = kit.drum.size(); bool newSound = GetDrumParams(drumName, kit.drum); std::string drumFileName = kit.drum[drumId].soundFile; std::string fileSound = directory + "Kits/" + kit.kitFolder + "/" + drumFileName; // Sound id must match drumId (index in the kit.drum vector) AddSound(fileSound, drumId); drumId++; if(!newSound) getSound = false; } //xmlFreeDoc(doc); xmlFree(doc); //xmlCleanupParser(); //xmlMemoryDump(); return; }
void SoundManager::ProcessRedbook() { if (!g_theProfileDB->IsUseRedbookAudio()) return; if (!m_musicEnabled) return; if (GetTickCount() > m_timeToCheckCD) { #if defined(USE_SDL) CDstatus status; if (m_cdrom) { status = SDL_CDStatus(m_cdrom); #else U32 status; if (m_redbook) { status = AIL_redbook_status(m_redbook); #endif switch (status) { #if !defined(USE_SDL) case REDBOOK_ERROR: #else case CD_TRAYEMPTY: break; case CD_ERROR: #endif break; #if !defined(USE_SDL) case REDBOOK_PLAYING: #else case CD_PLAYING: #endif break; #if !defined(USE_SDL) case REDBOOK_PAUSED: #else case CD_PAUSED: #endif break; #if !defined(USE_SDL) case REDBOOK_STOPPED: #else case CD_STOPPED: #endif if (m_curTrack != -1) PickNextTrack(); if (m_curTrack != -1 && !m_stopRedbookTemporarily) StartMusic(m_curTrack); break; } } m_timeToCheckCD = GetTickCount() + k_CHECK_CD_PERIOD; } } void SoundManager::Process(const uint32 &target_milliseconds, uint32 &used_milliseconds) { CivSound *sound; sint32 start_time_ms = GetTickCount(); if ((m_noSound) ||(m_usePlaySound)) { used_milliseconds = GetTickCount() - start_time_ms; return; } if (m_sfxSounds->GetCount() > 0) { m_soundWalker->SetList(m_sfxSounds); while (m_soundWalker->IsValid()) { sound = m_soundWalker->GetObj(); Assert(sound); if (!sound) continue; if (sound->IsPlaying()) { #if !defined(USE_SDL) if (AIL_quick_status(sound->GetHAudio()) == QSTAT_DONE) { #else if (!Mix_Playing(sound->GetChannel())) { #endif m_soundWalker->Remove(); delete sound; } else { m_soundWalker->Next(); } } } } if (m_voiceSounds->GetCount() > 0) { m_soundWalker->SetList(m_voiceSounds); while (m_soundWalker->IsValid()) { sound = m_soundWalker->GetObj(); Assert(sound); if (!sound) continue; if (sound->IsPlaying()) { #if !defined(USE_SDL) if (AIL_quick_status(sound->GetHAudio()) == QSTAT_DONE) { #else if ((-1 == sound->GetChannel()) || (!Mix_Playing(sound->GetChannel()))) { #endif m_soundWalker->Remove(); delete sound; } else { m_soundWalker->Next(); } } } } ProcessRedbook(); used_milliseconds = GetTickCount() - start_time_ms; } bool FindSoundinList(PointerList<CivSound> * sndList, sint32 soundID) { for ( PointerList<CivSound>::Walker walk(sndList); walk.IsValid(); walk.Next() ) { if (walk.GetObj()->GetSoundID() == soundID) { return true; } } return false; } void SoundManager::AddGameSound(const GAMESOUNDS &sound) { sint32 id = gamesounds_GetGameSoundID(sound); AddSound(SOUNDTYPE_SFX, 0, id, 0, 0); }
bool cSoundParser::AddStaticSound(NamedTypedObject*e_pRef,const char*e_strFileName) { return AddSound(e_pRef,e_strFileName); }
void SoundManager::loadSounds(char** path) { path[0] = "data/media/sounds/ambience1.flac"; path[1] = "data/media/sounds/ambience2.wav"; path[2] = "data/media/sounds/ambience3.flac"; path[3] = "data/media/sounds/ambience4.wav"; path[4] = "data/media/sounds/attack1.wav"; path[5] = "data/media/sounds/attack2.wav"; path[6] = "data/media/sounds/attack3.wav"; path[7] = "data/media/sounds/equipitem.wav"; path[8] = "data/media/sounds/menupressbutton.wav"; path[9] = "data/media/sounds/opendoor.wav"; path[10] = "data/media/sounds/openinventory.wav"; path[11] = "data/media/sounds/scorpionattack.wav"; path[12] = "data/media/sounds/scorpiondie.wav"; path[13] = "data/media/sounds/walksound.ogg"; path[14] = "data/media/sounds/hydrattack1.wav"; AddSound(path[0], "Ambience1"); AddSound(path[1], "Ambience2"); AddSound(path[2], "Ambience3"); AddSound(path[3], "Ambience1"); AddSound(path[4], "Attack1"); AddSound(path[5], "Attack2"); AddSound(path[6], "Attack3"); AddSound(path[7], "Equip Item"); AddSound(path[8], "Menu press button"); AddSound(path[9], "Open Door"); AddSound(path[10], "Open Inventory"); AddSound(path[11], "Scorpion Attack"); AddSound(path[12], "Scorpion Die"); AddSound(path[13], "Walksound"); AddSound(path[14], "Hydra Attack"); }
void InitSoundFX() { for (int i = 0; i < kMaxChannelNum; i++) { globals()->gChannel[i].soundAge = 0; globals()->gChannel[i].soundPriority = kNoSound; globals()->gChannel[i].whichSound = -1; SoundDriver::driver()->open_channel(globals()->gChannel[i].channelPtr); } ResetAllSounds(); AddSound(kComputerBeep4); AddSound(kComputerBeep1); AddSound(kComputerBeep2); AddSound(kComputerBeep3); AddSound(kMorseBeepSound); AddSound(kWarningTone); AddSound(kLandingWoosh); AddSound(kCloakOn); AddSound(kCloakOff); AddSound(kKlaxon); AddSound(kWarpOne); AddSound(kWarpTwo); AddSound(kWarpThree); AddSound(kWarpFour); AddSound(kTeletype); }
//----------------------------------------------------------------------------- // Purpose: // Input : hwndDlg - // uMsg - // wParam - // lParam - // Output : static BOOL CALLBACK //----------------------------------------------------------------------------- static BOOL CALLBACK SoundLookupDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam ) { switch(uMsg) { case WM_INITDIALOG: // Insert code here to put the string (to find and replace with) // into the edit controls. // ... { g_Params.PositionSelf( hwndDlg ); PopulateSoundEntryList( hwndDlg, &g_Params ); SetDlgItemText( hwndDlg, IDC_STATIC_PROMPT, g_Params.m_szPrompt ); SetWindowText( hwndDlg, g_Params.m_szDialogTitle ); SetFocus( GetDlgItem( hwndDlg, IDC_SOUNDENTRYLIST ) ); } return FALSE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: { int selindex = SendMessage( GetDlgItem( hwndDlg, IDC_SOUNDENTRYLIST ), LB_GETCURSEL, 0, 0 ); if ( selindex == LB_ERR ) { mxMessageBox( NULL, "You must select an entry from the list", g_appTitle, MB_OK ); return TRUE; } int soundindex = SendMessage( GetDlgItem( hwndDlg, IDC_SOUNDENTRYLIST ), LB_GETITEMDATA, selindex, 0 ); Assert( soundindex != LB_ERR ); Q_strncpy( g_Params.m_szSoundName, soundemitter->GetSoundName( soundindex ), sizeof ( g_Params.m_szSoundName ) ); EndDialog( hwndDlg, 1 ); } break; case IDCANCEL: EndDialog( hwndDlg, 0 ); break; case IDC_ADDENTRY: { // Create a new sound entry for this sound CAddSoundParams params; Q_memset( ¶ms, 0, sizeof( params ) ); Q_strcpy( params.m_szDialogTitle, "Add Sound Entry" ); Q_strcpy( params.m_szWaveFile, g_Params.m_szWaveFile ); if ( AddSound( ¶ms, hwndDlg ) ) { // Add it to soundemitter and check out script files if ( params.m_szSoundName[ 0 ] && params.m_szScriptName[ 0 ] ) { Q_strcpy( g_Params.m_szSoundName, params.m_szSoundName ); // Press the OK button for the user... EndDialog( hwndDlg, 1 ); } } } break; } return TRUE; } return FALSE; }
LevelMine::LevelMine(unique_ptr<Game> & game, const unique_ptr<PlayerTransfer> & playerTransfer) : Level(game, playerTransfer) { mName = LevelName::Mine; LoadLocalization("mine.loc"); mPlayer->mYaw.SetTarget(180.0f); LoadSceneFromFile("data/maps/mine.scene"); mPlayer->SetPosition(GetUniqueObject("PlayerPosition")->GetPosition()); Vector3 placePos = GetUniqueObject("PlayerPosition")->GetPosition(); Vector3 playerPos = mPlayer->GetCurrentPosition(); mPlayer->GetHUD()->SetObjective(mLocalization.GetString("objective1")); AddInteractiveObject("Note", make_shared<InteractiveObject>(GetUniqueObject("Note1")), [this] { mPlayer->GetInventory()->AddReadedNote(mLocalization.GetString("note1Desc"), mLocalization.GetString("note1")); }); AddInteractiveObject("Note", make_shared<InteractiveObject>(GetUniqueObject("Note2")), [this] { mPlayer->GetInventory()->AddReadedNote(mLocalization.GetString("note2Desc"), mLocalization.GetString("note2")); }); AddInteractiveObject("Note", make_shared<InteractiveObject>(GetUniqueObject("Note3")), [this] { mPlayer->GetInventory()->AddReadedNote(mLocalization.GetString("note3Desc"), mLocalization.GetString("note3")); }); AddInteractiveObject("Note", make_shared<InteractiveObject>(GetUniqueObject("Note4")), [this] { mPlayer->GetInventory()->AddReadedNote(mLocalization.GetString("note4Desc"), mLocalization.GetString("note4")); }); AddInteractiveObject("Note", make_shared<InteractiveObject>(GetUniqueObject("Note5")), [this] { mPlayer->GetInventory()->AddReadedNote(mLocalization.GetString("note5Desc"), mLocalization.GetString("note5")); }); AddInteractiveObject("Note", make_shared<InteractiveObject>(GetUniqueObject("Note6")), [this] { mPlayer->GetInventory()->AddReadedNote(mLocalization.GetString("note6Desc"), mLocalization.GetString("note6")); }); AddInteractiveObject("Note", make_shared<InteractiveObject>(GetUniqueObject("Note7")), [this] { mPlayer->GetInventory()->AddReadedNote(mLocalization.GetString("note7Desc"), mLocalization.GetString("note7")); }); AddInteractiveObject("Note", make_shared<InteractiveObject>(GetUniqueObject("Note8")), [this] { mPlayer->GetInventory()->AddReadedNote(mLocalization.GetString("note8Desc"), mLocalization.GetString("note8")); }); mStoneFallZone = GetUniqueObject("StoneFallZone"); mNewLevelZone = GetUniqueObject("NewLevel"); auto soundSystem = mGame->GetEngine()->GetSoundSystem(); soundSystem->SetReverbPreset(ReverbPreset::Cave); AddSound(mMusic = soundSystem->LoadMusic("data/music/chapter2.ogg")); mConcreteWall = GetUniqueObject("ConcreteWall"); mDeathZone = GetUniqueObject("DeadZone"); mDetonator = GetUniqueObject("Detonator"); AddSound(mAlertSound = soundSystem->LoadSound3D("data/sounds/alert.ogg")); mAlertSound->Attach(mDetonator); AddSound(mExplosionSound = soundSystem->LoadSound3D("data/sounds/blast.ogg")); mExplosionSound->SetReferenceDistance(10); mDetonatorActivated = 0; mExplosionFlashAnimator = 0; // Create detonator places AddItemPlace(mDetonatorPlace[0] = make_shared<ItemPlace>(GetUniqueObject("DetonatorPlace1"), Item::Type::Explosives)); AddItemPlace(mDetonatorPlace[1] = make_shared<ItemPlace>(GetUniqueObject("DetonatorPlace2"), Item::Type::Explosives)); AddItemPlace(mDetonatorPlace[2] = make_shared<ItemPlace>(GetUniqueObject("DetonatorPlace3"), Item::Type::Explosives)); AddItemPlace(mDetonatorPlace[3] = make_shared<ItemPlace>(GetUniqueObject("DetonatorPlace4"), Item::Type::Explosives)); mWireModels[0] = GetUniqueObject("WireModel1"); mWireModels[1] = GetUniqueObject("WireModel2"); mWireModels[2] = GetUniqueObject("WireModel3"); mWireModels[3] = GetUniqueObject("WireModel4"); mDetonatorModels[0] = GetUniqueObject("DetonatorModel1"); mDetonatorModels[1] = GetUniqueObject("DetonatorModel2"); mDetonatorModels[2] = GetUniqueObject("DetonatorModel3"); mDetonatorModels[3] = GetUniqueObject("DetonatorModel4"); mExplosivesModels[0] = GetUniqueObject("ExplosivesModel1"); mExplosivesModels[1] = GetUniqueObject("ExplosivesModel2"); mExplosivesModels[2] = GetUniqueObject("ExplosivesModel3"); mExplosivesModels[3] = GetUniqueObject("ExplosivesModel4"); mFindItemsZone = GetUniqueObject("FindItemsZone"); AddAmbientSound(soundSystem->LoadSound3D("data/sounds/ambient/mine/ambientmine1.ogg")); AddAmbientSound(soundSystem->LoadSound3D("data/sounds/ambient/mine/ambientmine2.ogg")); AddAmbientSound(soundSystem->LoadSound3D("data/sounds/ambient/mine/ambientmine3.ogg")); AddAmbientSound(soundSystem->LoadSound3D("data/sounds/ambient/mine/ambientmine4.ogg")); AddAmbientSound(soundSystem->LoadSound3D("data/sounds/ambient/mine/ambientmine5.ogg")); mExplosionTimer = ITimer::Create(); mBeepSoundTimer = ITimer::Create(); mBeepSoundTiming = 1.0f; CreateItems(); mReadyExplosivesCount = 0; MakeLadder("LadderBegin", "LadderEnd", "LadderEnter", "LadderBeginLeavePoint", "LadderEndLeavePoint"); MakeDoor("Door1", 90); MakeDoor("Door3", 90); MakeDoor("DoorToAdministration", 90); MakeDoor("Door6", 90); MakeDoor("DoorToDirectorsOffice", 90); MakeDoor("DoorToResearchFacility", 90); MakeKeypad("Keypad1", "Keypad1Key0", "Keypad1Key1", "Keypad1Key2", "Keypad1Key3", "Keypad1Key4", "Keypad1Key5", "Keypad1Key6", "Keypad1Key7", "Keypad1Key8", "Keypad1Key9", "Keypad1KeyCancel", MakeDoor("StorageDoor", 90), "7854"); MakeKeypad("Keypad2", "Keypad2Key0", "Keypad2Key1", "Keypad2Key2", "Keypad2Key3", "Keypad2Key4", "Keypad2Key5", "Keypad2Key6", "Keypad2Key7", "Keypad2Key8", "Keypad2Key9", "Keypad2KeyCancel", MakeDoor("DoorToResearchFacility", 90), "1689"); MakeKeypad("Keypad3", "Keypad3Key0", "Keypad3Key1", "Keypad3Key2", "Keypad3Key3", "Keypad3Key4", "Keypad3Key5", "Keypad3Key6", "Keypad3Key7", "Keypad3Key8", "Keypad3Key9", "Keypad3KeyCancel", MakeDoor("DoorMedical", 90), "9632"); mMusic->Play(); mStages["ConcreteWallExp"] = false; mStages["FindObjectObjectiveSet"] = false; mStages["FoundObjectsForExplosion"] = false; // create paths const char * ways[] = { "WayA", "WayB", "WayC", "WayD", "WayE", "WayF", "WayG", "WayH", "WayI", "WayJ", "WayK" }; Path p; for(auto w : ways) { p += Path(mScene, w); } p.Get("WayB1")->AddEdge(p.Get("WayA004")); p.Get("WayC1")->AddEdge(p.Get("WayA019")); p.Get("WayD1")->AddEdge(p.Get("WayA019")); p.Get("WayE1")->AddEdge(p.Get("WayA040")); p.Get("WayF1")->AddEdge(p.Get("WayA042")); p.Get("WayF009")->AddEdge(p.Get("WayG1")); p.Get("WayH1")->AddEdge(p.Get("WayA059")); p.Get("WayI1")->AddEdge(p.Get("WayA097")); p.Get("WayJ1")->AddEdge(p.Get("WayA073")); p.Get("WayK1")->AddEdge(p.Get("WayA027")); vector<shared_ptr<GraphVertex>> patrolPoints = { p.Get("WayA1"), p.Get("WayC024"), p.Get("WayB012"), p.Get("WayB012"), p.Get("WayD003"), p.Get("WayK005"), p.Get("WayE006"), p.Get("WayF019"), p.Get("WayG007"), p.Get("WayH010"), p.Get("WayA110"), p.Get("WayI009") }; mEnemy = make_unique<Enemy>(mGame, p.mVertexList, patrolPoints); mEnemy->SetPosition(GetUniqueObject("EnemyPosition")->GetPosition()); mExplosivesDummy[0] = GetUniqueObject("ExplosivesModel5"); mExplosivesDummy[1] = GetUniqueObject("ExplosivesModel6"); mExplosivesDummy[2] = GetUniqueObject("ExplosivesModel7"); mExplosivesDummy[3] = GetUniqueObject("ExplosivesModel8"); mExplodedWall = GetUniqueObject("ConcreteWallExploded"); mExplodedWall->Hide(); mExplosionFlashPosition = GetUniqueObject("ExplosionFlash"); mPlayer->GetInventory()->RemoveItem(Item::Type::Crowbar, 1); DoneInitialization(); }