Old 09-12-2017, 01:41 AM   #1
arpeggio
Human being with feelings
 
Join Date: May 2017
Posts: 7
Default when is a Script executed

Hello to you all Reaper and scriot users.
I have a common question how script are executed and especialy
when record stops.
I suppose a script is one time running when it is executed.
So is it possible to monitor program things that are happening inside of Reaper and let the script do something in reaction to that.
So now what i want and have been trying and looking for the last months,
I am going to build a kind of Live, say Looper behavior, so begin recording at the next measuse, do some recording, and then stop recording at the next measure, Loop on, go to the beginning of the loop, go to the next track and start recording.
Seems simple, your "normal" looping behavior, but the thing is
I want to execute something when Recording stops, and the things done with SWS actions are executed immidiately, so it can be done in two steps after the recording is stopped first and after the measure, a loop stops goes to the beginning of the loop and starts recording on the next track.
Help me out here and we build a looping station.
Thanks in advance, Dian from the Netherlands
arpeggio is offline   Reply With Quote
Old 09-12-2017, 02:22 AM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,900
Default

Hi !

I know i am not answering your questions, but if you are interested in Live-like looper feature, hace a look at Helgoboss Playtime REAPER extension :

Https://www.helgoboss.org/projects/playtime/

I dont know if it can help you for your particular request but I thought it could interest you anyway
X-Raym is offline   Reply With Quote
Old 09-12-2017, 08:50 AM   #3
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,109
Default

Apart from scripts which are run only once when executed it's also possible to do scripts that are continiously executed in the background, this is done with reaper.defer() (in Lua).

Such a script could be used to check for recording state and then do stuff accordingly.

Here's a minimal Lua example script using this and and outputting the current recording state in the console. Hope it helps to get started.

Code:
function msg(m)
  return reaper.ShowConsoleMsg(tostring(m) .. "\n")
end

lastRecordingState = -1

function CheckForRecordingState()
  recordingState = reaper.GetToggleCommandState(1013) -- action: "Transport: Record", return values: 0 = recording stopped, 1 = recording started
  
  if lastRecordingState ~= recordingState then
    msg("Recording state: " .. recordingState)
  end
  
  lastRecordingState = recordingState
  
  reaper.defer(CheckForRecordingState) -- continiously calls itself
end

CheckForRecordingState() -- initially call the function

Last edited by nofish; 09-12-2017 at 01:31 PM.
nofish is offline   Reply With Quote
Old 09-12-2017, 02:50 PM   #4
arpeggio
Human being with feelings
 
Join Date: May 2017
Posts: 7
Default yeah this is GREAT

Yes, this is excactely what i was looking for, nofish thanks fo getting my started on making my first Reaper script that does some great stuff. To be continued, i let you know my progress.
And yes X-Raym, thanks for the tip, i have checked that out, even in Live it is not possible to make loops of different lengts without first make the loop with it's looplengt, as far as i get the grasp of things, and maybe i am wrong and did not take alot of affort the try.
Anyway, this is my attemt to get it working in Reaper couse it is great and................
Realy great fun and satisfying to make your own idea's get to work for you, and share it, and show it, and help you out making music on the fly.
That's my thing and making this work is my passion and hoby.
See my ipeggio(it's on youtube, github and the muff wiggler forum), an arpeggiator for making music on the fly. Dian

Last edited by arpeggio; 09-13-2017 at 06:00 AM.
arpeggio is offline   Reply With Quote
Old 09-13-2017, 11:44 AM   #5
arpeggio
Human being with feelings
 
Join Date: May 2017
Posts: 7
Default working, work in progress

Hello and thanks again for the advice. I am working, i mean thinkening, hard the get a grasp of this, learning LUA, the experimenting, trail and error way. Wauw nice work.
I had a crach and a memory overflow before that.
I tryed the following,
This is the middle part of the nofish code, that worked great

if (lastRecordingState ~= recordingState and recordingState == 0)then
reaper.mean_OnCommand() id's for loopitem. (I use the command stop start recording at next measure to start stop recording, so when recording stops the item is selected)
Go to next track, start recording and toggle repeat.
msg("Recording state: " .. recordingState)
end

And then it does some quick on off recording and at firts it moves through all the tracks.
So i will do some experimentations this evening.
Thanks in advance for the help and advice, Dian
I like this.
arpeggio is offline   Reply With Quote
Old 09-16-2017, 03:20 PM   #6
arpeggio
Human being with feelings
 
Join Date: May 2017
Posts: 7
Default great it WORKs

Here is the code
First start recording, i use start recording from next measure
Then run the script
Then stop recording at next measure, and the script does it's work
Code:
function msg(m)
  return reaper.ShowConsoleMsg(tostring(m) .. "\n")
end

lastRecordingState = -1

function CheckForRecordingState()
  recordingState = reaper.GetToggleCommandState(1013) -- action: "Transport: Record", return values: 0 = recording stopped, 1 = recording started
  
  if (lastRecordingState ~= recordingState) and (recordingstate == 0) then
  reaper.Main_OnCommand(41039, 1)    --loop selected item
    reaper.Main_OnCommand(40285, 1)  --goto next track
  reaper.Main_OnCommand(40632, 1)   --goto loopstart
  reaper.Main_OnCommand(1013, 1)  --record
    reaper.Main_OnCommand(1068, 1) --toggle reapet
    msg("Recording state: " .. recordingState)
   return
  end
  
  lastRecordingState = recordingState
  
  reaper.defer(CheckForRecordingState) -- continiously calls itself
end

CheckForRecordingState() -- initially call the function
So the whole code is actualy used once ( see the 'return'), thats at record end, but thats enough for me to record tracks on the fly without stopping playback.
Dian

Last edited by arpeggio; 09-16-2017 at 03:38 PM. Reason: embed code
arpeggio 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 07:29 PM.


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