Old 02-10-2021, 11:42 AM   #761
GameAudioRvlzzr
Human being with feelings
 
GameAudioRvlzzr's Avatar
 
Join Date: Apr 2016
Location: Stuttgart, Germany
Posts: 217
Default

Quote:
Originally Posted by amagalma View Post
You can do it in one script.
Code:
reaper.atexit(function() return end)

function main()
  state = reaper.JS_VKeys_GetState( 0 )
  if state:byte( 0x41 ) == 1 then
    reaper.ShowConsoleMsg("you pressed A\n")
  end
  reaper.defer(main)
end

main()
Turns out, that triggers more than 1 time with each keypress. I tries using getUp insteaf of getState, but that got really weird, triggering constantly, wether i pressed or not.

How do i get 1 keypress detection only?
GameAudioRvlzzr is offline   Reply With Quote
Old 02-10-2021, 02:31 PM   #762
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by GameAudioRvlzzr View Post
Turns out, that triggers more than 1 time with each keypress. I tries using getUp insteaf of getState, but that got really weird, triggering constantly, wether i pressed or not.

How do i get 1 keypress detection only?

Code:
reaper.atexit(function() return end)

local time = reaper.time_precise()
function main()
  local state = reaper.JS_VKeys_GetUp( time )
  if state:byte( 0x41 ) == 1 then
    reaper.ShowConsoleMsg("you pressed A\n")
    time = reaper.time_precise()
  end
  reaper.defer(main)
end

main()
__________________
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 02-10-2021, 03:48 PM   #763
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

Quote:
Originally Posted by amagalma View Post
It will execute. If you don't want it to execute or want it to execute under some circumstances, or want it to do different things depending on the context, then intercept the key and do not let it pass through to Reaper but do your stuff
Good to know! How do you normally intercept so it won't get to reaper in a script?
daniellumertz is online now   Reply With Quote
Old 02-11-2021, 08:08 AM   #764
GameAudioRvlzzr
Human being with feelings
 
GameAudioRvlzzr's Avatar
 
Join Date: Apr 2016
Location: Stuttgart, Germany
Posts: 217
Default

Quote:
Originally Posted by amagalma View Post
Code:
reaper.atexit(function() return end)

local time = reaper.time_precise()
function main()
  local state = reaper.JS_VKeys_GetUp( time )
  if state:byte( 0x41 ) == 1 then
    reaper.ShowConsoleMsg("you pressed A\n")
    time = reaper.time_precise()
  end
  reaper.defer(main)
end

main()
Yes, thank you very much!

Quote:
Originally Posted by daniellumertz View Post
Good to know! How do you normally intercept so it won't get to reaper in a script?
I‘d like to know that, too.
GameAudioRvlzzr is offline   Reply With Quote
Old 02-11-2021, 12:04 PM   #765
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Using reaper.JS_VKeys_Intercept( keyCode, intercept )
__________________
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 02-11-2021, 01:17 PM   #766
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

This should be used very carefully, as you can make Reaper quite non-working, as intercepting the key means, Reaper will not get it.

Haven't checked, if things like the markerlist could be affected, that typing in markertitles could lack the intercepted key.
So especially if you intend to release this script using this function, test it intensely to avoid non-working Reaper-installations(at least keyboard wise non-working).

Or as Spidey said: with great power comes great responsibility.
__________________
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 02-11-2021, 02:34 PM   #767
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

I double what Mespotine said! Interceptions must be used very carefully! The worst thing that can happen is leaving Reaper in an unresponsive state where you will have to exit (or kill the process) without being able to save...
__________________
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 02-11-2021, 09:35 PM   #768
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

thanks for the warning message ! Will take care if I use it ! No script in my mind currently that would use this ( currently I am not coding anything but i am already with saudade, yesteday I open some code in VScode and was like ahnm)
daniellumertz is online now   Reply With Quote
Old 02-12-2021, 04:28 AM   #769
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

I am doing substantial but very careful use of mouse and window messages interceptions in my ripple edge editing script. Actually, without these the script could not be what it is.
__________________
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 02-12-2021, 01:41 PM   #770
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

I have seen the thread and sometimes go there to read the news ! It is something I might someday buy it ! Now I don't have the money (even for the discounted ) as R$ is going down the hill in this Brazilian governament + pandemic ...

Someday, someday!!!

Thx for creating it, it is awesome to have you around!
daniellumertz is online now   Reply With Quote
Old 02-12-2021, 01:53 PM   #771
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Thank you It's awesome for me too to be here along such good people
__________________
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 02-15-2021, 02:22 PM   #772
hapibeli
Human being with feelings
 
hapibeli's Avatar
 
Join Date: Feb 2011
Location: British Columbia
Posts: 62
Default Ext to force Reaper to allow release of sound control while using different program

Is there? May be silly I know...yet?
__________________
Jesus is coming...Look busy!
hapibeli is offline   Reply With Quote
Old 02-15-2021, 03:56 PM   #773
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

You mean like disabling the current audio device so it can be used by another one?
If yes, then it's no, unfortunately.
__________________
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 02-15-2021, 04:36 PM   #774
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Preferences > Audio > Close audio device when stopped and application is inactive. There's also Audio_Quit in the API for closing the audio device from scripts.

Or if you meant unlocking the media files for use in other programs: Preferences > Media > Set media items offline when application is inactive. For scripts there's CF_GetMediaSourceOnline in SWS (alternative is running the "Item: Set all media offline" action).
cfillion is offline   Reply With Quote
Old 02-15-2021, 05:12 PM   #775
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
Originally Posted by cfillion View Post
Preferences > Audio > Close audio device when stopped and application is inactive. There's also Audio_Quit in the API for closing the audio device from scripts.
Didn't think of that one.

This feature should be toggleable by changing the configuration variable audiocloseinactive as well.

https://mespotin.uber.space/Ultrasch...ocloseinactive
__________________
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 04-22-2021, 06:28 AM   #776
inframan
Human being with feelings
 
Join Date: Apr 2009
Posts: 91
Default how to get # of last measure in project

is there a simple command to get the bar number of last measure in project, or do I need to use some combination of TimeMap functions ?
inframan is offline   Reply With Quote
Old 04-23-2021, 01:39 PM   #777
Lopez
Human being with feelings
 
Join Date: Aug 2011
Location: Germany
Posts: 241
Default

Hey guys, I need some really noob'ish help.

I just want a simple "info" window which translates actual bpm setting to ms or s.
So far, no problem, I managed it with lua to get an console output like this:



Actually, it contains all I want however, it could be a bit improved:
  • dockable, like a toolbar
  • follow bpm changes
  • aligned (eg 1/1 left, 2000ms right, you got the idea)
  • look like the active theme, so let's say "more beautiful" at all

It can't be a big deal or take more than some hours, even for me as lua rookie, I'm able to code but I have no idea where to start :/

Here's the code from the plugin, don't laugh too hard, it's my very first one


Code:
function main()

reaper.ClearConsole();

winWidth   = 200
winHeight  = 400
rounder    = 1

bpm =  reaper.Master_GetTempo();
reaper.ShowConsoleMsg("BPM   = " .. bpm .. "\n\n");

check_ms_onlyFull(bpm);

reaper.ShowConsoleMsg("\n\n");

check_ms_fullBars(bpm);

end


function check_msALL (bpm)
  local mSeconds = 60000 / bpm

  reaper.ShowConsoleMsg("1/1.  = "  ..  round((mSeconds * 6), rounder) .. " ms" .. "\n");
  reaper.ShowConsoleMsg("1/1   = "  ..  round(mSeconds * 4, rounder) .. " ms" .. "\n");
  reaper.ShowConsoleMsg("1/1T  = "  ..  round(mSeconds * 2.666, rounder) .. " ms" .. "\n");
  
  reaper.ShowConsoleMsg("1/2.   = "  ..  round(mSeconds * 3, rounder) .. " ms" .. "\n");
  reaper.ShowConsoleMsg("1/2   = "  ..  round(mSeconds * 2, rounder) .. " ms" .. "\n");
  reaper.ShowConsoleMsg("1/2T  = "  ..  round(mSeconds * 1.333, rounder) .. " ms" .. "\n");
  
  reaper.ShowConsoleMsg("1/4   = "  ..  round(mSeconds * 1, rounder) .. " ms" .. "\n");
  reaper.ShowConsoleMsg("1/4.  = "  ..  round(mSeconds * 1.5, rounder) .. " ms" .. "\n");
  reaper.ShowConsoleMsg("1/4T  = "  ..  round(mSeconds * 0.666, rounder) .. " ms" .. "\n"); 
  
  reaper.ShowConsoleMsg("1/8   = "  ..  round(mSeconds * 0.5, rounder) .. " ms" .. "\n");
  reaper.ShowConsoleMsg("1/8.  = "  ..  round(mSeconds * 0.75, rounder) .. " ms" .. "\n");
  reaper.ShowConsoleMsg("1/8T  = "  ..  round(mSeconds * 0.333, rounder) .. " ms" .. "\n");
  
  reaper.ShowConsoleMsg("1/16  = " ..  round(mSeconds * 0.25, rounder) .. " ms" .. "\n");
  reaper.ShowConsoleMsg("1/16. = " ..  round(mSeconds * 0.375, rounder) .. " ms" .. "\n");
  reaper.ShowConsoleMsg("1/16T = " ..  round(mSeconds * 0.1665, rounder) .. " ms" .. "\n");
  
  reaper.ShowConsoleMsg("1/32  = " ..  round(mSeconds * 0.125, rounder) .. " ms" .. "\n");
  reaper.ShowConsoleMsg("1/32. = " ..  round(mSeconds * 0.1875, rounder) .. " ms" .. "\n");
  reaper.ShowConsoleMsg("1/32T = " ..  round(mSeconds * 0.08325, rounder) .. " ms" .. "\n");
  

end

function check_ms_onlyFull (bpm)
  local mSeconds = 60000 / bpm

  reaper.ShowConsoleMsg("1/1   = "   ..  round(mSeconds * 4,     rounder) .. " ms" .. "\n");
  reaper.ShowConsoleMsg("1/2   = "   ..  round(mSeconds * 2,     rounder) .. " ms" .. "\n");
  reaper.ShowConsoleMsg("1/4   =  "  ..  round(mSeconds * 1,     rounder) .. " ms" .. "\n");
  reaper.ShowConsoleMsg("1/8   =  "  ..  round(mSeconds * 0.5,   rounder) .. " ms" .. "\n");
  reaper.ShowConsoleMsg("1/16  =  "  ..  round(mSeconds * 0.25,  rounder) .. " ms" .. "\n");
  reaper.ShowConsoleMsg("1/32  =   " ..  round(mSeconds * 0.125, rounder) .. " ms" .. "\n");
 

end


function check_ms_fullBars (bpm)
  local mSeconds = 60 / bpm

  reaper.ShowConsoleMsg("1  bar  =  "   ..  round(mSeconds * 4,     rounder) .. " s" .. "\n");
  reaper.ShowConsoleMsg("2  bars =  "   ..  round(mSeconds * 8,     rounder) .. " s" .. "\n");
  reaper.ShowConsoleMsg("4  bars =  "   ..  round(mSeconds * 16,     rounder) .. " s" .. "\n");
  reaper.ShowConsoleMsg("8  bars = "   ..  round(mSeconds * 32,     rounder) .. " s" .. "\n");
  reaper.ShowConsoleMsg("16 bars = "   ..  round(mSeconds * 64,     rounder) .. " s" .. "\n");
  reaper.ShowConsoleMsg("32 bars = "   ..  round(mSeconds * 128,     rounder) .. " s" .. "\n");
 

end



function round(number, decimals)
  local power = 10^decimals
  return math.floor(number * power) / power
end

main()
__________________
Lopez is offline   Reply With Quote
Old 04-24-2021, 09:17 AM   #778
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default

Quote:
Originally Posted by Lopez View Post
Hey guys, I need some really noob'ish help.

I just want a simple "info" window which translates actual bpm setting to ms or s.
So far, no problem, I managed it with lua to get an console output like this:



Actually, it contains all I want however, it could be a bit improved:
  • dockable, like a toolbar
  • follow bpm changes
  • aligned (eg 1/1 left, 2000ms right, you got the idea)
  • look like the active theme, so let's say "more beautiful" at all

It can't be a big deal or take more than some hours, even for me as lua rookie, I'm able to code but I have no idea where to start :/
It sounds like you want to do 2 things. Build a GUI and run your script as deferred to continue to update. I would start with learning to run a deferred script. There are lots of great resources on the forums for that.

As far as building a GUI, there are again a lot of great resources for it in the forum, but it’s going to take you a lot longer to work on and is much more time consuming than “a couple of hours”. Lokasenna GUI2 or SCYTHE are great places to start learning about GUI in reaper
__________________
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 04-25-2021, 08:02 AM   #779
Lopez
Human being with feelings
 
Join Date: Aug 2011
Location: Germany
Posts: 241
Default

Different question:

Is it possible to modify theme settings via lua, e.g. "master.mcp.fxlist.font" which is set in rtconfig?

I can change font on a global way via
Actions -> Theme Development -> Walter font 1

So,... it should be possible to change it via lua as well, doesn't it?

Something like this has no effect :/
Code:
reaper.ThemeLayout_SetLayout( 'master.mcp.fxlist.font', 'whateverHereComesItHasNoEffect-yet' );
Any help highly appreciated!
__________________
Lopez is offline   Reply With Quote
Old 04-25-2021, 08:13 AM   #780
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
Originally Posted by Lopez View Post
Different question:

Is it possible to modify theme settings via lua, e.g. "master.mcp.fxlist.font" which is set in rtconfig?

I can change font on a global way via
Actions -> Theme Development -> Walter font 1

So,... it should be possible to change it via lua as well, doesn't it?

Something like this has no effect :/
Code:
reaper.ThemeLayout_SetLayout( 'master.mcp.fxlist.font', 'whateverHereComesItHasNoEffect-yet' );
Any help highly appreciated!
Not this way.

Fonts themselves can only be changed in the theme editor itself (Options -> Theme -> Theme Editor), not programmatically.


The ThemeLayout-functions themselves work together with a concept called Theme-parameters. They need to be added deliberately into a theme to be influenced.
So to influence anything of master.mcp.fxlist.font, you need to make it influenceable in the theme itself.

In this thread, I made a demo for how theme-parameters work and how you can influence them via API(using a minimal theme and a script for influencing them):
https://forums.cockos.com/showthread.php?t=227833

In this thread, I showed my own theme-parameter monitor. If you use this, you can see, which theme-parameters are supported by the current theme and can be influenced.
The default v6-theme has numerous ones, but most other themes don't have any.

But it will not have an influence on fonts afaik, rather on positions/sizes of theme-elements.
__________________
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 04-25-2021, 09:28 AM   #781
Lopez
Human being with feelings
 
Join Date: Aug 2011
Location: Germany
Posts: 241
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Not this way.
(...)
But it will not have an influence on fonts afaik, rather on positions/sizes of theme-elements.
First, thanks for your answer!!

I _can_ change the font size via Actions -> Theme development



But its a lot of clickin' around and not handy for moles like me

This is crazy... you can change almost everything within Reaper, even with scripting, BUT the font size. Can anyone explain why!?

Don't feel offended, it's a serious question, I'd like to have a "increase/decrease font size" button, if necessary for each Walter font so far.

