Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Feature Requests

Reply
 
Thread Tools Display Modes
Old 12-01-2020, 09:19 AM   #1
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 3,232
Default req: API:reaper.GoToRegion( in the next 16th/8th/bar)

we have this API:
reaper.GoToRegion(ReaProject proj, integer region_index, boolean use_timeline_order)

which does:
Seek to region after current region finishes playing (smooth seek).

request: A way that in this api we can just do the same but for Seek to region:
- in the next 16th note
- in the next 8th note
- in the next bar
- in the next two bars
- immediately

benefit: extra musical timing option for live performance, instead of the fixed region length
__________________
i had to come back !
deeb is online now   Reply With Quote
Old 12-30-2020, 02:00 AM   #2
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 3,232
Default

Maybe not clear but this enables an Ableton live way of performing (without multiple starting play back positions) but still would be amazing to do performances and record on the fly without being constrained with fixed structures, since we could change to new section musically however we feel.

Would be amazing 2021 start like this.
__________________
i had to come back !
deeb is online now   Reply With Quote
Old 02-17-2021, 09:52 AM   #3
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 3,232
Default

bump trigger! this is supper useful for live/djing/looper style coff coff for you too justin!
__________________
i had to come back !
deeb is online now   Reply With Quote
Old 02-20-2021, 05:40 AM   #4
lexaproductions
Human being with feelings
 
Join Date: Jan 2013
Posts: 657
Default

Yeah this is doable. The only problem is that you can’t be more precise than 33ms so depending on you tempo, you may feel some changes.
Also 16th or 8ths are risky as you need enough triggering time for it to work.
lexaproductions is online now   Reply With Quote
Old 02-20-2021, 07:03 AM   #5
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 3,232
Default

Quote:
Originally Posted by lexaproductions View Post
Yeah this is doable. The only problem is that you can’t be more precise than 33ms so depending on you tempo, you may feel some changes.
Also 16th or 8ths are risky as you need enough triggering time for it to work.
Thank you lexaproductions for your input!

if done natively it can’t be more precise than 33ms? you mean for fast triggering things that will quickly happen like 16th or 8ths?

Ableton has something similar to this i guess and is precise! missing tempo (even sligthly) is a no no no i think ...!
__________________
i had to come back !
deeb is online now   Reply With Quote
Old 02-20-2021, 07:21 AM   #6
lexaproductions
Human being with feelings
 
Join Date: Jan 2013
Posts: 657
Default

Yeah. Reaper's internal smooth seek function is very tight. But as far as I know, it only works on regions and or bars. Don't think you can use it on eight and 16ths.
lexaproductions is online now   Reply With Quote
Old 02-21-2021, 07:14 PM   #7
lexaproductions
Human being with feelings
 
Join Date: Jan 2013
Posts: 657
Default

Try these and let me know if it works. Like I said, Only Region and Bar are very tight. The others are hit and miss... I still use the defer method for stuff that is non critical. Works great.

This is the example for Bar Smooth Seek. They're all the same script, only the "seek_mode" parameter changes for each seeking value.
Code:
--------------------------------------
----------|| HEADER ||----------------
--------------------------------------
--[[
 * ReaScript Name: SmoothSeek.lua
 * Description: Smooth seeking to edit cursor regardless of the Setting in the preferences->Seeking page
 * Instructions: Make copies of this script and set the "seek_mode" parameter accordingly to what you want it to do.
 * Author: Alex Paquette
 * Licence: GPL v3
 * Extensions Needed: SWS|S&M - JS_API
 * Version: 1.0
--]]


-----------------------------------------------------------
---------|| INIT ||----------------------------------------
-----------------------------------------------------------
local reaper, gfx, string, table, math = reaper, gfx, string, table, math


---------|| parameter ||-----------------------------------
local padding = 0
local seek_mode = 1 -- Seek after target finishes --> 0:Region 1:Bar, 2:1/4, 3:1/8, 4:1/16, 5:1/3


-----------------------------------------------------------
---------|| FUNCTIONS ||-----------------------------------
-----------------------------------------------------------
function GetBoundaries(time, proj)
	proj = proj or 0
	local bar = {}
	local _, msr = reaper.TimeMap2_timeToBeats(proj, time)
	local beat_qn = reaper.TimeMap2_timeToQN(proj,time)
	local curbeat_time = reaper.TimeMap2_QNToTime(proj,beat_qn)
	bar.nextbeat = reaper.TimeMap2_QNToTime(proj,beat_qn+1)
	bar.nexteight = ((bar.nextbeat - curbeat_time)/2)+curbeat_time
	bar.nextsixteenth = ((bar.nextbeat - curbeat_time)/4)+curbeat_time
	bar.nexttriplet = ((bar.nextbeat - curbeat_time)/3)+curbeat_time
	return bar
