Old 05-02-2021, 02:32 PM   #2481
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by SNJUK2 View Post
Nothing happens
One more try, this requires the js_ReaScriptAPI extension

Code:
local midi_1_window = reaper.JS_Window_Find("MIDI 1", true)
if midi_1_window then reaper.JS_Window_Destroy(midi_1_window) end
Edgemeal is offline   Reply With Quote
Old 05-02-2021, 02:38 PM   #2482
SNJUK2
Human being with feelings
 
SNJUK2's Avatar
 
Join Date: Feb 2017
Location: Zhytomyr,Ukraine
Posts: 449
Default

Quote:
Originally Posted by Edgemeal View Post
One more try, this requires the js_ReaScriptAPI extension

Code:
local midi_1_window = reaper.JS_Window_Find("MIDI 1", true)
if midi_1_window then reaper.JS_Window_Destroy(midi_1_window) end
Yes!!! Its work Thank you very match
SNJUK2 is offline   Reply With Quote
Old 05-03-2021, 04:49 AM   #2483
Skorobagatko
Human being with feelings
 
Skorobagatko's Avatar
 
Join Date: Mar 2017
Location: Ukraine, Kyiv
Posts: 546
Default

Need help to modify existing script, so it would not only move items to the fixed item lane but move it to the separate lane like this:



Code:
--[[
   * Category:    Item
   * Description: Move selected items to a track with name "n"
   * Oписание:    Переместить выбранные элементы на дорожку с именем "n"
   * GIF:         ---
   * Website:     http://forum.cockos.com/showthread.php?t=212819
   * Donation:    http://money.yandex.ru/to/410018003906628
   * DONATION:    http://paypal.me/ReaArchie?locale.x=ru_RU
   * Author:      Archie
   * Version:     1.02
   * customer:    Maestro Sound[RMM Forum]
   * gave idea:   Maestro Sound[RMM Forum]
--=======================================]]



    local NameTrack = "Fx Lane"
                 -- = 1 Show window for typing the name,
                 --  Or add track name
                 --  Example: NameTrack = "Drums"



    --===========================================================================
    --//////////////////////////////   SCRIPT   \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    --===========================================================================



    -----------------------------------------------------------------------------
    local function No_Undo()end; local function no_undo()reaper.defer(No_Undo)end
    -----------------------------------------------------------------------------



    local name_script = [[Move selected items to a track with name "n"]]
    local CountSelItem = reaper.CountSelectedMediaItems( 0 )
    if CountSelItem == 0 then no_undo() return end

    local retval, retvals_csv,desttr,par_ID,Undo
    if not NameTrack then NameTrack = 1 end

    if NameTrack == 1 then
          retval, retvals_csv = reaper.GetUserInputs( "Move selected items to a track with name 'n'", 1,
                                        "                Name track:,extrawidth=40", "Name_Track" )
        if retval == false then no_undo() return end
    else
        retvals_csv = NameTrack
    end

    local CountTrack = reaper.CountTracks( 0 )
    for i = 1,CountTrack do
        local track = reaper.GetTrack(0,i-1)
        local retval, stringNeedBig = reaper.GetSetMediaTrackInfo_String( track, "P_NAME", "", 0 )
        if stringNeedBig == retvals_csv then
            par_ID =  reaper.CSurf_TrackToID( track, true )
            desttr = reaper.CSurf_TrackFromID( par_ID, true )
            break
        end
    end


    if par_ID and desttr then
        for i = 1,CountTrack do
            local track = reaper.GetTrack(0,i-1)
            local CountTrItem = reaper.CountTrackMediaItems( track )
            for i = CountTrItem-1,0,-1 do
                local item = reaper.GetTrackMediaItem( track, i )
                local sel = reaper.GetMediaItemInfo_Value( item, "B_UISEL" )
                if sel == 1 then
                    reaper.MoveMediaItemToTrack( item,desttr)
                    Undo = 1
                end
            end
        end
    end

    if Undo == 1 then
        reaper.Undo_BeginBlock()
        reaper.Undo_EndBlock(name_script,1)
    else
        no_undo()
    end

    reaper.UpdateArrange()
Skorobagatko is offline   Reply With Quote
Old 05-04-2021, 02:40 AM   #2484
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

I can't see the start of the tracks to see where you are moving exactly.

__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak

Last edited by MusoBob; 05-04-2021 at 02:48 AM.
MusoBob is offline   Reply With Quote
Old 05-06-2021, 08:55 AM   #2485
Phazma
Human being with feelings
 
Join Date: Jun 2019
Posts: 2,872
Default

Quote:
Originally Posted by jrk View Post
Names a track for the first fx VSTi added to it:
eel script

Code:
// Names "unnamed" tracks for their first VSTi / VST3i

function main()
(
	n = CountTracks(0);

	i = 0;
	namestr = #;
	while (i<n)
	(
		trk = GetTrack(0,i);
		GetTrackName(trk, tname);
		
		match("Track %d", tname) ?
		(
			fxn = TrackFX_GetCount(trk);
			j = 0; found = 0;
			while((j<fxn) && !found)
			(
				TrackFX_GetFXName(trk, j, namestr);
			
				match("VST*i: %{new_name}s", namestr)?
				(
					found = 1;
					GetSetMediaTrackInfo_String(trk, "P_NAME", new_name, 1);
				);
				j +=1;
			);		
		);
		i+= 1;
	);
	
	defer("main();");
);

