Skip to content

Instantly share code, notes, and snippets.

@anotherlab
Last active March 20, 2023 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anotherlab/bea0fe9308b66d7bc60b60a521362d13 to your computer and use it in GitHub Desktop.
Save anotherlab/bea0fe9308b66d7bc60b60a521362d13 to your computer and use it in GitHub Desktop.
PowerShell script to update Adobe Audition's MachineSpecificSettings.xml to use the specific input and output devices
# Update MachineSpecificSettings when Windows does to change the UID for the audio hardware
# To use Get-AudioDevice, install AudioDeviceCmdlets
# Install-Module -Name AudioDeviceCmdlets
# See https://github.com/frgnca/AudioDeviceCmdlets
#
# I used https://jsonlint.com/ for verifying the embedded JSON that Adobe uses
# get the latest version of Audition installed
$version = (gci ([IO.Path]::Combine( $env:APPDATA, "Adobe\Audition")) | sort-object Name -Descending | Select-Object -First 1).Name
# build the path to the machine setting file
$AuditionSettings = ([IO.Path]::Combine( $env:APPDATA, "Adobe\Audition\"+$version+"\MachineSpecificSettings.xml"))
# read the settings
$xml=[xml](Get-Content $AuditionSettings)
# get the node that stores the audio device settings
# xpath is crazy. I cheated and pasted the settings into https://xmltoolbox.appspot.com/xpath_generator.html
$node = $xml.SelectSingleNode("//Section[@label='Root']/Section[@label='Prefs']/Section[@label='AudioDevice']/KeyVal[@Key='abe.io.audio.settings']")
# The audio device settings are serialized into a compressed JSON string and stored as the node content
$jdataString = $node.'#text'
# deserialize the json to an object
$jdata = ($jdataString | ConvertFrom-Json)
# the devices to use.
# These are mine, pick your own
$microphoneName = "Microphone (Rode Podcaster)"
$outputdevicename = "Syba (USB Advanced Audio Device)"
# get a list of all of the audio devices
$devices = Get-AudioDevice -List
# walk through that list to get UID of the devices
foreach($device in $devices)
{
if ($device.Name -eq $microphoneName)
{
# Adobe only uses a subset of the ID returned here
$uid = $device.ID.SubString(18, 36)
}
if ($device.Name -eq $outputdevicename)
{
$outputuid = $device.ID.SubString(18, 36)
}
}
# now walk the Audition's hardware settings until we find the MME setting
foreach($j in $jdata.'abe.io.audio.classes')
{
# It's JSON and each item in the collection has different members
# So we check to make sure that we have the right item
if ($null -ne $j."abe.io.audio.mme.inputdevicename")
{
# if the input uid has changed, then update the device object
if ($j."abe.io.audio.mme.inputdeviceuid" -ne $uid)
{
$j."abe.io.audio.mme.inputdevicename" = $microphoneName
$j."abe.io.audio.mme.inputdeviceuid" = $uid
}
}
if ($null -ne $j."abe.io.audio.mme.outputdevicename")
{
# if the output uid has changed, then update the device object
if ($j."abe.io.audio.mme.outputdeviceuid" -ne $outputuid)
{
$j."abe.io.audio.mme.outputdevicename" = $outputdevicename
$j."abe.io.audio.mme.outputdeviceuid" = $outputuid
}
}
}
# serialize the object back to a single line string
$updatedData = ($jdata | convertto-json -Depth 5 -Compress)
# if it's changed, then update the node and save the file
if ($jdataString -ne $updatedData)
{
$node.'#text' = $updatedData
write-host "Updated settings"
$xml.Save($AuditionSettings)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment