Devialet Chat

Full Version: REW filters to Sweetroom eq.txt script (windows only)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
(30-Oct-2020, 13:10)Soniclife Wrote: [ -> ]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.

Hello Soniclife, you did a great job. Respect!!
Thanks!

If I may, what is the source for the table you shared above? This is really great and I have never seen it expressed so well.

Thanks.

Cheers,
Bernard
(31-Oct-2020, 01:11)bernardl Wrote: [ -> ]Thanks!

If I may, what is the source for the table you shared above? This is really great and I have never seen it expressed so well.

Thanks.

Cheers,
Bernard
Both images come from xkcd, I'd not noticed before but there is no indication on his images who made them.
Thanks! Great job!!!!

What is the REW filters you mentioned for exporting? I just use the mic do a measurement and rew show me a graphic wave line, do I need to put a filter on top of the wave line??
(01-Nov-2020, 14:46)PeppaPig Wrote: [ -> ]What is the REW filters you mentioned for exporting? I just use the mic do a measurement and rew show me a graphic wave line, do I need to put a filter on top of the wave line??
The useful answer to this would require a huge response, I bought my measurement mic over 4 years ago, it's only in the last 6 months I really feel I am beginning to understand how to measure properly and do something useful with the measurements. I suggest looking around for tutorials on how to use REW, there are a lot out there, links to multiple ones have been posted to this site since sweet room was announced, FWIW I still recommend the moving mic method. I think watching some of the videos ones might be the best place to start, unless you hate videos like me, then try some experiments. The best place to start is lowering some of the big peaks your room will have in the bass, and then listen to the result, then start looking into house curves (targets). This topic requires deep knowledge to get simple results, I wish it didn't, I just want to listen to some tunes, not learn physics!
Not sure if anyone has linked to this before, but Magnus has published this tutorial which you might find useful:
https://community.roonlabs.com/t/a-guide...roon/23800