main();
crikey, my tabs have gone very long....
Could anyone make a script (or ideally add the functionality to the above script) that also sets the track to a certain track layout if an instrument is loaded into it (layout name can be specified by user in script)?

And furthermore, in my theme, when this is applied on a track which is a child inside a folder it needs yet another layout, so it would be much appreciated if it could detect if the track is a normal track with an instrument and set it to layout with "name_A" and if it is a child track with an instrument set it to layout with "name_B". I know this is a very specific request but would help a lot to keep my sessions and workflow streamlined.
Phazma is offline   Reply With Quote
Old 05-06-2021, 11:49 AM   #2486
lowellben
Human being with feelings
 
lowellben's Avatar
 
Join Date: Aug 2010
Location: They put me in a home.
Posts: 3,432
Default

Please see this thread:
https://forum.cockos.com/showthread....40#post2440740

Could someone please help create a script that exports FX text comments (from base64) into a plaintext human-readable .txt file in the project folder?

I'd like to have the ability to list out all the FX comments per track in a project. Happy to sponsor if it's a very time-consuming task.

Similar to the existing script to export out Plugins users in a project and preset names - edgemeal_Save project plugin info to text file and edgemeal_Save project plugin info to project notes.

Info:
This info is saved in the <COMMENT> field of the FX chain chunk in the .RPP file and is encoded in base64 format.

And if you want to write scripts to get/set them, you can use Ultraschall-Api, which has dedicated functions to set/get comments in FXStateChunks, as shown in solger's example.

This does the base64 encoding/decoding for you.

==========
Concept:
==========

Track 1 - Piano:
* Kontakt: FX comment here about this particular preset info.

Track 2 - Bass:
* Trilian: My FX comment about the bass tone in this preset, go back and fix the EQ later.
* ReaEQ: This EQ comment reminds me to fine-tune the LPF @ maybe 2khz

Track 3 - Piano:
* Addictive Keys: FX comment here about this particular preset info.
* VintageVerb: Is this too wet? Double check after mixdown.


etc....


Thank you for any help with this.
__________________
47.8% of statistics are made up.
lowellben is offline   Reply With Quote
Old 05-08-2021, 06:11 AM   #2487
Pink Wool
Human being with feelings
 
Pink Wool's Avatar
 
Join Date: Apr 2020
Posts: 1,501
Default Cycling track selection? Possible?

Hey!

I'm looking for a script to go to the next track but once it reaches the end of the track list, it would jump to the first track on the track list. So it would cycle the track list through. And obviously a "go to previous" one would be needed too.

Is this possible? I seem to remember someone asking for this previously and getting a script for it but can't seem to find anything now

Thanks in advance,
PW
Pink Wool is offline   Reply With Quote
Old 05-08-2021, 07:38 AM   #2488
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Quote:
Originally Posted by Pink Wool View Post
Hey!

I'm looking for a script to go to the next track but once it reaches the end of the track list, it would jump to the first track on the track list...
If no tracks are selected it will select track 1:
Code:
track_count = reaper.CountTracks( 0 )

sel_track = reaper.GetSelectedTrack2( 0, 0, false )

if not sel_track then
  set_track = reaper.GetTrack( 0,0 )
  
  reaper.SetTrackSelected( set_track, 1 )
  
else

  track_number = reaper.GetMediaTrackInfo_Value(sel_track, 'IP_TRACKNUMBER')
  
  reaper.Main_OnCommand( 40297, 0 ) -- Track: Unselect all tracks
  
  if track_number > track_count -1 then
    track_number = 0
  end
  
  set_track = reaper.GetTrack( 0,track_number )
  
  reaper.SetTrackSelected( set_track, 1 )
end
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 05-09-2021, 12:26 AM   #2489
Pink Wool
Human being with feelings
 
Pink Wool's Avatar
 
Join Date: Apr 2020
Posts: 1,501
Default

Quote:
Originally Posted by MusoBob View Post
If no tracks are selected it will select track 1:
Code:
track_count = reaper.CountTracks( 0 )

sel_track = reaper.GetSelectedTrack2( 0, 0, false )

if not sel_track then
  set_track = reaper.GetTrack( 0,0 )
  
  reaper.SetTrackSelected( set_track, 1 )
  
else

  track_number = reaper.GetMediaTrackInfo_Value(sel_track, 'IP_TRACKNUMBER')
  
  reaper.Main_OnCommand( 40297, 0 ) -- Track: Unselect all tracks
  
  if track_number > track_count -1 then
    track_number = 0
  end
  
  set_track = reaper.GetTrack( 0,track_number )
  
  reaper.SetTrackSelected( set_track, 1 )
end
Thanks MusoBob! That works perfectly! Is there any way to make this go the other way?
Pink Wool is offline   Reply With Quote
Old 05-09-2021, 12:49 AM   #2490
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

LOL yes I just mentioned that here, it could be made to go backward
https://forum.cockos.com/showthread.php?t=253335
Code:
track_count = reaper.CountTracks( 0 )

sel_track = reaper.GetSelectedTrack2( 0, 0, false )

if not sel_track then
  set_track = reaper.GetTrack( 0,track_count -1 )
  
  reaper.SetTrackSelected( set_track, 1 )
  
else

  track_number = reaper.GetMediaTrackInfo_Value(sel_track, 'IP_TRACKNUMBER')
  
  reaper.Main_OnCommand( 40297, 0 ) -- Track: Unselect all tracks
  
  if track_number < 2 then
    track_number = track_count +1 
  end
  
  set_track = reaper.GetTrack( 0,track_number -2 )
  
  reaper.SetTrackSelected( set_track, 1 )
end
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 05-09-2021, 01:24 AM   #2491
Pink Wool
Human being with feelings
 
Pink Wool's Avatar
 
Join Date: Apr 2020
Posts: 1,501
Default

Quote:
Originally Posted by MusoBob View Post
LOL yes I just mentioned that here, it could be made to go backward
https://forum.cockos.com/showthread.php?t=253335
Code:
track_count = reaper.CountTracks( 0 )

sel_track = reaper.GetSelectedTrack2( 0, 0, false )

if not sel_track then
  set_track = reaper.GetTrack( 0,track_count -1 )
  
  reaper.SetTrackSelected( set_track, 1 )
  
else

  track_number = reaper.GetMediaTrackInfo_Value(sel_track, 'IP_TRACKNUMBER')
  
  reaper.Main_OnCommand( 40297, 0 ) -- Track: Unselect all tracks
  
  if track_number < 2 then
    track_number = track_count +1 
  end
  
  set_track = reaper.GetTrack( 0,track_number -2 )
  
  reaper.SetTrackSelected( set_track, 1 )
end
Well, that's just awesome! Thank you very much!
Pink Wool is offline   Reply With Quote
Old 05-10-2021, 07:12 AM   #2492
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

I'm looking for a script.
let all items selected, which have the highest pitch value.
for example:
10 selected items, only one have pitch +13, all others less.
Then only the one with +13 should remain selected.
Thanks
Dragonetti is offline   Reply With Quote
Old 05-10-2021, 07:40 AM   #2493
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by Dragonetti View Post
I'm looking for a script.
let all items selected, which have the highest pitch value.
for example:
10 selected items, only one have pitch +13, all others less.
Then only the one with +13 should remain selected.
Added "Select the item with highest or lowest pitch" to ReaPack (two actions: one for selecting the highest and another for the lowest, in case that would also be useful).

Last edited by cfillion; 05-10-2021 at 07:59 AM.
cfillion is offline   Reply With Quote
Old 05-10-2021, 08:16 AM   #2494
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

thanks, that was super fast
I can also use the lowest, I thought I can do it myself
Dragonetti is offline   Reply With Quote
Old 05-10-2021, 10:25 AM   #2495
Pink Wool
Human being with feelings
 
Pink Wool's Avatar
 
Join Date: Apr 2020
Posts: 1,501
Default

I'm looking for a script that adds 4 envelope points but has two of them -1db so that they form a slope. Here's an image of what I'm looking for:

https://imgur.com/a/ErrD6VO

Would this be possible do via a script?

Thanks in advance,
PW
Pink Wool is offline   Reply With Quote
Old 05-10-2021, 01:14 PM   #2496
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

yeah, what timming difference do you want ? By the grid as in your ss?
daniellumertz is offline   Reply With Quote
Old 05-10-2021, 10:27 PM   #2497
Pink Wool
Human being with feelings
 
Pink Wool's Avatar
 
Join Date: Apr 2020
Posts: 1,501
Default

Quote:
Originally Posted by daniellumertz View Post
yeah, what timming difference do you want ? By the grid as in your ss?
Yeah, I assume that would be easiest. Would it get too involved if it was changeable?
Pink Wool is offline   Reply With Quote
Old 05-11-2021, 08:15 AM   #2498
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

Hi scripters
Is it possible to change the script of me2beats so that all columns get the same source?
Now the script chooses a different source for each item.
The script should actually only shuffle the first track and transfer these sources to the lower tracks.
Thanks


Code:
-- @description Switch item source file to random in folder
-- @version 1.0
-- @author me2beats
-- @changelog
--  + init

local r = reaper; local function nothing() end; local function bla() r.defer(nothing) end

function shuffle(array)

  function swap(array, index1, index2)
    array[index1], array[index2] = array[index2], array[index1]
  end

  local counter = #array
  while counter > 1 do
    local index = math.random(counter)
    swap(array, index, counter)
    counter = counter - 1
  end
end

local items = r.CountSelectedMediaItems()
if items == 0 then bla() return end


r.Undo_BeginBlock()
r.PreventUIRefresh(1)

r.Main_OnCommand(40440,0)

