Old 05-24-2022, 02:17 PM   #2801
Triode
Human being with feelings
 
Triode's Avatar
 
Join Date: Jan 2012
Posts: 1,186
Default

This script would be nice: Set active takes in selected items to complementary colour of the track.

Context: I set reaper to colour my waveforms by the take colour and the items by the track colour. Highlighting significant parts of the take in the complementary colour will stand out nicely every time with the above script.

I have beer for you
__________________
Mixing / Brush and Beater Drums Online: www.outoftheboxsounds.com
Triode is online now   Reply With Quote
Old 05-30-2022, 09:18 AM   #2802
sephirious
Human being with feelings
 
sephirious's Avatar
 
Join Date: Sep 2020
Posts: 16
Default a simple but much desired glue script

ive been working with multichannel audio recently and fell into an issue involving the existing glues .

i really need


"Glue items, ignoring time selection, including fade in/out (auto increase channel count with take fx)"



i tried my way around it and the best i was able to do was make an action to glue twice, but with 16 channel clips its gets really expensive on storage

the fades really throw me off and i need the channel count increase

thank you i dont know the protocol will putting email addresses in the forum so message me here or reply here and ill check back

thank you
__________________
http://axisproject.net
sephirious is offline   Reply With Quote
Old 06-02-2022, 01:47 AM   #2803
hans
Human being with feelings
 
Join Date: Aug 2020
Posts: 281
Default

This is the incredible smart Script: CS_Smart Trim Left Edge.lua

It is trimming and snapping the item edge to under the mouse cursor. It works great on one item, but not on items layered in free item positioning lanes. Is it possible to get the script understand the lanes and separate the lanes like if the items were on different tracks?

hans is offline   Reply With Quote
Old 06-02-2022, 09:03 AM   #2804
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

Hi
Can someone code this?
thanks

Xenakios/SWS: Switch item source file to next in folder

Only for audio files (wav,mp3).
Now the script would also load a midi file.
Code:
next_source = reaper.NamedCommandLookup("_XENAKIOS_SISFTNEXTIF")


function()reaper.Main_OnCommand(next_source,0)
Dragonetti is offline   Reply With Quote
Old 06-05-2022, 03:27 AM   #2805
Yanick
Human being with feelings
 
Yanick's Avatar
 
Join Date: May 2018
Location: Moscow, Russia
Posts: 612
Default

Quote:
Originally Posted by Dragonetti View Post
Hi
Can someone code this?
thanks

Xenakios/SWS: Switch item source file to next in folder

Only for audio files (wav,mp3).
Now the script would also load a midi file.
Code:
next_source = reaper.NamedCommandLookup("_XENAKIOS_SISFTNEXTIF")


function()reaper.Main_OnCommand(next_source,0)
The SWS switch will only be from the folder in which the source file is located, which is not suitable if the project is portable and has its own directory.

For midi, I have scripts - you need to select a folder, it is remembered for the project, then switch next / previous

Yannick_Add MIDI file into project - select folder for MIDI files and replace the take.lua
Yannick_Add MIDI file into project - switch next MIDI take from recent folder.lua
Yannick_Add MIDI file into project - switch previous MIDI take from recent folder.lua
Yanick is offline   Reply With Quote
Old 06-05-2022, 03:53 PM   #2806
Skorobagatko
Human being with feelings
 
Skorobagatko's Avatar
 
Join Date: Mar 2017
Location: Ukraine, Kyiv
Posts: 546
Default

