Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
REW filters to Sweetroom eq.txt script (windows only)
#1
Hi,

I did the manual creation of the eq.txt file once, and as I expected I didn't like typing numbers from one place into another, this is how my brain works.

[Image: automation.png]


[Image: is_it_worth_the_time.png]

Despite knowing this I've gone ahead and created a Powershell script to take the filters created in REW and produce the eq.txt file in the required format.

Usage.
  1. Export your filters from REW as txt into a directory.
  2. Copy the script to this same location.
  3. Run the script.
  4. Check the eq.txt it creates in something like notepad.
1. After creating the filters click on your left measurement and do File>Export>Export Filter settings as text.
Add a comment when prompted if you want to, it's a good idea though.
Name the file Left.txt and save it in a new directory.
Repeat the above for the right channel calling it Right.txt and putting it in the same dir.
If you want to use the alt config save those as Left_alt.txt and Right_alt.txt to the same location, these are optional, they will be used if there.

2.
Copy the code below into notepad and save it as Sweetroom.ps1
Code:
cd "$PSScriptRoot"

Set-Content .\eq.txt @"
// Name for this EQ configuration
"NAME":"SWEET",

// Remote indicator
// Allow for the bottom's right button to toggle between main and alternate set of EQs
// Useful in A/B tests or during fine EQ tuning
"REMOTE",

// Parameters for left channel
// Static dB gain for the left channel
"dB_GAIN_L":"0.0", // main gain
"dB_GAIN_L_ALT":"0.0", // alternate gain

// Peak/Notch filters for the left channel (main)
// syntax:"EQ_x_L":[Frequency, dB_gain, Q_factor]
"@

$Filter = 0
foreach($line in Get-Content .\Left.txt) {
    if($line -match " on  PK"){
        $Filter++

        $Freq = $line.Substring($line.IndexOf("Fc")+2,8)
        $Freq = $Freq.Trim()

        $Gain = $line.Substring($line.IndexOf("Gain")+4,7)
        $Gain = $Gain.Trim()
       
        $Q = $line.Substring($line.IndexOf("Q")+1,7)
        $Q = $Q.Trim()
       
        $string = -join ( """EQ_", $Filter, "_L"":[", $Freq, ", ", $Gain, ", ", $Q, "],")

        Add-Content .\eq.txt $string
    }
}

If (Test-Path .\Left_alt.txt) {
    Add-Content .\eq.txt @"
   
// Peak/Notch filters for the left channel (alternate)
// syntax:"EQ_x_L_ALT":[Frequency, dB_gain, Q_factor]
"@
    $Filter = 0
    foreach($line in Get-Content .\Left_alt.txt) {
        if($line -match " on  PK"){
            $Filter++

            $Freq = $line.Substring($line.IndexOf("Fc")+2,8)
            $Freq = $Freq.Trim()

            $Gain = $line.Substring($line.IndexOf("Gain")+4,7)
            $Gain = $Gain.Trim()
       
            $Q = $line.Substring($line.IndexOf("Q")+1,7)
            $Q = $Q.Trim()
       
            $string = -join ( """EQ_", $Filter, "_L_ALT"":[", $Freq, ", ", $Gain, ", ", $Q, "],")

            Add-Content .\eq.txt $string
        }
    }
}

Add-Content .\eq.txt @"

// Parameters for right channel
// Static dB gain for the right channel
"dB_GAIN_R":"0.0", // main gain
"dB_GAIN_R_ALT":"0.0", // alternate gain

// Peak/Notch filters for the right channel (main)
// syntax:"EQ_x_R":[Frequency, dB_gain, Q_factor]
"@

$Filter = 0
foreach($line in Get-Content .\Right.txt) {
    if($line -match " on  PK"){
        $Filter++
       
        $Freq = $line.Substring($line.IndexOf("Fc")+2,8)
        $Freq = $Freq.Trim()
       
        $Gain = $line.Substring($line.IndexOf("Gain")+4,7)
        $Gain = $Gain.Trim()
       
        $Q = $line.Substring($line.IndexOf("Q")+1,7)
        $Q = $Q.Trim()
               
        $string = -join ( """EQ_", $Filter, "_R"":[", $Freq, ", ", $Gain, ", ", $Q, "],")

        Add-Content .\eq.txt $string
    }
}

If (Test-Path .\Right_alt.txt) {
    Add-Content .\eq.txt @"
   
// Peak/Notch filters for the right channel (alternate)
// syntax:"EQ_x_R_ALT":[Frequency, dB_gain, Q_factor]
"@
    $Filter = 0
    foreach($line in Get-Content .\Right_alt.txt) {
        if($line -match " on  PK"){
            $Filter++

            $Freq = $line.Substring($line.IndexOf("Fc")+2,8)
            $Freq = $Freq.Trim()

            $Gain = $line.Substring($line.IndexOf("Gain")+4,7)
            $Gain = $Gain.Trim()
       
            $Q = $line.Substring($line.IndexOf("Q")+1,7)
            $Q = $Q.Trim()
       
            $string = -join ( """EQ_", $Filter, "_R_ALT"":[", $Freq, ", ", $Gain, ", ", $Q, "],")

            Add-Content .\eq.txt $string
        }
    }
}

Get-Content .\eq.txt

#pause
Each time you want to use copy it from where you saved it to the directory with the left and right filters you just exported from REW.

3. Right click the Sweetroom.ps1 script and choose "Run with Powershell".
A blue box should briefly appear, and eq.txt should be created in the folder.  If eq.txt already exists it will be overwritten.
The first time you go to do this it's likely to fail, powershell scripts are disabled in Windows by default, and you need to change the permissions to allow scripts you created to run, the following 2 links explain how, you probably want to grant the "RemoteSigned" permission.
https://www.howtogeek.com/106273/how-to-...windows-7/
https://tecadmin.net/powershell-running-...ed-system/

4. Open the eq.txt file and do a quick sanity check that it looks like you expected, if so go ahead and copy it to the SD card to use it.

Any problems I'll try and help, I'm fairly certain I've explained this badly. 
Use at your own risk.

P.S. The gain required for a filter to not clip that REW calculates isn't in the text file it saves, so I've ignored this for now, if you want to use this either edit the eq.txt produced, or edit the script to hard code the adjustment you want.  I'm not using this, and I don't get clipping, why this is I have some ideas, but best discussed elsewhere on the forum.

P.P.S I think it's best if we keep how to use REW and how to create filters in it to other threads.
Roon, Rega P9 + Dynavector XX2Mk2 > 440 Pro > Sonus Faber Guarneri Evolution
Reply


Messages In This Thread
REW filters to Sweetroom eq.txt script (windows only) - by Soniclife - 30-Oct-2020, 13:10

Forum Jump:


Users browsing this thread: 1 Guest(s)