for j = 0, r.CountSelectedMediaItems()-1 do
  local it = r.GetSelectedMediaItem(0,j)
  
  
  local tk = r.GetActiveTake(it)
  if not tk then goto cnt end
  if r.TakeIsMIDI(tk) then goto cnt end
  local src = r.GetMediaItemTake_Source(tk)
  if not src then goto cnt end
  local src_fn = r.GetMediaSourceFileName(src, '')
  local folder = src_fn:match[[(.*)\]]

  local clonedsource

  local pos, new_fn, files
  pos = r.GetExtState(folder, 'pos')
  if not (pos and pos ~= '') then
  
    local t = {}
    for i = 0, 10000 do
      local fn = r.EnumerateFiles(folder, i)
      if not fn or fn == '' then break end
      if fn:match'%.wav$' or fn:match'%.mp3$' or fn:match'%.aiff$' then
        t[#t+1] = folder..[[\]]..fn
      end
    end

    files = #t
    shuffle(t)
    
  
    for i = 1, files do
      local ext_key = tostring(i)
      r.SetExtState(folder, ext_key, t[i], 0)
    end

    r.SetExtState(folder, 'pos', 1, 0)
    r.SetExtState(folder, 'files', files, 0)
    pos = 1
    new_fn = t[1]
  else
    files = tonumber(r.GetExtState(folder, 'files'))
    pos = tonumber(r.GetExtState(folder, 'pos'))
    local f
    for i = 1, files do
      if pos <= files-1 then pos = pos+1 else pos = 1 end
      new_fn = r.GetExtState(folder, tostring(pos))
      if r.file_exists(new_fn) then f = pos break end
    end
    if not f then new_fn = nil
    else
      r.SetExtState(folder, 'pos', pos, 0)
    end

  end
  
  if new_fn then
    clonedsource = r.PCM_Source_CreateFromFile(new_fn)
    r.SetMediaItemTake_Source(tk, clonedsource)
    r.GetSetMediaItemTakeInfo_String(tk, 'P_NAME', new_fn:match[[.*\(.*)]], 1)
    r.UpdateItemInProject(it)
  end
  
  ::cnt::
  
end

r.Main_OnCommand(40439,0)
r.Main_OnCommand(40047,0)
r.PreventUIRefresh(-1)

r.Undo_EndBlock('Switch item source', -1)
Dragonetti is offline   Reply With Quote
Old 05-11-2021, 09:23 PM   #2499
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

ok dear pink wool here is your request, I made some changes, you can work by pressing a keyshortcut but you can also use with mouse wheel.


Basic up/down



It also adjusts the points inside your selection !


Currently it work only in volume/dB/gain envelopes. Working on this...

The name of the script is Create 4 Points Inside Time Selection Using Grid Values

My reapack:
https://raw.githubusercontent.com/da...ster/index.xml

Or the file if you want to ctrlc ctrlv
https://github.com/daniellumertz/Dan...d%20Values.lua

I will try to make it work in all envelopes need to see somethings first!

Last edited by daniellumertz; 05-11-2021 at 09:39 PM.
daniellumertz is offline   Reply With Quote
Old 05-11-2021, 11:11 PM   #2500
Pink Wool
Human being with feelings
 
Pink Wool's Avatar
 
Join Date: Apr 2020
Posts: 1,501
Default

Quote:
Originally Posted by daniellumertz View Post
ok dear pink wool here is your request, I made some changes, you can work by pressing a keyshortcut but you can also use with mouse wheel.


Basic up/down



It also adjusts the points inside your selection !


Currently it work only in volume/dB/gain envelopes. Working on this...

The name of the script is Create 4 Points Inside Time Selection Using Grid Values

My reapack:
https://raw.githubusercontent.com/da...ster/index.xml

Or the file if you want to ctrlc ctrlv
https://github.com/daniellumertz/Dan...d%20Values.lua

I will try to make it work in all envelopes need to see somethings first!

Hey! Thank you so much! I don't know how I could adjust it with a mouse wheel? Also, would it be possible to have the script work even when the envelope lane is not active? Currently the mouse has to be on the envelope lane for this to work.

Thank you!


Edit: Also, I know this might be asking a lot, but would it be possible that if only 3 grid lines are in the time selection, the script would only add 3 points? It's fine as is but just wondering if that would be possible?

Last edited by Pink Wool; 05-11-2021 at 11:27 PM.
Pink Wool is offline   Reply With Quote
Old 05-12-2021, 12:51 AM   #2501
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Quote:
Originally Posted by Dragonetti View Post
Hi scripters
Is it possible to change the script of me2beats so that all columns get the same source?
Now the script chooses a different source for each item.
The script should actually only shuffle the first track and transfer these sources to the lower tracks.
Thanks
I'm not sure what the script does at the moment and what you want it to do.
If you can give me step by step guide what I need to do to test it.
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 05-12-2021, 01:29 AM   #2502
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

Quote:
Originally Posted by Pink Wool View Post
Hey! Thank you so much! I don't know how I could adjust it with a mouse wheel?
In your action list bind the script to some shortcut using the mousewheel like alt shift wheel

Quote:
Also, would it be possible to have the script work even when the envelope lane is not active? Currently the mouse has to be on the envelope lane for this to work.
I can edit for this tomorrow should take some small minutes minutes

Quote:
Edit: Also, I know this might be asking a lot, but would it be possible that if only 3 grid lines are in the time selection, the script would only add 3 points? It's fine as is but just wondering if that would be possible?
Can you post a ss of how you want it behave vs how it is behaving ?
daniellumertz is offline   Reply With Quote
Old 05-12-2021, 04:39 AM   #2503
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

@MusoBob
The columns should get the same source file.
As you can see here in the gif, every item gets a random source. This will destroy the chords.
Dragonetti is offline   Reply With Quote
Old 05-12-2021, 04:57 AM   #2504
Pink Wool
Human being with feelings
 
Pink Wool's Avatar
 
Join Date: Apr 2020
Posts: 1,501
Default

Quote:
Originally Posted by daniellumertz View Post
In your action list bind the script to some shortcut using the mousewheel like alt shift wheel



I can edit for this tomorrow should take some small minutes minutes



Can you post a ss of how you want it behave vs how it is behaving ?
Thank you! The binding worked great! I didn't know it was possible to bind a mousewheel! So many possibilities!


Here's a screencap on what I mean:

https://imgur.com/a/dpFAcFx

Last edited by Pink Wool; 05-12-2021 at 05:09 AM.
Pink Wool is offline   Reply With Quote
Old 05-13-2021, 12:30 AM   #2505
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

Quote:
Originally Posted by Pink Wool View Post
Edit: Also, I know this might be asking a lot, but would it be possible that if only 3 grid lines are in the time selection, the script would only add 3 points? It's fine as is but just wondering if that would be possible?
Done and updated on repository

Quote:
Originally Posted by Pink Wool View Post
Hey! Thank you so much! I don't know how I could adjust it with a mouse wheel? Also, would it be possible to have the script work even when the envelope lane is not active? Currently the mouse has to be on the envelope lane for this to work.
I did a version for this but didn't updated on repository I think I wouldn't like to use this way, but if that is what you wish:

Code:
 
-- @version 1.2.pinkwool
-- @author Daniel Lumertz
-- @changelog
--    + Only 3 points if need
--    + return if no time selection


-- User Configs
local dB_change = -0.5 
local points_shape = 0
local undo_points = true

function print(...)
    for k,v in ipairs({...}) do
        reaper.ShowConsoleMsg(tostring(v))
    end
    reaper.ShowConsoleMsg("\n")
end

--[[ function DeleteEvelopePointAtPositions(envelope, ...) -- Envelope and time positions of the points
    local countPts = reaper.CountEnvelopePoints(envelope)
    for i = countPts-1, 0, -1  do
        local retval, time, value, shape, tension, selected = reaper.GetEnvelopePoint(envelope, i)
        for k,v in ipairs({...}) do
            if time == v then  
                reaper.DeleteEnvelopePointEx( envelope, -1, i ) 
            end
        end
    end
end 
-- Maybe I use someday will leave here
]]

function SetEvelopePointInRange(envelope,offset,start,fim) -- Envelope and time positions of the points
    local countPts = reaper.CountEnvelopePoints(envelope)
    for i = 0, countPts-1  do
        local retval, time, value, shape, tension, selected = reaper.GetEnvelopePoint(envelope, i)
        if time > start and time < fim then
            local newval = AddDBinLinear(value, offset )
            reaper.SetEnvelopePoint(envelope, i, nil, newval, nil, nil, nil, true)
        end
    end
end 

function AddDBinLinear(valbefore, addval )
    local val_before_in_DB = 20 * math.log(valbefore,10) -- Linear to dB
    local dB_newval = val_before_in_DB + addval -- add to dB
    local new_linear = 10^(dB_newval/20) -- dB to Linear
    return new_linear
end

--If User put with mouse wheel it invert the db_change value
local _,_,_,_,_,_,val = reaper.get_action_context()
if val >= 0 then
    dB_change = dB_change * -1
end

-- Get Env info
local window, segment, details = reaper.BR_GetMouseCursorContext()
local envelope, _ = reaper.BR_GetMouseCursorContext_Envelope()
if not envelope then  
    local track = reaper.BR_GetMouseCursorContext_Track()
    if not track then return end
    envelope = reaper.GetTrackEnvelopeByName( track, "Volume" )
end
--local _, envname = reaper.GetEnvelopeName( envelope )
--local isvol = string.match(envname, "Volume")

-- Get Time pos
local time1, time4 = reaper.GetSet_LoopTimeRange2(0, false, false, 0, 0, false)
local time2 = reaper.BR_GetNextGridDivision( time1 ) -- You can set another time offset here I am using grid
local time3 = reaper.BR_GetPrevGridDivision( time4 ) -- You can set another time offset here I am using grid
if time1 == time4 then return end -- if no TS

if undo_points then reaper.Undo_BeginBlock() end
reaper.PreventUIRefresh(1)

-- Get Value info where will add points
local retval, value_before1, dVdS, ddVdS, dddVdS = reaper.Envelope_Evaluate( envelope, time1, reaper.format_timestr_pos( 1, '', 4 ), 1 )
local retval, value_before2, dVdS, ddVdS, dddVdS = reaper.Envelope_Evaluate( envelope, time2, reaper.format_timestr_pos( 1, '', 4 ), 1 )
local retval, value_before3, dVdS, ddVdS, dddVdS = reaper.Envelope_Evaluate( envelope, time3, reaper.format_timestr_pos( 1, '', 4 ), 1 )
local retval, value_before4, dVdS, ddVdS, dddVdS = reaper.Envelope_Evaluate( envelope, time4, reaper.format_timestr_pos( 1, '', 4 ), 1 )

-- Add Value
--if isvol then
local new_value2 = AddDBinLinear(value_before2, dB_change)
local new_value3 = AddDBinLinear(value_before3, dB_change)
--[[ local scaling_mode = reaper.GetEnvelopeScalingMode( envelope )
local value_before2_linear = reaper.ScaleFromEnvelopeMode( 1, value_before2 )
print(value_before2) ]]

-- To delete points at same time position
reaper.DeleteEnvelopePointRange( envelope, time1-(10^-10), time1+(10^-10))
reaper.DeleteEnvelopePointRange( envelope, time2-(10^-10), time2+(10^-10))
reaper.DeleteEnvelopePointRange( envelope, time3-(10^-10), time3+(10^-10))
reaper.DeleteEnvelopePointRange( envelope, time4-(10^-10), time4+(10^-10))

-- Change Points on range
SetEvelopePointInRange(envelope,dB_change,time1,time4)

-- Insert New Points
reaper.InsertEnvelopePoint( envelope, time1, value_before1, points_shape, 0, false, true )
reaper.InsertEnvelopePoint( envelope, time2, new_value2, points_shape, 0, false, true )
if time2 ~= time3 then 
    reaper.InsertEnvelopePoint( envelope, time3, new_value3, points_shape, 0, false, true )
end
reaper.InsertEnvelopePoint( envelope, time4, value_before4, points_shape, 0, false, true )

reaper.Envelope_SortPoints( envelope )
reaper.PreventUIRefresh(-1)
reaper.UpdateArrange()

if undo_points then 
    reaper.Undo_EndBlock("Create 4 Points Inside Time Selection Using Grid Values", -1) 
else 
    reaper.defer(function() end )
end
todo: make work in other envelopes other than vol/gain envelopes
daniellumertz is offline   Reply With Quote
Old 05-13-2021, 01:13 AM   #2506
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Quote:
Originally Posted by Dragonetti View Post
@MusoBob
The columns should get the same source file.
As you can see here in the gif, every item gets a random source. This will destroy the chords.
You will have to guide me what to do as I'm confused what I need to do.
I run the script and it does nothing, but if I run the SWS one it creates a copy in stereo.
I'm like a deer with no eyes, a no idea

__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 05-13-2021, 02:52 AM   #2507
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

I have a wav file.
It is in a folder with several wav files.
When I select the wav file and run the script, another wav file is randomly loaded from the folder and replaces the first one.
This works fine when I only have the wav files on one track.
With my chord function and the columns, the same random wav file should always be selected vertically.

Thanks
Dragonetti is offline   Reply With Quote
Old 05-13-2021, 04:03 AM   #2508
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Wouldn't you need the B note wavs in one folder then the D, Gb and A etc.. in other folders ?
So if you want to shuffle the B notes on the bottom track it will only be selecting B note wav files ?
Trying to get my head around it.
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 05-13-2021, 04:21 AM   #2509
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

In your first pic you want the random items in the same order on each track, is it just duplicating ? I thought they were chords with the root note on the bottom track ?




I have 3 items in the same folder all 2 bars long and it shuffles them but keeps the same start position in source:

__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak

Last edited by MusoBob; 05-13-2021 at 04:37 AM.
MusoBob is offline   Reply With Quote
Old 05-13-2021, 06:20 AM   #2510
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

None of this has anything to do with the item pitch
The chords remain.

https://www.youtube.com/watch?v=EK5X_lXcNwc

Last edited by Dragonetti; 05-13-2021 at 06:38 AM.
Dragonetti is offline   Reply With Quote
Old 05-13-2021, 08:59 PM   #2511
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Quote:
Originally Posted by Dragonetti View Post
..This works fine when I only have the wav files on one track...
OK I think it's all coming back to me now.
You are using the C notes and transpose with the chord script I made.
So you want it to shuffle the pattern on one track then duplicate that on the other chord note tracks.
When it shuffles it keeps the same pitch so that's good.
So if I get the script just to shuffle the items belonging to the lowest track of all the selected items then
source = reaper.GetMediaItemTake_Source( take ) of all the items on the lowest track
then
reaper.SetMediaItemTake_Source( take, source ) of all the other tracks to the same source.
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 05-14-2021, 03:12 AM   #2512
RoyalDragonSir
Human being with feelings
 
RoyalDragonSir's Avatar
 
Join Date: May 2021
Location: South Africa
Posts: 3
Default Request for action script.

Hi everyone, I'm wondering if someone could make a script for a custom action. It would be amazing if someone could make an action that arms the automation envelope of the last touched parameter.

There already is an action that does this with track FX, but it doesn't work with mixer tracks parameters like volume pan etc, it only works with parameters of plugins.

An action that would do this with all parameters would be amazing, or if that's difficult to achieve, an action that does this with all other parameters besides plugin parameters would still be incredibly helpful.

Even better than an action would be if it were possible to get REAPER to automatically arm envelopes for any touched parameter when in latch preview mode. When in latch preview mode, REAPER already automatically creates and arms new envelopes for adjusted parameters, but if when in latch preview mode you adjust a parameter with an already existing envelope that is currently not armed, it doesn't re-arm said parameter.

It occurs to me that it may not be clear why this action is necessary, I'm not going to go into it in this post for the sake of brevity but if anyone would like to know I will gladly explain.(it has to do with an efficient latch preview based mixing workflow I'm trying to develop)

