Old 10-27-2019, 10:05 PM   #521
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 2,877
Default

Is is not necessary. Just type reaper.Main_OnCommand rather than Main_OnCommand.
cfillion is offline   Reply With Quote
Old 10-28-2019, 05:07 AM   #522
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,482
Default

Quote:
Originally Posted by Zamyen View Post
for key in pairs(reaper) do _G[key]=reaper[key] end
FWIW, thats not recommended,
https://forum.cockos.com/showpost.ph...64&postcount=9
Edgemeal is offline   Reply With Quote
Old 10-31-2019, 01:01 AM   #523
estux
Human being with feelings
 
Join Date: Sep 2018
Posts: 47
Default

How do I clear (reset to default) the color of a track or item in lua?
estux is offline   Reply With Quote
Old 10-31-2019, 02:13 AM   #524
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 2,877
Default

Clear the 25th bit of I_CUSTOMCOLOR to disable a track or item's custom color.

Code:
local track = reaper.GetTrack(0, 0)
local color = reaper.GetMediaTrackInfo_Value(track, 'I_CUSTOMCOLOR')
color = color & ~(1<<8*3)
reaper.SetMediaTrackInfo_Value(track, 'I_CUSTOMCOLOR', color)
cfillion is offline   Reply With Quote
Old 10-31-2019, 02:33 AM   #525
estux
Human being with feelings
 
Join Date: Sep 2018
Posts: 47
Default

Quote:
Originally Posted by cfillion View Post
Clear the 25th bit of I_CUSTOMCOLOR to disable a track or item's custom color.

Code:
local track = reaper.GetTrack(0, 0)
local color = reaper.GetMediaTrackInfo_Value(track, 'I_CUSTOMCOLOR')
color = color & ~(1<<8*3)
reaper.SetMediaTrackInfo_Value(track, 'I_CUSTOMCOLOR', color)
Awesome, thanks!!
estux is offline   Reply With Quote
Old 10-31-2019, 05:34 PM   #526
Zamyen
Human being with feelings
 
Join Date: Dec 2008
Posts: 58
Default

Quote:
Originally Posted by cfillion View Post
Is is not necessary. Just type reaper.Main_OnCommand rather than Main_OnCommand.
Quote:
Originally Posted by Edgemeal View Post
Thanks a lot for the info and advice, I have managed to remove this from all my scripts as well.
Zamyen is offline   Reply With Quote
Old 10-31-2019, 10:00 PM   #527
IonianStreams
Human being with feelings
 
IonianStreams's Avatar
 
Join Date: May 2019
Location: Front Range Colorado
Posts: 7
Default JS "phase" variable

I recently began looking into phase correlation/cancellation issues. This got me looking into LOSER's "JS Channel Phase Meter" plugin and the JSFX code therein. LOSER uses the variable "phase" in this code. This is clearly a system variable as it is referenced without ever being initialized. And it is obviously some measure of phase correlation. But where is "phase" documented? What exactly does it measure? Why does it vary with his "Check Interval" slider? I don't find anything in the https://www.reaper.fm/sdk/js/js.php documentation on "phase". More generally, where does one find documentation/resources for the audio concepts in JSFX (i.e., beyond just JS syntax and basics)? [Maybe this should be in newbieland forum but I didn't see any JS Qs in there.]
__________________
I understand. At least I think I understand, which is the same thing... I think.
IonianStreams is offline   Reply With Quote
Old 10-31-2019, 10:48 PM   #528
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 8,130
Default

"phase" is just a normal variable.

It's set to zero and counted up and down.

-Michael
mschnell is offline   Reply With Quote
Old 11-01-2019, 03:53 AM   #529
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,987
Default

Quote:
Originally Posted by IonianStreams View Post
This is clearly a system variable as it is referenced without ever being initialized.
It's not a system variable, it's zeroed in the @block section of the code. The "t" variable is more suspect as it's never zeroed anywhere and is also not a system variable. (Could be Eel/JesuSonic always initializes user variables to zero, though...)
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is offline   Reply With Quote
Old 11-01-2019, 10:25 AM   #530
IonianStreams
Human being with feelings
 
