Last active
June 1, 2025 04:32
-
-
Save milnak/b083541b3cd22fa55a273743593d6336 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set a Transcribe XSC file to my desired default settings. | |
# the XSC file format is meh, so Read-Xsc is a bit weird. | |
param ([Parameter(Mandatory)][string]$Path) | |
function Read-Xsc { | |
param ([Parameter(Mandatory)][string]$Path) | |
$data = [ordered]@{} | |
$version = $null | |
$transcribe = $null | |
$section = $null | |
if (-not (Test-Path -Path $Path -PathType Leaf)) { | |
throw 'File not found' | |
} | |
switch -regex -file $Path { | |
# Document Version | |
'^XSC Transcribe.Document Version (\d+\.\d+)' { | |
$version = $matches[1] | |
continue | |
} | |
# System Info (transcribe platform,v_major,v_minor,?,?,? | |
'^Transcribe!,(.+)$' { | |
$transcribe = $matches[1] | |
continue | |
} | |
# SectionStart | |
'^SectionStart,(.+)$' { | |
if ($section) { throw "Unclosed section: $section" } | |
$section = $matches[1] | |
$data[$section] = [ordered]@{} | |
continue | |
} | |
# SectionEnd | |
'^SectionEnd,(.+)$' { | |
if ($matches[1] -ne $section) { throw "Unmatched SectionEnd: $($matches[1])" } | |
$section = $matches[1] | |
$section = $null | |
continue | |
} | |
# key,value | |
'^(.+?),(.+)$' { | |
if (-not $section) { throw "key,value not in section!: $_" } | |
$key, $value = $matches[1, 2] | |
if ($section -eq 'Loops' -and $key -eq 'L') { | |
# e.g. "L,15,0,0,0,,White,,0:00:00.000000,0:00:00.000000" | |
# use "L,15" as key, rest as value. | |
$i = $value.IndexOf(',') | |
$data[$section]['L,' + $value.Substring(0, $i)] = $value.Substring($i + 1) | |
} | |
else { | |
$data[$section][$key] = $value | |
} | |
continue | |
} | |
} | |
[PSCustomObject]@{ | |
Version = $version | |
Transcribe = $transcribe | |
Data = $data | |
} | |
} | |
function Write-Xsc { | |
param ([Parameter(Mandatory)]$XSC) | |
"XSC Transcribe.Document Version $($XSC.Version)" | |
"Transcribe!,$($XSC.Transcribe)" | |
$data = $XSC.Data | |
Foreach ($section in $data.get_keys()) { | |
'' | |
"SectionStart,$section" | |
foreach ($key in $data[$section].get_keys()) { | |
'{0},{1}' -f $key, $data[$section][$key] | |
} | |
"SectionEnd,$section" | |
} | |
} | |
$xsc = Read-Xsc -Path $Path | |
$xsc.Data['Main']['SaveDate'] = (Get-Date -Format 'yyyy-MM-dd HH:mm') | |
$xsc.Data['Main']['WindowSize'] = '1698|951|860|421,0' | |
$xsc.Data['View0']['FX_EQ'] = '0,0,0,0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0' | |
$xsc.Data['View0']['FX_Misc'] = '1,0,70,0,80,0' | |
$xsc.Data['View0']['FX_Speed'] = '0,0,100000,0' | |
$xsc.Data['View0']['FX_Transposition'] = '0,0,0,0,0' | |
$xsc.Data['View0']['FX_Tuning'] = '0,0,0,0,0,0,60,50,0' | |
$xsc.Data['View0']['HorizProfileZoom'] = '0.008539' | |
$xsc.Data['View0']['ShowAsMono'] = '1' | |
$xsc.Data['View0']['TimelineOffset'] = '0:00:00.000000' | |
$xsc.Data['View0']['ViewSplitterPos'] = '0.819860' | |
Write-Xsc -XSC $xsc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment