Old 06-28-2017, 07:02 PM   #1
tylerdodds
Human being with feelings
 
tylerdodds's Avatar
 
Join Date: Jan 2017
Location: Midland, TX
Posts: 10
Default Realtime Spontaneous Auto Fade

I'm trying to figure out a way to fade out the audio on a track spontaneously and in real time during playback.

I searched the form a while back and discovered a thread that I cannot find anymore about a JS plugin that could autofade when receiving a midi note. I cannot get the plugin to work and so I thought I would reach out and see if anyone can offer some help either with this plugin or any other ideas.

I copied the code below into a textedit document (on mac) and saved it as plain text. I deleted the extension and put in the proper folder for JS plugins. It shows up in the JS folder in Reaper and I see the GUI and parameters, but I can't get the midi note to trigger the fade.


Here is the code...




desc: MIDI triggered Autofade
slider1:1<0,10,0.1>Fade In Time (seconds)
slider2:1<0,20,0.1>Fade Out Time (seconds)
slider3:3<0,3,1{-inf,Fading OUT,Fading IN,0dB}>Status
//////////////////////////////////////
// Adapt this sliders to your needs //
////////////////////////////////////////////
//
slider4:60<0,127,1>MIDI Note number
slider5:1<1,16,1>MIDI channel
//
////////////////////////////////////////////
@init
fade_dir = 1;
slider3 = 3;
fade_step = 0.05;
db_min = -70;
fade_in_time = slider1 * srate * fade_step / (db_min * -1);
fade_out_time = slider2 * srate * fade_step / (db_min * -1);
fade_time_cntr = 0;
attenuation = 0;
trig_event = 0;
fade_event = 0;
@slider
fade_in_time = slider1 * srate * fade_step / (db_min * -1);
fade_out_time = slider2 * srate * fade_step / (db_min * -1);
@block
///////////////////////////////////////////////////////////////
// Please adapt the MIDI code to your needs. //
// Set trig_event = 1 if the desired event has occurred //
////////////////////////////////////////////////////////////////////////////////
//
midi_event_chn = $x90 + slider5 - 1;
midirecv(offset,msg1,msg23);
msg2 = msg23 & $xff;
msg3 = (msg23 / 256) & $xff;
(msg1 & $xFF) == midi_event_chn ? (
msg2 == slider4 ? (
msg3 > 0 ? trig_event = 1;
);
);
//
////////////////////////////////////////////////////////////////////////////////
trig_event != 0 ? (
trig_event = 0;
fade_event = 1;
fade_dir *= -1;
fade_time_cntr = fade_in_time;
fade_dir == -1 ? fade_time_cntr = fade_out_time;
);
@sample
fade_event == 1 ? (
fade_dir == -1 ? (
fade_time_cntr -= 1;
fade_time_cntr <= 0 ? (
fade_time_cntr = fade_out_time;
attenuation -= fade_step;
attenuation <= db_min ? (
attenuation = db_min;
fade_event = 0;
slider3 = 0;
) : slider3 = 1;
);
)
:
(
fade_time_cntr -= 1;
fade_time_cntr <= 0 ? (
fade_time_cntr = fade_in_time;
attenuation += fade_step;
attenuation >= 0 ? (
attenuation = 0;
fade_event = 0;
slider3 = 3;
) : slider3 = 2;
);
);
);
spl0 *= 10^(attenuation/20);
spl1 *= 10^(attenuation/20);



Thanks!!!!
tylerdodds is offline   Reply With Quote
Old 06-29-2017, 12:57 AM   #2
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 3,604
Default

The code works here ...

Make sure to set up and use the correct MIDI note (MIDI note number + MIDI channel) which you want to use to trigger the fade. As example: for C2 set the MIDI note number slider to 36.

And also check the Track settings (Record enabled, Monitor Input enabled, correct MIDI input selected) for instance via right-click on the Track Record Arm Button.

Last edited by solger; 06-29-2017 at 01:14 AM.
solger is offline   Reply With Quote
Old 06-29-2017, 06:16 PM   #3
tylerdodds
Human being with feelings
 
tylerdodds's Avatar
 
Join Date: Jan 2017
Location: Midland, TX
Posts: 10
Default

Ahhh I didn't have monitoring on!
Thanks for the help! This plugin works great
tylerdodds is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:52 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.