For me, this would be helpful, making Reaper more accessible.

Maybe I need to open a feature request to get such a functionality!?
Attached Images
File Type: png Theme_development.png (11.9 KB, 673 views)
__________________
Lopez is offline   Reply With Quote
Old 04-25-2021, 10:37 AM   #782
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Fontsizes can not be changed really at runtime, maybe by adjusting themes some can be adjusted.

There are numerous people who have a problem with too small fontsizes recently in Reaper, so there's actually a FR for such things, so you should chime in there:

https://forum.cockos.com/showthread.php?t=239893

It also mentions a hack of Reaper, which seems to be able to customize the fontsize, but it is a hack and not official.
__________________
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 04-27-2021, 07:14 AM   #783
daeavelwyn
Human being with feelings
 
daeavelwyn's Avatar
 
Join Date: Dec 2014
Posts: 597
Default

Hi guys,

Quite a noob qestion here, I'd like to iterate throught chords in a MIDI item to put a text event on each chord.

Actually chords are one bar long and i've set my grid to whole note so reaper.MIDI_GetGrid(take) give me 4.0

I've tried several stuff with "MIDI_GetProjTimeFromPPQPos","MIDI_GetPPQPosFromPr ojTime", "MIDI_GetProjQNFromPPQPos" and stuff like that but can' figure which is the best way to do this simple thing :-s

I take any advices !
daeavelwyn is offline   Reply With Quote
Old 04-27-2021, 08:16 AM   #784
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

Hm, the info you need is the time in QN or beats or seconds of where is a chord?
(I never insert text which action is it? reaper.MIDI_SetTextSysexEvt() ?)


Also you can do as you are doing hardcoding each 4 QuarterNote, but you could also check if there is 3 or more (or even 2 or more) notes played together(or in a time range) and if there is insert the text.

I would like to know what function you are trying to use to try to help more...
daniellumertz is online now   Reply With Quote
Old 04-27-2021, 08:28 AM   #785
daeavelwyn
Human being with feelings
 
daeavelwyn's Avatar
 
Join Date: Dec 2014
Posts: 597
Default

Hello Daniel,

Quote:
Originally Posted by daniellumertz View Post
Hm, the info you need is the time in QN or beats or seconds of where is a chord?
Thanks for your answer, i'm quite already aware that I have to use QN and PPQN, but I'm looking for the best logical way to manage them while the goal is starting from the first note of the active take and going to the end of the take. In fact, I'm more looking for snippets if some reascript's Jedi like you could provide some, it'd really help me to have a better understanding of all those concepts !


Quote:
Originally Posted by daniellumertz View Post
(I never insert text which action is it? reaper.MIDI_SetTextSysexEvt() ?)
yes, I use "reaper.MIDI_InsertTextSysexEvt( take, true, false, chordPos, 6, chord ) -- Text Event Type 6 Insert Midi Marker " to insert textEvent

Quote:
Originally Posted by daniellumertz View Post
Also you can do as you are doing hardcoding each 4 QuarterNote, but you could also check if there is 3 or more (or even 2 or more) notes played together(or in a time range) and if there is insert the text.
I'd rather to avoid this if there is a faster and better solution :-/

Quote:
Originally Posted by daniellumertz View Post
I would like to know what function you are trying to use to try to help more...
In fact, actually I have no function yet. I have done some works to get a parsed string returning a chord from selected notes which works very well but I want to put chords every grid set by user (for example every measure) and I can't understand which is the best way to travel throught an item.

Last edited by daeavelwyn; 04-27-2021 at 08:33 AM.
daeavelwyn is offline   Reply With Quote
Old 04-27-2021, 03:32 PM   #786
daeavelwyn
Human being with feelings
 
daeavelwyn's Avatar
 
Join Date: Dec 2014
Posts: 597
Default

Ok, so i'm still investigating over the way reaper use ppqn, qn and time and got in trouble with some points. I got a midi item starting at measure 5 at a tempo of 87.

