marauder2k9 Posted October 11, 2018 Share Posted October 11, 2018 I was checking around the source files on how torque3d handles audio. Am i right in saying that torque3d uses the linear falloff model from openal? If so has anyone toyed around with both adding the reverb openal uses and an exponential falloff? i was thinking of implementing it instead of using the linear falloff model. This would bring in a more realistic falloff over distances for audio but also would give built in reverb functions to torque3d, there are more effects in openal as well that i may implement as well. There are a few effects that could come in handy for people that either dont have or dont want to use fmod for example the equalizer. Quote Link to comment Share on other sites More sharing options...
Duion Posted October 12, 2018 Share Posted October 12, 2018 In the code there are also alternatives for audio, like logarithmic distance falloff and many other advanced effects, but those are limited to the proprietary FMOD sound engine, that is obviously not in the open source version of Torque3D.This is probably where we do not have a complex open source version of this, since it was just ported quickly and then left that way, so yes we could need alternatives for that. I would also like to have the environment sound effects back, like when you are in a big hall all sounds will echo more etc which was also a part of FMOD probably. Quote Link to comment Share on other sites More sharing options...
marauder2k9 Posted October 12, 2018 Author Share Posted October 12, 2018 thats reverb basically, with openal you can do that, i think there is a basic implementation of reverb in openal in torque but not a full one? like certain features are initialised but not used, most probably to have one single layer between openal and fmod, but openal can do nearly the same as fmod only fmod can use soundbanks and has that fancy interface whereas with a more fleshed out implementation of openal it would all be done in torques gui without the need of a separate app and with mostly text inputs. Quote Link to comment Share on other sites More sharing options...
Duion Posted October 12, 2018 Share Posted October 12, 2018 I would be totally satisfied with a better distance falloff model, that linear one is horrible, if you have a lot of sounds with high range, such as gunshots obviously, with a lot of players it will be a constant loud noise that gets very annoying and if you make the distance smaller, you obviously hardly ever hear anyone.So yes that would be cool if you could implement that. Quote Link to comment Share on other sites More sharing options...
marauder2k9 Posted October 12, 2018 Author Share Posted October 12, 2018 done: https://forums.torque3d.org/viewtopic.php?f=23&t=1423 Quote Link to comment Share on other sites More sharing options...
marauder2k9 Posted October 13, 2018 Author Share Posted October 13, 2018 thats the exponential falloff added anyway, time to add the rest of the features Quote Link to comment Share on other sites More sharing options...
marauder2k9 Posted October 13, 2018 Author Share Posted October 13, 2018 little snag: This reports an error in that it cant return effect; due to function type, i have to be able to call effect in other parts of this file anyone any ideas? void SFXALVoice::setReverb(const SFXReverbProperties& reverb) { ALuint effect; ALenum err; mOpenAL.alGenEffects(1, &effect); mOpenAL.alEffecti(effect, AL_EFFECT_TYPE, AL_EFFECT_REVERB); mOpenAL.alEffectf(effect, AL_REVERB_DENSITY, reverb.mDensity); mOpenAL.alEffectf(effect, AL_REVERB_DIFFUSION, reverb.mDiffusion); mOpenAL.alEffectf(effect, AL_REVERB_MIN_GAIN, reverb.mReverb); mOpenAL.alEffectf(effect, AL_REVERB_GAINHF, reverb.mRoomHF); mOpenAL.alEffectf(effect, AL_REVERB_DECAY_TIME, reverb.mDecayTime); mOpenAL.alEffectf(effect, AL_REVERB_DECAY_HFRATIO, reverb.mDecayHFRatio); mOpenAL.alEffectf(effect, AL_REVERB_REFLECTIONS_GAIN, reverb.mReflections); mOpenAL.alEffectf(effect, AL_REVERB_REFLECTIONS_DELAY, reverb.mReflectionsDelay); mOpenAL.alEffectf(effect, AL_REVERB_LATE_REVERB_DELAY, reverb.mReverbDelay); mOpenAL.alEffectf(effect, AL_REVERB_AIR_ABSORPTION_GAINHF, reverb.mAirAbsorptionHF); mOpenAL.alEffectf(effect, AL_REVERB_ROOM_ROLLOFF_FACTOR, reverb.mRoomRolloffFactor); mOpenAL.alEffecti(effect, AL_REVERB_DECAY_HFLIMIT, reverb.mDecayHFRatio); err = alGetError(); if (err != AL_NO_ERROR) { fprintf(stderr, "OpenAL error: %s\n", alGetString(err)); if (mOpenAL.alIsEffect(effect)) mOpenAL.alDeleteEffects(1, &effect); return; } return effect; } I will probably need to create a different function SFXALVoice::setEffect or something like that but this was just to test that the values in torque can be passed to the reverb in openal and produce expected changes to the sound Quote Link to comment Share on other sites More sharing options...
marauder2k9 Posted October 13, 2018 Author Share Posted October 13, 2018 Fixed previous error, now hit another snag ALuint SFXALVoice::LoadEffect(EFXEAXREVERBPROPERTIES *reverb) { effect = 0; /* Create the effect object and check if we can do EAX reverb. */ 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); return effect; } SFXALVoice* SFXALVoice::create( SFXALDevice* device, SFXALBuffer *buffer ) { AssertFatal( buffer, "SFXALVoice::create() - Got null buffer!" ); ALuint sourceName; EFXEAXREVERBPROPERTIES reverb = EFX_REVERB_PRESET_CASTLE_LARGEROOM; ALuint slot, effect; effect = LoadEffect(&reverb); device->mOpenAL.alGenSources( 1, &sourceName ); AssertFatal( device->mOpenAL.alIsSource( sourceName ), "AL Source Sanity Check Failed!" ); // Is this 3d? // Okay, this looks odd, but bear with me for a moment. AL_SOURCE_RELATIVE does NOT indicate // whether or not the volume of the sound should change depending on the position of the listener. // OpenAL assumes that the volume will ALWAYS depend on the position of the listener. What AL_SOURCE_RELATIVE // does do is dictate if the position of THIS SOURCE is relative to the listener. If AL_SOURCE_RELATIVE is AL_TRUE // and the source's position is 0, 0, 0, then the source is directly on top of the listener at all times, which is what // we want for non-3d sounds. device->mOpenAL.alSourcei( sourceName, AL_SOURCE_RELATIVE, ( buffer->mIs3d ? AL_FALSE : AL_TRUE ) ); device->mOpenAL.alSource3i(sourceName,AL_AUXILIARY_SEND_FILTER, slot, 0 , AL_FILTER_NULL); In this block of code effect = LoadEffect(&reverb); is throwing up an error "a nonstatic member reference must be relative to a specific object" Any ideas? Quote Link to comment Share on other sites More sharing options...
marauder2k9 Posted October 13, 2018 Author Share Posted October 13, 2018 I've tried changing ALuint SFXALVoice::LoadEffect to static ALuint SFXALVoice::LoadEffectbut then it cant load all the mOpenAL for the same reason Quote Link to comment Share on other sites More sharing options...
OTHGMars Posted October 13, 2018 Share Posted October 13, 2018 Try voice->LoadEffect(&reverb) before return voice; but after voice = new SFXALVoice...Load effect should be non-static in that case. Quote Link to comment Share on other sites More sharing options...
marauder2k9 Posted October 13, 2018 Author Share Posted October 13, 2018 that worked 100% thank you!!!Now to test if the effect actually gets applied lol Quote Link to comment Share on other sites More sharing options...
marauder2k9 Posted October 13, 2018 Author Share Posted October 13, 2018 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 Quote Link to comment Share on other sites More sharing options...
marauder2k9 Posted October 14, 2018 Author Share Posted October 14, 2018 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 effectIn 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 =/ Quote Link to comment Share on other sites More sharing options...
marauder2k9 Posted October 14, 2018 Author Share Posted October 14, 2018 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 Quote Link to comment Share on other sites More sharing options...
marauder2k9 Posted October 14, 2018 Author Share Posted October 14, 2018 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 Quote Link to comment Share on other sites More sharing options...
marauder2k9 Posted October 15, 2018 Author Share Posted October 15, 2018 Such a good feeling when u get something working :D now to link it up with torques guiVhNd-vsGPxM Quote Link to comment Share on other sites More sharing options...
marauder2k9 Posted October 15, 2018 Author Share Posted October 15, 2018 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 4danpjvFC7Q Quote Link to comment Share on other sites More sharing options...
NeonTiger Posted October 16, 2018 Share Posted October 16, 2018 Great work, i plan on messing around with this during the weekend. Quote Link to comment Share on other sites More sharing options...
marauder2k9 Posted October 16, 2018 Author Share Posted October 16, 2018 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 Quote Link to comment Share on other sites More sharing options...
marauder2k9 Posted October 17, 2018 Author Share Posted October 17, 2018 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 ReverbReverbEchoDistortionFlangerChorusPitch ShifterVocal MorpherAuto-WahRing ModulatorCompressorEqualizerAlthough 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)lowpassbandpasshighpassOnly 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 Quote Link to comment Share on other sites More sharing options...
marauder2k9 Posted October 19, 2018 Author Share Posted October 19, 2018 solved the reverb cutting out issue Rt8IBW2VZ08 Quote Link to comment Share on other sites More sharing options...
marauder2k9 Posted October 21, 2018 Author Share Posted October 21, 2018 reverb zones :D NQRpTZ1vUZ0 Quote Link to comment Share on other sites More sharing options...
marauder2k9 Posted October 21, 2018 Author Share Posted October 21, 2018 reverb zones effect pull request is live Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.