コード例 #1
0
ファイル: OALExtProvider.cpp プロジェクト: k3a/Panther3D-2
	void COALExtProvider::SetEaxReverb(ALuint effect, ALuint slot, ALuint source, EFXEAXREVERBPROPERTIES& output)
	{
		if(!m_initialized)
			return;

		if(!SetEFXEAXReverbProperties(&output, effect))
			return;

		alAuxiliaryEffectSloti(slot, AL_EFFECTSLOT_EFFECT, effect);
		alSource3i(source, AL_AUXILIARY_SEND_FILTER, slot, 0, AL_FILTER_NULL);
	}
コード例 #2
0
ファイル: QOpenALEngine.cpp プロジェクト: shujaatak/QFFmpeg
void QOpenALEngine::openEFX() {
    if (ALFWIsEFXSupported())
    {
        if (CreateAuxEffectSlot(&uiEffectSlot))
        {
            if (CreateEffect(&uiEffect, AL_EFFECT_EAXREVERB))
            {
                // ConvertReverbParameters(&eaxBathroom, &efxReverb);
                efxReverb=eaxBathroom;

                // Set the Effect parameters
                if (!SetEFXEAXReverbProperties(&efxReverb, uiEffect))
                    return;
                // Load Effect into Auxiliary Effect Slot
                alAuxiliaryEffectSloti(uiEffectSlot, AL_EFFECTSLOT_EFFECT, uiEffect);
                // Enable (non-filtered) Send from Source to Auxiliary Effect Slot
                alSource3i(uiSource, AL_AUXILIARY_SEND_FILTER, uiEffectSlot, 0, AL_FILTER_NULL);
            }
        }
    }
}
コード例 #3
0
void Audio::init()
{
#ifdef WIN32
	EFXEAXREVERBPROPERTIES efxReverb;
	int attrib[] = {ALC_MAX_AUXILIARY_SENDS, 4};
	int sends;
	ALenum al_err;
#endif

	debugf("Using default audio device: %s\n", alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER));
	device = alcOpenDevice(NULL);
	if (device == NULL)
	{
		debugf("No sound device/driver has been found.\n");
		return;
	}

#ifdef WIN32
    context = alcCreateContext(device, attrib);
#else
    context = alcCreateContext(device, NULL);
#endif
	if (context == NULL)
	{
		debugf("alcCreateContext failed.\n");
	}

	if ( alcMakeContextCurrent(context) == ALC_FALSE )
	{
		ALCenum error = alcGetError(device);

		switch (error)
		{
		case ALC_NO_ERROR:
			debugf("alcMakeContextCurrent failed: No error.\n");
			break;
		case ALC_INVALID_DEVICE:
			debugf("alcMakeContextCurrent failed: Invalid device.\n");
			break;
		case ALC_INVALID_CONTEXT:
			debugf("alcMakeContextCurrent failed: Invalid context.\n");
			break;
		case ALC_INVALID_ENUM:
			debugf("alcMakeContextCurrent failed: Invalid enum.\n");
			break;
		case ALC_INVALID_VALUE:
			debugf("alcMakeContextCurrent failed: Invalid value.\n");
			break;
		case ALC_OUT_OF_MEMORY:
			debugf("alcMakeContextCurrent failed: Out of memory.\n");
			break;
		}
		return;
	}
#ifdef WIN32
	alcGetIntegerv(device, ALC_MAX_AUXILIARY_SENDS, 1, &sends);
	debugf("%d sends per audio source\n", sends);
#endif
	alListenerf(AL_REFERENCE_DISTANCE, 100.0f);

	//gain = 	(distance / AL_REFERENCE_DISTANCE) ^ (-AL_ROLLOFF_FACTOR
	alDistanceModel(AL_EXPONENT_DISTANCE);
	alListenerf(AL_ROLLOFF_FACTOR, 0.000001f);
//	alListenerf(AL_MAX_DISTANCE, 10000.0f);

	alDopplerFactor(1.0f);
