Old 08-19-2020, 08:13 AM   #41
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

Do you have a list of scale patterns, so people can copy'n'paste them directly from the docs to include them into the parameters?
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 08-19-2020, 08:40 AM   #42
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Do you have a list of scale patterns, so people can copy'n'paste them directly from the docs to include them into the parameters?
some basics scales:
2773- lydian 101010110101
2741- major 101011010101
1717- Mixolydian 101011010110 (don't know if need to put the 0 in the end of a scale that ends with 0, thinking in music theory ( or imagining an piano ) it makes sense tho.)
1709- Dorian 101101010110
1453-Minor 101101011010
1451-Phrygian 110101011010
1387-Locrian 110101101010
4095-Chromatic 111111111111
1365-whole tone 101010101010
etc etc etc...

there can be 4096 scales using 12 division per octave so don't need to list everything hehe this site have many tools for exploring scales ( also give the number that reaper uses when searching scales ) https://ianring.com/musictheory/scales/finder.php
daniellumertz is online now   Reply With Quote
Old 08-19-2020, 08:51 AM   #43
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

No problem. Just some basic scales for those beginning is a nice start.

Thanks
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 08-19-2020, 09:19 AM   #44
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

Quote:
Originally Posted by daniellumertz View Post
(like 101011010101 major 2741 )
Quote:
Originally Posted by daniellumertz View Post
some basics scales:
2773- lydian 101010110101
2741- major 101011010101
1717- Mixolydian 101011010110 (don't know if need to put the 0 in the end of a scale that ends with 0, thinking in music theory ( or imagining an piano ) it makes sense tho.)
1709- Dorian 101101010110
1453-Minor 101101011010
1451-Phrygian 110101011010
1387-Locrian 110101101010
Remember that Reaper uses big endian, so they should be written in reverse. You can use the code I posted previously to get them in big endian.
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 08-21-2020 at 04:01 AM.
amagalma is offline   Reply With Quote
Old 08-19-2020, 03:27 PM   #45
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 Meo-Ada Mespotine View Post
Do you have a list of scale patterns, so people can copy'n'paste them directly from the docs to include them into the parameters?
There are also some on the stash:
https://stash.reaper.fm/browse.php?q...=th&o=nd&pp=24
nofish is offline   Reply With Quote
Old 08-19-2020, 03:39 PM   #46
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,793
Default

How to change the source channels on a send after creating the send. My track has many sends on it and I know how to create a send and how to change a source channel but it changes the wrong one. How to get the last created send?

https://forum.cockos.com/showthread.php?t=241380
Coachz is offline   Reply With Quote
Old 08-19-2020, 03:50 PM   #47
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 Coachz View Post
How to change the source channels on a send after creating the send. My track has many sends on it and I know how to create a send and how to change a source channel but it changes the wrong one. How to get the last created send?

https://forum.cockos.com/showthread.php?t=241380
Haven't used it myself but wouldn't that be
SetTrackSendInfo_Value with 'I_SRCCHAN'?
nofish is offline   Reply With Quote
Old 08-19-2020, 03:53 PM   #48
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,793
Default

Quote:
Originally Posted by nofish View Post
Haven't used it myself but wouldn't that be
SetTrackSendInfo_Value with 'I_SRCCHAN'?
You would think that would work but if you check out my previous post you'll see that Reaper seems to be sorting sends and so often the one you just created is not the last one in order necessarily which is causing me to change the wrong send. So it's like I need some pointer or way to get the last created send after I create it
Coachz is offline   Reply With Quote
Old 08-19-2020, 04:14 PM   #49
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 Coachz View Post
You would think that would work but if you check out my previous post you'll see that Reaper seems to be sorting sends and so often the one you just created is not the last one in order necessarily which is causing me to change the wrong send. So it's like I need some pointer or way to get the last created send after I create it
I see (missed that in the previous post, sorry).
Are you creating them via API or Reaper GUI?
If the first, CreateTrackSend returns the index of the created send, which you could then use with SetTrackSendInfo_Value?
nofish is offline   Reply With Quote
Old 08-19-2020, 04:43 PM   #50
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,793
Default

Thanks nofish. I'll give that a try. I'm using the API. How did you know it returns the index. All I saw was this and didn't know what integer was returning.

integer reaper.CreateTrackSend(MediaTrack tr, MediaTrack desttrIn)
Coachz is offline   Reply With Quote
Old 08-19-2020, 05:21 PM   #51
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

It says in the doc.

Quote:
return >=0 on success (== new send/receive index)
nofish is offline   Reply With Quote
Old 08-19-2020, 05:26 PM   #52
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,793
Default

Damn I missed that! Thanks so much.
Coachz is offline   Reply With Quote
Old 08-19-2020, 06:01 PM   #53
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
Default

Quote:
Originally Posted by amagalma View Post
Remember that Reaper uses little endian, so they should be written in reverse. You can use the code I posted previously to get them in little endian.
Opss.. That is true, forget that because I made the function switch the order .


coach I made a script (send for a bus for a while) that a part of it is for looking into the sends

if you created the send in the script I think it is the last one or the first not sure (not on my pc right now). But if it was created before and not sure if was the last created, I think I made a loop to see the tracks it was connected .
daniellumertz is online now   Reply With Quote
Old 08-19-2020, 09:50 PM   #54
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
Default

If there is a condition to end the script mid it "case of an error" how do you automatically undo what have been changed till that point?

End the undo block and then MainonCommand Undo?
daniellumertz is online now   Reply With Quote
Old 08-20-2020, 04:40 AM   #55
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

Quote:
Originally Posted by daniellumertz View Post
If there is a condition to end the script mid it "case of an error" how do you automatically undo what have been changed till that point?

End the undo block and then MainonCommand Undo?
Mostly yes. There's also a function for undo and even redo.
But better is to check for possible errors first before changing anything. It's less intrusive and as the undo-system if Reaper has its quirks, you may end up with the wrong things undone in rare cases and can't do something about it.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 08-20-2020, 08:11 AM   #56
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,793
Default

Quote:
Originally Posted by nofish View Post
It says in the doc.
That worked great. Thanks again for helping me fix this. Yay !
Coachz is offline   Reply With Quote
Old 08-21-2020, 04:11 AM   #57
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

Guys, just for not spreading wrong information, the system that Reaper uses to store scales is called big endian. I had confused the terms. Big endian means that the most significant bit is first. For example, take the number 103 (one hundred and three) in decimal. It is written in big endian, which means that first comes the digit that shows hundreds, then the digit that shows tens and last the digit that shows units. I corrected it in my posts above
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 08-21-2020, 04:57 AM   #58
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,793
Default

Quote:
Originally Posted by daniellumertz View Post
Opss.. That is true, forget that because I made the function switch the order .


coach I made a script (send for a bus for a while) that a part of it is for looking into the sends

if you created the send in the script I think it is the last one or the first not sure (not on my pc right now). But if it was created before and not sure if was the last created, I think I made a loop to see the tracks it was connected .
Thank you. I got my script working. Yay
Coachz is offline   Reply With Quote
Old 08-22-2020, 09:43 AM   #59
Embass
Human being with feelings
 
Embass's Avatar
 
Join Date: Jan 2014
Posts: 923
Default

I want to change auto-save path for this action:
SWS/S&M: Resources - Auto-save track template (with items, envelopes)

Is it possible to change this path on the fly?

my code looks like this, but it doesnt work..

Code:
local project_path = reaper.GetProjectPath("")
local reaper_res_path = reaper.GetResourcePath()
local sws_ini_path = reaper_res_path.."\\S&M.ini"

-- boolean reaper.BR_Win32_WritePrivateProfileString(string sectionName, string keyName, string value, string filePath)
-- [BR] Equivalent to win32 API WritePrivateProfileString(). For example, you can use this to write to REAPER.ini

-- change auto save path in S&M.ini file
local ok = reaper.BR_Win32_WritePrivateProfileString(
	"Resources", -- section
	"AutoSaveDirTrackTemplates", 
	project_path, -- auto save path
	sws_ini_path
)

-- not sure if i need this.. 
local ok = reaper.BR_Win32_WritePrivateProfileString(
	"Resources", -- section
	"AutoFillDirTrackTemplates", 
	project_path, -- auto save path
	sws_ini_path
)

-- SWS/S&M: Resources - Auto-save track template (with items, envelopes) 
local command_id = reaper.NamedCommandLookup("_S&M_SAVE_TRTEMPLATE_SLOT2")
reaper.Main_OnCommand(command_id, 0) -- run action
Embass is offline   Reply With Quote
Old 08-22-2020, 12:32 PM   #60
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,793
Default Refresh midi editor window

Is there an equivalent to UpdateArrange for the midi editor window?
Coachz is offline   Reply With Quote
Old 08-22-2020, 12:56 PM   #61
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 Coachz View Post
Is there an equivalent to UpdateArrange for the midi editor window?
There's an open FR so looks like the answer is no currently.
https://forum.cockos.com/showthread.php?t=193104
nofish is offline   Reply With Quote
Old 08-22-2020, 01:07 PM   #62
Coachz
Human being with feelings
 
Coachz's Avatar
 
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,793
Default

Quote:
Originally Posted by nofish View Post
There's an open FR so looks like the answer is no currently.
https://forum.cockos.com/showthread.php?t=193104
Ahh, thanks nofish. Let me buy you a trout. :-)
Coachz is offline   Reply With Quote
Old 08-22-2020, 01:17 PM   #63
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 Coachz View Post
Ahh, thanks nofish. Let me buy you a trout. :-)
I had to look that up, but err..no thank you lol.
nofish is offline   Reply With Quote
Old 08-22-2020, 01:39 PM   #64
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
Default

