Skip to content

Commit

Permalink
Add adjustable pan law to some panners
Browse files Browse the repository at this point in the history
  • Loading branch information
junh1024 committed Feb 1, 2024
1 parent 78f9adf commit be0a2ad
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 22 deletions.
80 changes: 72 additions & 8 deletions Library/surroundlib1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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

Expand All @@ -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;
Expand All @@ -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)
// ();
11 changes: 7 additions & 4 deletions Panners/1.0 to 15.1 Panner (S).txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@ 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

@init

@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);
2 changes: 2 additions & 0 deletions Panners/1.0 to 15.1 Panner GUI (L).txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions Panners/7.1 Mono Panner.txt
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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);
6 changes: 2 additions & 4 deletions Panners/7.1 to 15.1 Height Panner.txt
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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);


7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Specialist/Pan Zone V2.txt
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit be0a2ad

Please sign in to comment.