So if i'm right, the two expressions below should return the same resutl no ?

but the first returns : 11.033764367816 and the second returns : 11.037356321839

Code:
item_startPos=reaper.GetMediaItemInfo_Value( item, "D_POSITION")-- get start of item
Debug("item start position : "..item_startPos)
		
test2= reaper.MIDI_GetProjTimeFromPPQPos( take, 5)
Debug(test2)
Please help me to know where I'm wrong !
daeavelwyn is offline   Reply With Quote
Old 04-27-2021, 04:44 PM   #787
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

Hm nooo Using reaper.MIDI_GetProjTimeFromPPQPos(take, 5) you are getting the position of the 5 PPQ of the Item. But reaper.MIDI_GetProjTimeFromPPQPos(take, 0) Is where the item start.

PPQ are a measure of Pulses Per Quarter note (PPQ). Reaper in preferences:Media:MIDI have by default 960 Ticks(Pulses) per quarter note. So requesting reaper.MIDI_GetProjTimeFromPPQPos(take, 5) will give the time 5 pulses after the start

Consider:
Code:
  function print(var)
    reaper.ShowConsoleMsg(tostring(var).."\n")
  end
  
  reaper.ClearConsole()
  
  local item = reaper.GetSelectedMediaItem(0,0)
  local take = reaper.GetMediaItemTake(item,0)
  local dposition = reaper.GetMediaItemInfo_Value( item, "D_POSITION")
  local ppq0 = reaper.MIDI_GetProjTimeFromPPQPos(take, 0)
  local ppq5 = reaper.MIDI_GetProjTimeFromPPQPos(take, 5)
  
  print("with reaper.GetMediaItemInfo_Value( item, D_POSITION)  is where Item Start in seconds: "..dposition )
  print("with reaper.MIDI_GetProjTimeFromPPQPos(take, 0) is where is the 0 PPQ position of the take (AKA where it start) in seconds: "..ppq0 )
  print("with reaper.MIDI_GetProjTimeFromPPQPos(take, 5) is where is the 5 PPQ position of the take in seconds: "..ppq5 )
daniellumertz is online now   Reply With Quote
Old 04-27-2021, 05:41 PM   #788
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 1,992
Default

How I would calculate where to insert each item

Code:
  function print(var)
    reaper.ShowConsoleMsg(tostring(var).."\n")
  end
  
  reaper.ClearConsole()
  
  local item = reaper.GetSelectedMediaItem(0,0)
  local take = reaper.GetMediaItemTake(item,0)
  
function BeatToPPQ(beat, ppqvalue) --Calculate the ppq, based on a beat value. 
   local beat = beat - 1
   return beat * ppqvalue
end
 
 reaper.MIDI_InsertTextSysexEvt( take, false, false, 0, 1, "Start Item" )
 local bar1beat2 = BeatToPPQ(1, 960) -- I will hardcode ppqvalue 
 reaper.MIDI_InsertTextSysexEvt( take, false, false, bar1beat2, 1, "1Bar 2Beat" )
 local bar2 = BeatToPPQ(5, 960) -- I will hardcode ppqvalue 
 reaper.MIDI_InsertTextSysexEvt( take, false, false, bar2, 1, "2Bar" )
 local bar4beat3 = BeatToPPQ(4+4+4+3, 960) -- I will hardcode ppqvalue
 reaper.MIDI_InsertTextSysexEvt( take, false, false, bar4beat3, 1, "4Bar 3Beat" )
 local bar4beat4dot5 = BeatToPPQ(4+4+4+4.5, 960) -- I will hardcode ppqvalue
 reaper.MIDI_InsertTextSysexEvt( take, false, false, bar4beat4dot5, 1, "4Bar 4.5Beat" )
Also I would not hardcode the ppq value, I can see latter how to get it. But if anyone knows how to get ppq resolution value of a item
daniellumertz is online now   Reply With Quote
Old 04-29-2021, 05:53 AM   #789
daeavelwyn
Human being with feelings
 