this thread should be sticky ? maybe call a forum mod?
can names be tagged ?

like @daniellumertz
daniellumertz is online now   Reply With Quote
Old 08-22-2020, 01:52 PM   #65
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 daniellumertz View Post
this thread should be sticky ? maybe call a forum mod?
Agreed. Actually I 'reported' the first post when I created it and asked if it could be stickied but no reaction so far.
Maybe someone else can try also?

Quote:
can names be tagged ?

like @daniellumertz
Not that the tagged forum member gets a notification afaik.
nofish is offline   Reply With Quote
Old 08-22-2020, 02:06 PM   #66
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
Default

I REPORTED YOU NOFISH!!1!
hahaha
asked over there, let's see if they agree...
daniellumertz is online now   Reply With Quote
Old 08-22-2020, 03:41 PM   #67
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,110
Default

Thanks.
nofish is offline   Reply With Quote
Old 08-23-2020, 06:22 PM   #68
Hypex
Human being with feelings
 
Join Date: Mar 2015
Location: Australia
Posts: 453
Default

Okay here's one. I've looked through the API and actions list. I don't see a way to do it directly. I don't know if it can be done. Perhaps in a round about way.


Okay so, in the case only a track is selected on the timeline, can you locate the item under the edit cursor of the selected track?
Hypex is offline   Reply With Quote
Old 08-23-2020, 07:24 PM   #69
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
Default

