|
|
|
12-03-2021, 07:10 AM
|
#1
|
Human being with feelings
Join Date: Jun 2019
Posts: 2,875
|
Offset playback start position by track time offset
For users of sample libraries it is often common to apply negative track delay to compensate for the attack time of samples which would otherwise sound a bit delayed when the midi is on grid.
However starting playback on beat will have the first midi note play too close to the second note or cut out entirely. This can make it difficult to audition a part of the arrangement and forces the user to search a point a little bit before the beat to start playback.
The issue could be solved if Reaper had an option to automatically offset the playback starting point by as much as the highest time offset in the project.
For example let's say I have 3 tracks with different VSTIs, the first one playing in time, the second one anticipated by -50ms and the third one anticipated by -100ms to compensate for the sample attack time. Now, if I place the edit cursor on the first beat of a measure and press play, playback will start 100ms before that measure in order to have all Midi notes played properly.
Looping has the same issue of course, but I don't know how that could be solved. Reaper would have to play the first note of the measure before the play cursor jumps back to that note. If it can be addressed to it would be perfect, otherwise I would already appreciate a lot of just initial playback start could compensate for the time offset.
|
|
|
12-03-2021, 05:27 PM
|
#2
|
Human being with feelings
Join Date: Jan 2011
Posts: 1,182
|
+1. Would be great
|
|
|
12-05-2021, 07:23 AM
|
#3
|
Human being with feelings
Join Date: Feb 2016
Location: Hollyweird
Posts: 2,637
|
+1 I do miss this from other DAWs as it's quite a common case in music production
|
|
|
12-05-2021, 08:19 AM
|
#4
|
Human being with feelings
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
|
Lua Transport: Play/Stop with calculating maximum negative offset from all tracks, triggering play at this offset
Code:
if reaper.GetPlayState()&1==1 then
reaper.OnStopButtonEx(0 )
--reaper.OnPauseButtonEx( 0 )
else
local SR = tonumber(reaper.format_timestr_pos( 1-reaper.GetProjectTimeOffset( 0,false ), '', 4 )) -- get sample rate obey project start offset
play_offs= 0
for i =1, reaper.CountTracks(0) do
local tr = reaper.GetTrack(0,i-1)
local offs = reaper.GetMediaTrackInfo_Value( tr, 'D_PLAY_OFFSET' )
local offs_flag = reaper.GetMediaTrackInfo_Value( tr, 'I_PLAY_OFFSET_FLAG' )
if offs_flag&1~=1 then
if offs_flag&2==2 then play_offs=math.min(play_offs,offs/SR) else play_offs=math.min(play_offs,offs) end
end
end
cur_pos = reaper.GetCursorPositionEx( 0 )
reaper.PreventUIRefresh( 1 )
reaper.SetEditCurPos2( 0, cur_pos+play_offs, false, true )
reaper.OnPlayButtonEx( 0 )
reaper.SetEditCurPos2( 0, cur_pos, false, false )
reaper.PreventUIRefresh( -1 )
end
(added to Reapack as m pl_Transport Play Stop (obey longest negative track offset))
Last edited by mpl; 12-05-2021 at 08:25 AM.
|
|
|
12-05-2021, 08:39 AM
|
#5
|
Human being with feelings
Join Date: Feb 2016
Location: Hollyweird
Posts: 2,637
|
Sick! Thanks so much genius mpl
|
|
|
12-05-2021, 12:18 PM
|
#6
|
Human being with feelings
Join Date: Jun 2019
Posts: 2,875
|
Quote:
Originally Posted by mpl
(added to Reapack as mpl_Transport Play Stop (obey longest negative track offset))
|
Thanks mpl!
Somehow it doesn't work as expected though.. I have a sample library that requires -250ms offset and I did set the track to -250ms but the first note is still cut off.. it does start playback earlier but not early enough it seems.
Here a video (first normal Reaper play/stop, then mpl play/stop and finally moving cursor to play/stop how it should sound): https://vimeo.com/653456710?activityReferer=1
|
|
|
12-05-2021, 12:56 PM
|
#7
|
Human being with feelings
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
|
Quote:
Originally Posted by Phazma
Thanks mpl!
Somehow it doesn't work as expected though.. I have a sample library that requires -250ms offset and I did set the track to -250ms but the first note is still cut off.. it does start playback earlier but not early enough it seems.
Here a video (first normal Reaper play/stop, then mpl play/stop and finally moving cursor to play/stop how it should sound): https://vimeo.com/653456710?activityReferer=1
|
Maybe Anticipative Processing setting give some influence to this? Also make sure Options: Chase MIDI note-ons in project playback is On.
|
|
|
12-05-2021, 05:55 PM
|
#8
|
Human being with feelings
Join Date: Jun 2019
Posts: 2,875
|
Quote:
Originally Posted by mpl
Maybe Anticipative Processing setting give some influence to this? Also make sure Options: Chase MIDI note-ons in project playback is On.
|
Both of these seem to have no influence. But thanks for trying to troubleshoot.
Here a second video with a drum sound (to understand better what is happening):
https://vimeo.com/manage/videos/653518488/
|
|
|
12-05-2021, 10:56 PM
|
#9
|
Human being with feelings
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
|
Quote:
Originally Posted by Phazma
|
Hmm maybe MIDI clock timing quantisation issue? Try shift additionally 10ms by editing this line in code like
Code:
reaper.SetEditCurPos2( 0, cur_pos+play_offs-0.01, false, true )
|
|
|
12-06-2021, 02:27 AM
|
#10
|
Human being with feelings
Join Date: Jun 2019
Posts: 2,875
|
Quote:
Originally Posted by mpl
Hmm maybe MIDI clock timing quantisation issue? Try shift additionally 10ms by editing this line in code like
Code:
reaper.SetEditCurPos2( 0, cur_pos+play_offs-0.01, false, true )
|
-0.01 only works when the negative track offset (and the sample) are at -10ms. For -250ms it works when I set it to -0.25. I guess this means that this value should not be a constant but be calculated and adjusted automatically based on the negative track delay.
|
|
|
12-06-2021, 06:02 PM
|
#11
|
Human being with feelings
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
|
Wait, Ive built everything around media offset in the track routing settings (previously called "playback track offset"). But probably you are using JSFX (time_adjustnent) instead?
Because it seems play_offs is always equal zero in your case, which means - the script doesn't get correct negative offset from track parameter.
|
|
|
12-07-2021, 04:50 AM
|
#12
|
Human being with feelings
Join Date: Jun 2019
Posts: 2,875
|
Quote:
Originally Posted by mpl
Wait, Ive built everything around media offset in the track routing settings (previously called "playback track offset"). But probably you are using JSFX (time_adjustnent) instead?
|
No, I am using the media/track playback offset.
Quote:
Originally Posted by mpl
Because it seems play_offs is always equal zero in your case, which means - the script doesn't get correct negative offset from track parameter.
|
It does offset, just not the right amount. But now I have tried multiplying by 2x instead of adding a constant and that seems to work correctly:
Code:
reaper.SetEditCurPos2( 0, cur_pos+play_offs*2, false, true )
I will have to try it a bit more in actual work to see if there are any unwanted problems.
|
|
|
12-15-2021, 11:02 AM
|
#13
|
Human being with feelings
Join Date: Jun 2009
Location: France_var
Posts: 416
|
Thx, for this scipt. Could someone please explain how to use the script ?
|
|
|
12-15-2021, 11:59 AM
|
#14
|
Human being with feelings
Join Date: Jun 2019
Posts: 2,875
|
Quote:
Originally Posted by otsoa
Thx, for this scipt. Could someone please explain how to use the script ?
|
You just assign the keyboard shortcut that you use for "Transport: Play/stop" (usually the space bar) to "Script: mpl_Transport Play Stop (obey longest negative track offset)" instead.
If no offset is present on any track, the script will normally start/stop playback, just like Reaper's own action. If one or more negative offsets are present, the script will start playback earlier by the amount of the highest offset.
At least that is what should happen. As described above, during my tests I noticed that for some reason that script starts playback earlier only by half of the necessary amount. If that affects you too, you can correct that by changing this line:
Code:
reaper.SetEditCurPos2( 0, cur_pos+play_offs, false, true )
to:
Code:
reaper.SetEditCurPos2( 0, cur_pos+play_offs*2, false, true )
This tweak of adding *2 will double the calculated time. So if no offset delay is present it will be 0ms*2=0ms and start playback normally. If 100ms of maximum negative offset are present but the script only calculates 50ms, this tweak will correct it by doing 50ms*2=100ms.
Keep in mind that it will not work when the Midi Editor is focused (unless you use a global shortcut for the script) which is a bit of a bummer. It would be great if mpl could add the script also to the Midi Editor section.
|
|
|
12-16-2021, 11:24 AM
|
#15
|
Human being with feelings
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
|
Is multiplication by 2 necessary (so for some reason it works and if you multiplicate by, say, 1.9 it doesn't work)? Or my script does wrong value move?
You can assign script shortcut to "pass to arrange" action in MIDI editor, this will retranslate shortcut through midi editor to arrange.
|
|
|
12-17-2021, 01:48 AM
|
#16
|
Human being with feelings
Join Date: Jun 2019
Posts: 2,875
|
Quote:
Originally Posted by mpl
You can assign script shortcut to "pass to arrange" action in MIDI editor, this will retranslate shortcut through midi editor to arrange.
|
Thanks, didn't know this action existed!
Quote:
Originally Posted by mpl
Is multiplication by 2 necessary (so for some reason it works and if you multiplicate by, say, 1.9 it doesn't work)? Or my script does wrong value move?
|
The script always works, but the value move it does is only half of the actual media playback offset.
Example: BPM = 120 , Offset = -500ms
At 120bpm, each beat duration is 250ms. So if have -500ms delay, playback should start exactly 2 beats before the beat on which I place the cursor. But your script by default makes it start only (exactly) 1 beat earlier.
So your script by default does:
Offset = -500ms, playback start = -250ms -> incorrect
If I add *1.5 (for example):
Offset = -500ms, playback start = -375ms -> incorrect
If I add *2:
Offset = -500ms, playback start = -500ms -> correct
|
|
|
12-17-2021, 12:48 PM
|
#17
|
Human being with feelings
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
|
Ok I updated script, thanks.
|
|
|
12-17-2021, 02:17 PM
|
#18
|
Human being with feelings
Join Date: Jun 2019
Posts: 2,875
|
Thanks to you for the fix!
|
|
|
12-18-2021, 07:10 AM
|
#19
|
Human being with feelings
Join Date: Jun 2009
Location: France_var
Posts: 416
|
Quote:
Originally Posted by Phazma
You just assign the keyboard shortcut that you use for "Transport: Play/stop" (usually the space bar) to "Script: mpl_Transport Play Stop (obey longest negative track offset)" instead.
If no offset is present on any track, the script will normally start/stop playback, just like Reaper's own action. If one or more negative offsets are present, the script will start playback earlier by the amount of the highest offset.
At least that is what should happen. As described above, during my tests I noticed that for some reason that script starts playback earlier only by half of the necessary amount. If that affects you too, you can correct that by changing this line:
Code:
reaper.SetEditCurPos2( 0, cur_pos+play_offs, false, true )
to:
Code:
reaper.SetEditCurPos2( 0, cur_pos+play_offs*2, false, true )
This tweak of adding *2 will double the calculated time. So if no offset delay is present it will be 0ms*2=0ms and start playback normally. If 100ms of maximum negative offset are present but the script only calculates 50ms, this tweak will correct it by doing 50ms*2=100ms.
Keep in mind that it will not work when the Midi Editor is focused (unless you use a global shortcut for the script) which is a bit of a bummer. It would be great if mpl could add the script also to the Midi Editor section.
|
Ok, thx !
|
|
|
01-09-2022, 08:59 PM
|
#20
|
Human being with feelings
Join Date: Jan 2019
Posts: 245
|
Thanks for the script, mpl. It works when you play from the beginning of the item but not when you're looping. Hopefully this will be addressed by Cockos at some point
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 04:49 PM.
|