示例#1
0
DsVolume OpenALAudio::get_loop_wav_volume(int id)
{
   StreamContext *sc;
   StreamMap::const_iterator itr;
   float position[3];
   float gain;

   if (!this->wav_init_flag)
      return DsVolume(0, 0);

   itr = this->streams.find(id);
   if (itr == this->streams.end())
      return DsVolume(0, 0);

   sc = itr->second;

   alGetSourcef(sc->source, AL_GAIN, &gain);
   alGetSourcefv(sc->source, AL_POSITION, position);

   if (sc->fade_frames != 0)
      gain *= 1.f - float(sc->fade_frames_played) / sc->fade_frames;

   return DsVolume(ratio_to_millibels(gain),
		(long)((position[0] / PANNING_MAX_X) * 10000.f + .5f)); // (long) cast fixes warning.

}
示例#2
0
	Vector3f SoundEmitter::GetPosition() const
	{
		Vector3f position;
		alGetSourcefv(m_source, AL_POSITION, position);

		return position;
	}
示例#3
0
	Vector3f SoundEmitter::GetVelocity() const
	{
		Vector3f velocity;
		alGetSourcefv(m_source, AL_VELOCITY, velocity);

		return velocity;
	}
示例#4
0
		Vec3 Source::velocity ()
		{
			Vec3 value;

			alGetSourcefv(_source_id, AL_VELOCITY, (ALfloat *)value.data());

			return value;
		}
示例#5
0
		Vec3 Source::position ()
		{
			Vec3 value;

			alGetSourcefv(_source_id, AL_POSITION, (ALfloat *)value.data());

			return value;
		}
示例#6
0
	//-------------------------------------------------------------------------------------------------
    float SoundOpenAL::getPan() const
	{
		ALfloat pos[3] = { 0.0f, 0.0f, 0.0f };
		alGetSourcefv(sourceId, AL_POSITION, pos);

		float pan = (pos[0] / (2.0f * PosPanFactor)) + 0.5f;
		return pan;
	}
示例#7
0
void al_getsourcefv( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) {

	if (NULL == alGetSourcefv) mogl_glunsupported("alGetSourcefv");
	alGetSourcefv((ALuint)mxGetScalar(prhs[0]),
		(ALenum)mxGetScalar(prhs[1]),
		(ALfloat*)mxGetData(prhs[2]));

}
示例#8
0
void Source::getPosition(float *v) const
{
	if (channels > 1)
		throw SpatialSupportException();

	if (valid)
		alGetSourcefv(source, AL_POSITION, v);
	else
		setFloatv(v, position);
}
示例#9
0
void Source::getVelocity(float *v) const
{
	if (channels > 1)
		throw SpatialSupportException();

	if (valid)
		alGetSourcefv(source, AL_VELOCITY, v);
	else
		setFloatv(v, velocity);
}
示例#10
0
void Source::getDirection(float *v) const
{
	if (channels > 1)
		throw SpatialSupportException();

	if (valid)
		alGetSourcefv(source, AL_DIRECTION, v);
	else
		setFloatv(v, direction);
}
int main( void )
{
	ALCdevice *device;
	ALCcontext *context = NULL;
	ALfloat pregain = FLOAT_VAL;
	ALfloat postgain = 0.0;
	ALuint sid;

	device = alcOpenDevice( NULL );
	if( device == NULL ) {
		return EXIT_FAILURE;
	}

	context = alcCreateContext( device, NULL );
	if( context == NULL ) {
		alcCloseDevice( device );

		return EXIT_FAILURE;
	}

	alcMakeContextCurrent( context );

	alListenerf( AL_GAIN, pregain );
	alGetListenerfv( AL_GAIN, &postgain );

	if( postgain != pregain ) {
		fprintf( stderr, "Listener GAIN f***ed up: %f vs %f\n",
			 pregain, postgain );
	}

	alGenSources( 1, &sid );

	alSourcef( sid, AL_GAIN, pregain );
	alGetSourcefv( sid, AL_GAIN, &postgain );

	if( postgain != pregain ) {
		fprintf( stderr, "Source GAIN f***ed up: %f vs %f\n",
			 pregain, postgain );
	}

	fprintf( stderr, "All tests okay\n" );

	fflush( stderr );

	alcMakeContextCurrent( NULL );

	alcCloseDevice( device );

	return EXIT_SUCCESS;
}
示例#12
0
//Get position of source (3d sound)
bool SoundManager::GetSourcePosition( unsigned int source, float& posx, float& posy, float& posz )
{
	ALfloat pos[3];
	alGetSourcefv(mSources[source].source, AL_POSITION, pos);
	//Check errors
	ALenum error(alGetError());
	if(error != AL_NO_ERROR)
	{
		SingletonLogMgr::Instance()->AddNewLine("SoundManager::GetSourcePosition","Failure while getting source values (" + GetALErrorString(error,false) + ")",LOGEXCEPTION);
		return false;
	}
	posx = pos[0];
	posy = pos[1];
	posz = pos[2];
	return true;
}
示例#13
0
	value lime_al_get_sourcefv (int source, int param, int count) {
		
		ALfloat* values = new ALfloat[count];
		alGetSourcefv (source, param, values);
		
		value result = alloc_array (count);
		
		for (int i = 0; i < count; i++) {
			
			val_array_set_i (result, i, alloc_float (values[i]));
			
		}
		
		delete [] values;
		return result;
		
	}