I think you have to loop the items in that track and get info about where they start and end, then compare to the edit cursor position.

something like:

Code:
 cursor_pos = reaper.GetCursorPosition()
 track = reaper.GetSelectedTrack( 0, 0 )
 n_item = reaper.CountTrackMediaItems( track )

 for i = 0 , n_item - 1 do

local   loop_item = reaper.GetTrackMediaItem( track, i )    
local   loop_item_start  = reaper.GetMediaItemInfo_Value( loop_item, "D_POSITION" )
local   loop_item_len    = reaper.GetMediaItemInfo_Value( loop_item, "D_LENGTH" ) 
local   loop_item_end =   loop_item_start + loop_item_len
    if loop_item_start <= cursor_pos and cursor_pos <= loop_item_end then 
        item_under_edit_cursor = loop_item
    end
end
Edit: oh didn't know about this functions mespotine, cooll!!!
daniellumertz is online now   Reply With Quote
Old 08-23-2020, 08:13 PM   #70
Hypex
Human being with feelings
 
Join Date: Mar 2015
Location: Australia
Posts: 453
Default

Quote:
Originally Posted by daniellumertz View Post
I think you have to loop the items in that track and get info about where they start and end, then compare to the edit cursor position.

Thanks for the answer. That was fast! I thought it may be something similar. A bit like finding a whole track length.
Hypex is offline   Reply With Quote
Old 08-24-2020, 05:54 AM   #71
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
Default

So I am using

window, segment, details = reaper.BR_GetMouseCursorContext()
local track = reaper.BR_GetMouseCursorContext_Track()

to get the track under mouse but depending on the zoom level It gets a bit weird and don't return the actual track under mouse. (SWS Beta latest version here)

some other way to do it ? Maybe using GetTrackFromPoint() and some reaper/lua function to get mouse xy?
daniellumertz is online now   Reply With Quote
Old 08-24-2020, 03:11 PM   #72
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 daniellumertz View Post
Maybe using GetTrackFromPoint() and some reaper/lua function to get mouse xy?
Yes, this should do I think (untested):
Code:
tr = reaper.GetTrackFromPoint(reaper.GetMousePosition())
nofish is offline   Reply With Quote
Old 08-24-2020, 03:12 PM   #73
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

