void cOAL_EffectSlot::SetAutoAdjust( bool abAuto ) { DEF_FUNC_NAME(""); FUNC_USES_AL; RUN_AL_FUNC( alAuxiliaryEffectSloti (mlObjectId, AL_EFFECTSLOT_AUXILIARY_SEND_AUTO, (ALboolean) abAuto)); }
void cOAL_Device::SetDistanceModel(eOAL_DistanceModel aModel) { DEF_FUNC_NAME("OAL_SetDistanceModel"); FUNC_USES_AL; ALenum distModel; switch(aModel) { case eOAL_DistanceModel_Inverse: distModel = AL_INVERSE_DISTANCE; break; case eOAL_DistanceModel_Inverse_Clamped: distModel = AL_INVERSE_DISTANCE_CLAMPED; break; case eOAL_DistanceModel_Linear: distModel = AL_LINEAR_DISTANCE; break; case eOAL_DistanceModel_Linear_Clamped: distModel = AL_LINEAR_DISTANCE_CLAMPED; break; case eOAL_DistanceModel_Exponent: distModel = AL_EXPONENT_DISTANCE; break; case eOAL_DistanceModel_Exponent_Clamped: distModel = AL_EXPONENT_DISTANCE_CLAMPED; break; case eOAL_DistanceModel_None: distModel = AL_NONE; default: break; } RUN_AL_FUNC(alDistanceModel(distModel)); }
void cOAL_Device::SetListenerVelocity (const float* apVel ) { DEF_FUNC_NAME ("cOAL_Device::SetListenerVelocity()"); FUNC_USES_AL; RUN_AL_FUNC(alListenerfv (AL_VELOCITY,apVel)); }
void cOAL_Device::SetListenerPosition (const float* apPos ) { DEF_FUNC_NAME ("cOAL_Device::SetListenerPosition()"); FUNC_USES_AL; RUN_AL_FUNC(alListenerfv ( AL_POSITION, apPos )); }
bool cOAL_EffectSlot::DestroyLowLevelID() { DEF_FUNC_NAME("cOAL_EffectSlot::DestroyLowLevelID()"); FUNC_USES_AL; RUN_AL_FUNC(alDeleteAuxiliaryEffectSlots(1,&mlObjectId)); return (!AL_ERROR_OCCURED && !IsValidObject()); }
bool cOAL_EffectSlot::CreateLowLevelID() { DEF_FUNC_NAME("cOAL_EffectSlot::CreateLowLevelID()"); FUNC_USES_AL; RUN_AL_FUNC(alGenAuxiliaryEffectSlots(1,&mlObjectId)); return (!AL_ERROR_OCCURED && IsValidObject()); }
void cOAL_Device::SetListenerOrientation(const float* apForward, const float* apUp) { DEF_FUNC_NAME ("cOAL_Device::SetListenerOrientation()"); FUNC_USES_AL; float fOrientation[6] = { apForward[0], apForward[1], apForward[2], apUp[0], apUp[1], apUp[2] }; RUN_AL_FUNC(alListenerfv ( AL_ORIENTATION, fOrientation )); }
void cOAL_EffectSlot::SetGain ( float afGain ) { DEF_FUNC_NAME(""); FUNC_USES_AL; if (afGain <0) afGain = 0; if (afGain >1) afGain = 1; RUN_AL_FUNC( alAuxiliaryEffectSlotf (mlObjectId, AL_EFFECTSLOT_GAIN, afGain)); }
bool cOAL_EffectSlot::AttachEffect ( cOAL_Effect *apEffect ) { DEF_FUNC_NAME("cOAL_EffectSlot::AttachEffect()"); FUNC_USES_AL; mpEffect = apEffect; RUN_AL_FUNC ( alAuxiliaryEffectSloti (mlObjectId, AL_EFFECTSLOT_EFFECT, ((mpEffect == NULL)? AL_EFFECT_NULL : mpEffect->GetEffectID()) ) ); return !AL_ERROR_OCCURED; }
void cOAL_Device::SetListenerGain ( float afGain ) { DEF_FUNC_NAME ("cOAL_Device::SetListenerGain()"); FUNC_USES_AL; if ( afGain < 0 ) afGain = 0; if ( afGain > 1 ) afGain = 1; RUN_AL_FUNC(alListenerf ( AL_GAIN, afGain )); }
void cOAL_EffectSlot::Update() { DEF_FUNC_NAME(""); FUNC_USES_AL; if (mpEffect) { mpEffect->Lock(); if (mpEffect->NeedsUpdate()) { RUN_AL_FUNC( alAuxiliaryEffectSloti(mlObjectId, AL_EFFECTSLOT_EFFECT, mpEffect->GetEffectID()) ); //LogMsg("",eOAL_LogVerbose_Medium, eOAL_LogMsg_Info, "Slot updated\n"); mpEffect->SetUpdated(); } mpEffect->Unlock(); } }
bool cOAL_Device::Init( cOAL_Init_Params& acParams ) { DEF_FUNC_NAME(cOAL_Device::Init); FUNC_USES_ALC; FUNC_USES_AL; LogMsg("",eOAL_LogVerbose_Low, eOAL_LogMsg_Command, "Initializing device: %s...\n", (acParams.msDeviceName == "")? "\"preferred\"":acParams.msDeviceName.c_str() ); LogMsg("",eOAL_LogVerbose_High, eOAL_LogMsg_Info, "Configuring streaming options:\n"); cOAL_Stream::SetBufferSize(acParams.mlStreamingBufferSize); LogMsg("",eOAL_LogVerbose_High, eOAL_LogMsg_Info, "\tSetting buffer size to %d bytes\n",cOAL_Stream::GetBufferSize()); cOAL_Stream::SetBufferCount(acParams.mlStreamingBufferCount); LogMsg("",eOAL_LogVerbose_High, eOAL_LogMsg_Info, "\tSetting queue length to %d buffers\n",cOAL_Stream::GetBufferCount()); LogMsg("",eOAL_LogVerbose_Low, eOAL_LogMsg_Info, "Attempting to open device...\n" ); // Open the device, if fails return false if(acParams.msDeviceName.empty()) mpDevice = alcOpenDevice(NULL); else mpDevice = alcOpenDevice( acParams.msDeviceName.c_str() ); if(mpDevice == NULL) { LogMsg("",eOAL_LogVerbose_Low, eOAL_LogMsg_Error, "Error opening device\n" ); return false; } LogMsg("",eOAL_LogVerbose_Low, eOAL_LogMsg_Info, "Success.\n" ); // Get ALC extensions ( ie EFX ) LogMsg("",eOAL_LogVerbose_Low, eOAL_LogMsg_Info, "Checking present ALC extensions\n" ); for (int i = 0; i < NUM_ALC_EXTENSIONS; ++i) { mvbExtensions[i] = RUN_ALC_FUNC((alcIsExtensionPresent(mpDevice,sExtensionNames[i].c_str()) == ALC_TRUE)); if (mvbExtensions[i]) { LogMsg("",eOAL_LogVerbose_High, eOAL_LogMsg_Info, "\t%s\n",sExtensionNames[i].c_str() ); } } ALCint lAttrList[] = { ALC_FREQUENCY, acParams.mlOutputFreq, #ifdef __APPLE__ #else ALC_MONO_SOURCES, acParams.mbVoiceManagement ? 256 : acParams.mlMinMonoSourcesHint, ALC_STEREO_SOURCES, acParams.mbVoiceManagement ? 0 : acParams.mlMinStereoSourcesHint, #endif ALC_MAX_AUXILIARY_SENDS, acParams.mlNumSendsHint, 0, }; LogMsg("",eOAL_LogVerbose_Low, eOAL_LogMsg_Info, "Creating context\n"); // Create and set a context mpContext = RUN_ALC_FUNC(alcCreateContext ( mpDevice, lAttrList )); RUN_ALC_FUNC(alcMakeContextCurrent ( mpContext )); if (ALC_ERROR_OCCURED) { LogMsg("",eOAL_LogVerbose_Low, eOAL_LogMsg_Error, "Error creating context\n"); return false; } ///////////////////////////////////////////////// //Retrieve device info, such as extensions LogMsg("",eOAL_LogVerbose_Low, eOAL_LogMsg_Info, "Checking present AL extensions\n" ); for (int i = NUM_ALC_EXTENSIONS; i < NUM_EXTENSIONS; ++i) { mvbExtensions[i] = RUN_AL_FUNC((alIsExtensionPresent(sExtensionNames[i].c_str()) == AL_TRUE)); if (mvbExtensions[i]) LogMsg("",eOAL_LogVerbose_High, eOAL_LogMsg_Info, "\t%s\n",sExtensionNames[i].c_str() ); } LogMsg("",eOAL_LogVerbose_Low, eOAL_LogMsg_Info, "Retrieving Output Devices\n"); vector<string> llDevices = GetOutputDevices(); vector<string>::iterator it; for (it = llDevices.begin(); it != llDevices.end(); ++it) { LogMsg("",eOAL_LogVerbose_Low, eOAL_LogMsg_Info, "\t%s\n", (*it).c_str()); } LogMsg("",eOAL_LogVerbose_Low, eOAL_LogMsg_Info, "Retrieving info\n" ); // Get device name msDeviceName = RUN_ALC_FUNC(alcGetString(mpDevice, ALC_DEVICE_SPECIFIER)); // Get vendor name (just fancy stuff,not very useful) msVendorName = RUN_ALC_FUNC(alGetString( AL_VENDOR )); //Get renderer info msRenderer = RUN_ALC_FUNC(alGetString ( AL_RENDERER )); // Get the OpenAL impl. version RUN_ALC_FUNC(alcGetIntegerv ( mpDevice, ALC_MAJOR_VERSION, sizeof(ALCint), &mlMajorVersion )); RUN_ALC_FUNC(alcGetIntegerv ( mpDevice, ALC_MINOR_VERSION, sizeof(ALCint), &mlMinorVersion )); RUN_ALC_FUNC(alcGetIntegerv ( mpDevice, ALC_MAX_AUXILIARY_SENDS, sizeof(ALCint), &mlEFXSends)); LogMsg("",eOAL_LogVerbose_High, eOAL_LogMsg_Info, "Device name: %s\n", msDeviceName.c_str() ); LogMsg("",eOAL_LogVerbose_High, eOAL_LogMsg_Info, "OpenAL version: %d.%d\n", mlMajorVersion, mlMinorVersion ); // Check device version if ( (mlMajorVersion < acParams.mlMajorVersionReq) || ((mlMajorVersion == acParams.mlMajorVersionReq) && (mlMinorVersion < acParams.mlMinorVersionReq)) ) { LogMsg("",eOAL_LogVerbose_None, eOAL_LogMsg_Error, "Version required: %d.%d\n",acParams.mlMajorVersionReq,acParams.mlMinorVersionReq); return false; } // If alSourceNumHint == -1, create as many sources as possible if (acParams.mlNumSourcesHint == -1) acParams.mlNumSourcesHint = 4096; ///////////////////////////////////////////////// //Start EFX if requested if (acParams.mbUseEFX && IsExtensionAvailable (OAL_ALC_EXT_EFX)) { LogMsg("",eOAL_LogVerbose_Low, eOAL_LogMsg_Info, "Starting EFX on request\n" ); mpEFXManager = new cOAL_EFXManager; mbEFXActive = mpEFXManager->Initialize( acParams.mlNumSlotsHint, mlEFXSends, acParams.mbUseThread, acParams.mlSlotUpdateFreq ); if (!mbEFXActive) { mpEFXManager->Destroy(); delete mpEFXManager; } } LogMsg("",eOAL_LogVerbose_Low, eOAL_LogMsg_Info, "Creating Source Manager\n" ); //Create The source manager mpSourceManager = new cOAL_SourceManager; if ( mpSourceManager->Initialize( acParams.mbVoiceManagement, acParams.mlNumSourcesHint, acParams.mbUseThread, acParams.mlUpdateFreq, mlEFXSends ) == false) { LogMsg("",eOAL_LogVerbose_None, eOAL_LogMsg_Error, "Error creating Source Manager\n"); return false; } return true; }