Kind regards,

RDS

Last edited by RoyalDragonSir; 05-14-2021 at 06:01 AM. Reason: removed one incorrect word
RoyalDragonSir is offline   Reply With Quote
Old 05-14-2021, 06:22 AM   #2513
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

@MusoBob I think it's right

@all

I have the same problem so many times.
In REAPER, columns (chords, drum patterns, etc.) are not treated as a unit, not even in groupings.
Is it possible to program a frame where you put one
reaper.Main_OnCommand () so that
the action or script for a chord scenario works.
Chord scenario would treat the selected columns equally.

Would an API be conceivable?
Or one FR for several vertical groups?

Thanks

Dragonetti is offline   Reply With Quote
Old 05-14-2021, 04:37 PM   #2514
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default

Quote:
Originally Posted by RoyalDragonSir View Post
Hi everyone, I'm wondering if someone could make a script for a custom action. It would be amazing if someone could make an action that arms the automation envelope of the last touched parameter.

There already is an action that does this with track FX, but it doesn't work with mixer tracks parameters like volume pan etc, it only works with parameters of plugins.

An action that would do this with all parameters would be amazing, or if that's difficult to achieve, an action that does this with all other parameters besides plugin parameters would still be incredibly helpful.

Even better than an action would be if it were possible to get REAPER to automatically arm envelopes for any touched parameter when in latch preview mode. When in latch preview mode, REAPER already automatically creates and arms new envelopes for adjusted parameters, but if when in latch preview mode you adjust a parameter with an already existing envelope that is currently not armed, it doesn't re-arm said parameter.

It occurs to me that it may not be clear why this action is necessary, I'm not going to go into it in this post for the sake of brevity but if anyone would like to know I will gladly explain.(it has to do with an efficient latch preview based mixing workflow I'm trying to develop)

Kind regards,

RDS
I've tried something like this, but to no avail. There's a great API command called "GetLastTouchedFX" but as you mentioned, it only works with plugins, and NOT things like volume/pan.... I did some searching and was unable to find any support for this in the API. At this point, I would say this is more of a feature request than a script request.

If I'm totally wrong and there is a way to do this, I'd LOVE to find out how!
__________________
My Reapack Repository: I write scripts for my own personal use.
I offer no support, but if you find one that helps you, go for it!
sonictim is offline   Reply With Quote
Old 05-14-2021, 08:23 PM   #2515
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Quote:
Originally Posted by Dragonetti View Post
@MusoBob I think it's right

@all

I have the same problem so many times.
In REAPER, columns (chords, drum patterns, etc.) are not treated as a unit, not even in groupings.
Is it possible to program a frame where you put one
reaper.Main_OnCommand () so that
the action or script for a chord scenario works.
Chord scenario would treat the selected columns equally.

Would an API be conceivable?
Or one FR for several vertical groups?

Thanks
Try this script, apply the random color or shuffle to the first/ top track then select all items on all tracks then run script.
You could add the random shuffle or color code to the script so it will apply it to the first track then the others.
EDIT: added same start pos of item
EDIT: added length & pos
EDIT: it will clone the first track items source, color, start, length etc.. leaving the pitch intact, assuming you are using all the same root note eg: C that has been transposed to the chord note.
Code:
 reaper.Main_OnCommand( 40297, 0 ) -- Track: Unselect all tracks

 sel_item_count = reaper.CountSelectedMediaItems( 0 )
 track_count = 0
 sel_track_count = 0
 track_number = 0
 first_track_item_count = 0
 first_track_number = 0
 

 item_count = reaper.CountMediaItems( 0 )
  for i = 0, item_count -1 do
    item = reaper.GetMediaItem( 0, i )
    if reaper.IsMediaItemSelected( item ) then
      track = reaper.GetMediaItemTrack( item )
      track_number = reaper.GetMediaTrackInfo_Value( track, "IP_TRACKNUMBER")
      first_track_number = track_number
      first_item = i
      break
    end 
  end

  previous_track_number = 0
  items_table_selected_items = {}
  track_table_number = {}
  for i = 0, item_count -1 do
    item = reaper.GetMediaItem( 0, i )
    if reaper.IsMediaItemSelected( item ) then
      table.insert(items_table_selected_items, i)
      track = reaper.GetMediaItemTrack( item )
      track_number = reaper.GetMediaTrackInfo_Value( track, "IP_TRACKNUMBER")
      if track_number > previous_track_number then
        sel_track_count = sel_track_count +1
        reaper.SetTrackSelected( track, 1 )
        table.insert(track_table_number, track_number)
        last_track_number = track_number
        previous_track_number = track_number
      end  
    end 
  end  

  item_table_color = {}
  item_table_source = {}
  item_table_source_start = {}
  item_table_source_filename = {}
  item_table_source_length = {}
  item_table_source_pos = {}
  
  
  
  for i = first_item, sel_item_count -1 do
    item = reaper.GetMediaItem( 0, i )
    if reaper.IsMediaItemSelected( item ) then
      
      track = reaper.GetMediaItemTrack( item )
      track_number = reaper.GetMediaTrackInfo_Value( track, "IP_TRACKNUMBER")
      
      if track_number == first_track_number +1 then
        break
      end
      
      reaper.SetTrackSelected( track, 1 )
      previous_track_number = track_number
      first_track_item_count = first_track_item_count +1
      
      item = reaper.GetMediaItem( 0, i )
      take = reaper.GetActiveTake( item )
      color = reaper.GetMediaItemInfo_Value( item, "I_CUSTOMCOLOR" )
      source_length = reaper.GetMediaItemInfo_Value( item, "D_LENGTH" )
      source_pos = reaper.GetMediaItemInfo_Value( item, "D_POSITION" )
      source_start = reaper.GetMediaItemTakeInfo_Value( take, "D_STARTOFFS" )
      source = reaper.GetMediaItemTake_Source(take)
      retval, source_filename = reaper.GetSetMediaItemTakeInfo_String(take, "P_NAME", "", 0)
      
      
      table.insert(item_table_color, color)
      table.insert(item_table_source_start, source_start)  
      table.insert(item_table_source, source)
      table.insert(item_table_source_pos, source_pos)
      table.insert(item_table_source_length, source_length)
      table.insert(item_table_source_filename, source_filename)
    end
  end 
            
  b = 1 
  for i = 1, sel_item_count do
    t = items_table_selected_items[i]
    item = reaper.GetMediaItem( 0, t)
    
    reaper.SetMediaItemInfo_Value( item, "I_CUSTOMCOLOR", item_table_color[b] )
    take = reaper.GetActiveTake( item )
    
    reaper.SetMediaItemTakeInfo_Value(take, "D_STARTOFFS", item_table_source_start[b], 1)
    
    reaper.SetMediaItemInfo_Value( item, "D_LENGTH", item_table_source_length[b] )
    
    reaper.SetMediaItemInfo_Value( item, "D_POSITION", item_table_source_pos[b] )
    
    reaper.SetMediaItemTake_Source( take, item_table_source[b])
    reaper.GetSetMediaItemTakeInfo_String(take, "P_NAME", item_table_source_filename[b], 1)
    
    b = b +1
    if b > first_track_item_count then b =1 end
    
  end