daeavelwyn's Avatar
 
Join Date: Dec 2014
Posts: 597
Default

Hello Daniel,

Sorry for the late reply, I've been very busy the last two days. Thanks a lot foryour answer, it really helps me to have a better understanding of those mechanism. I have now to dig deeper in on my side and make my own tests.

regards
daeavelwyn is offline   Reply With Quote
Old 05-03-2021, 07:55 PM   #790
humbuckr
Human being with feelings
 
Join Date: Jan 2017
Posts: 1
Default How to write script to automate loading a vst plug-in and processing audio files

Noob to Reascript. Here's what I'd like to do, would love to know if Reascript handles this kind of thing.

I need to be able to process several dry unprocessed mono audio files (about 10 seconds in length) through a VST plugin with a provided preset and save 4 distinct stereo audio files.

dry-file1.wav (mono) > pluginA using preset file > processed-file1.wav (stereo)
dry-file2.wav (mono) > pluginA using preset file > processed-file2.wav (stereo)
dry-file3.wav (mono) > pluginA using preset file > processed-file3.wav (stereo)
dry-file4.wav (mono) > pluginA using preset file > processed-file4.wav (stereo)

thanks for this forum and the offer to ask questions.
humbuckr is offline   Reply With Quote
Old 05-04-2021, 12:20 AM   #791
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
Originally Posted by humbuckr View Post
Noob to Reascript. Here's what I'd like to do, would love to know if Reascript handles this kind of thing.

I need to be able to process several dry unprocessed mono audio files (about 10 seconds in length) through a VST plugin with a provided preset and save 4 distinct stereo audio files.

dry-file1.wav (mono) > pluginA using preset file > processed-file1.wav (stereo)
dry-file2.wav (mono) > pluginA using preset file > processed-file2.wav (stereo)
dry-file3.wav (mono) > pluginA using preset file > processed-file3.wav (stereo)
dry-file4.wav (mono) > pluginA using preset file > processed-file4.wav (stereo)

thanks for this forum and the offer to ask questions.
Use BatchConverter, which allows using FXChains.
So create an FXChain with all presets-settings, save it as RFXChain-file and process it using the BatchConverter, which allows using RFXChain-files.
__________________
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 05-12-2021, 12:04 AM   #792
sonictim
Human being with feelings
 
sonictim's Avatar
 
Join Date: Feb 2020
Location: Los Angeles
Posts: 463
Default RPP-PROX dragged to timeline

I'm playing around with the idea of exporting/archiving subprojects elsewhere on my drive.

Once I've successfully done this (created a new subproject session, created the RPP-PROX) in a folder other than the default subproject folder for my project, if I drag the RPP-PROX onto my timeline, it says OFFLINE. If I look at the source media info, it is looking for material in the subproject directory of the session, and not where the session I created the RPP-PROX is located.

I started playing around with the action "File: Save project and render RPP-PROX". I would assume it would create an RPP-PROX that points to the project I ran the action on, but again, this doesn't seem to be the case.


So this is puzzling to me, and leads me to the following questions.

Can an RPP-PROX be dragged to the timeline and successfully link to the subproject it represents? If so, are there specific rules about how to accomplish this? If not, why the heck not?

*UPDATE - it appears I CAN drag an RPP-PROX into my project, but only if it is created by the project in the project's default subproject directory. The second I move the .RPP/.RPP-PROX out of that directory and try to drag into my session, it no longer finds the session and declares the media offline.

Is this a bug? I'd assume an RPP-PROX should open from any location on my computer.

**SECOND UPDATE - No idea what happened. I just reinstalled Reaper and now I can drag in RPP-PROX from anywhere. Leaving this post in case anyone else has the same trouble.
__________________
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!

Last edited by sonictim; 05-13-2021 at 05:48 PM.
sonictim is offline   Reply With Quote
Old 05-18-2021, 05:31 AM   #793
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default

