VideoHelp Forum




+ Reply to Thread
Results 1 to 2 of 2
  1. SurroundUpmix - Free Stereo to 5.1 / 7.1 Surround Upmixer (PowerShell)

    Version 2.2.0 | Windows 10/11 | Free & offline | No cloud

    I tried to create a surround upmix workflow that actually makes sense - one that uses AI stem separation to produce a proper surround mix rather than just spreading the stereo image wider.

    Most upmix tools work by duplicating or phase-shifting the stereo signal. The result sounds okay on paper but all the instruments end up bleeding into every speaker. This approach is different. It uses Demucs-GUI - a free AI tool - to split the audio into its individual components first (bass, drums, vocals, instruments), and then places each one where it belongs in the surround field.

    The result is a genuine multichannel mix where vocals sit in the center channel, bass and drums fill the front, and ambient and harmonic content spreads to the rear and sides. The subwoofer channel is derived from the real low-frequency content of the full mix.

    The whole thing runs locally on your machine with free tools and produces a 24-bit FLAC file in either 5.1 or 7.1 that you can mux into an MKV or use directly in any media player that supports multichannel audio.

    What it does
    1. You run Demucs-GUI on your stereo audio - it uses AI to separate the track into 4 stems: bass, drums, vocals, other
    2. You point SurroundUpmix at the stems folder
    3. The script processes the stems through a 3-stage phase analysis (using CenterCutCL) to identify center vs. side content in each stem
    4. Each stem gets placed into the correct speakers based on what it contains
    5. A subwoofer (LFE) channel is built from the low frequencies of the full mix
    6. Everything is combined and saved as a 24-bit FLAC

    Processing a 46-minute episode takes around 10-15 minutes on a modern machine. No cloud, no subscription, no re-encoding of video.

    What You Need (all free)

    1. Demucs-GUI - separates your audio into stems using AI
    https://github.com/CarlGao4/Demucs-Gui/releases

    Choose the right version:
    • cuda_mkl version - for NVIDIA GPU (GTX 700 series or newer) or Intel Arc / Intel Xe GPU - much faster
    • cpu version - works on any machine, slower

    In Demucs-GUI: add your file, select model htdemucs_ft, click Start. Output will be a folder with bass.flac, drums.flac, vocals.flac, other.flac.

    2. SoX - Sound eXchange - audio channel processing
    https://sourceforge.net/projects/sox/files/sox/
    Download version 14.4.2 for Windows. Place sox.exe in: SurroundUpmix\bin\SoX\sox.exe

    3. CenterCutCL - phase-based center/side separation (core of the upmix)
    http://www.moitah.net/download/latest/Center_Cut_GUI.zip
    Extract and place CenterCutCL.exe in: SurroundUpmix\bin\CenterCutCL.exe
    (Last updated 2010 but works perfectly on modern Windows)

    4. ffmpeg - optional, only needed for loudness matching
    https://www.gyan.dev/ffmpeg/builds/
    Download ffmpeg-release-full.7z, extract ffmpeg.exe and place in: SurroundUpmix\bin\ffmpeg\ffmpeg.exe

    Folder Structure

    Code:
    SurroundUpmix\
    |
    |-- SurroundUpmix.ps1       <- the script
    |
    +-- bin\
        |-- CenterCutCL.exe
        |-- SoX\
        |   +-- sox.exe
        +-- ffmpeg\
            +-- ffmpeg.exe
    The script always looks for its tools in the bin folder next to itself.

    How to Run

    Open PowerShell by right-clicking inside the SurroundUpmix folder and selecting "Open in Terminal".

    Single track:
    Code:
    .\SurroundUpmix.ps1 "D:\Audio\Stems\MySong"
    7.1 output:
    Code:
    .\SurroundUpmix.ps1 "D:\Audio\Stems\MySong" -OutputFormat 7.1
    With loudness matching (recommended):
    Code:
    .\SurroundUpmix.ps1 "D:\Audio\Stems\MySong" -LoudnessMatch
    Match loudness to original MKV:
    Code:
    .\SurroundUpmix.ps1 "D:\Audio\Stems\MySong" -LoudnessMatch -SourceFile "D:\Audio\MySong.mkv"
    Batch - process an entire folder of tracks:
    Code:
    .\SurroundUpmix.ps1 "D:\Audio\Stems" -Batch
    Interactive mode (no typing needed - dialogs will ask everything):
    Code:
    .\SurroundUpmix.ps1
    Output location

    Code:
    D:\Audio\Stems\MySong\           <- your stems are here
    D:\Audio\Stems\Final_5.1\        <- output goes here automatically
        MySong_5.1.flac
    For 7.1 the folder is called Final_7.1. You can override with -OutputPath if you want it somewhere else.

    All Options

    Code:
    -OutputFormat 7.1         Create 7.1 instead of 5.1 (default: 5.1)
    -LoudnessMatch            Match output volume to original via EBU R128
    -SourceFile "file.mkv"    Use original file as loudness reference
    -AudioTrack 1             Which audio track in source file (0 = first)
    -Batch                    Process all stem subfolders in a parent folder
    -CleanTemp                Delete old temp files before starting
    -KeepTemp                 Keep temp files after finishing
    -DebugMode                Show every command the script runs
    -UpmixBass 4.0            How to place bass (4.0 / 5.0 / mono / front / rear)
    -UpmixDrums 4.0           How to place drums
    -UpmixVocals 5.0          How to place vocals
    -UpmixOther 5.0           How to place other instruments
    Routing values explained:
    • 4.0 - front left/right + surround left/right, no discrete center
    • 5.0 - same as 4.0 plus a dedicated center channel (best for vocals)
    • mono - everything in center only
    • front - everything in front left/right only
    • rear - everything in rear/surround only

    What it looks like while running

    Code:
    Tool check  (script v2.2.0)
      SoX    : SoX v14.4.2
      CC     : Center Cut CL v1.6.1
      ffmpeg : ffmpeg version 2026-03-15-git-...
    
    Step 1: Pre-combining stems by upmix method...
      4.0  <- bass, drums  [combining]
        [SOX] [########################################] 100.0%
    
    Step 2: Upmixing...
      Upmixing -> 5.0  [Combined_vocals_other.wav]
        [SOX] [########################################] 100.0%
        [CC ] v 8.3 s
    
    Step 5: Normalizing and encoding to FLAC...
      Source : -23.4 LUFS
      Upmix  : -23.4 LUFS
      Gain   : +0.0 dB
        [SOX] [########################################] 100.0%
    
      Done!
      Output: D:\Audio\Stems\Final_5.1\MySong_5.1.flac
      Clipping  : none
    Troubleshooting

    "Required binary not found"
    A tool is missing from the bin folder. Check the folder structure shown above.

    "No stems found"
    The folder does not contain bass.flac, drums.flac etc. Make sure Demucs-GUI finished and you are pointing to the correct subfolder.

    "execution of scripts is disabled"
    Open PowerShell as Administrator and run:
    Code:
    Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
    Output too quiet or too loud
    Use -LoudnessMatch to automatically match the volume to the original.

    System Requirements
    • Windows 10 or Windows 11
    • PowerShell 5.1 or newer (already included in Windows 10/11)
    • For GPU acceleration in Demucs-GUI: NVIDIA GTX 700 series or newer, or Intel Arc / Intel Xe

    Quick Start Checklist
    • Download and install Demucs-GUI
    • Run Demucs-GUI on your audio file using the htdemucs_ft model
    • Download SoX and place sox.exe in bin\SoX\
    • Download CenterCutCL and place CenterCutCL.exe in bin\
    • Optionally download ffmpeg and place ffmpeg.exe in bin\ffmpeg\
    • Place SurroundUpmix.ps1 in the SurroundUpmix folder
    • Open PowerShell in that folder and run the script
    • Add -OutputFormat 7.1 if you want 7.1 (default is 5.1)

    Getting the Script

    The script is attached to this post as SurroundUpmix.txt.
    1. Download the attached SurroundUpmix.txt file
    2. Rename it to SurroundUpmix.ps1 (just change the extension from .txt to .ps1)
    3. Place it inside your SurroundUpmix folder next to the bin subfolder

    Windows may hide file extensions. If you cannot see the .txt part of the filename:
    1. Open any Explorer window
    2. Click View at the top
    3. Tick File name extensions
    4. Now you can rename the file correctly

    Before running - allow PowerShell scripts (one time only):
    1. Press the Windows key, type PowerShell
    2. Right-click it and choose Run as Administrator
    3. Run this command:

    Code:
    Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
    Type Y and press Enter. You only need to do this once on your machine.

    Then to run it:
    1. Open the SurroundUpmix folder in Explorer
    2. Hold Shift and right-click an empty spot in the folder
    3. Choose Open PowerShell window here (or "Open in Terminal")
    4. Type and press Enter:

    Code:
    .\SurroundUpmix.ps1
    A dialog will open and guide you from there.
    Image Attached Files
    Quote Quote  
  2. ===== UPDATE - SurroundUpmix v2.9.8 =====

    So I've had quite a busy few days with this script since posting it on Thursday. Some feedback came in pointing out a few issues, and someone asked whether it would be possible to have presets for different content types -- specifically mentioning anime. That got me thinking, and once I started looking at it properly I realised there was a lot more that could be done on the DSP side of things -- so I ended up going down a bit of a rabbit hole over the weekend.

    Here's what changed:


    --- PRESETS ---

    The biggest addition. Instead of one generic processing mode, you now pick a preset at startup that shapes how the upmix sounds:

    Code:
    Music  -- wider surrounds, air and cymbals pushed to the rear, 15ms decorrelation
    Movie  -- tighter soundstage, +1dB centre boost for dialogue clarity, 10ms decorrelation
    Anime  -- forward centre (+2dB), BGM-friendly surround balance, 12ms decorrelation
    PLIIx  -- approximation of Dolby Pro Logic IIx, very wide and diffuse surrounds, 20ms decorrelation
    None   -- basic upmix, no preset DSP applied
    In interactive mode a dialog appears after you pick 5.1 or 7.1. From the command line use -Preset Music/Movie/Anime/PLIIx.


    --- ADAPTIVE DSP ---

    The script now analyses the stem files before processing and adjusts settings based on what it finds in the audio:

    - Stereo width (mid/side ratio): wide mixes get a slightly reduced centre and longer decorrelation delays; narrow or mono-leaning mixes get a more prominent centre
    - Spectral brightness: brighter stems get more high-frequency content blended into the surrounds
    - Stem energy balance: if vocals are significantly louder than the other stems, surround gain is pulled back slightly to keep dialogue front-focused

    You can see exactly what was measured and what was adjusted on the console:

    Code:
    [ADAPTIVE] Width=0.462 (raw=0.213) | Bright=0.286 | Centre=4.0 dB (0.0) | Surround=-1.7 dB | Decorr=12/14 ms
    The preset sets the baseline and the adaptive layer modifies it from there. They don't interfere with each other.


    --- DSP PROCESSING ---

    A few things were added to support the presets properly:

    - Front high-shelf filter: rolls off the top end on FL/FR but leaves the centre channel untouched, so the surrounds have more relative air without the dialogue being affected
    - Frequency-split routing: high-frequency content from the original stereo stem gets blended into the surrounds at reduced level for a bit of natural shimmer
    - Surround decorrelation: asymmetric delay plus allpass filters on Ls/Rs (and SL/SR in 7.1 mode) to prevent the surrounds from sounding like a copy of each other


    --- BUG FIXES ---

    Quite a few things needed fixing during testing, some from the new features and some that were already there:

    - Script was crashing on first run with a PowerShell parse error. Turned out to be a character encoding issue -- some Unicode symbols in the script were being misread. All non-ASCII characters replaced with plain ASCII equivalents, UTF-8 BOM added so Windows reads the file correctly.

    - Several functions were using 2>&1 to capture SoX and ffmpeg output. This works fine in normal use, but with PowerShell's ErrorActionPreference set to Stop, the stderr output from those tools was being treated as terminating exceptions. Fixed by setting ErrorActionPreference to Continue locally inside each function that calls external tools.

    - "None" preset mode was crashing because a gain variable was referenced before it had been initialised. Fixed by moving the default assignment earlier in the script.

    - The final FLAC was occasionally clipping by 1-2 samples when loudness correction required adding a small amount of gain. Switched from SoX's --norm global option to the gain -n effect, which does a guaranteed two-pass normalisation and prevents output clipping.

    - Adaptive analysis was writing temporary working files into the source stems folder. Fixed -- they now go into the processing temp folder with everything else.

    - Error messages when tools or folders were missing were showing as raw PowerShell exception blocks (the ugly red wall of text with CategoryInfo and FullyQualifiedErrorId). Replaced with clean readable messages.

    - In batch mode, the output folder location was being determined by whichever folder you happened to select in the picker, which could be inconsistent across runs if you clicked at different levels of the folder tree. Fixed -- the output folder is now anchored to the actual location of the track folders, so it ends up in the same place regardless of which parent folder you selected.


    --- USABILITY ---

    - Clip warnings during processing are now colour-coded: temp file clips appear in grey with a note that they're normal and handled by normalisation; output file clips appear in red. The summary at the end separates the two so you can tell at a glance whether the actual output file is clean.

    - Debug mode is now accessible from the interactive menu as a Yes/No dialog at the end of the preset selection flow. Previously it was command-line only.

    - Preset selection dialog made wider so the description text isn't cut off.


    --- TUNING FEEDBACK WELCOME ---

    The adaptive DSP layer has several constants that control how strongly width, brightness and stem energy affect the centre, surrounds and decorrelation delays. These are currently tuned based on limited test content, so real-world feedback from different material would help a lot.

    If you try the script and something sounds off -- surrounds too wide, centre buried, fronts too thin, whatever it is -- just post these three lines from the console output, mention which preset you selected, and add one sentence describing what bothered you:

    Code:
    Stem energy: vocals=0.0932  other=0.0495  ratio=1.88  (vocal-heavy)
    Dynamic surround gain: -0.8 dB
    [ADAPTIVE] Width=0.462 (raw=0.213) | Bright=0.286 | Centre=4.0 dB (0.0) | Surround=-1.7 dB | Decorr=12/14 ms
    Those numbers show exactly which measurement drove the issue and which constant to adjust. The more variety of content and presets people run through it, the better the defaults can get.


    --- WHAT HASN'T CHANGED ---

    The core pipeline is the same: Demucs stems -> CenterCutCL phase cascade -> SoX channel assembly -> ffmpeg loudness measurement -> FLAC output. Tool requirements (SoX, CenterCutCL, ffmpeg) are unchanged. Folder structure is unchanged. All command-line parameters are backward compatible.


    --- DOWNLOAD ---

    Attachment below. Just replace the .ps1 file in your SurroundUpmix folder, nothing else needs to change.

    If you run into anything, enable debug mode (either -DebugMode on the command line or answer Yes to the debug dialog in the menu) and paste the console output. It prints every SoX, CenterCutCL and ffmpeg command as it runs, which makes it easy to see exactly where something went wrong.
    Image Attached Files
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!