//	alDopplerVelocity(8.0f);
//	alSpeedOfSound(343.3f * UNITS_TO_METERS);
#ifdef WIN32
	alListenerf(AL_METERS_PER_UNIT, 0.3f);

	ALFWIsEFXSupported();
	alGenAuxiliaryEffectSlots(1, &slot);
	al_err = alGetError();
	if (al_err != AL_NO_ERROR)
	{
		debugf("Unable to generate slot: %s\n", GetALErrorString(al_err));
		return;
	}

	alGenEffects(1, &effect);
	al_err = alGetError();
	if (al_err != AL_NO_ERROR)
	{
		debugf("Unable to generate effect: %s\n", GetALErrorString(al_err));
		return;
	}
	alEffecti(effect, AL_EFFECT_TYPE, AL_EFFECT_EAXREVERB);
	al_err = alGetError();
	if (al_err != AL_NO_ERROR)
	{
		debugf("Unable to set effect: %s\n", GetALErrorString(al_err));
		return;
	}
	ConvertReverbParameters(&eaxBathroom, &efxReverb);
	SetEFXEAXReverbProperties(&efxReverb, effect);

//	alEffectf(effect, AL_REVERB_GAIN, 1.0f);
//	alEffectf(effect, AL_REVERB_DECAY_TIME, 20.0f);
//	alEffectf(effect, AL_REVERB_DENSITY, 0.25f);

	alGenFilters(1, &filter);
	al_err = alGetError();
	if (al_err != AL_NO_ERROR)
	{
		debugf("Unable to generate filter: %s\n", GetALErrorString(al_err));
		return;
	}

	alFilteri(filter, AL_FILTER_TYPE, AL_FILTER_LOWPASS);
	alFilterf(filter, AL_LOWPASS_GAIN, 0.5f);
	alFilterf(filter, AL_LOWPASS_GAINHF, 0.5f);
#endif
}
コード例 #4
0
ALSequencer::ALSequencer()
{
	bInitialised = false;
	bDestroying = false;

	fileCount = 0;
	startPos =
	endPos = 0;
	curPos = MAX_SEQUENCE;
	sfxPos = 0;

	pWaveLoader = NULL;

	bPlay = false;

	flEffectSends[0] = 
	flEffectSends[1] = 
	flEffectSends[2] = 
	flEffectSends[3] = 0.0f;

	ulOutputChannels = 0;
	ulNumEffects = 0;
	ulNumSamples = 0;
	ulBuffersProcessed = 0;

	pOutput = 0;
	pEffectOutput[0] = 
	pEffectOutput[1] = 
	pEffectOutput[2] = 
	pEffectOutput[3] = 0;

	if (InitializeOpenAL(NULL, 2, 4, 10240, 44100)) {
		alutInitWithoutContext(NULL, NULL);

		ulOutputChannels = GetNumOutputChannels();
		ulNumEffects = GetNumEffects();
		ulNumSamples = GetNumSamplesPerBuffer();

		bOutOfMemory = false;
		pOutput = malloc(ulOutputChannels * ulNumSamples * 2);
		for (unsigned long ulLoop = 0; ulLoop < ulNumEffects; ulLoop++)
		{
			pEffectOutput[ulLoop] = malloc(ulNumSamples * 2);
			if (pEffectOutput[ulLoop] == NULL)
				bOutOfMemory = true;
		}

		pWaveLoader = new CWaves();

		bInitialised = true;

		if (pWaveLoader && pOutput && !bOutOfMemory) {
			Start();

			EFXEAXREVERBPROPERTIES EFXEAXReverb[1] = { EFX_EAX_REVERB_HANGAR };

			SetEFXEAXReverbProperties(&EFXEAXReverb[0], 0);

			hThread = CreateThread(NULL, 0, ALSequencer::ThreadFuncWrapper, this, 0, &dwThreadId);
		}
	}
}