Beispiel #1
0
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);
            }
        }
    }
}
Beispiel #2
0
MOboolean moSoundManager::Init() {

	if (!m_pResourceManager) return false;

  moResource::Init();

#ifdef MO_WIN32
    #ifdef MO_USING_ALFW
	ALenum			eBufferFormat = 0;

	ALFWInit();

	if (!ALFWInitOpenAL())
	{
		ALFWprintf("Failed to initialize OpenAL\n");
		ALFWShutdown();
		return 0;
	}

	// For this example, we are going to play a 5.1 test file ...
	/*eBufferFormat = alGetEnumValue("AL_FORMAT_51CHN16");
	if (!eBufferFormat)
	{
		ALFWprintf("No support for 5.1 playback!\n");
		ALFWShutdownOpenAL();
		ALFWShutdown();
		return 0;
	}
*/

	if (ALFWIsXRAMSupported()) {
		//continue
	}
	if (ALFWIsEFXSupported()) {

		//esto deberia configurarse desde el config
		moSoundEffect* pneweffect = new moSoundEffect();
		/*
		ALuint genfxid;
		if (pneweffect) {
			alGenEffects(1, &genfxid);
			pneweffect->m_EffectId  = genfxid;
			alEffecti(pneweffect->m_EffectId, AL_EFFECT_TYPE, AL_EFFECT_COMPRESSOR);
			m_effects_array.Add(pneweffect);
		}

		pneweffect = new moSoundEffect();
		genfxid;
		if (pneweffect) {
			alGenEffects(1, &genfxid);
			pneweffect->m_EffectId  = genfxid;
			alEffecti(pneweffect->m_EffectId, AL_EFFECT_TYPE, AL_EFFECT_EQUALIZER);
			m_effects_array.Add(pneweffect);
		}*/
	}
  #endif
	#endif

	#ifdef MO_LINUX

	#endif

	m_sounds_array.Init( 0, NULL );

	m_bInitialized = true;

	return m_bInitialized;
}
Beispiel #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
}