Audio in Torque 3d

Expanding and utilizing the engine via C++.
23 posts Page 2 of 3
marauder2k9
Posts: 211
Joined: Wed Feb 18, 2015 7:36 am
by marauder2k9 » Sun Oct 14, 2018 12:36 am
that worked 100% thank you!!!

Now to test if the effect actually gets applied lol
marauder2k9
Posts: 211
Joined: Wed Feb 18, 2015 7:36 am
by marauder2k9 » Sun Oct 14, 2018 12:44 am
its crashing each time i go to play a sound, think i might have to create a separate file for effects such as reverb etc
marauder2k9
Posts: 211
Joined: Wed Feb 18, 2015 7:36 am
by marauder2k9 » Sun Oct 14, 2018 1:02 pm
Okay i have it stable now but no reverb effect is being made. I think the function to create the reverb isnt being called:

in sfxALDevice.cpp i have
ALuint SFXALDevice::setReverb(EFXEAXREVERBPROPERTIES *reverb)
{
	ALuint effect = 0;

		mOpenAL.alGenEffects(1, &effect);

		mOpenAL.alEffecti(effect, AL_EFFECT_TYPE, AL_EFFECT_REVERB);

		mOpenAL.alEffectf(effect, AL_REVERB_DENSITY, reverb->flDensity);
		mOpenAL.alEffectf(effect, AL_REVERB_DIFFUSION, reverb->flDiffusion);
		mOpenAL.alEffectf(effect, AL_REVERB_GAIN, reverb->flGain);
		mOpenAL.alEffectf(effect, AL_REVERB_GAINHF, reverb->flGainHF);
		mOpenAL.alEffectf(effect, AL_REVERB_DECAY_TIME, reverb->flDecayTime);
		mOpenAL.alEffectf(effect, AL_REVERB_DECAY_HFRATIO, reverb->flDecayHFRatio);
		mOpenAL.alEffectf(effect, AL_REVERB_REFLECTIONS_GAIN, reverb->flReflectionsGain);
		mOpenAL.alEffectf(effect, AL_REVERB_REFLECTIONS_DELAY, reverb->flReflectionsDelay);
		mOpenAL.alEffectf(effect, AL_REVERB_LATE_REVERB_GAIN, reverb->flLateReverbGain);
		mOpenAL.alEffectf(effect, AL_REVERB_LATE_REVERB_DELAY, reverb->flLateReverbDelay);
		mOpenAL.alEffectf(effect, AL_REVERB_AIR_ABSORPTION_GAINHF, reverb->flAirAbsorptionGainHF);
		mOpenAL.alEffectf(effect, AL_REVERB_ROOM_ROLLOFF_FACTOR, reverb->flRoomRolloffFactor);
		mOpenAL.alEffecti(effect, AL_REVERB_DECAY_HFLIMIT, reverb->iDecayHFLimit);

	/* Check if an error occured, and clean up if so. */


	return effect;
}

This defines the effect and brings in all the details available to openal to create a reverb effect

In sfxALVoice.cpp i have
void SFXALVoice::setReverb(SFXALDevice* device)
{
	EFXEAXREVERBPROPERTIES reverb = EFX_REVERB_PRESET_ARENA;
	AL_SANITY_CHECK();
	ALuint effect, slot;
	effect = device->setReverb(&reverb);
	slot = 0;

	mOpenAL.alGenAuxiliaryEffectSlots(1, &slot);
	mOpenAL.alAuxiliaryEffectSloti(slot, AL_EFFECTSLOT_EFFECT, effect);

	mOpenAL.alSource3i(mSourceName, AL_AUXILIARY_SEND_FILTER, slot, 0, AL_FILTER_NULL);
}
EFXEAXREVERBPROPERTIES reverb = EFX_REVERB_PRESET_ARENA this loads a preset in openal and adds the values into sfxALDevice setReverb then creates the required effect slots for openal to create the effect with the source, this is stable and doesnt crash everytime a sound is played but i think that is becuase the function isnt being called =/
marauder2k9
Posts: 211
Joined: Wed Feb 18, 2015 7:36 am
by marauder2k9 » Mon Oct 15, 2018 1:31 am
Okay, downloaded the openal sdk installed it and now it works lol stupid me forgot to download the sdk, now i have openal32.dll in my directory and hopefully it will work
marauder2k9
Posts: 211
Joined: Wed Feb 18, 2015 7:36 am
by marauder2k9 » Mon Oct 15, 2018 1:38 am
it still crashes when trying to call the code inside create voice but at least now i know it is loading all the function addresses
marauder2k9
Posts: 211
Joined: Wed Feb 18, 2015 7:36 am
by marauder2k9 » Mon Oct 15, 2018 3:24 am
Such a good feeling when u get something working :D now to link it up with torques gui

marauder2k9
Posts: 211
Joined: Wed Feb 18, 2015 7:36 am
by marauder2k9 » Tue Oct 16, 2018 12:06 am
Another example of the reverb, u may notice a little glitch in this, the reverb cuts off as soon as the sound file finishes playing rather than when the reverb finishes if anyone has any suggestions

NeonTiger
Posts: 3
Joined: Sun Aug 02, 2015 4:50 am
by NeonTiger » Tue Oct 16, 2018 5:25 pm
Great work, i plan on messing around with this during the weekend.
marauder2k9
Posts: 211
Joined: Wed Feb 18, 2015 7:36 am
by marauder2k9 » Tue Oct 16, 2018 5:36 pm
I should have an implementation with environment based ambience finished off tonight this was a proof of concept to get it working, i want to get echo, compressors and filters working now too
marauder2k9
Posts: 211
Joined: Wed Feb 18, 2015 7:36 am
by marauder2k9 » Wed Oct 17, 2018 4:29 am
finished an implementation of an effects layer that takes info from sfxdescription and sfxenvironment to decide whether an sfxalvoice should have a certain effect. also created parameters in both sfxdescription and sfxenvironment for other effects available in openal:

EAX Reverb
Reverb
Echo
Distortion
Flanger
Chorus
Pitch Shifter
Vocal Morpher
Auto-Wah
Ring Modulator
Compressor
Equalizer

Although u can only use 4 of these at any given time as i understand it openal advises a max of 4 auxiliary sends and each effect has to have its own send. i think......

the 4 filters available are:
Null (yes it is a filter type lol)
lowpass
bandpass
highpass

Only one filter can be applied to each send as i understand it.

This will all create static environments for audio effects, im afraid my coding knowledge cant create the dynamic environment processing available in openal to automatically adjust reverb effects due to the size of a zone. As i understand it open al eax reverb effects can take into account the distance from the source to the listener and attenuate the reverb properties to be a lot more realistic for example if ur in a large room the reverberation of the sound would get less and less the closer the source of the sound gets to the listener. i know this may sound easy to implement but once an effect changes its parameters it needs to be deleted then recreated each time.

NOTE: i would of had a video up tonight showcasing these changes but youtube is down so probably wont get a chance to upload a video until the weekend
23 posts Page 2 of 3

Who is online

Users browsing this forum: No registered users and 4 guests