Hi folks!
I'm trying to make an eel script based on mouse focus. So I need get is the mouse on item or not.
But this code is shown as wrong. What I missed, could anybody help?
Code:
#refstring="item";
x=strcmp(#refstring,BR_GetMouseCursorContext(#details ));
AZpercussion is offline   Reply With Quote
Old 05-18-2021, 05:43 AM   #794
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
Originally Posted by AZpercussion View Post
Hi folks!
I'm trying to make an eel script based on mouse focus. So I need get is the mouse on item or not.
But this code is shown as wrong. What I missed, could anybody help?
Code:
#refstring="item";
x=strcmp(#refstring,BR_GetMouseCursorContext(#details ));
What do you mean exactly with wrong? Does it show an error-message? Or does it highlight parts of your code?
__________________
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 05-18-2021, 05:53 AM   #795
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
What do you mean exactly with wrong? Does it show an error-message? Or does it highlight parts of your code?
It shows a message that second string in this code undefined and selects this string.
AZpercussion is offline   Reply With Quote
Old 05-18-2021, 10:17 AM   #796
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by AZpercussion View Post
Hi folks!
I'm trying to make an eel script based on mouse focus. So I need get is the mouse on item or not.
But this code is shown as wrong. What I missed, could anybody help?
Code:
#refstring="item";
x=strcmp(#refstring,BR_GetMouseCursorContext(#details ));
I'm not fluent with eel but this seems to work:
Code:
BR_GetMouseCursorContext(#window,#segment,#details);
x=strcmp(#details,"item");// x is 0 if mouse is over item, -1 otherwise
But I'd suggest using native functions GetMousePosition and GetItemFromPoint instead of BR_GetMouseCursorContext as it seems more reliable I've read here.

And is there a specific reason you use eel instead of Lua, personally I find Lua easier but that may depend on habits of course.
nofish is offline   Reply With Quote
Old 05-18-2021, 11:40 AM   #797
benmrx
Human being with feelings
 
benmrx's Avatar
 
Join Date: Aug 2010
Posts: 396
Default

Quote:
Originally Posted by nofish View Post
I'd suggest using native functions GetMousePosition and GetItemFromPoint instead of BR_GetMouseCursorContext as it seems more reliable I've read here.
I can only say that I'm using those two functions above a LOT in quite a few scripts and I haven't run into any issues yet.
benmrx is offline   Reply With Quote
Old 05-18-2021, 01:44 PM   #798
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by benmrx View Post
I can only say that I'm using those two functions above a LOT in quite a few scripts and I haven't run into any issues yet.
At least for getting track under mouse using BR_GetMouseCursorContext there do seem to be issues (https://github.com/reaper-oss/sws/issues/1519), could well be that I thought about that.
nofish is offline   Reply With Quote
Old 05-18-2021, 02:41 PM   #799
AZpercussion
Human being with feelings
 
Join Date: Oct 2019
Location: Moscow / Tbilisi
Posts: 909
Default

Quote:
Originally Posted by nofish View Post
I'm not fluent with eel but this seems to work:
Code:
BR_GetMouseCursorContext(#window,#segment,#details);
x=strcmp(#details,"item");// x is 0 if mouse is over item, -1 otherwise
Thanks! But it don't want to work, and in lua too...
I choose eel just becouse of reaper have it's description and I tried to write simple js plugins before.
Anyway, thanks, I'll try with these native functions.
AZpercussion is offline   Reply With Quote
Old 05-19-2021, 06:02 AM   #800
FNGL
Human being with feelings
 
FNGL's Avatar
 
Join Date: Jun 2018
Location: Norway
Posts: 5
Default Get list of groups and filter out the used groups?

Hi! This is my first time writing my own ReaScript, so I'm in need of some basic help.

I'm trying to make a script that can group things for me on an unused group. So, I'm wondering how I can get a list of groups? And if there is an obvious way to filter out the groups that are busy, I'd love to hear about that too!
FNGL 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 11:34 AM.


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