Full Screen


These source items were 2 bar in length so it will keep the same start in source pos.
Full Screen


Full Screen


Full Screen
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak

Last edited by MusoBob; 05-18-2021 at 06:56 PM.
MusoBob is offline   Reply With Quote
Old 05-15-2021, 02:11 AM   #2516
RoyalDragonSir
Human being with feelings
 
RoyalDragonSir's Avatar
 
Join Date: May 2021
Location: South Africa
Posts: 3
Default

Quote:
Originally Posted by sonictim View Post
I've tried something like this, but to no avail. There's a great API command called "GetLastTouchedFX" but as you mentioned, it only works with plugins, and NOT things like volume/pan.... I did some searching and was unable to find any support for this in the API. At this point, I would say this is more of a feature request than a script request.

If I'm totally wrong and there is a way to do this, I'd LOVE to find out how!
Thanks very much for your reply Sonictim,

I'm no programmer, but in the API, I see a command like this: reaper.GetLastTouchedTrack(). Then, in the brackets, maybe it's possible to fill with something like "paramnumber"?

Like this in total: reaper.GetLastTouchedTrack(paramnumber) in Lua.

Again I'm not a programmer so I have no idea if this would make a difference, and I'm assuming it probably wouldn't?

I feel I should probably explain why I need this feature, in the hopes that maybe someone can offer a workaround if no script is possible.