Quote:
Originally Posted by daniellumertz View Post
So I am using

window, segment, details = reaper.BR_GetMouseCursorContext()
local track = reaper.BR_GetMouseCursorContext_Track()

to get the track under mouse but depending on the zoom level It gets a bit weird and don't return the actual track under mouse. (SWS Beta latest version here)

some other way to do it ? Maybe using GetTrackFromPoint() and some reaper/lua function to get mouse xy?

x, y = reaper.GetMousePosition()
retval, info = reaper.GetTrackFromPoint( x, y )
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 08-25-2020, 01:15 AM   #74
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
Default

thx people! I swear I looked for get mouse in the docs and didn't found hahaha worked better than the SWS actions, for some reason SWS when have multiple tracks with small size it get a bit funky heheh
daniellumertz is online now   Reply With Quote
Old 08-26-2020, 06:42 PM   #75
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
Default

is there a way to an script dont create a undo point?

I created this script to change track height using MW but wished it didn't go to my undo history






if anyone wants also

Code:
is_new_value,filename,sectionID,cmdID,mode,resolution,val = reaper.get_action_context()
if is_new_value then
 x, y = reaper.GetMousePosition()
 track, _ = reaper.GetTrackFromPoint(x,y)
   if track then
   old_height = reaper.GetMediaTrackInfo_Value(track,"I_TCPH")
    if val > 0 then
    reaper.SetMediaTrackInfo_Value(track, "I_HEIGHTOVERRIDE", (old_height+15))
    else
    reaper.SetMediaTrackInfo_Value(track, "I_HEIGHTOVERRIDE", (old_height-15))   
    end
   end
end
reaper.TrackList_AdjustWindows(false)
reaper.UpdateArrange()
daniellumertz is online now   Reply With Quote
Old 08-26-2020, 07:21 PM   #76
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

If it doesn't defer, you can add the following line at the end of the script:

Code:
reaper.defer()
This prevents creation of undo-points.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 08-27-2020, 07:25 AM   #77
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
Default

hmm didn't workk with this script, for some reason it doesent do nothing with defer at the end ...


edit:
one way is
reaper.Undo_DoUndo2( 0 )
at the end of the script with the rest as one undo block, works, but I still find it a little intrusive. Because the user could lost some redo options

Last edited by daniellumertz; 08-27-2020 at 07:37 AM.
daniellumertz is online now   Reply With Quote
Old 08-27-2020, 09:06 AM   #78
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

reaper.defer() shall do nothing but it also supresses creation of undo-points. It's a hack, as defer-scripts don't create undo-points, unless explicitly done.

But you can check this only, if you run the script from outside of Reaper's IDE and not from the inside. Means, you need to close the IDE and run it from the actions-list and then you can see, whether undo isn't created or not.

BTW: Which undo-points are created? Can you post a list of the things listed in the undo-list?
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 08-27-2020, 09:50 AM   #79
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
Default

each time i execute the script I posted above ( which is many as I am triggering it using mouse wheel to increase / decrease the track height ) it create a ReaScipt:Run

testing I noticed that the defer works just the first time I execute.

My hypothesis why defer is not working in this case: problem is that after one time running(that goes well) it is now in the background and then I can't execute it more times ( which is how it is supposed to work (see gif posts above)). So I need to exit the script after the defer, what is used to that reaper.atexit() ??

Code with defer
Code:
is_new_value,filename,sectionID,cmdID,mode,resolution,val = reaper.get_action_context()
if is_new_value then
 x, y = reaper.GetMousePosition()
 track, _ = reaper.GetTrackFromPoint(x,y)
   if track then
   old_height = reaper.GetMediaTrackInfo_Value(track,"I_TCPH")
    if val > 0 then
    reaper.SetMediaTrackInfo_Value(track, "I_HEIGHTOVERRIDE", (old_height+15))
    else
    reaper.SetMediaTrackInfo_Value(track, "I_HEIGHTOVERRIDE", (old_height-15))   
    end
   end
end
reaper.TrackList_AdjustWindows(false)
reaper.UpdateArrange()
reaper.defer()
daniellumertz is online now   Reply With Quote
Old 08-27-2020, 10:00 AM   #80
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,630
Default

Hmm..ok this is something I've never experienced so far.

This is probably the right time to post again one of my most popular feature-requests: https://forum.cockos.com/showthread.php?t=215672
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine 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:15 PM.


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