static int InitDSound(HWND hWnd) { HRESULT hr; pDirectSoundCreate8 SoundCreate; dsoundDLL = LoadLibrary("dsound.dll"); if (dsoundDLL == NULL) { WriteLog("not find dsound.dll"); } SoundCreate = (pDirectSoundCreate8)GetProcAddress(dsoundDLL, "DirectSoundCreate8"); hr = SoundCreate(NULL, &lpDS, NULL); if (FAILED(hr)) { goto end; } hr = lpDS->SetCooperativeLevel(hWnd, DSSCL_PRIORITY); if (FAILED(hr)) { goto end; } DSBUFFERDESC desc; ZeroMemory(&desc,sizeof(DSBUFFERDESC)); desc.dwSize = sizeof(DSBUFFERDESC); desc.dwFlags = DSBCAPS_PRIMARYBUFFER; hr = lpDS->CreateSoundBuffer(&desc, &lpDSP, NULL); if (FAILED(hr)) { goto end; } WriteLog("init sound\n"); return 1; end: return 0; }
//========================================================= //========================================================= void CWeaponGravityGun::PrimaryAttack( void ) { if ( !m_active ) { SendWeaponAnim( ACT_VM_PRIMARYATTACK ); EffectCreate(); SoundCreate(); } else { EffectUpdate(); SoundUpdate(); } }
void audio_play(int n,short *data) { int endian = 1; #define little_endian ((*((char *)&endian) == 1)) int priv = 0; AuEvent ev; Sound s = SoundCreate(SoundFileFormatNone, little_endian ? AuFormatLinearSigned16LSB : AuFormatLinearSigned16MSB, 1, samp_rate, n, "Chit chat"); if (aud) { #ifdef USE_ALL_ARGS AuStatus ret_status; AuFlowID flow = 0; int monitor = 0; int multiplier = 0; if (!AuSoundPlayFromData(aud, s, data, AuNone, AuFixedPointFromFraction(volume, 100), done, &priv, &flow, &multiplier, &monitor, &ret_status)) #else if (!AuSoundPlayFromData(aud, s, data, AuNone, AuFixedPointFromFraction(volume, 100), done, &priv, NULL, NULL, NULL, NULL)) #endif perror("problems playing data"); else { while (1) { AuNextEvent(aud, AuTrue, &ev); AuDispatchEvent(aud, &ev); if (priv) break; } } } SoundDestroy(s); }
void OptionsOnSelect( VariantList* pVList ) { Entity* pEntClicked = pVList->m_variant[1].GetEntity(); Config* config = Config::GetInstance(); if( pEntClicked->GetName() == GUI_IMAGEBUTTON_OPTIONS_BACK_BUTTON ) { GetApp()->buttonClickSound(); SlideScreen( pEntClicked->GetParent(), false ); GetMessageManager()->CallEntityFunction( pEntClicked->GetParent(), 500, "OnDelete", NULL ); MainMenuCreate( pEntClicked->GetParent()->GetParent() ); } if( pEntClicked->GetName() == GUI_IMAGEBUTTON_OPTIONS_LANGUAGE_BUTTON ) { GetApp()->buttonClickSound(); SlideScreen( pEntClicked->GetParent(), false ); GetMessageManager()->CallEntityFunction( pEntClicked->GetParent(), 500, "OnDelete", NULL ); LanguageCreate( pEntClicked->GetParent()->GetParent() ); } if( pEntClicked->GetName() == GUI_IMAGEBUTTON_OPTIONS_SOUND_BUTTON ) { GetApp()->buttonClickSound(); SlideScreen( pEntClicked->GetParent(), false ); GetMessageManager()->CallEntityFunction( pEntClicked->GetParent(), 500, "OnDelete", NULL ); SoundCreate( pEntClicked->GetParent()->GetParent() ); } if( pEntClicked->GetName() == GUI_IMAGEBUTTON_OPTIONS_LEVEL_BUTTON ) { GetApp()->buttonClickSound(); SlideScreen( pEntClicked->GetParent(), false ); GetMessageManager()->CallEntityFunction( pEntClicked->GetParent(), 500, "OnDelete", NULL ); LevelMenuCreate( pEntClicked->GetParent()->GetParent() ); } config->FreeInstance(); }