Skip to content

Commit 31d05a5

Browse files
Release Phil Ranger GUI and Audio Library (JSFX) v0.Alpha2 (#410)
1 parent 72cd3d6 commit 31d05a5

5 files changed

Lines changed: 929 additions & 0 deletions

File tree

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
desc: GUI and Audio Library
2+
author: Phil Ranger
3+
version: 0.Alpha2
4+
provides:
5+
philranger_GUI and Audio Library/PhilRangerAudioLibraryAlpha2.jsfx-inc
6+
philranger_GUI and Audio Library/Knob.png
7+
philranger_GUI and Audio Library/Highlight.png
8+
philranger_GUI and Audio Library/Switch.png
9+
about:
10+
This is about the library, not the plugin itself as it is given only as an example of using most of the function's library. Comments welcome!
11+
Resizing of the graphic components is automatic, automatic memory management, JSFX exclusively so it's easy to understand, edit and improve
12+
Main graphic functions included: Linear and non-linear range management, GUI for Texts and numbers, panels, pictures, knobs, sliders, switches and meters. Sliders, switches and knobs have a default style or can be whatever picture you want.
13+
Audio functions included: EQ (all main types), enveloppe follower, clipper, delay (with clipping@+12 dB) and conversion utilities
14+
15+
import philranger_Phil Ranger GUI and Audio Library/PhilRangerAudioLibraryAlpha2.jsfx-inc
16+
17+
/* Existing widgets: Panels, pictures, switches, knobs, meters, sliders
18+
Right-click = set to default value
19+
Ctrl-click = finer adjustment
20+
21+
Global variables:
22+
PR.Text.Font="Arial";
23+
PR.Color.Text="D0D0FFF"; //Blueish pale gray
24+
PR.Color.Main="808080FF"; //Gray
25+
PR.Color.Panel="300050A0"; //Dark Violet
26+
PR.Color.Contour="303040FF"; //Blueish Gray
27+
PR.Color.Shadow = "00000080"; //Semi-transparent black
28+
*/
29+
30+
//Load pictures if desired. They will be referred to by their number.
31+
filename:0,Highlight.png
32+
filename:1,Knob.png
33+
filename:2,Switch.png
34+
35+
// Adding a "-" right after the > would make the default slider invisible
36+
slider1:Frequency=1000<20,20000,1>-Frequency (Hz)
37+
slider2:Gain=0<-24,24,1>-Gain (dB)
38+
Slider3:Q=0.5<0.1,10,1>-Q
39+
40+
Slider4:Delayms=120<0,1000,1>-Delay (ms)
41+
Slider5:Feedback=30<0,100,1>-Feedback (%)
42+
Slider6:DelayMix=20<0,100,1>-Delay Mix (%)
43+
44+
slider7:ClipLevel=-3<-20,15,1>-Clip Level
45+
46+
slider8:Unmute=1<0,1,1>-Unmute
47+
48+
slider9:Pad=0<0,1,1>-Pad (20dB)
49+
50+
slider10:EQStyle=0<0,6,1,{Peaking,Low Pass, High Pass, Band Pass, Notch, Low Shelf, High Shelf}>EQ Style
51+
52+
in_pin:left input
53+
in_pin:right input
54+
out_pin:left output
55+
out_pin:right output
56+
57+
@init // "my" isn't a reserved word: it just indicates that you could use any variable, as opposed to the library functions and globalvariables, which all begin with "PR."
58+
// Define ranges for the widgets. Use same values as for the slider definitions
59+
myRangeFrequency =PR.NewFrequencyRange(1000,20,20000); //Ranges: DefaultValue MinValue MaxValue
60+
myRangeGain=PR.NewLinearRange(0,-24,24);
61+
myRangeQ=PR.NewFrequencyRange(0.7,0.1,10);
62+
63+
myRangeDelay=PR.NewLinearRange(120,0,1000);
64+
myRangeFeedback=PR.NewLinearRange(30,0,100);
65+
myRangeMix=PR.NewLinearRange(20,0,100);
66+
67+
myRangeClip=PR.NewLinearRange(-3,-20,15);
68+
69+
// Reserve memory for the widgets and give startup values
70+
myLeftEQ=PR.NewEQ();
71+
myRightEQ=PR.NewEQ();
72+
PR.SetPeakingEQ(myLeftEQ,Frequency,Gain,Q);//F,G,Q
73+
PR.SetPeakingEQ(myRightEQ,Frequency,Gain,Q);//F,G,Q
74+
myEnveloppeFollower=PR.NewEnveloppeFollower(); //Attack Time, Release Time
75+
PR.SetEnveloppeFollower(myEnveloppeFollower, 0.001, 0.5); //Attack and Release Time
76+
77+
myDelayLeft=PR.NewDelay(1000); //Maximum delay, in milliseconds
78+
myDelayRight=PR.NewDelay(1000); //Maximum delay, in milliseconds
79+
PR.SetDelay(Delayms,Feedback,myDelayLeft);
80+
PR.SetDelay(Delayms,Feedback,myDelayRight);
81+
82+
// Set shapes for the widgets. Memory needs to ba allocated beforehand.
83+
// Sizes are in % of the total width of the plugin.
84+
// Positions of widgetss are their centers (top corner wouldn't make sense for knobs)
85+
myShapePanel=PR.NewRectangle(50,50,98,98); //Panels are rectangular: Xcenter,Ycenter, Width, Height
86+
myShapeHighlight=PR.NewCircle(70,70,150); // Picture display don't consider height, so they use a circle: X Y and size, will not stretch the picture
87+
88+
myShapeFrequency=PR.NewRectangle(15,28,6,32); //will be a rectangular slider
89+
myShapeGain=PR.NewCircle(33,25,12); // will be a round knob. Center x, center y, Size
90+
myShapeQ=PR.NewCircle(55,25,12); //Will be a round knob
91+
92+
myShapeDelay=PR.NewCircle(20,62,12); //Will be a round knob
93+
myShapeFeedback=PR.NewCircle(50,62,12); //Will be a round knob
94+
MyShapeMix=PR.NewCircle(80,62,12); //Will be a round knob
95+
96+
myShapeMeter=PR.NewCircle(80,25,15); //meters use a circle
97+
98+
myShapeClip=PR.NewRectangle(34,89,52,5); //will be a rectangular slider
99+
100+
myShapeUnmute=PR.NewRectangle(72,88,3,7); //will be a rectangular switch
101+
myShapePad=PR.NewRectangle(88,88,10,4); //will be a rectangular switch
102+
103+
@slider
104+
// No need to do anything here as I used named variables for the slider definitions
105+
106+
@block
107+
(EQStyle==0)? (
108+
PR.SetPeakingEQ(myLeftEQ,Frequency,Gain,Q);
109+
PR.SetPeakingEQ(myRightEQ,Frequency,Gain,Q);
110+
);
111+
(EQStyle==1)? (
112+
PR.SetLowPassEQ(myLeftEQ,Frequency,Gain,Q);
113+
PR.SetLowPassEQ(myRightEQ,Frequency,Gain,Q);
114+
);
115+
(EQStyle==2)? (
116+
PR.SetHighPassEQ(myLeftEQ,Frequency,Gain,Q);
117+
PR.SetHighPassEQ(myRightEQ,Frequency,Gain,Q);
118+
);
119+
(EQStyle==3)? (
120+
PR.SetBandPassEQ(myLeftEQ,Frequency,Gain,Q);
121+
PR.SetBandPassEQ(myRightEQ,Frequency,Gain,Q);
122+
);
123+
(EQStyle==4)? (
124+
PR.SetNotchEQ(myLeftEQ,Frequency,Gain,Q);
125+
PR.SetNotchEQ(myRightEQ,Frequency,Gain,Q);
126+
);
127+
(EQStyle==5)? (
128+
PR.SetLowShelfEQ(myLeftEQ,Frequency,Gain,Q);
129+
PR.SetLowShelfEQ(myRightEQ,Frequency,Gain,Q);
130+
);
131+
(EQStyle==6)? (
132+
PR.SetHighShelfEQ(myLeftEQ,Frequency,Gain,Q);
133+
PR.SetHighShelfEQ(myRightEQ,Frequency,Gain,Q);
134+
);
135+
136+
PR.SetDelay(myDelayLeft,Delayms,Feedback);
137+
PR.SetDelay(myDelayRight,Delayms,Feedback);
138+
139+
@sample
140+
(Pad==1) ? (spl0=spl0/10; spl1=spl1/10;);
141+
142+
//Processing: Unmute(or not) the clipped output of the eq
143+
spl0 = Unmute * PR.Clip(ClipLevel,PR.EQ(myLeftEQ,spl0));
144+
spl1 = Unmute * PR.Clip(ClipLevel,PR.EQ(myRightEQ,spl1));
145+
146+
PR.Delay(myDelayLeft, spl0);
147+
Mix=Delaymix/100;
148+
spl0 = PR.Clip(ClipLevel,(1-Mix)*spl0+Mix*PR.Delay(myDelayLeft,spl0));
149+
spl1 = PR.Clip(ClipLevel,(1-Mix)*spl1+Mix*PR.Delay(myDelayRight,spl1));
150+
151+
//For the meter:
152+
myMeterValue = PR.EnveloppeFollower((spl0+spl1)/2, myEnveloppeFollower); //Value, AttackTime, ReleaseTime
153+
154+
@gfx 500 500
155+
// right click = default value, ctrl-drag = smaller movements
156+
//Main panel, using 98% of the size
157+
PR.Color.Panel="30005060"; //Dark Purple. There are default colors if you don't want to bother.
158+
PR.DisplayPanel(myShapePanel); //Rectangle. Uses PR.Color.Contour; PR.Color.Panel as the background color
159+
//Name of the plugin
160+
PR.DisplayTextCenter(50,5,5,"My First Little Plugin");//x,y,size,text
161+
162+
//Little panels to visually define the sections
163+
PR.Color.Panel="100050A0"; //Dark Violet.
164+
PR.DisplayPanel(50,30,90,40); //EQ sub-panel. x,y,width,height.
165+
PR.DisplayTextCenter(15,46,3,"Frequency");//x,y,size,text
166+
PR.DisplayTextCenter(33,35,3,"Gain (dB)");//x,y,size,text
167+
PR.DisplayTextCenter(55,35,3,"Q");//x,y,size,text
168+
169+
PR.DisplayPanel(50,65,90,28); //Delay sub-panel.
170+
PR.DisplayTextCenter(20,72,3,"Delay (ms)");//x,y,size,text
171+
PR.DisplayTextCenter(50,72,3,"Feedback (%)");//x,y,size,text
172+
PR.DisplayTextCenter(80,72,3,"Mix (%)");//x,y,size,text
173+
174+
PR.DisplayPanel(34,89,58,18); //Clipper sub-panel
175+
PR.DisplayText(21,93,3,"Clip Level: dB");//x,y,size,text
176+
PR.DisplayText(33,93,3,PR.NumbertoText(ClipLevel));//x,y,size,number
177+
178+
PR.DisplayPanel(72,89,15,18); //Unmute sub-panel
179+
PR.DisplayTextCenter(72,94,3,"Unmute"); //x,y,size,text
180+
181+
PR.DisplayPanel(88,89,15,18); //Visual Style sub-panel
182+
PR.DisplayTextCenter(88,94,3,"20 dB Pad");//x,y,size,text
183+
184+
//Add a highlight picture because I think it looks cool
185+
gfx_a = 0.2; //Picture will be quite transparent.
186+
PR.DisplayPicture(myShapeHighlight,0); //x,y,width,PictureNumber.
187+
188+
PR.DisplaySlider(myShapeFrequency,myRangeFrequency,1);// Shape,Range,SliderNumber,[PictureNumber].
189+
PR.DisplayKnob(myShapeGain,myRangeGain,2);
190+
PR.DisplayKnob(myShapeQ,myRangeQ,3);
191+
192+
//Now using pictures instead of default shapes
193+
PR.DisplayKnob(myShapeDelay,myRangeDelay,4,1);// Shape,Range,SliderNumber,[PictureNumber]. Uses PR.Color.Contour; PR.Color.Main; PR.Color.Shadow; PR.Color.Text;
194+
PR.DisplayKnob(myShapeFeedback,myRangeFeedback,5,1);
195+
PR.DisplayKnob(MyShapeMix,myRangeMix,6,1);
196+
197+
PR.DisplaySlider(myShapeClip,myRangeClip,7,1);// Shape,Range,SliderNumbe,PictureNumberr.
198+
PR.DisplaySwitch(myShapeUnmute,8,2); // Rectangle, Slider Numbe,PictureNumberr. Uses PR.Color.Contour; PR.Color.Main; PR.Color.Shadow;
199+
PR.DisplaySwitch(myShapePad,9,1);
200+
201+
// Meters don't have a picture, Let's change its background color
202+
mydBMeterValue=PR.LinearTodB(myMeterValue);
203+
PR.DisplayMeter(myShapeMeter,mydBMeterValue,-45,6); //Circle, Value Min Max
204+
PR.DisplayTextCenter(80,35,3,"Output (dB)");//x,y,size,text
205+
206+
PR.End();// Required at the end of gfx block
23.2 KB
Loading
14.5 KB
Loading

0 commit comments

Comments
 (0)