end

---------------------------------------------
function Seek_Native(mode)
	local targetTime = reaper.GetCursorPosition()
	local currState = reaper.SNM_GetIntConfigVar('smoothseek', -1)
	if mode == 0 then mode = 3 end
	reaper.SNM_SetIntConfigVar('smoothseek', mode) -- Change the Smooth Seek Setting...
    reaper.SetEditCurPos(targetTime, true, true)
    reaper.SNM_SetIntConfigVar('smoothseek', currState) -- Put it back to what it was
end

---------------------------------------------
function Seek_WithDeferLoop(mode) -- 2:1/4, 3:1/8, 4:1/16, 5:1/3
	local playpos = reaper.GetPlayPosition()
	local infos = GetBoundaries(playpos+padding)
	local timingAdjust = reaper.GetOutputLatency()+0.08
	local division
	if mode == 2 then division = infos.nextbeat
	elseif mode == 3 then division = infos.nexteight
	elseif mode == 4 then division = infos.nextsixteenth
	elseif mode == 5 then division = infos.nexttriplet
	end

	local targetTime = division-playpos+reaper.time_precise()
	local isClickMuted = false
-- Polling loop function
	local function Loop()
		if reaper.GetPlayState() == 0 then return end -- if stopped while running abort without doing anything.
		local t = reaper.time_precise()
		if t - targetTime+timingAdjust > 0.0001 then -- if arrived at target
			reaper.OnPlayButton()
			return
		end
		reaper.defer(function() Loop() end)
	end
-- Call polling loop function
	Loop()
end



-----------------------------------------------------------
---------|| RUN FUNCTION ||--------------------------------
-----------------------------------------------------------
local function run()
	if reaper.GetPlayState() ~= 1 then return end
	if seek_mode < 2 then
		Seek_Native(seek_mode) 
	else
		Seek_WithDeferLoop(seek_mode) -- to seek according to other values.  Not very precise...
	end
end



-----------------------------------------------------------
---------|| RUNTIME ||-------------------------------------
-----------------------------------------------------------
run()
reaper.defer(function() end)
lexaproductions is online now   Reply With Quote
Old 02-22-2021, 07:03 AM   #8
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 3,232
Default

Uau! thank you so much ! i'll try it as soon as possible!
Also manny interesting stuff in here! Thank you!
__________________
i had to come back !
deeb is online now   Reply With Quote
Old 02-22-2021, 08:02 AM   #9
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 3,232
Default

I still didn't spend much time understanding the script, so i am not sure what it is doing.

With 0 - region: seems smooth but sometimes a glitch on the one
with 1 - bar: seems smooth too but sometimes a glitch on the one
with 2 - seems like the math might be wrong (seems it's waiting literally 1 beat and then change, instead of changing on the next beat)

I still didn't took enough time looking on the code.

You are on mac?
__________________
i had to come back !

Last edited by deeb; 02-22-2021 at 10:12 AM.
deeb is online now   Reply With Quote
Old 02-22-2021, 07:59 PM   #10
lexaproductions
Human being with feelings
 
Join Date: Jan 2013
Posts: 657
Default

I am on Mac yes.
The glitch on the one might come from the MEdia buffer size and the pre buffer % settings. I have a very old Macbook Pro 2012 with an old OS and it works great.

For the other ones, I think it is not accurate because of the defer refresh rate that is only 30Hz. But I might be wrong on that.

Last edited by lexaproductions; 02-22-2021 at 10:32 PM.
lexaproductions is online now   Reply With Quote
Old 02-23-2021, 01:28 AM   #11
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 3,232
Default

i am on mac too, catalina. With 30 ms was clearly better then 200!

this was my buffer settings:



this is the only buffer ("request block size") setting that i know. The other i will have to look - MEdia buffer size and the pre buffer % .

Which buffer size you experimented with?

I wonder if is possible to query this buffer size by API! maybe something could be done on the math!!
__________________
i had to come back !
deeb is online now   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 07:29 AM.


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