mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 15:14:35 +00:00
Merge pull request #1730 from marauder2k9-torque/SFXSystem-Refactor
Sfx system refactor
This commit is contained in:
commit
dae2a7714f
66 changed files with 3710 additions and 7727 deletions
|
|
@ -70,9 +70,7 @@ function CoreModule::onCreate(%this)
|
|||
|
||||
// Init the physics plugin.
|
||||
physicsInit();
|
||||
|
||||
sfxStartup();
|
||||
|
||||
|
||||
// Set up networking.
|
||||
setNetPort(0);
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ function createCanvas(%windowTitle)
|
|||
if ($isDedicated)
|
||||
{
|
||||
GFXInit::createNullDevice();
|
||||
sfxCreateDevice("Null","Null Device", false, 8);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,13 +3,21 @@ function Core_SFX::onCreate(%this)
|
|||
{
|
||||
exec("./scripts/audio." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/audioData." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/audioStates." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/audioEnvironments." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/audioAmbience." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/audioDescriptions." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/audioEnvironments." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/audioStates." @ $TorqueScriptFileExtension);
|
||||
exec("./scripts/audioOptions." @ $TorqueScriptFileExtension);
|
||||
}
|
||||
|
||||
function Core_SFX::onDestroy(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function Core_SFX::initClient(%this)
|
||||
{
|
||||
if($pref::SFX::autoDetect)
|
||||
{
|
||||
AutodetectSound();
|
||||
}
|
||||
}
|
||||
|
|
@ -24,7 +24,11 @@
|
|||
// Source groups.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
singleton SFXDescription( AudioMaster );
|
||||
singleton SFXDescription( AudioMaster )
|
||||
{
|
||||
useCustomReverb = false;
|
||||
};
|
||||
|
||||
singleton SFXSource( AudioChannelMaster )
|
||||
{
|
||||
description = AudioMaster;
|
||||
|
|
@ -33,8 +37,16 @@ singleton SFXSource( AudioChannelMaster )
|
|||
singleton SFXDescription( AudioChannel )
|
||||
{
|
||||
sourceGroup = AudioChannelMaster;
|
||||
useCustomReverb = false;
|
||||
};
|
||||
|
||||
singleton SFXDescription( AudioEffectChannel )
|
||||
{
|
||||
sourceGroup = AudioChannelMaster;
|
||||
useCustomReverb = true;
|
||||
};
|
||||
|
||||
|
||||
singleton SFXSource( AudioChannelDefault )
|
||||
{
|
||||
description = AudioChannel;
|
||||
|
|
@ -45,7 +57,7 @@ singleton SFXSource( AudioChannelGui )
|
|||
};
|
||||
singleton SFXSource( AudioChannelEffects )
|
||||
{
|
||||
description = AudioChannel;
|
||||
description = AudioEffectChannel;
|
||||
};
|
||||
singleton SFXSource( AudioChannelMessages )
|
||||
{
|
||||
|
|
@ -66,7 +78,7 @@ AudioChannelMusic.play();
|
|||
AudioChannelMessages.play();
|
||||
|
||||
// Stop in-game effects channels.
|
||||
AudioChannelEffects.stop();
|
||||
AudioChannelEffects.play();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Master SFXDescriptions.
|
||||
|
|
@ -145,10 +157,6 @@ function sfxStartup()
|
|||
function sfxInit()
|
||||
{
|
||||
// If already initialized, shut down the current device first.
|
||||
|
||||
if( sfxGetDeviceInfo() !$= "" )
|
||||
sfxShutdown();
|
||||
|
||||
if ($isDedicated)
|
||||
{
|
||||
sfxCreateDevice("Null","Null Device", false, 8);
|
||||
|
|
@ -156,12 +164,16 @@ function sfxInit()
|
|||
}
|
||||
|
||||
// Start it up!
|
||||
%maxBuffers = $pref::SFX::useHardware ? -1 : $pref::SFX::maxSoftwareBuffers;
|
||||
if ( !sfxCreateDevice( $pref::SFX::provider, $pref::SFX::device, $pref::SFX::useHardware, %maxBuffers ) )
|
||||
return false;
|
||||
%info = sfxGetDeviceInfo();
|
||||
if(%info $= "" )
|
||||
{
|
||||
%maxBuffers = $pref::SFX::useHardware ? -1 : $pref::SFX::maxSoftwareBuffers;
|
||||
if ( !sfxCreateDevice() )
|
||||
return false;
|
||||
}
|
||||
|
||||
// This returns a tab seperated string with
|
||||
// the initialized system info.
|
||||
// the initialized system info
|
||||
%info = sfxGetDeviceInfo();
|
||||
$pref::SFX::provider = getField( %info, 0 );
|
||||
$pref::SFX::device = getField( %info, 1 );
|
||||
|
|
@ -440,4 +452,4 @@ function sfxResume( %pauseSet )
|
|||
// Clear our pause set... the caller is left
|
||||
// to clear his own if he passed one.
|
||||
%pauseSet.clear();
|
||||
}*/
|
||||
}*/
|
||||
|
|
@ -23,22 +23,27 @@
|
|||
singleton SFXAmbience( AudioAmbienceDefault )
|
||||
{
|
||||
environment = AudioEnvOff;
|
||||
dopplerFactor = "1";
|
||||
};
|
||||
|
||||
singleton SFXAmbience( AudioAmbienceOutside )
|
||||
{
|
||||
environment = AudioEnvPlain;
|
||||
states[ 0 ] = AudioLocationOutside;
|
||||
dopplerFactor = "1";
|
||||
};
|
||||
|
||||
singleton SFXAmbience( AudioAmbienceInside )
|
||||
{
|
||||
environment = AudioEnvRoom;
|
||||
states[ 0 ] = AudioLocationInside;
|
||||
dopplerFactor = "1";
|
||||
};
|
||||
|
||||
singleton SFXAmbience( AudioAmbienceUnderwater )
|
||||
{
|
||||
environment = AudioEnvUnderwater;
|
||||
states[ 0 ] = AudioLocationUnderwater;
|
||||
dopplerFactor = "0.5";
|
||||
speedOfSound = "1500.0";
|
||||
};
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -6,8 +6,8 @@ new SimGroup(AudioSettingsGroup)
|
|||
new SimGroup()
|
||||
{
|
||||
class = "SubOptionsGroup";
|
||||
displayName = "Audio Devices";
|
||||
|
||||
displayName = "Audio Settings";
|
||||
|
||||
new SimGroup(AudioSettingsProviderGroup)
|
||||
{
|
||||
class = "AudioOptionsSettings";
|
||||
|
|
@ -15,7 +15,7 @@ new SimGroup(AudioSettingsGroup)
|
|||
OptionName = "Audio Provider";
|
||||
Description = "";
|
||||
};
|
||||
|
||||
|
||||
new SimGroup(AudioSettingsDeviceGroup)
|
||||
{
|
||||
class = "AudioOptionsSettings";
|
||||
|
|
@ -26,58 +26,92 @@ new SimGroup(AudioSettingsGroup)
|
|||
};
|
||||
};
|
||||
|
||||
function getDeviceDisplayName(%fullName)
|
||||
{
|
||||
%openPos = strstr(%fullName, "(");
|
||||
%closePos = strstr(%fullName, ")");
|
||||
|
||||
if (%openPos == -1 || %closePos == -1)
|
||||
return %fullName;
|
||||
|
||||
// +1 to skip past the "(" itself
|
||||
return trim(getSubStr(%fullName, %openPos + 1, %closePos - %openPos - 1));
|
||||
}
|
||||
|
||||
function AudioSettingsGroup::populateSettings(%this)
|
||||
{
|
||||
AudioSettingsProviderGroup.clear();
|
||||
AudioSettingsDeviceGroup.clear();
|
||||
|
||||
%buffer = sfxGetAvailableDevices();
|
||||
%count = getRecordCount( %buffer );
|
||||
%pCount = sfxGetProviderCount();
|
||||
|
||||
for(%i = 0; %i < %count; %i++)
|
||||
// --- First pass: build deduplicated provider list ---
|
||||
for (%i = 0; %i < %pCount; %i++)
|
||||
{
|
||||
%record = getRecord(%buffer, %i);
|
||||
%provider = getField(%record, 0);
|
||||
%device = getField(%record, 1);
|
||||
%providerType = sfxGetProviderType(%i);
|
||||
|
||||
//When the client is actually running, we don't care about null audo devices
|
||||
if(%provider $= "null")
|
||||
if (%providerType $= "NullProvider")
|
||||
continue;
|
||||
|
||||
//We can't have duplicate providers, so double check for uniqueness
|
||||
%foundProvider = false;
|
||||
foreach(%registeredProviders in AudioSettingsProviderGroup)
|
||||
|
||||
%alreadyAdded = false;
|
||||
foreach (%entry in AudioSettingsProviderGroup)
|
||||
{
|
||||
if(%registeredProviders.displayName $= %provider)
|
||||
if (%entry.displayName $= %providerType)
|
||||
{
|
||||
%foundProvider = true;
|
||||
%alreadyAdded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!%foundProvider)
|
||||
if (!%alreadyAdded)
|
||||
{
|
||||
//Provider entry
|
||||
%providerEntry = new ArrayObject()
|
||||
{
|
||||
class = "OptionsQualityLevel";
|
||||
displayName = %provider;
|
||||
key["$pref::SFX::provider"] = %provider;
|
||||
class = "OptionsQualityLevel";
|
||||
displayName = %providerType;
|
||||
key["$pref::SFX::provider"] = %providerType;
|
||||
};
|
||||
|
||||
AudioSettingsProviderGroup.add(%providerEntry);
|
||||
}
|
||||
|
||||
//Device Entry
|
||||
%deviceEntry = new ArrayObject()
|
||||
{
|
||||
class = "OptionsQualityLevel";
|
||||
displayName = %device;
|
||||
provider = %provider; //this is for filtering later, if we need to
|
||||
key["$pref::SFX::device"] = %device;
|
||||
};
|
||||
}
|
||||
|
||||
// --- Second pass: for each provider, collect its devices ---
|
||||
foreach (%providerEntry in AudioSettingsProviderGroup)
|
||||
{
|
||||
%providerType = %providerEntry.displayName;
|
||||
|
||||
AudioSettingsDeviceGroup.add(%deviceEntry);
|
||||
for (%i = 0; %i < %pCount; %i++)
|
||||
{
|
||||
if (sfxGetProviderType(%i) !$= %providerType)
|
||||
continue;
|
||||
|
||||
%deviceName = sfxGetProviderDevice(%i);
|
||||
|
||||
%deviceEntry = new ArrayObject()
|
||||
{
|
||||
class = "OptionsQualityLevel";
|
||||
displayName = getDeviceDisplayName(%deviceName);
|
||||
providerType = %providerType;
|
||||
key["$pref::SFX::device"] = %deviceName;
|
||||
};
|
||||
AudioSettingsDeviceGroup.add(%deviceEntry);
|
||||
}
|
||||
}
|
||||
|
||||
// Highlight the currently active entries
|
||||
%activeProvider = $pref::SFX::provider;
|
||||
%activeDevice = $pref::SFX::device;
|
||||
|
||||
foreach (%entry in AudioSettingsProviderGroup)
|
||||
{
|
||||
if (%entry.displayName $= %activeProvider)
|
||||
AudioSettingsProviderGroup.currentValue = %activeProvider;
|
||||
}
|
||||
|
||||
foreach (%entry in AudioSettingsDeviceGroup)
|
||||
{
|
||||
if (%entry.displayName $= %activeDevice && %entry.providerType $= %activeProvider)
|
||||
AudioSettingsDeviceGroup.currentValue = %activeDevice;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -93,11 +127,15 @@ function AudioSettingsDeviceGroup::onApply(%this)
|
|||
|
||||
function updateAudioOptionsSettings()
|
||||
{
|
||||
if ( !sfxCreateDevice( $pref::SFX::provider,
|
||||
$pref::SFX::device,
|
||||
$pref::SFX::useHardware,
|
||||
-1 ) )
|
||||
if ( !sfxCreateDeviceFromName($pref::SFX::provider, $pref::SFX::device) )
|
||||
error( "Unable to create SFX device: " @ $pref::SFX::provider
|
||||
SPC $pref::SFX::device
|
||||
SPC $pref::SFX::useHardware );
|
||||
}
|
||||
|
||||
function AutodetectSound()
|
||||
{
|
||||
// Nothing to actually do in here?
|
||||
// function here for convenience.
|
||||
$pref::SFX::autoDetect = false;
|
||||
}
|
||||
|
|
@ -223,7 +223,6 @@ function OptionsMenu::openOptionsCategory(%this, %categoryName)
|
|||
else if(%categoryName $= "Audio")
|
||||
{
|
||||
$MenuList = AudioSettingsList;
|
||||
|
||||
%this.currentCatgeoryIdx = 1;
|
||||
}
|
||||
else if(%categoryName $= "KBM")
|
||||
|
|
@ -856,6 +855,8 @@ function OptionsMenu::resetSettings(%this)
|
|||
function OptionsMenu::populateAudioSettings(%this)
|
||||
{
|
||||
AudioSettingsList.clear();
|
||||
OptionsMenu.optsListCount = -1;
|
||||
|
||||
AudioSettingsGroup.populateSettings();
|
||||
|
||||
//Process the lists
|
||||
|
|
|
|||
|
|
@ -12,6 +12,53 @@ function SoundAsset::onChanged(%this)
|
|||
if (isObject($PreviewSoundSource))
|
||||
sfxStop($PreviewSoundSource);
|
||||
}
|
||||
function SoundAsset::onShowActionMenu(%this)
|
||||
{
|
||||
GenericAsset::onShowActionMenu(%this);
|
||||
|
||||
%assetId = %this.getAssetId();
|
||||
|
||||
EditAssetPopup.objectData = %assetId;
|
||||
EditAssetPopup.objectType = AssetDatabase.getAssetType(%assetId);
|
||||
|
||||
EditAssetPopup.reloadItems();
|
||||
|
||||
EditAssetPopup.showPopup(Canvas);
|
||||
}
|
||||
|
||||
|
||||
function SoundAsset::onEditProperties(%this)
|
||||
{
|
||||
Canvas.pushDialog(AssetBrowser_editAsset);
|
||||
|
||||
AssetBrowser_editAssetWindow.text = "Asset Properties - " @ %this.getAssetId();
|
||||
|
||||
AssetEditInspector.tempAsset = %this.deepClone();
|
||||
|
||||
AssetEditInspector.inspect(%this);
|
||||
AssetBrowser_editAsset.editedObjectData = %this.getAssetId();
|
||||
AssetBrowser_editAsset.editedObject = %this;
|
||||
AssetBrowser_editAsset.editedObjectType = AssetDatabase.getAssetType(%this.getAssetId());
|
||||
|
||||
//remove some of the groups we don't need:
|
||||
for(%i=0; %i < AssetEditInspector.getCount(); %i++)
|
||||
{
|
||||
%caption = AssetEditInspector.getObject(%i).caption;
|
||||
|
||||
if(%caption $= "Ungrouped" || %caption $= "Object" || %caption $= "Editing"
|
||||
|| %caption $= "Persistence" || %caption $= "Dynamic Fields")
|
||||
{
|
||||
AssetEditInspector.remove(AssetEditInspector.getObject(%i));
|
||||
%i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Called when the AssetType has it's properties saved from the onEditProperties process
|
||||
function SoundAsset::onSaveProperties(%this)
|
||||
{
|
||||
%this.refreshAsset();
|
||||
}
|
||||
|
||||
function SoundAsset::buildBrowserElement(%this, %previewData)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue