|
|
|
10-01-2020, 03:08 AM
|
#1
|
Human being with feelings
Join Date: Mar 2007
Posts: 3,978
|
How to modify tonegate jsfx code for synced oscillator option? [SOLVED]
Can anybody help to modify the code of "tonegate" JSFX to have its internal oscillator "synced to trigger" instead of free-running as it is now, please?
(I mean that the wave would start always from start when triggered and not at random point of the phase)?
EDIT 20201231: Solved thanks to sai'ke in post#3
Last edited by akademie; 01-14-2021 at 06:31 PM.
Reason: solution addition
|
|
|
12-31-2020, 05:57 PM
|
#2
|
Human being with feelings
Join Date: Mar 2007
Posts: 3,978
|
Kindly bumping,
if anyone knows how to modify, please?
|
|
|
12-31-2020, 06:32 PM
|
#3
|
Human being with feelings
Join Date: Aug 2009
Location: NL
Posts: 1,453
|
A quick and dirty hack would be to change:
Code:
a ?
(
silentcnt=0;
seekto=1;
) : (
(silentcnt+=1) > sillen ? seekto=0;
);
to:
Code:
a ?
(
seekv < .001 ? (
pos = 0;
);
silentcnt=0;
seekto=1;
) : (
(silentcnt+=1) > sillen ? seekto=0;
);
When the threshold is breached, it'll reset the phase until the gate is opened to a certain extent (seekv is how far the gate has been opened). The waveform should still be silent there.
What do you need this for exactly?
|
|
|
12-31-2020, 06:57 PM
|
#4
|
Human being with feelings
Join Date: Mar 2007
Posts: 3,978
|
Thanks sai'ke, I will try that.
EDIT: Quickly tried to modify the code using your suggestion and it work pretty good and stable.
Thank you very much again
Quote:
Originally Posted by sai'ke
What do you need this for exactly?
|
For generating "stable" kick drums
(With original Tonegate effect each kick hit is different and not punchy all the time when phase at start of wave is fluctuating.)
Last edited by akademie; 12-31-2020 at 08:01 PM.
|
|
|
01-24-2021, 02:15 PM
|
#5
|
Human being with feelings
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,031
|
Sharing back the result somewhere would be nice. Not a must.
|
|
|
01-25-2021, 09:41 PM
|
#6
|
Human being with feelings
Join Date: Mar 2007
Posts: 3,978
|
Well, here it is.
My modified (and extended) version of original Tone Gate effect.
Credits:
original code ... daniel arena (remainclam.org)
oscillator start sync option ... sai'ke (thanks)
osc.sync idea and extended options ... akademie
download:
tonegate-sync-mod-ext
Code:
// License: GPL - http://www.gnu.org/licenses/gpl.html
// cobbled together from a bunch of other plugins - tonegenerator, noisegate, lowpassfilter,
// plus some more bits
// by daniel arena (dan@remaincalm.org)
// http://remaincalm.org
// yay!
// 2008/04/23 - added dynamic pitch
// 2021/01/25 - oscillator start sync modification (v 1.00) by akademie/sai'ke
// forum thread: https://forum.cockos.com/showthread.php?t=242920
// actual mod is in "fire sample!" section, also new sliders 11, 12, 13 & 14 were added for new parameters UI access
desc: Tone Gate (SyncMOD Extended v1.00)
//desc: Tone Gate (SyncMOD Extended v1.00) [remaincalm.org]
//tags: generator processing gate
//author: remaincalm.org
//modificators: akademie, sai'ke
// tone gen
slider1:-15<-120,6,1>Wet Mix (dB)
slider2:-3<-120,6,1>Dry Mix (dB)
slider3:80<20,400,1>Frequency (Hz)
slider4:0<0,2,1{Sine,Square,Noise}>Waveform
slider5:1000<50,10000>Lowpass (Hz)
slider6:-20<-120,6,1>Threshold (dB)
slider7:50<1,4000,10>Silence Length For Fadeout (ms)
slider8:10<1,100,5>Fade In Response (ms)
slider9:100<1,1000,10>Fade Out Response (ms)
slider10: 0<0,4,1{Normal,Div 2,Div 4,Mult 2,Mult 4}>Dynamic Pitch
slider11: 0<0,1,1{OSC sync ON,OSC Sync OFF}>OSC Sync
slider12: 1<0,10,0.1>Speed 1 coeficient (TEST)
slider13: 10<0,10,0.1>Speed 2 coeficient (TEST)
slider14: 4<0.1,20,0.1>Speed 3 coeficient (decay) (TEST)
in_pin:left input
in_pin:right input
out_pin:left output
out_pin:right output
@init
// sin
silentcnt=0;
seekv=0; seekto=0;
a = 0;
@slider
// gate
thresh=2 ^ (slider6/6);
sillen=slider7*srate/1000;
fadeout = 1/pow(10,1/(srate*slider9/1000));
fadein = 1/pow(10,1/(srate*slider8/1000));
// gen
vol=2 ^ (slider1/6);
dry=2 ^ (slider2/6);
adj=2*$pi* slider3 / srate;
// filter
damp=0.01+0.2*20;
c = 1/tan($pi*slider5/srate);
fk = 1 / (1 + c*(c+damp));
fa1 = 2 * (1 - c*c) * fk;
fa0 = (1 + c*(c-damp)) * fk;
oldamp=damp;
// generator cursor and freq
init_freq = slider3;
decaytime = fadeout/slider14;
//decaytime = fadeout/4;
// pitch mode
slider10 == 0 ?
(
final_freq = init_freq;
);
slider10 == 1 ?
(
final_freq = 0.5*init_freq;
);
slider10 == 2 ?
(
final_freq = 0.25*init_freq;
);
slider10 == 3 ?
(
final_freq = 2*init_freq;
);
slider10 == 4 ?
(
final_freq = 4*init_freq;
);
@sample
// gate - detector
a=abs(spl0) > thresh || abs(spl1) > thresh;
// fire sample!
a ?
(
slider11 == 0 ? (
// seekv < .001 || slider11 > 0 ? (
seekv < .001 ? (
pos = 0;
);
);
silentcnt=0;
seekto=1;
) : (
(silentcnt+=slider12) > sillen*slider13/10 ? seekto=0;
);
// we should make this better, me thinks
seekto > 0.5 ?
( // fading in
seekv=seekv*fadein + (1-fadein);
)
:
( // fading out
seekv=seekv*fadeout;
);
//generator
oldspl0 = spl0;
oldspl1 = spl1;
(silentcnt < (srate * decaytime)) ?
(
freq = final_freq * (silentcnt/(srate * decaytime)) +
init_freq * (1-(silentcnt/(srate * decaytime))) ;
) :
(
freq = final_freq;
);
adj=2*$pi* freq / srate;
// sin
slider4==0 ?
(
spl0=cos(pos);
);
// square
slider4==1 ?
(
cos(pos)>0 ?
(
spl0=0.7;
) :
(
spl0=0;
);
);
// noise
slider4==2 ?
(
spl0=(rand(2)-1);
);
// filter
fd0l = (fk*spl0) - (fa1*fd1l) - (fa0*fd2l);
spl0 = fd0l + fd1l + fd1l + fd2l;
fd2l = fd1l;
fd1l = fd0l;
// mix
spl1=spl0;
spl0 = spl0 * seekv * vol + oldspl0 * dry;
spl1 = spl1 * seekv * vol + oldspl1 * dry;
pos=pos+adj;
Last edited by akademie; 01-25-2021 at 09:46 PM.
|
|
|
01-26-2021, 06:58 PM
|
#7
|
Human being with feelings
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,031
|
Thanks a lot my friend.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 04:21 AM.
|