bool XAudio2SourceVoice::Init() { if (!XAudio2CheckedCall(XAudio2Device::XAudio2->CreateSourceVoice(&m_Source, (WAVEFORMATEX*)m_wfx, 0, 2.0f, &m_Callback))) { ConsolePrintf(TEXT("Failed to create XAudio2 source voice.")); return false; } UINT32 NumEffects = 0; // Create the reverb effect IUnknown* ReverbXAPO = nullptr; bool bReverbEnabled = (m_EffectFlags & ILLUSYNTH_FX_REVERB) ? true : false; if (!XAudio2CheckedCall(CreateFX(__uuidof(FXReverb), &ReverbXAPO))) { ConsolePrintf(TEXT("XAudio2: Failed to create reverb XAPO.")); return false; } // Create the EQ effect IUnknown* EQ_XAPO = nullptr; bool bEQEnabled = (m_EffectFlags & ILLUSYNTH_FX_EQ) ? true : false; if (!XAudio2CheckedCall(CreateFX(__uuidof(FXEQ), &EQ_XAPO))) { ConsolePrintf(TEXT("XAudio2: Failed to create EQ XAPO.")); return false; } // NOTE: The order of these effects must match the order in the // header file XAUDIO2_EFFECT_DESCRIPTOR EffectDescriptors[] = { { ReverbXAPO, bReverbEnabled, 1 }, { EQ_XAPO, bEQEnabled, 1 } }; XAUDIO2_EFFECT_CHAIN EffectChain; EffectChain.EffectCount = sizeof(EffectDescriptors) / sizeof(XAUDIO2_EFFECT_DESCRIPTOR); EffectChain.pEffectDescriptors = EffectDescriptors; if (!XAudio2CheckedCall(m_Source->SetEffectChain(&EffectChain))) { ConsolePrintf(TEXT("XAudio2: Failed to set effect chain on source voice.")); return false; } m_bInitialized = true; ReverbXAPO->Release(); EQ_XAPO->Release(); return true; }
/* ================== FullscreenFXManager::Initialize ================== */ void FullscreenFXManager::Initialize( idPlayerView *pv ) { // set the playerview playerView = pv; blendBackMaterial = declManager->FindMaterial( "textures/smf/blendBack" ); // allocate the fx CreateFX( "helltime", "helltime", 1000 ); CreateFX( "warp", "warp", 0 ); CreateFX( "envirosuit", "envirosuit", 500 ); CreateFX( "doublevision", "doublevision", 0 ); CreateFX( "multiplayer", "multiplayer", 1000 ); CreateFX( "influencevision", "influencevision", 1000 ); CreateFX( "bloom", "bloom", 0 ); // pre-cache the texture grab so we dont hitch renderSystem->CropRenderSize( 512, 512, true ); renderSystem->CaptureRenderToImage( "_accum" ); renderSystem->UnCrop(); renderSystem->CropRenderSize( 512, 256, true ); renderSystem->CaptureRenderToImage( "_scratch" ); renderSystem->UnCrop(); renderSystem->CaptureRenderToImage( "_currentRender" ); }
bool CClientFXMgr::CreateFXKey(const CLIENTFX_CREATESTRUCT &fxInit, CClientFXInstance* pInst, const FX_KEY* pKey ) { if( !pKey ) return false; // // We need to go ahead and create this effect // FX_BASEDATA fxData; fxData.m_tTransform = fxInit.m_tTransform; fxData.m_bUseTargetData = fxInit.m_bUseTargetData; fxData.m_hTargetObject = fxInit.m_hTargetObject; fxData.m_vTargetOffset = fxInit.m_vTargetOffset; fxData.m_pFxMgr = this; fxData.m_hParentObject = fxInit.m_hParentObject; fxData.m_hParentRigidBody = fxInit.m_hParentRigidBody; fxData.m_hNodeAttach = fxInit.m_hNode; fxData.m_hSocketAttach = fxInit.m_hSocket; fxData.m_dwFlags = fxInit.m_dwFlags; // Create the FX CBaseFX *pNewFX = CreateFX(pKey->m_pFxRef->m_sName, &fxData, pKey->m_pProps); if( pNewFX ) { pNewFX->SetVisible(false); pNewFX->ClearState(FS_INITIALFRAME | FS_ACTIVE | FS_SHUTTINGDOWN | FS_SUSPENDED); // Add it onto the list for link referencing pInst->m_ActiveFXList.AddTail(&pNewFX->m_FXListLink); } else { return false; } return true; }
void fx::InitAll(ID3D10Device* device) { SkyFX = CreateFX(device, L"sky.fx"); NormalMapFX = CreateFX(device, L"normalmap.fx"); }
// Initialisation of the CXAudio2 engine void CXAudio2::Init(const CXAudio2SetupParameters& params) { // Copy parameters numChannels = params.numChannels; maxFrequencyRatio = params.maxFrequencyRatio; SetCommandBatching(params.commandBatching); SetCacheMode(params.cacheMode); SetCacheLimit(params.cacheLimit); // Initialize COM CoInitializeEx(NULL, COINIT_MULTITHREADED); #ifdef _DEBUG // Request debug XAudio2 engine hr = XAudio2Create(&pXAudio2, XAUDIO2_DEBUG_ENGINE, XAUDIO2_DEFAULT_PROCESSOR); #else // Request standard XAudio2 engine hr = XAudio2Create(&pXAudio2, 0, XAUDIO2_DEFAULT_PROCESSOR); #endif // XAudio2Create failed if (FAILED(hr)) throw CXAudio2Error(hr, "Failed to create XAudio2"); // Mastering limiter & volume meter effect chain for mastering voice XAUDIO2_EFFECT_DESCRIPTOR descriptor[2]; int count = 0; // Create the mastering limiter if enabled if (params.limiter_enable) { IUnknown* pLimiter; hr = CreateFX(__uuidof(FXMasteringLimiter), &pLimiter); if (FAILED(hr)) throw CXAudio2Error(hr, "Failed to create mastering limiter"); descriptor[0].InitialState = true; descriptor[0].OutputChannels = 2; descriptor[0].pEffect = pLimiter; // Write volume meter to next descriptor count++; } // Create the volume meter for the mastering voice #ifdef _DEBUG hr = XAudio2CreateVolumeMeter(&(master.pVolumeMeter), XAUDIO2FX_DEBUG); #else hr = XAudio2CreateVolumeMeter(&(master.pVolumeMeter), 0); #endif if (FAILED(hr)) throw CXAudio2Error(hr, "Failed to create XAudio2 volume meter"); // Set up the effect chain to apply the volume metering to the mastering voice descriptor[count].InitialState = true; descriptor[count].OutputChannels = 2; descriptor[count].pEffect = master.pVolumeMeter; master.volumeMeterEffectIndex = count; count++; XAUDIO2_EFFECT_CHAIN chain; chain.EffectCount = count; chain.pEffectDescriptors = descriptor; // Create stereo mastering voice hr = pXAudio2->CreateMasteringVoice(&(master.pMaster), 2, XAUDIO2_DEFAULT_SAMPLERATE, 0, 0, &chain); if (FAILED(hr)) throw CXAudio2Error(hr, "Failed to create XAudio2 mastering voice"); // Get the device details pXAudio2->GetDeviceDetails(0, &deviceDetails); // Set up the channel strip channels.reserve(numChannels); for (int i = 0; i < numChannels; i++) channels.push_back(Channel(this, i)); // Set the master volume as per parameters; -3.0dB by default to help prevent clipping master.SetVolume(params.masterGain); }
void fx::InitAll(ID3D10Device* device) { SkyFX = CreateFX(device, L"sky.fx"); CubeMapFX = CreateFX(device, L"cubemap.fx"); }
bool CClientFXMgr::CreateFXKey( CLIENTFX_INSTANCE* pInst, FX_KEY* pKey ) { if( !pInst || !pKey ) return false; // // We need to go ahead and create this effect // assert(m_hCamera); FX_BASEDATA fxData; fxData.m_vPos = pInst->m_vPos; fxData.m_rRot = pInst->m_rRot; fxData.m_dwID = pInst->m_dwID; fxData.m_hTarget = pInst->m_hTarget; fxData.m_dwObjectFlags = pInst->m_dwObjectFlags; fxData.m_dwObjectFlags2 = pInst->m_dwObjectFlags2; fxData.m_bUseTargetData = pInst->m_bUseTargetData; fxData.m_vTargetPos = pInst->m_vTargetPos; fxData.m_vTargetNorm = pInst->m_vTargetNorm; fxData.m_hCamera = m_hCamera; // Save the parent fxData.m_hParent = pInst->m_hParent; // Is this FX supposed to be motion linked to another FX? if (pKey->m_bLinked) { CLinkListNode<FX_LINK> *pNode = pInst->m_collActiveFX.GetHead(); while (pNode) { if (pNode->m_Data.m_dwID == pKey->m_dwLinkedID) { // This is the one !!! if (pInst->ExistFX(pNode->m_Data.m_pFX)) { CBaseFX *pMotionLinkFX = pNode->m_Data.m_pFX; fxData.m_hParent = pMotionLinkFX->GetFXObject(); } // done break; } pNode = pNode->m_pNext; } } // Create the FX CBaseFX *pNewFX = CreateFX(pKey->m_pFxRef->m_sName, &fxData, pKey->m_pProps, pInst->m_hParent); if( pNewFX ) { pNewFX->SetVisible(false); pNewFX->ClearState(FS_INITIALFRAME | FS_ACTIVE | FS_SHUTTINGDOWN | FS_SUSPENDED); // Add it onto the list for link referencing FX_LINK fxLink; fxLink.m_dwID = pKey->m_dwID; fxLink.m_pFX = pNewFX; fxLink.m_pRef = pKey; pInst->m_collActiveFX.AddHead(fxLink); } else { return false; } return true; }