This script stopped working (maybe because of the Reaper's update?), could someone help to make it work again please?

"Script: Lokasenna_Delete note under mouse cursor.lua"

Code:
-- For debugging purposes, prints a message to the Reaper console
function Msg(message)
	
	reaper.ShowConsoleMsg(tostring(message).."\n")
	
end



function Main()
	
	reaper.Undo_BeginBlock()
	
	cur_editor = reaper.MIDIEditor_GetActive()
	cur_take = reaper.MIDIEditor_GetTake(cur_editor)

	__, __, __ = reaper.BR_GetMouseCursorContext()
	__, noteRow, __, __, __ = reaper.BR_GetMouseCursorContext_MIDI()
	
	mouse_time = reaper.BR_GetMouseCursorContext_Position()
	mouse_ppq_pos = reaper.MIDI_GetPPQPosFromProjTime(cur_take, mouse_time)
	
	notes, __, __ = reaper.MIDI_CountEvts(cur_take)

	-- loop through every note in the current MIDI editor to see whether they're under the cursor
	for i = 0, notes - 1 do
		
		__, __, __, start_note, end_note, __, pitch, __ = reaper.MIDI_GetNote(cur_take, i)
		
		if start_note < mouse_ppq_pos and end_note > mouse_ppq_pos and noteRow == pitch then 
			reaper.MIDI_DeleteNote(cur_take, i)
			break
		end
	end

	reaper.Undo_EndBlock("LS Delete note under mouse cursor", -1)
	
	
end

Main()
Skorobagatko is offline   Reply With Quote
Old 06-05-2022, 05:18 PM   #2807
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Quote:
Originally Posted by Skorobagatko View Post
This script stopped working (maybe because of the Reaper's update?), could someone help to make it work again please?

"Script: Lokasenna_Delete note under mouse cursor.lua"
Hmmm, according to documentation, 'noteRow' should be the 3rd value returned, but is second in that code, so,..

I changed this line,
Code:
__, noteRow, __, __, __ = reaper.BR_GetMouseCursorContext_MIDI()
To this,
Code:
__, __, noteRow = reaper.BR_GetMouseCursorContext_MIDI()
And now it seems to work here.
Note, tested on Win10_x64, REAPER v6.59+dev0604/x64, SWS v2.13.1.0 (pre-release)

Last edited by Edgemeal; 06-05-2022 at 05:28 PM.
Edgemeal is offline   Reply With Quote
Old 06-05-2022, 05:35 PM   #2808
jcfitn
Human being with feelings
 
Join Date: Apr 2022
Posts: 23
Default Keys modifiers + MIDI CC

There are any way to make a script to use modifier with MIDI?

Example: you keep the ctrl down and you turn a knob for a different CC message.
jcfitn is offline   Reply With Quote
Old 06-06-2022, 04:54 AM   #2809
Yanick
Human being with feelings
 
Yanick's Avatar
 
Join Date: May 2018
Location: Moscow, Russia
Posts: 612
Default

Quote:
Originally Posted by Dragonetti View Post
Hi
Can someone code this?
thanks

Xenakios/SWS: Switch item source file to next in folder

Only for audio files (wav,mp3).
Now the script would also load a midi file.
Code:
next_source = reaper.NamedCommandLookup("_XENAKIOS_SISFTNEXTIF")


function()reaper.Main_OnCommand(next_source,0)
Only for audio files - Archie has it, but if something doesn't work there, I'll make my own script
Yanick is offline   Reply With Quote
Old 06-07-2022, 04:25 AM   #2810
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

Thanks Yanik
The Archie script does the right thing.
But it would still have to snap the individual items together.

Script: Archie_Item; Switch item source file to next in folder restore original size(only Audio).lua

EDIT:
1.Since I have to include the script in a larger one, I don't want an extra arc function(arc_function_lua.lua)
2.The upper track should be the main track, and the others should be some kind of copy, then it is also possible to add a random function.

Last edited by Dragonetti; 06-07-2022 at 06:49 AM.
Dragonetti is offline   Reply With Quote
Old 06-07-2022, 07:04 AM   #2811
Skorobagatko
Human being with feelings
 
Skorobagatko's Avatar
 
Join Date: Mar 2017
Location: Ukraine, Kyiv
Posts: 546
Default

Quote:
Originally Posted by Edgemeal View Post
Hmmm, according to documentation, 'noteRow' should be the 3rd value returned, but is second in that code, so,..

I changed this line,
Code:
__, noteRow, __, __, __ = reaper.BR_GetMouseCursorContext_MIDI()
To this,
Code:
__, __, noteRow = reaper.BR_GetMouseCursorContext_MIDI()
And now it seems to work here.
Note, tested on Win10_x64, REAPER v6.59+dev0604/x64, SWS v2.13.1.0 (pre-release)
I get this when try to replace this line with yours:

Skorobagatko is offline   Reply With Quote
Old 06-07-2022, 07:37 AM   #2812
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Quote:
Originally Posted by Skorobagatko View Post
I get this when try to replace this line with yours:
The line I changed has nothing to do with that error. The code should probably check if the Take is valid but since the script is supposed to be run from the MIDI Editor (with an active take) you should never get that error. Sorry but I'm not sure whats going on your end.
Edgemeal is offline   Reply With Quote
Old 06-07-2022, 07:41 AM   #2813
Skorobagatko
Human being with feelings
 
Skorobagatko's Avatar
 
Join Date: Mar 2017
Location: Ukraine, Kyiv
Posts: 546
Default

Quote:
Originally Posted by Edgemeal View Post
The line I changed has nothing to do with that error. The code should probably check if the Take is valid but since the script is supposed to be run from the MIDI Editor (with an active take) you should never get that error. Sorry but I'm not sure whats going on your end.
It's working now, thanks for the help!
Skorobagatko is offline   Reply With Quote
Old 06-10-2022, 11:42 PM   #2814
cool
Human being with feelings
 
Join Date: Dec 2017
Location: Sunny Siberian Islands
Posts: 962
Default

Hi guys!

I have a script based on the old script from MPL: it goes through the items and marks (sets the Snap Offsets) the maximum peak at the beginning of each item.

Works great, but I have a quest that I can't solve: How to refine this script so that it marks not, conditionally, the loudest peak, but a quiet peak according to a thrashhold, in the sample decay, for example?


I tried changing the conditions in the original code, going through the buffer from the end to the beginning, but none of this worked. Unfortunately, my experience here is not enough even to get a starting point.


Code:
 items = reaper.CountSelectedMediaItems(0)

for i=0, items-1 do

   item = reaper.GetSelectedMediaItem(0,i);
     
      if item then
     
               take = reaper.GetActiveTake( item )

          if take then

              local source = reaper.GetMediaItemTake_Source(take)    
              local accessor = reaper.CreateTakeAudioAccessor(take)
              local srate = reaper.GetMediaSourceSampleRate(source)
              local chan = reaper.GetMediaSourceNumChannels(source)
              local buffsize = srate*2
              local buffer = reaper.new_array(srate*chan)
              
              reaper.GetAudioAccessorSamples(accessor, srate, chan, 0, srate, buffer)
          
     local sampleMax, maxPeakSample, sampleMax0 = 0
     local maximumHasNotBeenFound = true

    local previousSample = nil
    for i = 1, buffsize do
            
            local sample = math.abs(buffer[i])
            
            if i > 1 and sample < previousSample and previousSample > 0.5 then
                maximumHasNotBeenFound = false
            end

            sampleMax = math.max(sample, sampleMax)
            if sampleMax ~= sampleMax0 and maximumHasNotBeenFound then
                maxPeakSample = i/chan - 1
            end
            
            previousSample = sample
            sampleMax0 = sampleMax
    end
              
              pos = maxPeakSample/srate

              reaper.DestroyAudioAccessor(accessor)

              reaper.SetMediaItemInfo_Value(item, "D_SNAPOFFSET", pos)

end
end
end
reaper.UpdateArrange()
cool is offline   Reply With Quote
Old 06-12-2022, 03:49 PM   #2815
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
Default

Quote:
Originally Posted by cool View Post
Hi guys!

I have a script based on the old script from MPL: it goes through the items and marks (sets the Snap Offsets) the maximum peak at the beginning of each item.

Works great, but I have a quest that I can't solve: How to refine this script so that it marks not, conditionally, the loudest peak, but a quiet peak according to a thrashhold, in the sample decay, for example?

I tried changing the conditions in the original code, going through the buffer from the end to the beginning, but none of this worked. Unfortunately, my experience here is not enough even to get a starting point.
you have to code smoothed envelope follower, then find envelope fall/rise threshold crossing points + some closed points clever filtering. This is the way one of the part of Aligh Takes script works. You can PM me or ask in the MPL scripts common thread with more details. (sorry I don't follow such threads, only PM and dedicated threads I started)

Last edited by mpl; 06-12-2022 at 03:55 PM.
mpl is offline   Reply With Quote
Old 06-18-2022, 09:13 PM   #2816
Pink Wool
Human being with feelings
 
Pink Wool's Avatar
 
Join Date: Apr 2020
Posts: 1,524
Default

Would like a script to reset peak indicators after x seconds. Is this doable? Any takers?

Thanks in advance!
Pink Wool is offline   Reply With Quote
Old 06-27-2022, 12:38 PM   #2817
RobinGShore
Human being with feelings
 
Join Date: May 2013
Location: New York
Posts: 781
Default

Is someone able to make a script that toggles the arming of send volume envelopes for the selected tracks.

Kind of surprised this doesn't exist already (SWS has an action for toggling receive envelope arming but not sends), but I searched around for awhile and couldn't find anything
RobinGShore is offline   Reply With Quote
Old 06-27-2022, 01:32 PM   #2818
sockmonkey72
Human being with feelings
 
sockmonkey72's Avatar
 
Join Date: Sep 2021
Location: Berlin
Posts: 1,966
Default

Quote:
Originally Posted by RobinGShore View Post
Is someone able to make a script that toggles the arming of send volume envelopes for the selected tracks.

Kind of surprised this doesn't exist already (SWS has an action for toggling receive envelope arming but not sends), but I searched around for awhile and couldn't find anything
Code:
-- ToggleSendVolumeEnvelopes.lua
-- sockmonkey72 / Jeremy Bernstein

count = reaper.CountSelectedTracks(0)
for i = 0,count-1 do
  tr = reaper.GetSelectedTrack(0, i)
  if tr then
    envCount = reaper.CountTrackEnvelopes(tr)
    for j = 0,envCount-1 do
      env = reaper.GetTrackEnvelope(tr, j)
      if env then
        val = reaper.GetEnvelopeInfo_Value(env, "P_DESTTRACK")
        if val ~= 0 then
          _, name = reaper.GetEnvelopeName(env)
          if name:match("Volume") then
            _, state = reaper.GetEnvelopeStateChunk(env, "", 0)
            if state:match("ARM 1") then 
              state = state:gsub("ARM 1", "ARM 0")
            elseif state:match("ARM 0") then 
              state = state:gsub("ARM 0", "ARM 1") 
            end
            reaper.SetEnvelopeStateChunk(env, state, 1);
          end
        end
      end
    end
  end
end
__________________
ReaPack Repository: right-click and copy index URL
sockmonkey72 is offline   Reply With Quote
Old 06-28-2022, 10:01 AM   #2819
RobinGShore
Human being with feelings
 
Join Date: May 2013
Location: New York
Posts: 781
Default

Quote:
Originally Posted by sockmonkey72 View Post
Code:
-- ToggleSendVolumeEnvelopes.lua
-- sockmonkey72 / Jeremy Bernstein

count = reaper.CountSelectedTracks(0)
for i = 0,count-1 do
  tr = reaper.GetSelectedTrack(0, i)
  if tr then
    envCount = reaper.CountTrackEnvelopes(tr)
    for j = 0,envCount-1 do
      env = reaper.GetTrackEnvelope(tr, j)
      if env then
        val = reaper.GetEnvelopeInfo_Value(env, "P_DESTTRACK")
        if val ~= 0 then
          _, name = reaper.GetEnvelopeName(env)
          if name:match("Volume") then
            _, state = reaper.GetEnvelopeStateChunk(env, "", 0)
            if state:match("ARM 1") then 
              state = state:gsub("ARM 1", "ARM 0")
            elseif state:match("ARM 0") then 
              state = state:gsub("ARM 0", "ARM 1") 
            end
            reaper.SetEnvelopeStateChunk(env, state, 1);
          end
        end
      end
    end
  end
end
Thank you! Any chance could make one that toggles arming for the width envelope as well?
RobinGShore is offline   Reply With Quote
Old 06-29-2022, 01:42 PM   #2820
sockmonkey72
Human being with feelings
 
sockmonkey72's Avatar
 
Join Date: Sep 2021
Location: Berlin
Posts: 1,966
Default

Quote:
Originally Posted by RobinGShore View Post
Thank you! Any chance could make one that toggles arming for the width envelope as well?
you mean the width envelope for the current track? there's no send envelope for width AFAICT.
__________________
ReaPack Repository: right-click and copy index URL
sockmonkey72 is offline   Reply With Quote
Old 06-29-2022, 01:45 PM   #2821
RobinGShore
Human being with feelings
 
Join Date: May 2013
Location: New York
Posts: 781
Default

Quote:
Originally Posted by sockmonkey72 View Post
you mean the width envelope for the current track? there's no send envelope for width AFAICT.
Yep, I mean the width envelope for the currently selected tracks, nothing to do with sends.
RobinGShore is offline   Reply With Quote
Old 06-29-2022, 01:50 PM   #2822
sockmonkey72
Human being with feelings
 
sockmonkey72's Avatar
 
Join Date: Sep 2021
Location: Berlin
Posts: 1,966
Default

Quote:
Originally Posted by RobinGShore View Post
Yep, I mean the width envelope for the currently selected tracks, nothing to do with sends.
That would look like this:

Code:
-- ToggleWidthEnvelopes.lua
-- sockmonkey72 / Jeremy Bernstein

count = reaper.CountSelectedTracks(0)
for i = 0,count-1 do
  tr = reaper.GetSelectedTrack(0, i)
  if tr then
    envCount = reaper.CountTrackEnvelopes(tr)
    for j = 0,envCount-1 do
      env = reaper.GetTrackEnvelope(tr, j)
      if env then
        _, name = reaper.GetEnvelopeName(env)
        if name == "Width" then
          _, state = reaper.GetEnvelopeStateChunk(env, "", 0)
          if state:match("ARM 1") then 
            state = state:gsub("ARM 1", "ARM 0")
          elseif state:match("ARM 0") then 
            state = state:gsub("ARM 0", "ARM 1") 
          end
          reaper.SetEnvelopeStateChunk(env, state, 1);
        end
      end
    end
  end
end
This only works for "Width" and not "Width (Pre-FX)", but it could be modified to work for both.
__________________
ReaPack Repository: right-click and copy index URL
sockmonkey72 is offline   Reply With Quote
Old 06-29-2022, 03:33 PM   #2823
Kr3eM
Human being with feelings
 
Kr3eM's Avatar
 
Join Date: Apr 2019
Posts: 231
Default Move item loop section content left/right one grid unit

If somebody is up for the task I looking for

Action: Move selected item(s) loop section content right one grid unit
Action: Move selected item(s) loop section content left one grid unit

Alternative/and/or static options:
1/16 , 1/8 , 1/4 , 1/2 , 1/1 , 2/1 and 4/1


Not sure if it's an 'easy' task or not.... guess I will find out eventually
Kr3eM is offline   Reply With Quote
Old 06-29-2022, 08:28 PM   #2824
RobinGShore
Human being with feelings
 
Join Date: May 2013
Location: New York
Posts: 781
Default

Quote:
Originally Posted by sockmonkey72 View Post
That would look like this:

Code:
-- ToggleWidthEnvelopes.lua
-- sockmonkey72 / Jeremy Bernstein

count = reaper.CountSelectedTracks(0)
for i = 0,count-1 do
  tr = reaper.GetSelectedTrack(0, i)
  if tr then
    envCount = reaper.CountTrackEnvelopes(tr)
    for j = 0,envCount-1 do
      env = reaper.GetTrackEnvelope(tr, j)
      if env then
        _, name = reaper.GetEnvelopeName(env)
        if name == "Width" then
          _, state = reaper.GetEnvelopeStateChunk(env, "", 0)
          if state:match("ARM 1") then 
            state = state:gsub("ARM 1", "ARM 0")
          elseif state:match("ARM 0") then 
            state = state:gsub("ARM 0", "ARM 1") 
          end
          reaper.SetEnvelopeStateChunk(env, state, 1);
        end
      end
    end
  end
end
This only works for "Width" and not "Width (Pre-FX)", but it could be modified to work for both.
This is perfect, thank you!
RobinGShore is offline   Reply With Quote
Old 07-03-2022, 08:54 AM   #2825
Pink Wool
Human being with feelings
 
Pink Wool's Avatar
 
Join Date: Apr 2020
Posts: 1,524
Default

Quote:
Originally Posted by Pink Wool View Post
Would like a script to reset peak indicators after x seconds. Is this doable? Any takers?

Thanks in advance!
Anyone?
Pink Wool is offline   Reply With Quote
Old 07-03-2022, 11:46 PM   #2826
sockmonkey72
Human being with feelings
 
sockmonkey72's Avatar
 
Join Date: Sep 2021
Location: Berlin
Posts: 1,966
Default

Quote:
Originally Posted by Pink Wool View Post
Anyone?
Here:

Code:
-- ClearClipsAfter3Seconds.lua
-- sockmonkey72 / Jeremy Bernstein


tracksAndTimes = {}

function loop()
  trackCount = reaper.CountTracks(0)
  now = os.time()
  for i=0,trackCount-1 do
    tr = reaper.GetTrack(0, i)
    if tr ~= nil then
      numChans = reaper.GetMediaTrackInfo_Value(tr, "I_NCHAN")
      wantsReset = false
      hasClip = false
      for j = 0,numChans-1 do
        holdDB = reaper.Track_GetPeakHoldDB(tr, j, false)
        if holdDB > 0. then
          hasClip = true
          clock = tracksAndTimes[tr]
          if clock == nil then
            tracksAndTimes[tr] = now -- add a timestamp for the first over detection
            break -- no need to iterate further
          elseif now - clock > 3. then
            tracksAndTimes[tr] = nil
            wantsReset = true -- we'll iterate at the end
            break
          end
        end
      end
      -- reset all channels in this case
      if wantsReset then
        for j = 0,numChans-1 do
          reaper.Track_GetPeakHoldDB(tr, j, true)
        end
      end
      if hasClip == false then
        if tracksAndTimes[tr] ~= nil then
          tracksAndTimes[tr] = nil -- zero it out, it was probably manually reset
        end
      end
    end
  end
  reaper.defer(loop)
end

reaper.defer(loop)
__________________
ReaPack Repository: right-click and copy index URL

Last edited by sockmonkey72; 07-04-2022 at 04:27 AM. Reason: fix case where clipping manually cleared
sockmonkey72 is offline   Reply With Quote
Old 07-04-2022, 02:34 AM   #2827
Pink Wool
Human being with feelings
 
Pink Wool's Avatar
 
Join Date: Apr 2020
Posts: 1,524
Default

Quote:
Originally Posted by sockmonkey72 View Post
Here:

Code:
-- ClearClipsAfter3Seconds.lua
-- sockmonkey72 / Jeremy Bernstein


tracksAndTimes = {}

function loop()
  trackCount = reaper.CountTracks(0)
  now = os.time()
  for i=0,trackCount-1 do
    tr = reaper.GetTrack(0, i)
    if tr ~= nil then
      numChans = reaper.GetMediaTrackInfo_Value(tr, "I_NCHAN")
      wantsReset = false
      for j = 0,numChans-1 do
        holdDB = reaper.Track_GetPeakHoldDB(tr, j, false)
        if holdDB > 0. then
          clock = tracksAndTimes[tr]
          if clock == nil then
            tracksAndTimes[tr] = now -- add a timestamp for the first over detection
            break -- no need to iterate further
          elseif now - clock > 3. then
            tracksAndTimes[tr] = nil
            wantsReset = true -- we'll iterate at the end
            break
          end
        else
          if tracksAndTimes[tr] ~= nil then
            tracksAndTimes[tr] = nil -- zero it out, it was probably manually reset
          end
        end
      end
      -- reset all channels in this case
      if wantsReset then
        for j = 0,numChans-1 do
          reaper.Track_GetPeakHoldDB(tr, j, true)
        end
      end
    end
  end
  reaper.defer(loop)
end

reaper.defer(loop)
Awesome! Thank you Sockmonkey! Is there a way to terminate the script? Normally when you run the script the second time, Reaper asks you if you want that. For some reason not with this script? Any idea why?
Pink Wool is offline   Reply With Quote
Old 07-04-2022, 02:51 AM   #2828
sockmonkey72
Human being with feelings
 
sockmonkey72's Avatar
 
Join Date: Sep 2021
Location: Berlin
Posts: 1,966
Default

Quote:
Originally Posted by Pink Wool View Post
Awesome! Thank you Sockmonkey! Is there a way to terminate the script? Normally when you run the script the second time, Reaper asks you if you want that. For some reason not with this script?
Huh, not sure why that should be. I get that dialog if I select the script from the Actions menu on my machine.
__________________
ReaPack Repository: right-click and copy index URL
sockmonkey72 is offline   Reply With Quote
Old 07-04-2022, 03:12 AM   #2829
Pink Wool
Human being with feelings
 
Pink Wool's Avatar
 
Join Date: Apr 2020
Posts: 1,524
Default

Quote:
Originally Posted by sockmonkey72 View Post
Huh, not sure why that should be. I get that dialog if I select the script from the Actions menu on my machine.
Never mind, it's working now! Thanks again! <3
Pink Wool is offline   Reply With Quote
Old 07-04-2022, 04:22 AM   #2830
sockmonkey72
Human being with feelings
 
sockmonkey72's Avatar
 
Join Date: Sep 2021
Location: Berlin
Posts: 1,966
Default

Quote:
Originally Posted by Pink Wool View Post
Never mind, it's working now! Thanks again! <3
Hey Pink Wool, I made a minor change to the case where clipping was manually reset (I just replaced the code in my post above), so you might want to grab that.
__________________
ReaPack Repository: right-click and copy index URL
sockmonkey72 is offline   Reply With Quote
Old 07-17-2022, 05:00 AM   #2831
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default Fast forward/rewind n seconds

Anybody up for doing a script* which does fast forward/rewind a fixed (user settable) amount of seconds?

(Similar to native actions 'Transport: Rewind/Fast forward a little bit' but with fixed time).

Thanks.

*If negative time = rewind the script could easily be copied to make ff/rewind variants.
Otherwise one script for ff and one for rewind would also do.
nofish is offline   Reply With Quote
Old 07-18-2022, 12:12 AM   #2832
sockmonkey72
Human being with feelings
 
sockmonkey72's Avatar
 
Join Date: Sep 2021
Location: Berlin
Posts: 1,966
Default

Quote:
Originally Posted by nofish View Post
Anybody up for doing a script* which does fast forward/rewind a fixed (user settable) amount of seconds?

(Similar to native actions 'Transport: Rewind/Fast forward a little bit' but with fixed time).

Thanks.

*If negative time = rewind the script could easily be copied to make ff/rewind variants.
Otherwise one script for ff and one for rewind would also do.
Fast forward 1s.lua
Code:
amount = 1. -- 1 second

now = reaper.GetPlayStateEx(0) % 2 == 0 and reaper.GetCursorPositionEx(0) or reaper.GetPlayPositionEx(0)
now = now + amount
reaper.SetEditCurPos2(0, now, true, true)
Rewind 1s.lua
Code:
amount = 1. -- 1 second

now = reaper.GetPlayStateEx(0) % 2 == 0 and reaper.GetCursorPositionEx(0) or reaper.GetPlayPositionEx(0)
now = now - amount
reaper.SetEditCurPos2(0, now, true, true)
I guess these could be extended to permit some global preference to set what that fixed time should be, with some interface for setting it, but the actual, functional code is quite minimal.
__________________
ReaPack Repository: right-click and copy index URL
sockmonkey72 is offline   Reply With Quote
Old 07-18-2022, 06:25 AM   #2833
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

Quote:
Originally Posted by sockmonkey72 View Post
Fast forward 1s.lua
Rewind 1s.lua
Exactly what I asked for, no need to get more fancy.
Thank you!
nofish is offline   Reply With Quote
Old 07-18-2022, 06:51 AM   #2834
Puck
Human being with feelings
 
Puck's Avatar
 
Join Date: Feb 2022
Location: Almost Canada
Posts: 505
Default

Quote:
Originally Posted by sockmonkey72 View Post
Code:
now = reaper.GetPlayStateEx(0) % 2 == 0 and reaper.GetCursorPositionEx(0) or reaper.GetPlayPositionEx(0)
I hope this isn’t too much to ask but I’m trying to learn scripting and haven’t seen what you did here yet and was hoping you could explain it.

It looks like it’s setting now to one function or the other depending on if Reaper is playing, I just don’t understand the (I’m assuming) shorthand. A quick google didn’t help so I thought I’d ask you
Puck is offline   Reply With Quote
Old 07-18-2022, 06:56 AM   #2835
sockmonkey72
Human being with feelings
 
sockmonkey72's Avatar
 
Join Date: Sep 2021
Location: Berlin
Posts: 1,966
Default

Quote:
Originally Posted by Puck View Post
I hope this isn’t too much to ask but I’m trying to learn scripting and haven’t seen what you did here yet and was hoping you could explain it.

It looks like it’s setting now to one function or the other depending on if Reaper is playing, I just don’t understand the (I’m assuming) shorthand. A quick google didn’t help so I thought I’d ask you
Hey Puck,

that "and"/"or" convention is the same as C's ?/: syntax for the ternary operator. It means (in pseudo-Lua syntax):

Code:
if (condition is TRUE) then
 do this
else
  do that
end
So in this specific case:

Code:
if reaper.GetPlayStateEx(0) % 2 == 0 then -- REAPER isn't playing
  now = reaper.GetCursorPositionEx(0) -- get the edit cursor position
else
  now = reaper.GetPlayPositionEx(0) -- get the playback position
end
__________________
ReaPack Repository: right-click and copy index URL
sockmonkey72 is offline   Reply With Quote
Old 07-18-2022, 07:37 AM   #2836
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

^ Nice, I didn't know either. Thanks.
nofish is offline   Reply With Quote
Old 07-18-2022, 02:06 PM   #2837
Puck
Human being with feelings
 
Puck's Avatar
 
Join Date: Feb 2022
Location: Almost Canada
Posts: 505
Default

Quote:
Originally Posted by sockmonkey72 View Post
Hey Puck,

that "and"/"or" convention is the same as C's ?/: syntax for the ternary operator. It means (in pseudo-Lua syntax):

Code:
if (condition is TRUE) then
 do this
else
  do that
end
So in this specific case:

Code:
if reaper.GetPlayStateEx(0) % 2 == 0 then -- REAPER isn't playing
  now = reaper.GetCursorPositionEx(0) -- get the edit cursor position
else
  now = reaper.GetPlayPositionEx(0) -- get the playback position
end
Thank you very much! I really appreciate you taking the time to answer.

So it's the presence of "and"/"or" that provides the logic (makes sense!).

But it does breed one more question:

I know from the API that reaper.GetPlayStateEX expects the reaproject and 0 = the active project, but I'm unsure why the "% 2" is there. The only thing regarding the % in lua I could find was the RegEx Pattern matching stuff, and I don't think that applies here. Can you explain that bit?

Sorry for taking the couple posts here in this thread to ask.
Puck is offline   Reply With Quote
Old 07-18-2022, 02:16 PM   #2838
sockmonkey72
Human being with feelings
 
sockmonkey72's Avatar
 
Join Date: Sep 2021
Location: Berlin
Posts: 1,966
Default

Quote:
Originally Posted by Puck View Post
Thank you very much! I really appreciate you taking the time to answer.

So it's the presence of "and"/"or" that provides the logic (makes sense!).

But it does breed one more question:

I know from the API that reaper.GetPlayStateEX expects the reaproject and 0 = the active project, but I'm unsure why the "% 2" is there. The only thing regarding the % in lua I could find was the RegEx Pattern matching stuff, and I don't think that applies here. Can you explain that bit?

Sorry for taking the couple posts here in this thread to ask.
reaper.GetPlayStateEx() returns a bitfield (in C) where
Code:
8421
0000
the position in the binary bitfield (below) corresponds to a value (above). A 1 in a position adds the value above to the final number. 0001 = 1, 0010 = 2, 0011 = 3 and so on. You probably know that already, but just for completeness.

In the docs for GetPlayStateEx(), it says:

&1=playing,&2=pause,&=4 is recording

which means that:

000 means stopped (0)
001 means playing (1)
010 means paused (2)
101 means recording (5)
110 means rec pause (6)

(I just tested these, so I know that's true).

so if I want to know if the transport is running, I check for the presence of a 1 in the 0th (rightmost) position (true for playing and recording, but false for stopped, paused and rec pause). Which is the same thing as an odd number. A good way to test for an odd number is the_number % 2 == 1. % is "modulo" and returns the remainder of a division operation.

So "reaper.GetPlayStateEx(0) % 2 == 0" means it's an even number, thus "the transport is not running".

Does that make sense?
__________________
ReaPack Repository: right-click and copy index URL

Last edited by sockmonkey72; 07-18-2022 at 02:26 PM.
sockmonkey72 is offline   Reply With Quote
Old 07-18-2022, 02:43 PM   #2839
Puck
Human being with feelings
 
Puck's Avatar
 
Join Date: Feb 2022
Location: Almost Canada
Posts: 505
Default

Quote:
Originally Posted by sockmonkey72 View Post
reaper.GetPlayStateEx() returns a bitfield (in C) where
Code:
8421
0000
the position in the binary bitfield (below) corresponds to a value (above). A 1 in a position adds the value above to the final number. 0001 = 1, 0010 = 2, 0011 = 3 and so on. You probably know that already, but just for completeness.

In the docs for GetPlayStateEx(), it says:

&1=playing,&2=pause,&=4 is recording

which means that:

000 means stopped (0)
001 means playing (1)
010 means paused (2)
101 means recording (5)
110 means rec pause (6)

(I just tested these, so I know that's true).

so if I want to know if the transport is running, I check for the presence of a 1 in the 0th (rightmost) position (true for playing and recording, but false for stopped, paused and rec pause). Which is the same thing as an odd number. A good way to test for an odd number is the_number % 2 == 1. % is "modulo" and returns the remainder of a division operation.

So "reaper.GetPlayStateEx(0) % 2 == 0" means it's an even number, thus "the transport is not running".

Does that make sense?
YES!

Thank you!

Funnily enough my gut was saying that was the remainder operator, I was just trying to google to confirm and for some reason couldn’t find it. I had never dealt with a bit field so thanks so much for explaining that.

Like all things programming it breeds other questions but I’ve gone on long enough

That makes perfect sense though and it’s very clever. Thanks again!!
Puck is offline   Reply With Quote
Old 07-29-2022, 06:56 AM   #2840
Kr3eM
Human being with feelings
 
Kr3eM's Avatar
 
Join Date: Apr 2019
Posts: 231
Default

Quote:
Originally Posted by Kr3eM View Post
If somebody is up for the task I looking for

Action: Move selected item(s) loop section content right one grid unit
Action: Move selected item(s) loop section content left one grid unit

Alternative/and/or static options:
1/16 , 1/8 , 1/4 , 1/2 , 1/1 , 2/1 and 4/1

Does anyone know if "Move item loop section contents" from mouse modifiers have an API entry? But perhaps it's of no use for making the scripts I'm looking for since it's a drag function...?
Kr3eM 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:12 PM.


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