Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 03-10-2018, 11:51 AM   #1
RCJacH
Human being with feelings
 
Join Date: Apr 2016
Location: Beijing, China
Posts: 215
Default JSFX What's a good way to stop the script on play_state change?

I have a minimal script here. the idea is that when slider1 is set to 1 while there is audio input in either channel, regardless of either playing or stopped, i will continue to add up; and when the play_state changes, the counting will stop and reset.

However, currently when I stop the script, the counting does not stop. I suspect that when stopping the script, it takes some time for spl to fade to 0.

Thus, is there a good way to achieve this? Stopping and reset everything when play_state changes?

Code:
desc: Test

slider1: 0<0,1,1>Test
in_pin: Input L
in_pin: Input R
out_pin: Output L
out_pin: Output R

@sample
!b_active && slider1 && (spl0 || spl1) ? b_active = 1;
f_playstate != play_state ? (
  i = b_active = 0;
  f_playstate = play_state;
);

b_active ? i += 1;
RCJacH is offline   Reply With Quote
Old 03-10-2018, 07:53 PM   #2
Time Waster
Human being with feelings
 
Time Waster's Avatar
 
Join Date: Aug 2013
Location: Bowral, Australia
Posts: 1,638
Default

Maybe f_playstate != play_state && slider1 == 1 ? (

I assume you stop the script by setting slider1 to 0?
__________________
Mal, aka The Wasters of Time
Mal's JSFX: ReaRack2 Modular Synth
Time Waster is offline   Reply With Quote
Old 03-10-2018, 10:08 PM   #3
RCJacH
Human being with feelings
 
Join Date: Apr 2016
Location: Beijing, China
Posts: 215
Default

Quote:
Originally Posted by Time Waster View Post
Maybe f_playstate != play_state && slider1 == 1 ? (

I assume you stop the script by setting slider1 to 0?
Hmm slider1 is designed to do something else, it starts the algorithm when set to 1, and completes the algorithm when set back to 0. I'm using it as a record/play button.

This problem occurs when slider1 automation has a value of 1 at the beginning of the project, so whenever the playback stops, the algorithm does not. It's not really affecting the output, but it's a bit resource consuming, thus I'm trying to find a resolution.
RCJacH is offline   Reply With Quote
Old 03-11-2018, 06:39 AM   #4
Time Waster
Human being with feelings
 
Time Waster's Avatar
 
Join Date: Aug 2013
Location: Bowral, Australia
Posts: 1,638
Default

Maybe you could just do this:

Code:
desc: Test

slider1: 0<0,1,1>Test
in_pin: Input L
in_pin: Input R
out_pin: Output L
out_pin: Output R

@sample
play_state ?
(
  !b_active && slider1 && (spl0 || spl1) ? b_active = 1;
  f_playstate != play_state ? (
    i = b_active = 0;
    f_playstate = play_state;
  );

  b_active ? i += 1;
);
That way if play stops, all the @sample code is by-passed. That would use the least resources. Although, simply adding 1 at each sample is not really a significant drain on the CPU.
__________________
Mal, aka The Wasters of Time
Mal's JSFX: ReaRack2 Modular Synth
Time Waster 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 02:54 AM.


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