From be0a2ad64d3a7d822ba57035cfa5587c9ce70430 Mon Sep 17 00:00:00 2001 From: junh1024 Date: Sat, 13 Jan 2024 22:12:59 +1300 Subject: [PATCH] Add adjustable pan law to some panners --- Library/surroundlib1.txt | 80 +++++++++++++++++++++++--- Panners/1.0 to 15.1 Panner (S).txt | 11 ++-- Panners/1.0 to 15.1 Panner GUI (L).txt | 2 + Panners/7.1 Mono Panner.txt | 5 +- Panners/7.1 to 15.1 Height Panner.txt | 6 +- README.md | 7 ++- Specialist/Pan Zone V2.txt | 2 +- 7 files changed, 91 insertions(+), 22 deletions(-) diff --git a/Library/surroundlib1.txt b/Library/surroundlib1.txt index b4a7062..dc669cc 100644 --- a/Library/surroundlib1.txt +++ b/Library/surroundlib1.txt @@ -73,8 +73,53 @@ function calculate_10_to_71_coeffs (pan) ( pan >=spk6pos-W && pan <=spk6pos+W )? spl6_coeff = abs(cos( ( (1.5* (pan - spk6pos )) )*($pi/180) )) : spl6_coeff=0; ( pan >=spk7pos-W && pan <=spk7pos+W )? spl7_coeff = abs(cos( ( (1.5* (pan - spk7pos )) )*($pi/180) )) : spl7_coeff=0; + + // inspector1= ( 60- abs ( ( pan + 30) %120 - 30 )) ; + // inspector1= abs(60-pan)+30; + + // inspector1= ( 60- abs(((pan+30)%120)-60) )/60 ; + +); + + +function calculate_10_to_71_coeffs_vari(pan, pan_law) +( + // calculate coefficients for -3dB pan law + ( pan >=spk0pos-W && pan <=spk0pos+W )? spl0_coeff_3 = abs(cos( ( (1.5* (pan - spk0pos )) )*($pi/180) )) : spl0_coeff_3=0; + ( pan >=spk1pos-W && pan <=spk1pos+W )? spl1_coeff_3 = abs(cos( ( (1.5* (pan - spk1pos )) )*($pi/180) )) : spl1_coeff_3=0; + (( pan >=spk4pos-W && pan <=spk4pos+W )||(pan>150))?spl4_coeff_3 = abs(cos( ( (1.5* (pan - spk4pos )) )*($pi/180) )) : spl4_coeff_3=0;//special handling + (( pan >=spk5pos-W || pan< -spk5pos ))?spl5_coeff_3 = abs(cos( ( (1.5* (pan - spk5pos )) )*($pi/180) )) : spl5_coeff_3=0;//for rear wraparound + ( pan >=spk6pos-W && pan <=spk6pos+W )? spl6_coeff_3 = abs(cos( ( (1.5* (pan - spk6pos )) )*($pi/180) )) : spl6_coeff_3=0; + ( pan >=spk7pos-W && pan <=spk7pos+W )? spl7_coeff_3 = abs(cos( ( (1.5* (pan - spk7pos )) )*($pi/180) )) : spl7_coeff_3=0; + + // calculate coefficients for -6dB pan law + ( pan >=spk0pos-W && pan <=spk0pos+W )? spl0_coeff_6 = ( 60- abs(((pan+spk0pos)%120)-60) )/60 : spl0_coeff_6=0; + ( pan >=spk1pos-W && pan <=spk1pos+W )? spl1_coeff_6 = ( 60- abs(((pan+spk1pos)%120)-60) )/60 : spl1_coeff_6=0; + (( pan >=spk4pos-W && pan <=spk4pos+W )||(pan>150))? spl4_coeff_6 = ( 60- abs(((pan+spk4pos)%120)-60) )/60 : spl4_coeff_6=0;//special handling + (( pan >=spk5pos-W || pan< -spk5pos ))? spl5_coeff_6 = ( 60- abs(((pan+spk5pos)%120)-60) )/60 : spl5_coeff_6=0;//for rear wraparound + ( pan >=spk6pos-W && pan <=spk6pos+W )? spl6_coeff_6 = ( 60- abs(((pan+spk6pos)%120)-60) )/60 : spl6_coeff_6=0; + ( pan >=spk7pos-W && pan <=spk7pos+W )? spl7_coeff_6 = ( 60- abs(((pan+spk7pos)%120)-60) )/60 : spl7_coeff_6=0; + + blend_coeff=(pan_law+6)/3; //map pan law to 0-1 + + // ell_coeff_pan=(ell_temp_6*(1-blend_coeff))+(ell_temp_3*blend_coeff); + + // apply variable pan law + spl0_coeff=(spl0_coeff_6*(1-blend_coeff))+(spl0_coeff_3*blend_coeff); + spl1_coeff=(spl1_coeff_6*(1-blend_coeff))+(spl1_coeff_3*blend_coeff); + spl4_coeff=(spl4_coeff_6*(1-blend_coeff))+(spl4_coeff_3*blend_coeff); + spl5_coeff=(spl5_coeff_6*(1-blend_coeff))+(spl5_coeff_3*blend_coeff); + spl6_coeff=(spl6_coeff_6*(1-blend_coeff))+(spl6_coeff_3*blend_coeff); + spl7_coeff=(spl7_coeff_6*(1-blend_coeff))+(spl7_coeff_3*blend_coeff); + + // pan law of 3dB for front & back always, since 90% time people will have at least LR channels + ( pan >=spk0pos && pan <=spk1pos ) ? ( spl0_coeff = spl0_coeff_3 ; spl1_coeff = spl1_coeff_3 ; ) ; + ( pan <=spk4pos || pan >=spk5pos ) ? ( spl4_coeff = spl4_coeff_3 ; spl5_coeff = spl5_coeff_3 ; ) ; ); + + + function do_10_to_71_pan(in0) ( spl0 = spl0_coeff * in0; @@ -85,9 +130,9 @@ function do_10_to_71_pan(in0) spl7 = spl7_coeff * in0; ); -function calculate_71_to_151_coeffs_pc(theslider1) +function calculate_71_to_151_coeffs_pc(height) ( //pan compensated - temp1 = theslider1*0.9 ; //map 0-100 to 0-90deg + temp1 = height*0.9 ; //map 0-100 to 0-90deg temp2 = temp1*$pi /180 ; //convert from degrees to rads top_coeff_pan = sin(temp2) ; //top coefficient @@ -97,15 +142,34 @@ function calculate_71_to_151_coeffs_pc(theslider1) ); -function calculate_71_to_151_coeffs_npc(theslider1) +function calculate_71_to_151_coeffs_npc(height) ( //non pan compensated - top_coeff_pan = ( theslider1/100); //vert coefficient - ell_coeff_pan = 1-( abs(theslider1/100)); + top_coeff_pan = ( height/100); //vert coefficient + ell_coeff_pan = 1-( abs(height/100)); ); + +function calculate_71_to_151_coeffs_vari(height,pan_law) +( + blend_coeff=(pan_law+6)/3; //map pan law to 0-1 -function do_71_to_151_pan(theslider1) + //compute coefficients for pan_law s of -3 & -6 + top_temp_3=(height/100)* ($pi/2); // map to 0-90deg then convert to rad + top_temp_3=sin(top_temp_3); + + ell_temp_3=(1-(height/100)) *($pi/2); + ell_temp_3=sin(ell_temp_3); + + ell_temp_6=(100-height)/100; + top_temp_6=height/100; + + //final coefficients according to pan law + ell_coeff_pan=(ell_temp_6*(1-blend_coeff))+(ell_temp_3*blend_coeff); + top_coeff_pan=(top_temp_6*(1-blend_coeff))+(top_temp_3*blend_coeff); +); + +function do_71_to_151_pan(height) ( - ( theslider1 >= 0 )? ( + ( height >= 0 )? ( //need top first otherwise it gets silenced spl8 = spl0 * top_coeff_pan; spl9 = spl1 * top_coeff_pan; @@ -131,5 +195,5 @@ function do_71_to_151_pan(theslider1) spl1 = spl1 * ell_coeff_pan; ); ); -// function calculate_71_to_151_coeffs_npc(theslider1) +// function calculate_71_to_151_coeffs_npc(height) // (); diff --git a/Panners/1.0 to 15.1 Panner (S).txt b/Panners/1.0 to 15.1 Panner (S).txt index a857fcd..8870f8d 100644 --- a/Panners/1.0 to 15.1 Panner (S).txt +++ b/Panners/1.0 to 15.1 Panner (S).txt @@ -2,6 +2,8 @@ desc: mono to 15.1 panner. (phantom center) slider1:0<-180,180>the pan (deg) slider2:0<-100,100,5>Height (+ve up, -ve down) +slider3:0<-3,3,0.5>Gain +slider4:-3<-6,-3,0.5>Pan law (dB) import surroundlib1.txt @@ -9,12 +11,13 @@ import surroundlib1.txt @slider -pan=slider1;//pan, from clockwise, degrees -calculate_10_to_71_coeffs (pan); -calculate_71_to_151_coeffs_pc(slider2); +gain=2^(slider3/6); // dB to linear +// pan=slider1;//pan, from clockwise, degrees +calculate_10_to_71_coeffs_vari (slider1,slider4); +calculate_71_to_151_coeffs_vari(slider2,slider4); @sample -in0=(spl0+spl1)*0.7071; //loudness compensation +in0=(spl0+spl1)*0.7071*gain; //loudness compensation do_10_to_71_pan(in0); do_71_to_151_pan(slider2); diff --git a/Panners/1.0 to 15.1 Panner GUI (L).txt b/Panners/1.0 to 15.1 Panner GUI (L).txt index 8844359..0d7f91a 100644 --- a/Panners/1.0 to 15.1 Panner GUI (L).txt +++ b/Panners/1.0 to 15.1 Panner GUI (L).txt @@ -107,6 +107,8 @@ slider5<2?(LFE_mode_gain=0.316):(LFE_mode_gain=1;); //new calculate_10_to_71_coeffs (slider1); +calculate_71_to_151_coeffs_pc(slider2); + @sample in0=(spl0+spl1)*0.7071; //loudness compensation diff --git a/Panners/7.1 Mono Panner.txt b/Panners/7.1 Mono Panner.txt index c88e976..a95592d 100644 --- a/Panners/7.1 Mono Panner.txt +++ b/Panners/7.1 Mono Panner.txt @@ -1,6 +1,7 @@ desc: mono to 7.1 panner (phantom center) slider1:0<-180,180,1>the pan (deg) +slider2:-3<-6,-3,0.5>Pan law (dB) import surroundlib1.txt @@ -10,9 +11,9 @@ import surroundlib1.txt @slider pan=slider1;//pan, from clockwise, degrees - calculate_10_to_71_coeffs (pan); +calculate_10_to_71_coeffs_vari(slider1,slider2); @sample in0=(spl0+spl1)*0.7071; //loudness compensation - do_10_to_71_pan(in0); +do_10_to_71_pan(in0); diff --git a/Panners/7.1 to 15.1 Height Panner.txt b/Panners/7.1 to 15.1 Height Panner.txt index 46c032d..c615c6f 100644 --- a/Panners/7.1 to 15.1 Height Panner.txt +++ b/Panners/7.1 to 15.1 Height Panner.txt @@ -1,7 +1,7 @@ desc:Makes 15.1 height by shifting the side 6 of 7.1 upwards slider1:0<-100,100,2>Height (%) -slider2:-6<-6,-3,3>Pan law (dB) +slider2:-6<-6,-3,0.5>Pan law (dB) import surroundlib1.txt @@ -35,10 +35,8 @@ out_pin:HSR @init @slider -slider2==-6?calculate_71_to_151_coeffs_npc(slider1):calculate_71_to_151_coeffs_pc(slider1); - +calculate_71_to_151_coeffs_vari(slider1,slider2); @sample do_71_to_151_pan(slider1); - diff --git a/README.md b/README.md index 075ebec..ff71cb4 100644 --- a/README.md +++ b/README.md @@ -121,9 +121,9 @@ Upmixers are considered experimental & are based on matrixes. It's advisable to - 5.1 to 7.1 Upmix V3 (L).txt: Using FFT [see FFT Notes](#fft-notes) to upmix 51 to 71. Since 71 is downmixed to 51 by combining the back 4, - Circle mode is downmix compatible since it re interprets the back 2 to back 4. Should work well on content downmixed from 61 or 71. - Square mode isn't downmix compatible since it upscales the corner 4 to the side. For specialist use only. -- 5.1 to 3D Upmix (L).txt: upmixes Using FFT [see FFT Notes](https://github.com/junh1024/Reaper-Surround#fft-notes) to height sounds that are closer to: - - Ambience: 90* - - Ambience +: 180* +- 5.1 to 3D Upmix (L).txt: upmixes Using FFT [see FFT Notes](#fft-notes) to height sounds that are closer to: + - Ambience: 90*. Sounds are reflected downwards after that. Sounds are more evenly upmixed. + - Ambience +: 180*. Wider sounds are upmixed more. - Discrete SFX: the absolute center - Pan Slice: the pan slider - Function Designer: view the shape of the above mode @@ -169,6 +169,7 @@ Specialist & Utility --- - DifferenceMaker.txt: subtracts Sidechain (3+4) from Main (1+2). Useful for getting the difference after an effect. - MSEDDouble.txt: Double Mid/Side Codec (1+2) & (5+6) +- Pan Zone V2.txt: Freeform FFT stereo imager (originally by Keith Handy). V2 adds more controls, more intuition, GUI, and PDC. - Simple Crossfade.txt: Fade between 2 sets of inputs, like a DJ mixer. - Surcode Fixer: Fixes delay &/ PDC, width adjustments of Surcode DPL. - Surround Fixer.txt diff --git a/Specialist/Pan Zone V2.txt b/Specialist/Pan Zone V2.txt index bf8027c..a55fe2e 100644 --- a/Specialist/Pan Zone V2.txt +++ b/Specialist/Pan Zone V2.txt @@ -1,4 +1,4 @@ -desc: Pan Zone V2 +desc: Pan Zone V2 (Keith Handy, junh1024) // original by Keith Handy https://forum.cockos.com/showthread.php?t=206624 // modified by junh1024