IonianStreams's Avatar
 
Join Date: May 2019
Location: Front Range Colorado
Posts: 7
Default JS "phase" variable

Thanks mschnell and Xenakios. You're both absolutely right. This is my first look at JS and I completely missed that phase line in @samples!

In the bigger picture, what I'm after is a phase correlation meter that shows more than just a hyperactive, flickering dot/slider showing the instantaneous phase (and "JS Channel Phase Meter" doesn't even show that, only "IN" and "OUT"). For example, Ozone's free Imager meter shows such a dot that floats between -1 and 1. I find myself watching it and trying to take a mental average of the value over the length of the song section I'm investigating. Why not have the meter compute/display such an average? I've not seen this in any of the JS or free meters out there.

So I programmed something in JS that seems to work. Phase correlation is calculated as done by LOSER and output to a slider at every 1024 samples. The slider mimics the Imager dot pretty well. But the program also calculates a running average of the phase correlation while song is playing, showing it in another slider. Finds the min & max correlation too. Seems to work OK. First, am I missing something in this approach?

Second, I've read that phase is calculated not as 1 or -1 based on sign(spl's) agreement, but as ArcTangent(spl0/spl1). Any comments on this is much appreciated.
__________________
I understand. At least I think I understand, which is the same thing... I think.
IonianStreams is offline   Reply With Quote
Old 11-02-2019, 09:45 AM   #531
IonianStreams
Human being with feelings
 
IonianStreams's Avatar
 
Join Date: May 2019
Location: Front Range Colorado
Posts: 7
Default JS "phase" variable

I found another LOSER JSFX, "JS Stereo Field Manipulator", in which he calculates the phase "angle" using the atan(spl0/spl1) math I was asking about. He uses it to rotate the phase. I guess the best way to learn this stuff is just by studying the experts' code. Climbing the learning curve. It's pretty cool that Reaper offers the ability to program your own fx.
__________________
I understand. At least I think I understand, which is the same thing... I think.
IonianStreams is offline   Reply With Quote
Old 11-06-2019, 09:06 PM   #532
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 853
Default Determine recording MIDI items

Is there a way to efficiently determine the list of MIDI items that are being actively recorded at any given moment?

I say efficiently because I want to do this continuously within a deferred loop given that the target items can actually change over time (e.g. as the play cursor traverses over other MIDI items with MIDI overdub enabled).

Otherwise I'm sure I could figure out how to do it the slow way. (Fetch current play position, enumerate over all tracks, determine which tracks are armed for recording, enumerate MIDI items on each armed track, determine which MIDI items intersect with the play position.) But I'd rather not, because that way is *very* inefficient.
tack is online now   Reply With Quote
Old 11-08-2019, 10:38 AM   #533
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,672
Default

Quote:
Originally Posted by tack View Post
Is there a way to efficiently determine the list of MIDI items that are being actively recorded at any given moment?

I say efficiently because I want to do this continuously within a deferred loop given that the target items can actually change over time (e.g. as the play cursor traverses over other MIDI items with MIDI overdub enabled).

Otherwise I'm sure I could figure out how to do it the slow way. (Fetch current play position, enumerate over all tracks, determine which tracks are armed for recording, enumerate MIDI items on each armed track, determine which MIDI items intersect with the play position.) But I'd rather not, because that way is *very* inefficient.
You could try to select the items at cursorposition(don't know, if there's an action for that) and just check them, using GetSelectedMediaItem

https://mespotin.uber.space/Ultrasch...ectedMediaItem

This is way faster than checking all MediaItems.
You may need to revert the item-selection after that again.

Edit:
This action could work, you would need to temporarily move the editcursor for that and select all tracks:
_XENAKIOS_SELITEMSUNDEDCURSELTX - Xenakios/SWS: Select items under edit cursor on selected tracks
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 11-08-2019, 10:43 AM   #534
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 853
Default

Quote:
Originally Posted by mespotine View Post
You could try to select the items at cursorposition(don't know, if there's an action for that)
It's an interesting idea. There's an action to select items under the edit cursor, but alas I don't see one to select items under the play cursor (which is the one that advances during recording).
tack is online now   Reply With Quote
Old 11-08-2019, 10:45 AM   #535
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 853
Default