I like to do a lot of my mixing work by making a time selection, then using a hotkey to activate latch preview mode on all tracks, then adjusting various parameters to taste, then using the action "Automation: Write current values for all writing envelopes to time selection" to have those settings statically applied only to the time selection without affecting said parameters outside of my time selection. The problem is that if any previously written envelopes within the time selection have non-static automation, as in a volume swell or anything non-static, the write command overwrites said automation with whatever static value the parameter was on at the moment of starting the action

I suppose I could just try to remember to always disarm the envelope of any parameter with non-static automation... This still would require manually finding and re-arming that envelope if I need to apply some static automation to it at a different time selection to where that envelope had moving automation. Sounds tedious TBH

So I was hoping to work around this by keeping all envelopes disarmed by default (there is already an action to disarm all) Then, when in latch preview mode, being able to easily arm ONLY the parameters that I wish to apply static automation to within the time selection with the hypothetical action of arm last touched parameter. This would be both highly efficient and would avoid accidental overwriting of non-static parameter changes.

Am I being silly? Am I missing some obvious way to keep control in this situation?

Again, thanks for taking the time to respond.

Regards,

RDS
RoyalDragonSir is offline   Reply With Quote
Old 05-15-2021, 08:03 AM   #2517
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

@MusoBob
Thank you for the effort. Unfortunately I can't do it yet. Once I thought it worked, but somehow not anymore.
I will continue trying

Edit:I have the bug.

Track 1,2,3 works
Track 3,4,5 does not work

but it can also occur 4,5,7 !!

Last edited by Dragonetti; 05-15-2021 at 09:12 AM.
Dragonetti is offline   Reply With Quote
Old 05-15-2021, 02:40 PM   #2518
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

I added length & pos to it.
Make sure you have the same amount of items on each track for it to work.
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 05-15-2021, 02:53 PM   #2519
Dragonetti
Human being with feelings
 
Join Date: Feb 2017
Location: Kiel
Posts: 974
Default

top track 1 works
top track 2 does not work

Dragonetti is offline   Reply With Quote
Old 05-15-2021, 03:33 PM   #2520
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

All my testing was done on track 1 so I changed
track_loop_count = 0
for i = first_track+1, sel_track_count+first_track-1 do
see if this works now.

__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak

Last edited by MusoBob; 05-15-2021 at 05:41 PM.
MusoBob 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 08:51 AM.


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