示例#14
0
value lime_al_get_sourcefv (value source, value param, value count) {

    int length = val_int (count);
    ALfloat* values = new ALfloat[length];

    alGetSourcefv (val_int (source), val_int (param), values);

    value result = alloc_array (length);

    for (int i = 0; i < length; ++i) {

        val_array_set_i (result, i, alloc_float (values[i]));

    }

    return result;

}
示例#15
0
文件: KLAL.c 项目: klib/example
bl KLAL_StopWithCheck( KLAL* p, ALfloat stopsec )
{
	
	if( !p )
		p = &klal;
	
	if( stopsec )
	{
		float f = 0;
		alGetSourcefv( p->src, AL_SEC_OFFSET, &f );
		if( stopsec<=f )
		{
			KLAL_Stop(p);
			return TRUE;
		}
	}
	return FALSE;
}
示例#16
0
AUD_Vector3 AUD_OpenALDevice::AUD_OpenALHandle::getSourceVelocity()
{
	AUD_Vector3 result = AUD_Vector3(0, 0, 0);

	if(!m_status)
		return result;

	m_device->lock();

	ALfloat v[3];
	alGetSourcefv(m_source, AL_VELOCITY, v);

	m_device->unlock();

	result = AUD_Vector3(v[0], v[1], v[2]);

	return result;
}
示例#17
0
AUD_Vector3 AUD_OpenALDevice::AUD_OpenALHandle::getSourceLocation()
{
	AUD_Vector3 result = AUD_Vector3(0, 0, 0);

	if(!m_status)
		return result;

	m_device->lock();

	ALfloat p[3];
	alGetSourcefv(m_source, AL_POSITION, p);

	m_device->unlock();

	result = AUD_Vector3(p[0], p[1], p[2]);

	return result;
}
示例#18
0
Vector3 OpenALDevice::OpenALHandle::getLocation()
{
	Vector3 result = Vector3(0, 0, 0);

	if(!m_status)
		return false;

	std::lock_guard<ILockable> lock(*m_device);

	if(!m_status)
		return result;

	ALfloat p[3];
	alGetSourcefv(m_source, AL_POSITION, p);

	result = Vector3(p[0], p[1], p[2]);

	return result;
}
示例#19
0
Vector3 OpenALDevice::OpenALHandle::getVelocity()
{
	Vector3 result = Vector3(0, 0, 0);

	if(!m_status)
		return false;

	std::lock_guard<ILockable> lock(*m_device);

	if(!m_status)
		return result;

	ALfloat v[3];
	alGetSourcefv(m_source, AL_VELOCITY, v);

	result = Vector3(v[0], v[1], v[2]);

	return result;
}
示例#20
0
//Get speed of source (3d source)
bool SoundManager::GetSourceSpeed(unsigned int source, float& velx, float& vely, float& velz)
{
	if (source >= 0 && (unsigned int)source<mSources.size() && mSources[source].reserved)
	{
		ALfloat vel[3];
		alGetSourcefv(mSources[source].source, AL_VELOCITY, vel);
		//Check errors
		ALenum error(alGetError());
		if(error != AL_NO_ERROR)
		{
			SingletonLogMgr::Instance()->AddNewLine("SoundManager::GetSourceSpeed","Failure while getting source values (" + GetALErrorString(error,false) + ")",LOGEXCEPTION);
		}
		velx = vel[0];
		vely = vel[1];
		velz = vel[2];
		return true;
	}
	else
	{
		SingletonLogMgr::Instance()->AddNewLine("SoundManager::GetSourceSpeed","Can't set source speed. Invalid source " + source ,LOGEXCEPTION);
		return false;
	}	
}
示例#21
0
	// 获取声源速度
	/////////////////////////////////////////////////////////////////////////////////
	float3 OALMusicBuffer::Velocity() const
	{
		float vel[3];
		alGetSourcefv(source_, AL_VELOCITY, vel);
		return ALVecToVec(float3(vel[0], vel[1], vel[2]));
	}
JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL10_nalGetSourcefv(JNIEnv *__env, jclass clazz, jint source, jint param, jlong valuesAddress, jlong __functionAddress) {
	ALfloat *values = (ALfloat *)(intptr_t)valuesAddress;
	alGetSourcefvPROC alGetSourcefv = (alGetSourcefvPROC)(intptr_t)__functionAddress;
	UNUSED_PARAMS(__env, clazz)
	alGetSourcefv(source, param, values);
}
示例#23
0
文件: Sound.cpp 项目: adam000/Apollo
float MusicVolume()
{
	ALfloat rv;
	alGetSourcefv(musicSource, AL_GAIN, &rv);
	return rv;
}
示例#24
0
文件: openal.c 项目: AmesianX/RosWine
ALvoid CDECL wine_alGetSourcefv(ALuint sid, ALenum param, ALfloat* values)
{
    alGetSourcefv(sid, param, values);
}
示例#25
0
文件: luaal.c 项目: darkf/almixer
static int lua_alGetSource(lua_State* lua_state)
{
	ALuint source_id;
	ALenum enum_parameter;
	int openal_primitive_type;

	source_id = lua_tointeger(lua_state, 1);
	enum_parameter = lua_tointeger(lua_state, 2);

	openal_primitive_type = lua_getTypeForEnum(enum_parameter);

	switch(openal_primitive_type)
	{
		case LUAOPENAL_BOOL_TYPE:
		{
			ALint ret_val;
			alGetSourcei(source_id, enum_parameter, &ret_val);
			lua_pushboolean(lua_state, ret_val);
			return 1;
			break;
		}
		case LUAOPENAL_INT_TYPE:
		{
			ALint ret_val;
			alGetSourcei(source_id, enum_parameter, &ret_val);
			lua_pushinteger(lua_state, ret_val);
			return 1;
			break;
		}
		case LUAOPENAL_FLOAT_TYPE:
		{
			ALfloat ret_val;
			alGetSourcef(source_id, enum_parameter, &ret_val);
			lua_pushnumber(lua_state, ret_val);
			return 1;
			break;
		}
		case LUAOPENAL_INT_3_TYPE:
		{
			ALint ret_val[3];
			alGetSourceiv(source_id, enum_parameter, ret_val);
			lua_pushinteger(lua_state, ret_val[0]);
			lua_pushinteger(lua_state, ret_val[1]);
			lua_pushinteger(lua_state, ret_val[2]);
			return 3;
			break;	
		}
		case LUAOPENAL_FLOAT_3_TYPE:
		{
			ALfloat ret_val[3];
			alGetSourcefv(source_id, enum_parameter, ret_val);
			lua_pushnumber(lua_state, ret_val[0]);
			lua_pushnumber(lua_state, ret_val[1]);
			lua_pushnumber(lua_state, ret_val[2]);
			return 3;
			break;			
		}
		default:
		{
			/* TODO: Figure out how to handle OpenAL extensions. */
			luaL_error(lua_state, "Unhandled parameter type for alGetSource*");
		}
	}
	return 0;
}
示例#26
0
static PyObject*
_sources_getprop (PyObject *self, PyObject *args)
{
    long bufnum;
    ALenum param;
    char *type;
    int size = 0, cnt;
    PropType ptype = INVALID;

    if (!CONTEXT_IS_CURRENT (((PySources*)self)->context))
    {
        PyErr_SetString (PyExc_PyGameError, "source context is not current");
        return NULL;
    }

    if (!PyArg_ParseTuple (args, "lls:get_prop", &bufnum, &param, &type))
    {
        PyErr_Clear ();
        if (!PyArg_ParseTuple (args, "lls|i:get_prop", &bufnum, &param, &type,
                               &size))
            return NULL;
        if (size <= 0)
        {
            PyErr_SetString (PyExc_ValueError, "size must not smaller than 0");
            return NULL;
        }
    }

    ptype = GetPropTypeFromStr (type);
    CLEAR_ALERROR_STATE ();
    switch (ptype)
    {
    case INT:
    {
        ALint val;
        alGetSourcei ((ALuint)bufnum, param, &val);
        if (SetALErrorException (alGetError (), 0))
            return NULL;
        return PyLong_FromLong ((long)val);
    }
    case FLOAT:
    {
        ALfloat val;
        alGetSourcef ((ALuint)bufnum, param, &val);
        if (SetALErrorException (alGetError (), 0))
            return NULL;
        return PyFloat_FromDouble ((double)val);
    }
    case INT3:
    {
        ALint val[3];
        alGetSource3i ((ALuint)bufnum, param, &val[0], &val[1], &val[2]);
        if (SetALErrorException (alGetError (), 0))
            return NULL;
        return Py_BuildValue ("(lll)", (long)val[0], (long)val[1],
                              (long)val[2]);
    }
    case FLOAT3:
    {
        ALfloat val[3];
        alGetSource3f ((ALuint)bufnum, param, &val[0], &val[1], &val[2]);
        if (SetALErrorException (alGetError (), 0))
            return NULL;
        return Py_BuildValue ("(ddd)", (double)val[0], (double)val[1],
                              (double)val[2]);
    }
    case INTARRAY:
    {
        PyObject *tuple, *item;
        ALint* val = PyMem_New (ALint, size);
        if (!val)
            return NULL;
        alGetSourceiv ((ALuint)bufnum, param, val);
        if (SetALErrorException (alGetError (), 0))
        {
            PyMem_Free (val);
            return NULL;
        }
        tuple = PyTuple_New ((Py_ssize_t) size);
        if (!tuple)
            return NULL;
        for (cnt = 0; cnt < size; cnt++)
        {
            item = PyLong_FromLong ((long)val[cnt]);
            if (!item)
            {
                PyMem_Free (val);
                Py_DECREF (tuple);
                return NULL;
            }
            PyTuple_SET_ITEM (tuple, (Py_ssize_t) cnt, item);
        }
        return tuple;
    }
    case FLOATARRAY:
    {
        PyObject *tuple, *item;
        ALfloat* val = PyMem_New (ALfloat, size);
        if (!val)
            return NULL;
        alGetSourcefv ((ALuint)bufnum, param, val);
        if (SetALErrorException (alGetError (), 0))
        {
            PyMem_Free (val);
            return NULL;
        }
        tuple = PyTuple_New ((Py_ssize_t) size);
        if (!tuple)
            return NULL;
        for (cnt = 0; cnt < size; cnt++)
        {
            item = PyFloat_FromDouble ((double)val[cnt]);
            if (!item || PyTuple_SET_ITEM (tuple, (Py_ssize_t) cnt, item) != 0)
            {
                PyMem_Free (val);
                Py_XDECREF (item);
                Py_DECREF (tuple);
                return NULL;
            }
        }
        return tuple;
    }
    default:
        PyErr_SetString (PyExc_ValueError, "invalid type specifier");
        return NULL;
    }
}
示例#27
0
文件: ALu.c 项目: OLR-xray/OLR-3.0
ALUAPI ALvoid ALUAPIENTRY aluCalculateSourceParameters(ALuint source,ALuint freqOutput,ALuint numOutputChannels,ALfloat *drysend,ALfloat *wetsend,ALfloat *pitch)
{
	ALfloat ListenerOrientation[6],ListenerPosition[3],ListenerVelocity[3];
	ALfloat InnerAngle,OuterAngle,OuterGain,Angle,Distance,DryMix,WetMix;
	ALfloat Direction[3],Position[3],Velocity[3],SourceToListener[3];
	ALfloat MinVolume,MaxVolume,MinDist,MaxDist,Rolloff;
	ALfloat Pitch,ConeVolume,SourceVolume,PanningFB,PanningLR,ListenerGain;
	ALuint NumBufferChannels;
	ALfloat U[3],V[3],N[3];
	ALfloat DopplerFactor, DopplerVelocity, flSpeedOfSound, flMaxVelocity;
	ALfloat flVSS, flVLS;
	ALuint DistanceModel;
	ALfloat Matrix[3][3];
	ALint HeadRelative;
	ALuint Buffer;
	ALenum Error;
	ALfloat flAttenuation;

	if (alIsSource(source))
	{
		//Get global properties
		alGetFloatv(AL_DOPPLER_FACTOR,&DopplerFactor);
		alGetIntegerv(AL_DISTANCE_MODEL,&DistanceModel);
		alGetFloatv(AL_DOPPLER_VELOCITY,&DopplerVelocity);
		alGetFloatv(AL_SPEED_OF_SOUND,&flSpeedOfSound);
				
		//Get listener properties
		alGetListenerfv(AL_GAIN,&ListenerGain);
		alGetListenerfv(AL_POSITION,ListenerPosition);
		alGetListenerfv(AL_VELOCITY,ListenerVelocity);
		alGetListenerfv(AL_ORIENTATION,ListenerOrientation);

		//Get source properties
		alGetSourcef(source,AL_PITCH,&Pitch);
		alGetSourcef(source,AL_GAIN,&SourceVolume);
		alGetSourcei(source,AL_BUFFER,&Buffer);
		alGetSourcefv(source,AL_POSITION,Position);
		alGetSourcefv(source,AL_VELOCITY,Velocity);
		alGetSourcefv(source,AL_DIRECTION,Direction);
		alGetSourcef(source,AL_MIN_GAIN,&MinVolume);
		alGetSourcef(source,AL_MAX_GAIN,&MaxVolume);
		alGetSourcef(source,AL_REFERENCE_DISTANCE,&MinDist);
		alGetSourcef(source,AL_MAX_DISTANCE,&MaxDist);
		alGetSourcef(source,AL_ROLLOFF_FACTOR,&Rolloff);
		alGetSourcef(source,AL_CONE_OUTER_GAIN,&OuterGain);
		alGetSourcef(source,AL_CONE_INNER_ANGLE,&InnerAngle);
		alGetSourcef(source,AL_CONE_OUTER_ANGLE,&OuterAngle);
		alGetSourcei(source,AL_SOURCE_RELATIVE,&HeadRelative);
		
		//Set working variables
		DryMix=(ALfloat)(1.0f);
		WetMix=(ALfloat)(0.0f);

		//Get buffer properties
		alGetBufferi(Buffer,AL_CHANNELS,&NumBufferChannels);
		//Only apply 3D calculations for mono buffers
		if (NumBufferChannels==1)
		{
			//1. Translate Listener to origin (convert to head relative)
			if (HeadRelative==AL_FALSE)
			{
				Position[0]-=ListenerPosition[0];
				Position[1]-=ListenerPosition[1];
				Position[2]-=ListenerPosition[2];
			}
			
			//2. Calculate distance attenuation
			Distance=(ALfloat)sqrt(aluDotproduct(Position,Position));

			// Clamp to MinDist and MaxDist if appropriate
			if ((DistanceModel == AL_INVERSE_DISTANCE_CLAMPED) ||
				(DistanceModel == AL_LINEAR_DISTANCE_CLAMPED)  ||
				(DistanceModel == AL_EXPONENT_DISTANCE_CLAMPED))
			{
				Distance=(Distance<MinDist?MinDist:Distance);
				Distance=(Distance>MaxDist?MaxDist:Distance);
			}

			flAttenuation = 1.0f;
			switch (DistanceModel)
			{
			case AL_INVERSE_DISTANCE:
				if (MinDist > 0.0f)
				{
					if ((MinDist + (Rolloff * (Distance - MinDist))) > 0.0f)
						flAttenuation = MinDist / (MinDist + (Rolloff * (Distance - MinDist)));
					else
						flAttenuation = 1000000;
				}
				break;

			case AL_INVERSE_DISTANCE_CLAMPED:
				if ((MaxDist >= MinDist) && (MinDist > 0.0f))
				{
					if ((MinDist + (Rolloff * (Distance - MinDist))) > 0.0f)
						flAttenuation = MinDist / (MinDist + (Rolloff * (Distance - MinDist)));
					else
						flAttenuation = 1000000;
				}
				break;

			case AL_LINEAR_DISTANCE:
				if (MaxDist != MinDist)
					flAttenuation = 1.0f - (Rolloff*(Distance-MinDist)/(MaxDist - MinDist));
				break;

			case AL_LINEAR_DISTANCE_CLAMPED:
				if (MaxDist > MinDist)
					flAttenuation = 1.0f - (Rolloff*(Distance-MinDist)/(MaxDist - MinDist));
				break;

			case AL_EXPONENT_DISTANCE:
				if ((Distance > 0.0f) && (MinDist > 0.0f))
					flAttenuation = (ALfloat)pow(Distance/MinDist, -Rolloff);
				break;

			case AL_EXPONENT_DISTANCE_CLAMPED:
				if ((MaxDist >= MinDist) && (Distance > 0.0f) && (MinDist > 0.0f))
					flAttenuation = (ALfloat)pow(Distance/MinDist, -Rolloff);
				break;

			case AL_NONE:
			default:
				flAttenuation = 1.0f;
				break;
			}

			// Source Gain + Attenuation
			DryMix = SourceVolume * flAttenuation;
			
			// Clamp to Min/Max Gain
			DryMix=__min(DryMix,MaxVolume);
			DryMix=__max(DryMix,MinVolume);
			WetMix=__min(WetMix,MaxVolume);
			WetMix=__max(WetMix,MinVolume);
			//3. Apply directional soundcones
			SourceToListener[0]=-Position[0];
			SourceToListener[1]=-Position[1];
			SourceToListener[2]=-Position[2];
			aluNormalize(Direction);
			aluNormalize(SourceToListener);
			Angle=(ALfloat)(180.0*acos(aluDotproduct(Direction,SourceToListener))/3.141592654f);
			if ((Angle>=InnerAngle)&&(Angle<=OuterAngle))
				ConeVolume=(1.0f+(OuterGain-1.0f)*(Angle-InnerAngle)/(OuterAngle-InnerAngle));
			else if (Angle>OuterAngle)
				ConeVolume=(1.0f+(OuterGain-1.0f)                                           );
			else
				ConeVolume=1.0f;

			//4. Calculate Velocity
			if (DopplerFactor != 0.0f)
			{
				flVLS = aluDotproduct(ListenerVelocity, SourceToListener);
				flVSS = aluDotproduct(Velocity, SourceToListener);

				flMaxVelocity = (DopplerVelocity * flSpeedOfSound) / DopplerFactor;

				if (flVSS >= flMaxVelocity)
					flVSS = (flMaxVelocity - 1.0f);
				else if (flVSS <= -flMaxVelocity)
					flVSS = -flMaxVelocity + 1.0f;

				if (flVLS >= flMaxVelocity)
					flVLS = (flMaxVelocity - 1.0f);
				else if (flVLS <= -flMaxVelocity)
					flVLS = -flMaxVelocity + 1.0f;

				pitch[0] = Pitch * ((flSpeedOfSound * DopplerVelocity) - (DopplerFactor * flVLS)) /
								   ((flSpeedOfSound * DopplerVelocity) - (DopplerFactor * flVSS));
			}
			else
			{
				pitch[0] = Pitch;
			}

			//5. Align coordinate system axes
			aluCrossproduct(&ListenerOrientation[0],&ListenerOrientation[3],U); // Right-vector
			aluNormalize(U);								// Normalized Right-vector
			memcpy(V,&ListenerOrientation[3],sizeof(V));	// Up-vector
			aluNormalize(V);								// Normalized Up-vector
			memcpy(N,&ListenerOrientation[0],sizeof(N));	// At-vector
			aluNormalize(N);								// Normalized At-vector
			Matrix[0][0]=U[0]; Matrix[0][1]=V[0]; Matrix[0][2]=-N[0];
			Matrix[1][0]=U[1]; Matrix[1][1]=V[1]; Matrix[1][2]=-N[1];
			Matrix[2][0]=U[2]; Matrix[2][1]=V[2]; Matrix[2][2]=-N[2];
			aluMatrixVector(Position,Matrix);

            //6. Convert normalized position into font/back panning
			if (Distance != 0.0f)
			{
				aluNormalize(Position);
				PanningLR=(0.5f+0.5f*Position[0]);
				PanningFB=(0.5f+0.5f*Position[2]);
			}
			else
			{
				PanningLR=0.5f;
				PanningFB=0.5f;
			}

			//7. Convert front/back panning into channel volumes
			switch (numOutputChannels)
			{
				case 1:
					drysend[0]=(ConeVolume*ListenerGain*DryMix*(ALfloat)1.0f				  );	//Direct
					wetsend[0]=(ListenerGain*WetMix*(ALfloat)1.0f							  );	//Room
					break;
				case 2:
					drysend[0]=(ConeVolume*ListenerGain*DryMix*(ALfloat)sqrt((1.0f-PanningLR)));	//FL Direct
					drysend[1]=(ConeVolume*ListenerGain*DryMix*(ALfloat)sqrt((     PanningLR)));	//FR Direct
					wetsend[0]=(           ListenerGain*WetMix*(ALfloat)sqrt((1.0f-PanningLR)));	//FL Room
					wetsend[1]=(           ListenerGain*WetMix*(ALfloat)sqrt((     PanningLR)));	//FR Room
			 		break;
				default:
					break;
			}
		}
		else
		{
			//1. Stereo buffers always play from front left/front right
			switch (numOutputChannels)
			{
				case 1:
					drysend[0]=(SourceVolume*1.0f*ListenerGain);
					wetsend[0]=(SourceVolume*0.0f*ListenerGain);
					break;
				case 2:
					drysend[0]=(SourceVolume*1.0f*ListenerGain);
					drysend[1]=(SourceVolume*1.0f*ListenerGain);
					wetsend[0]=(SourceVolume*0.0f*ListenerGain);
					wetsend[1]=(SourceVolume*0.0f*ListenerGain);
			 		break;
				default:
					break;
			}
			pitch[0]=(ALfloat)(Pitch);
		}
		Error=alGetError();
	}
}
示例#28
0
Vector3 Sound::getVector3(ALenum value)
{
  float out[3];
  alGetSourcefv(mSource, value, out);
  return Vector3(out);
}
示例#29
0
	// 获取声源方向
	/////////////////////////////////////////////////////////////////////////////////
	float3 OALMusicBuffer::Direction() const
	{
		float dir[3];
		alGetSourcefv(source_, AL_DIRECTION, dir);
		return ALVecToVec(float3(dir[0], dir[1], dir[2]));
	}
示例#30
0
	// 获取声源位置
	/////////////////////////////////////////////////////////////////////////////////
	float3 OALMusicBuffer::Position() const
	{
		float pos[3];
		alGetSourcefv(source_, AL_POSITION, pos);
		return ALVecToVec(float3(pos[0], pos[1], pos[2]));
	}