Quote:
Originally Posted by mespotine View Post
Edit:
This action could work, you would need to temporarily move the editcursor for that and select all tracks:
_XENAKIOS_SELITEMSUNDEDCURSELTX - Xenakios/SWS: Select items under edit cursor on selected tracks
Bearing in mind this would need to be called in each defer execution, I guess I'd have to move the edit cursor, run the action, and move it back, about 30 times a second.

Maybe that's not the end of the world if that honors PreventUIRefresh(). I'll give that a shot. Thanks for the idea!
tack is online now   Reply With Quote
Old 11-08-2019, 10:48 AM   #536
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,672
Default

It should survive 30 times per second, unless you work with thousands of tracks, according to my experiences.
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 11-08-2019, 11:11 AM   #537
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 853
Default

Quote:
Originally Posted by mespotine View Post
It should survive 30 times per second, unless you work with thousands of tracks, according to my experiences.
Well it was worth a shot, but it wreaks havoc on the undo history (Unselect all items + Select items under edit cursor in the undo history for each defer call). Also it doesn't seem to be possible to select items currently being recorded unless the track is set to one of the MIDI overdub/replace modes.

What I had wanted to do was to mimic Logic's behavior where recording MIDI items were red and active in the MIDI editor. That behavior isn't looking overly achievable in Reaper so far.

Thanks for the ideas anyway, mespotine!
tack is online now   Reply With Quote
Old 11-16-2019, 08:16 AM   #538
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Location: Croatia
Posts: 2,203
Default

Is there an easy way to import KeyMaps from ReaScript? I can't seem to find any API relevant for Lua scripts.

I would like to automatically update reaper-kb.ini and I would like to chose to only import actions/macros or only shortcuts from ReaperKeyMap files.

Bonus question: would it be possible to do the same for menus?
Breeder is offline   Reply With Quote
Old 11-17-2019, 09:48 AM   #539
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,672
Default

Short answer, no.
Long answer, I'm working on that for Ultraschall - Api.

Do you mean import at runtime or is importing with restart ok too?
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 11-19-2019, 04:03 AM   #540
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Location: Croatia
Posts: 2,203
Default

Quote:
Originally Posted by mespotine View Post
Short answer, no.
Long answer, I'm working on that for Ultraschall - Api.

Do you mean import at runtime or is importing with restart ok too?
Awesome. Runtime is always the best, but in my case, I can just ask the user to restart.
Maybe it would be possible through an extenstion to get it at runtime?
Breeder is offline   Reply With Quote
Old 11-19-2019, 09:02 AM   #541
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,672
Default

Yes, for more information on that, just head over to this thread:
https://forum.cockos.com/showthread.php?t=226007

Edit: Menus wouldn't be possible that way, but I don't know much about the C++-only-Reaper-functions, who allow accessing the menu. Maybe it's possible that way...
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 11-27-2019, 02:51 PM   #542
BirdBird
Human being with feelings
 
BirdBird's Avatar
 
Join Date: Mar 2019
Posts: 60
Default

How to call custom action from a script? I am trying to call a custom action through a lua script like: reaper.Main_OnCommand(reaper.NamedCommandLookup( "_749daf2e6c9d244d99884fae060ecce6"), 0, 0)

But the action is not triggering for some reason, is there anything that i am missing?
BirdBird is online now   Reply With Quote
Old 11-27-2019, 05:02 PM   #543
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,672
Default

In which section is the action? Main?
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 11-27-2019, 05:08 PM   #544
BirdBird
Human being with feelings
 
BirdBird's Avatar
 
Join Date: Mar 2019
Posts: 60
Default

The command is on the MIDI Editor, is there a different call in the API for that?

Edit: Thanks, there is, i just saw it
BirdBird is online now   Reply With Quote
Old 11-28-2019, 09:26 AM   #545
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,672
Default

Can we access gmem-states from the C++-extension-API somehow?
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
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 09:08 AM.


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