Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Reply
 
Thread Tools Display Modes
Old 11-03-2020, 03:21 PM   #1
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default [6.14] Tracks Null in One Position on the Timeline but Don't Null in another Position

[TL DR]In other words, if you manually align two audio items, (in MY experience) the following statement is true: two audio tracks that null perfectly in one position on the timeline, may not necessarily null if you change their position on the timeline (and yes of course I mean changing their position simultaneously).

I've added my own example but you can also recreate it by doing the following:

01. Add an audio to a new track in an empty project,
02. Duplicate the track,
03. Invert the phase on the second track,

Now at this stage, since the second track is a duplicate of the first one (and hence, their positions on the timeline are also absolutely IDENTICAL), no matter how and where you move the items on the timeline, as long as you move them together, their relationship to each other WILL stay the same (which means complete silence at the two buss, since the second track's phase is inverted). At least I haven't noticed a different behavior.

The problem arises when you MANUALLY try to align two audio items (even when one is the exact copy of the other). For instance, in this case, I deliberately changed the position of the second audio item and tried to MANUALLY align it back with the audio item on the first track (with snapping disabled of course). And sure AGAIN, I got the null back. But now that we've manually aligned them and got our null back, let's try the following:

04. Select both tracks and hit N to open up Nudge Dialog, with these settings: NUDGE - POSITION - 0.01 - SAMPLES
05. Fully zoom in on a visible drum part so you can see the movement of both audio items,
06. Nudge both items simultaneously at one hundredth of a sample per nudge, and after each nudge press play,
07. If you hear nothing after the nudge, press stop and then nudge again, and press play,

You do this enough, you WILL hear both supposedly "aligned" items NOT null anymore. For example I got it after 18 LEFT nudges (each nudge: one hundredth of a sample) in the session I've added to the report.

But to find out the result of each nudge, you have to stop and start the playback after every single nudge. You can't just keep the playback going and continue nudging, that won't work (another bug that's related to playback perhaps? or is this the normal behavior of playback?)

In other words, if you manually align two audio items, (in MY experience) the following statement is true: two audio tracks that null perfectly in one position on the timeline, may not necessarily null if you change their position on the timeline (and yes of course I mean changing their position simultaneously).

The beauty of a software like Adobe Audition is: There is no smaller unit than the actual sample size. So for instance in a 48kHz session, you get 48,000 samples in a second and NOTHING MORE. There is no "in between samples", so you can't for example put the audio at 500.4 sample mark, you either put it at 500 sample mark, or at 501 sample mark, and hence I GUESS less room for interpretations and consequently less room for bugs like this. So in Adobe Audition, if the content of two audio items are identical, it doesn't matter if you change the position or trim and shorten one of them, you can rest assured, that you can perfectly align them and they WILL NULL PERFECTLY, in EVERY SINGLE POSITION ON THE TIMELINE. I know REAPER does things differently, and you can mix and match different sample rates in one session, heck in one track even, and even if you only use one sample rate in your session, you can still put and move the audio anywhere on the timeline (for example you can put the audio item at 500.3 sample mark and move it freely), but I guess bugs like this are the direct result of such freedom? I may be wrong though.

Oh, I also tried this with "SNAP TO PROJECT SAMPLE RATE" turned on as well. Same behavior.

BTW, possibly a third bug: this may just be a visual bug, but when you zoom all the way in and nudge those tracks one hundredth of a sample, you WILL see that some nudges only result in one item moving and not both, I guess it's just a visual problem since we're nudging at that small of a size, but I may be wrong.

P.S. I f***ing LOVE REAPER.
Attached Files
File Type: rar REAPER BUG.rar (604.2 KB, 57 views)

Last edited by limitless; 12-05-2020 at 09:17 AM.
limitless is offline   Reply With Quote
Old 11-04-2020, 01:55 AM   #2
sonicowl
Human being with feelings
 
sonicowl's Avatar
 
Join Date: Oct 2015
Posts: 521
Default

Could be due to stretching.
sonicowl is offline   Reply With Quote
Old 11-04-2020, 03:41 AM   #3
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Stretching? What stretching? Neither of the audio items were stretched during the process.
limitless is offline   Reply With Quote
Old 11-09-2020, 12:14 AM   #4
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Here I made a GIF to show exactly what's going on. The second track is the render of the first one. If you look at the Master Track's Meter, when I first hit Play, both tracks completely cancel each other out, they completely null. As soon as I move their position and hit Play again, you can clearly see they no longer null. I move them again, they null again. I move them for the fourth time, they don't null, and this goes on...



1st position: NULL
2nd position: Signal comes back
3rd position: NULL
4th position: Signal comes back
5th position: NULL
6th position: NULL
7th position: Signal comes back
8th position: Signal comes back
9th position: NULL

SUSPICION A: I must however add that the signal is hollow and somewhat "phasey" when it comes back. Which I think means REAPER must be changing the position of one audio item slightly differently in relation to the other one (even though they're grouped). To me, the only explanation is either this, or a combination of this and the following:

SUSPICION B: Since both items are grouped and the only variable is their position on the timeline, you would expect their sum to be identical no matter where you put and/or move them. But as you can clearly see, that's not the case at all. So something must be going on under the surface. And I personally suspect it has to do with the way REAPER handles audio. Again I have to go back to what I was saying about Adobe Audition and the way it handles audio. In Adobe Audition, if the session or the audio file is in 48kHz, your cursor and playhead will *ONLY* get 48,000 possible positions in every second (AND NOTHING MORE). In REAPER on the other hand, (assuming the audio and the session are both at 48kHz), there's apparently no limit. You can split an audio exactly at its let's say 48th sample (which means at exactly 1 ms), orrrrr you can decide to split the audio at 48.6 or 49.73 or 731.852 sample mark.

Which can also mean you can put the beginning of your audio anywhere you want on the timeline. For instance at exactly 100th sample mark on the timeline, or at 100.724 sample mark. Sure, the position difference would be less than 1 sample, but as my documented experiment (GIF) shows, APPARENTLY WHERE YOU PUT YOUR AUDIO ON THE TIMELINE CAN MAKE A DIFFERENCE IN HOW IT SOUNDS, and I think that's the most important point of this whole conversation.

Again it's either this (SUSPICION B), or REAPER is simply moving one audio item slightly differently in relation to the other audio item (even though they're grouped) (SUSPICION A), which hilariously brings me back to (SUSPICION B), because I'm thinking what makes REAPER move one audio item differently compared to its grouped counterpart? Is it because REAPER simply has access to more positions in a second than exactly 48,000 positions, and hence there's more opportunity for things to go wrong?

Am I just reading too much into this? I personally don't think I am, but I'm biased. I may also be crazy. That's always a possibility.
limitless is offline   Reply With Quote
Old 12-01-2020, 08:52 AM   #5
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 13,139
Default

In the project you posted, you can look at the .RPP file and see that the two items are not at the exact same position:
Code:
      POSITION 1.39248727488775
vs
      POSITION 1.392487
(you can actually see the difference if you zoom all the way in, it's a couple of pixels)

So, they are positioned 0.00000027488775 seconds apart, which amounts to around 1% of a sample. In most instances, the positions of those files will round to the same sample position at the current samplerate, however if you position them in just the right place, the positions will round to a different sample position in the project, and as a result at those positions, they will be played one sample offset from each other.

Sooo, maybe use snap if you need them at the exact same time?
Justin is offline   Reply With Quote
Old 12-01-2020, 10:05 AM   #6
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Quote:
Originally Posted by Justin View Post
In the project you posted, you can look at the .RPP file and see that the two items are not at the exact same position:
Code:
      POSITION 1.39248727488775
vs
      POSITION 1.392487
(you can actually see the difference if you zoom all the way in, it's a couple of pixels)

So, they are positioned 0.00000027488775 seconds apart, which amounts to around 1% of a sample. In most instances, the positions of those files will round to the same sample position at the current samplerate, however if you position them in just the right place, the positions will round to a different sample position in the project, and as a result at those positions, they will be played one sample offset from each other.

Sooo, maybe use snap if you need them at the exact same time?
Well they are not exactly at the same position ON PURPOSE as I explained in my previous post, I deliberately moved one so I can MANUALLY try to align it again without the use of snapping (sure I could use snapping for these two takes since they were duplicates, but snapping won't be the answer when you want to align completely different audio takes with different lengths). And surely I got the null back after manual alignment mixed with deliberate sloppiness. The point is: I got NULL in one position on the timeline, and not NULL in other positions on the timeline, and as you explained the rounding causes this.

But picture this: you try to get a great snare sound by combining your snare top and bottom tracks which means you may change the position of snare bottom take for the desired sound you're after. Which means that the beginning of both takes are not exactly at the same position anymore, but you're happy with the result. Now for whatever reason you copy and paste them all over your timeline. Doesn't that mean that they will change position slightly depending on where they land on the timeline and therefore sound randomly different?

And if this is true, then am I correct in assuming that this whole thing can be avoided if from the get-go REAPER didn't let me go sub-sample (and I don't mean by using SNAP PROJECT TO SAMPLE RATE) but by a new setting in preferences that locks and snaps absolutely EVERYTHING to samples and therefore there wouldn't be any "in-between sample position" and hence no necessity for rounding the position of takes?

Last edited by limitless; 12-01-2020 at 12:17 PM.
limitless is offline   Reply With Quote
Old 12-01-2020, 11:52 AM   #7
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Quote:
Originally Posted by Justin View Post
In the project you posted, you can look at the .RPP file and see that the two items are not at the exact same position:
Code:
      POSITION 1.39248727488775
vs
      POSITION 1.392487
(you can actually see the difference if you zoom all the way in, it's a couple of pixels)

So, they are positioned 0.00000027488775 seconds apart, which amounts to around 1% of a sample. In most instances, the positions of those files will round to the same sample position at the current samplerate, however if you position them in just the right place, the positions will round to a different sample position in the project, and as a result at those positions, they will be played one sample offset from each other.

Sooo, maybe use snap if you need them at the exact same time?
In this new example, I recorded the same short audio twice in one go. And then splited the take afterwards, and put the second part on the second track, and aligned them to the best of my ability, this time being as accurate as I can. But since they were recorded twice from the same source, it means they are never exactly the same. So the null will never be -infinity, but nevertheless they null enough as you can see in Example_01.RPP. Now if you nudge them both left with these settings (NUDGE - POSITION - 0.01 - SAMPLES), you'll see that they won't NULL anymore: Example_02.RPP. And you can't really use snapping since they're not exactly the same.

This is the WeTransfer link to the (New Example.rar) file: https://we.tl/t-veCMslV6hb
limitless is offline   Reply With Quote
Old 12-01-2020, 12:08 PM   #8
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

This is the behavior I'm talking about. These are not the same takes so you can see how snapping won't be the solution. Don't you agree?

limitless is offline   Reply With Quote
Old 12-01-2020, 02:45 PM   #9
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 13,139
Default

If you want them to have the same behavior at all positions, trim the edge of one item to the edge of the other item, then they will be at the same position exactly and that will be that!

Alternatively, we could make a script which snapped all item positions to sample positions, you want that? Run that then everything will be good when copied...

Last edited by Justin; 12-01-2020 at 02:59 PM.
Justin is offline   Reply With Quote
Old 12-01-2020, 03:53 PM   #10
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Quote:
Originally Posted by Justin View Post
If you want them to have the same behavior at all positions, trim the edge of one item to the edge of the other item, then they will be at the same position exactly and that will be that!

Alternatively, we could make a script which snapped all item positions to sample positions, you want that? Run that then everything will be good when copied...
Dear Justin, in fact I did exactly that an hour ago to no avail. The same behavior. If you download this new session I've uploaded on WeTransfer website in my previous post, you'll see 2 session files. If you open Example_01.rpp, you'll see that they null to the best they can, but as soon as you nudge them left by (0.01 sample) they no longer null (Example_02.rpp).

I then went on to SPLIT the BEGINNING and the END of both items with snapping enabled so they both have the exact same length and position, but still as soon as I nudged them they did not null. The interesting part was that when I changed their position, they tend not to null at the beginning of every downbeat. You can see clearly what I mean in this gif.

limitless is offline   Reply With Quote
Old 12-01-2020, 04:58 PM   #11
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Other peculiarities which I think are the direct result of what we've been talking about:

You can see in this gif: I made two "take markers" at exactly the same position for both takes, but as soon as I nudge them both you can clearly see that both "take markers" won't align. Sometimes they do, other times they don't. I think that has to do with the (position rounding) you talked about. But the point is, this is not just a visual problem, their positions relative to each other really change, which I think shouldn't be acceptable, right?



In this next gif you can see the same problem but in a different scenario. I'm trimming the edge of this audio item, but you can clearly see that the audio waveform is also fidgeting in its own place, again I wish this was just a visual problem but it really affects the audio output.



If there's one thing that I like about Adobe Audition is that the samples positions are absolutely predefined with no room for interpretation. And I know REAPER does things differently.

Dear Justin, please don't think I'm trying to be unreasonably critical of REAPER. I absolutely LOVEEE REAPER. And I want it to be even more awesome.
limitless is offline   Reply With Quote
Old 12-01-2020, 05:08 PM   #12
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Quote:
Originally Posted by Justin View Post
Alternatively, we could make a script which snapped all item positions to sample positions, you want that? Run that then everything will be good when copied...
I think that would be freakin' awesome. But may I suggest one thing? And correct me if I'm wrong, but I think that what needs to snap to sample position is the CONTENT of each item and not necessarily the item itself. In this case, the edges of items may not matter as long as the audio content in the item snaps perfectly to sample position, I think that makes the whole difference.

Also is it possible for it to be implemented as a setting in preferences?

Last edited by limitless; 12-01-2020 at 05:16 PM.
limitless is offline   Reply With Quote
Old 12-01-2020, 05:34 PM   #13
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 13,139
Default

Here's a Lua reascript that snaps the position:
Code:
-- snaps all items to their nearest sample offset based on current
-- project sample rate, or if unset, audio device samplerate

srate = reaper.GetSetProjectInfo(0, "PROJECT_SRATE_USE",0,0)>0 and
        reaper.GetSetProjectInfo(0, "PROJECT_SRATE",0,0)
        
if not srate then
  ok,sval = reaper.GetAudioDeviceInfo("SRATE","")
  srate = ok and tonumber(sval)
end

if srate then
  for t=1,reaper.GetNumTracks() do
    track = reaper.GetTrack(0,t-1)
    for i=1,reaper.GetTrackNumMediaItems(track) do
      item = reaper.GetTrackMediaItem(track,i-1)
      pos = tonumber(reaper.GetMediaItemInfo_Value(item,"D_POSITION"))
      newpos = math.floor(pos * srate + 0.5) / srate
      if newpos ~= pos then
        reaper.SetMediaItemInfo_Value(item,"D_POSITION",newpos);
      end
    end
  end
else
  reaper.MB("Unknown samplerate", "Error",0)
end
It is not easily implementable as a preference, because of a lot of potential side effects, but it's something to think about. I'll post another one that also snaps start offsets to the sample too (though the samplerate it uses must be the media samplerate rather than the project samplerate...)
Justin is offline   Reply With Quote
Old 12-01-2020, 05:35 PM   #14
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

I also wish that in Snap/Grid Settings' (Show grid, line spacing) we could choose SAMPLE too.



And I also wish there was a way to force the (SNAP TO PROJECT SAMPLE RATE) to always stay ON, even when we close REAPER. Kind of sort of like how the settings in Project Settings always stay the same.
limitless is offline   Reply With Quote
Old 12-01-2020, 05:38 PM   #15
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 13,139
Default

Here's one that snaps both position and media offset:
Code:
-- snaps all items to their nearest sample offset based on current
-- project sample rate, or if unset, audio device samplerate

-- snaps all take start offsets to their nearest sample offset 
-- based on the media samplerate

srate = reaper.GetSetProjectInfo(0, "PROJECT_SRATE_USE",0,0)>0 and
        reaper.GetSetProjectInfo(0, "PROJECT_SRATE",0,0)
        
if not srate then
  ok,sval = reaper.GetAudioDeviceInfo("SRATE","")
  srate = ok and tonumber(sval)
end

if srate and srate > 0 then
  for t=1,reaper.GetNumTracks() do
    track = reaper.GetTrack(0,t-1)
    for i=1,reaper.GetTrackNumMediaItems(track) do
      item = reaper.GetTrackMediaItem(track,i-1)
      pos = tonumber(reaper.GetMediaItemInfo_Value(item,"D_POSITION"))
      newpos = math.floor(pos * srate + 0.5) / srate
      if newpos ~= pos then
        reaper.SetMediaItemInfo_Value(item,"D_POSITION",newpos);
      end
      for tk=1,reaper.GetMediaItemNumTakes(item) do
        take = reaper.GetMediaItemTake(item,tk-1)
        if take ~= nil then
          src = reaper.GetMediaItemTake_Source(take)
          media_srate = src and reaper.GetMediaSourceSampleRate(src)
          if media_srate and media_srate > 1 then
            offs = reaper.GetMediaItemTakeInfo_Value(take,"D_STARTOFFS")
            newoffs = math.floor(offs * media_srate + 0.5) / media_srate
            if newoffs ~= offs then
              reaper.SetMediaItemTakeInfo_Value(take,"D_STARTOFFS",newoffs)
            end
          end
        end
      end
    end
  end
else
  reaper.MB("Unknown samplerate", "Error",0)
end
Justin is offline   Reply With Quote
Old 12-01-2020, 05:50 PM   #16
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Quote:
Originally Posted by Justin View Post
Here's one that snaps both position and media offset:
Code:
-- snaps all items to their nearest sample offset based on current
-- project sample rate, or if unset, audio device samplerate

-- snaps all take start offsets to their nearest sample offset 
-- based on the media samplerate

srate = reaper.GetSetProjectInfo(0, "PROJECT_SRATE_USE",0,0)>0 and
        reaper.GetSetProjectInfo(0, "PROJECT_SRATE",0,0)
        
if not srate then
  ok,sval = reaper.GetAudioDeviceInfo("SRATE","")
  srate = ok and tonumber(sval)
end

if srate and srate > 0 then
  for t=1,reaper.GetNumTracks() do
    track = reaper.GetTrack(0,t-1)
    for i=1,reaper.GetTrackNumMediaItems(track) do
      item = reaper.GetTrackMediaItem(track,i-1)
      pos = tonumber(reaper.GetMediaItemInfo_Value(item,"D_POSITION"))
      newpos = math.floor(pos * srate + 0.5) / srate
      if newpos ~= pos then
        reaper.SetMediaItemInfo_Value(item,"D_POSITION",newpos);
      end
      for tk=1,reaper.GetMediaItemNumTakes(item) do
        take = reaper.GetMediaItemTake(item,tk-1)
        if take ~= nil then
          src = reaper.GetMediaItemTake_Source(take)
          media_srate = src and reaper.GetMediaSourceSampleRate(src)
          if media_srate and media_srate > 1 then
            offs = reaper.GetMediaItemTakeInfo_Value(take,"D_STARTOFFS")
            newoffs = math.floor(offs * media_srate + 0.5) / media_srate
            if newoffs ~= offs then
              reaper.SetMediaItemTakeInfo_Value(take,"D_STARTOFFS",newoffs)
            end
          end
        end
      end
    end
  end
else
  reaper.MB("Unknown samplerate", "Error",0)
end
Wowww, that was quick, thank you. I really appreciate this. Now I need to go learn how to use these scripts. Does the second one also snap the content of an audio item to sample position? Because that's the main problem we discussed.
limitless is offline   Reply With Quote
Old 12-01-2020, 07:02 PM   #17
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Quote:
Originally Posted by Justin View Post
It is not easily implementable as a preference, because of a lot of potential side effects, but it's something to think about.
I think having an ALWAYS PREDICTABLE timeline/playground is a fundamental part of every DAW. A timeline that does not surprise you with different results when you change the position of your item on it.

And although implementing this setting in the preferences has the potential to break some stuff, I think it's ultimately the right decision. But we understand that it's ultimately your decision, and the fact that you even considered thinking about it, is very encouraging. Thank you Justin.
limitless is offline   Reply With Quote
Old 12-02-2020, 05:13 AM   #18
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Quote:
Originally Posted by Justin View Post
Here's one that snaps both position and media offset:
I copied and pasted both scripts individually into Sublime Text and saved them as .lua files. Then opened Action List > New Action > New ReaScrpit and loaded the first one and I guess ran it? But it didn't do anything I guess? Neither did the second one. I'm sure I'm doing something wrong with these scripts. Please help, thanks.
limitless is offline   Reply With Quote
Old 12-02-2020, 06:16 AM   #19
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Quote:
Originally Posted by Justin View Post
It is not easily implementable as a preference, because of a lot of potential side effects, but it's something to think about.
Would it be complicated to implement an option in the preferences that forces the entire software to NOT go sub-sample, to NOT even recognize any position on the timeline smaller than a single sample, just like the way other DAWs behave? I think implementing that AS AN OPTION would solve all the problems we talked about here. And of course it can be hidden deep in the preferences and disabled by default, and if one chooses to enable it, one would be faced with a disclaimer that enabling this option may break some stuff. I think this would be the ultimate solution that solves these peculiarities we talked about. If you can consider such an option, it would make REAPER the only software that I need. Thank you.
limitless is offline   Reply With Quote
Old 12-02-2020, 07:15 AM   #20
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 13,139
Default

Quote:
Originally Posted by limitless View Post
I copied and pasted both scripts individually into Sublime Text and saved them as .lua files. Then opened Action List > New Action > New ReaScrpit and loaded the first one and I guess ran it? But it didn't do anything I guess? Neither did the second one. I'm sure I'm doing something wrong with these scripts. Please help, thanks.
It might not be noticeable, but here's what it looks like here:

Justin is offline   Reply With Quote
Old 12-02-2020, 12:25 PM   #21
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Quote:
Originally Posted by Justin View Post
It might not be noticeable, but here's what it looks like here
Yes, thank you Justin, the samples now snap using your script, I really appreciate it.

At the risk of sounding like a broken record however, I'd like to ask you to please hear me out just one more time.

Wouldn't it make more sense if this was a global implementation (as an opt-in option of course) rather than applying this action to items on the timeline afterwards? Because you can't be sure how all those minute positional changes affect the items' relationship to each other and the way they all sum/sound compared to how they collectively summed/sounded before applying the action. But if you were to implement it globally as an option which forces the entire software to NOT go sub-sample, to NOT even recognize any position on the timeline smaller than a single sample, just like other DAWs, it would mean before we even load items on the timeline, we can rest assured that all the items' positional relationships to each other WILL EXACTLY stay the same no matter where we'd move them. So if our project and the items within it are all say at 48 kHz, we can rest assured that they all can only have 48,000 possible positions in every second, nothing less and certainly nothing more. This, as an OPTION would be the ultimate solution.

And correct me if I'm wrong, but I think global implementation of this, can also make REAPER even snappier because it has to keep track of fewer numbers representing the items' positions (in case of a 48 kHz project, only 48,000 positions in a second instead of however many positions in a second REAPER can handle now).

If you can consider such an option, it would make REAPER the only software that I need. Thank you.

Last edited by limitless; 12-02-2020 at 12:33 PM.
limitless is offline   Reply With Quote
Old 12-02-2020, 03:29 PM   #22
mlprod
Human being with feelings
 
Join Date: Jul 2015
Location: Stockholm, Sweden
Posts: 888
Default

Snap to sample rate works just fine here, remember you need to have the project sample rate ticked aswell for that to work.

In what situations would you activly choose to move something by a sub sample lenght?
__________________
Magnus Lindberg Productions - VRTKL Audio - Redmount Studios
magnuslindberg.com
mlprod is offline   Reply With Quote
Old 12-02-2020, 04:46 PM   #23
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Quote:
Originally Posted by mlprod View Post
In what situations would you activly choose to move something by a sub sample lenght?
I don't. But if you freely move an item in REAPER you can never be sure if it snaps exactly to a sample position, in fact odds are overwhelmingly against that, unless of course SNAP TO PROJECT SAMPLE RATE is turned on. And even then if you attempt to move an item whose initial position is not snapped to a sample position, (say for instance you've moved it before and now it starts at 682.4 sample mark), by having SNAP TO PROJECT SAMPLE RATE turned on and then moving it again, you'll only move it based on its current (682.4) position. So if you moved it 20,000 samples to the right, it'd start at 20,682.4 sample mark. And that's where Justin's reascrpit comes into the picture. By using the script, your item snaps to its nearest sample position (in our example, it would snap to 682 sample mark). Now from this point on, by having SNAP TO PROJECT SAMPLE RATE turned on you can hopefully be sure that no matter where you move your item, it'll always snap to sample positions.

EDIT: After testing SNAP TO PROJECT SAMPLE RATE option again, this time it appears to work as advertised. It snaps to absolute sample positions even when the item's initial position is not at an absolute sample position. My bad.

Last edited by limitless; 12-02-2020 at 07:45 PM.
limitless is offline   Reply With Quote
Old 12-02-2020, 07:09 PM   #24
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 10,221
Default

edit:
I quoted/replied before limitless' edit/correction.

Last edited by nofish; 12-02-2020 at 08:07 PM.
nofish is offline   Reply With Quote
Old 12-02-2020, 07:53 PM   #25
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Quote:
Originally Posted by nofish View Post
If that's the case (I didn't test) than Snap to project sample rate is broken imo, as it should snap absolute and not relative (to my understanding at least. edit: As I thought that's exactly the purpose of this option, to avoid having items start at inter-sample values...).
Please read the correction I added to my previous post, thanks.
limitless is offline   Reply With Quote
Old 12-03-2020, 01:20 AM   #26
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,296
Default

Quote:
Originally Posted by Justin View Post
It is not easily implementable as a preference, because of a lot of potential side effects, but it's something to think about. I'll post another one that also snaps start offsets to the sample too (though the samplerate it uses must be the media samplerate rather than the project samplerate...)
Sorry for being late to the party. I have written some auto-looping scripts where the inter-sample sizing of part bit me in the butt. I thought about posting a Feature Request to have a minimum snap of a sample.

In fact, I can't really come up with a reason not to have all material both snapped and sized to the nearest sample. Actually, maybe it has to do with lining up items with beats and measures and if they were 100% trimmed to the nearest sample there would be gaps?

Anyway, thanks for those scripts, Justin!! I think I will keep these handy.

Cheers,

Andrew K
__________________
Cheers... Andrew K
Reaper v6.15 Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
Thonex is offline   Reply With Quote
Old 12-03-2020, 01:50 AM   #27
mlprod
Human being with feelings
 
Join Date: Jul 2015
Location: Stockholm, Sweden
Posts: 888
Default

Quote:
Originally Posted by limitless View Post

EDIT: After testing SNAP TO PROJECT SAMPLE RATE option again, this time it appears to work as advertised. It snaps to absolute sample positions even when the item's initial position is not at an absolute sample position. My bad.
Has always worked fine here, i always have it on and the projects sample rate ticked in project prefs.
__________________
Magnus Lindberg Productions - VRTKL Audio - Redmount Studios
magnuslindberg.com
mlprod is offline   Reply With Quote
Old 12-05-2020, 07:47 AM   #28
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Quote:
Originally Posted by Justin View Post
It is not easily implementable as a preference, because of a lot of potential side effects, but it's something to think about.
Quote:
Originally Posted by Thonex View Post
In fact, I can't really come up with a reason not to have all material both snapped and sized to the nearest sample. Actually, maybe it has to do with lining up items with beats and measures and if they were 100% trimmed to the nearest sample there would be gaps?
Take a shot every time I say "ABSOLUTE SAMPLE POSITION".

No, there wouldn't be any "gaps", the audio stream is continuous. Most DAWs simply round off the beat length by less than a sample so that the next item can snap to the next absolute sample position. And the way they do it has to do with the actual tempo and sample rate numbers, and whether those two numbers divide nicely.

Allow me to explain:

From this point on let's assume our sample rate is 48 kHz and for the sake of simplicity let's not worry about anything shorter than the length of a beat, let's just know that they too will follow the same principle.

Now if the tempo is 120 BPM, then that's easy because it means there are exactly two beats in every second and every beat lasts exactly 24,000 samples, and the beginning of every beat will ALWAYS line up perfectly with measures/beats grid lines, and that would be that (48,000x60/120=24,000). The problem however arises when your sample rate (48 kHz in our case) is not divisible by your tempo number. Let's take 116 BPM for instance, which in a perfect world means every beat lasts 24,827.58620689655 samples exactly (48,000x60/116=24,827.58620689655). But as I previously stated, DAWs have to round off that length by a fraction of a sample to make room for the beginning of the next beat so that the next beat can also start at an absolute sample position. So in our case Beat 01 will become 24,828 samples. But under the hood DAWs keep using the original number in all its non-rounded glory as their reference for their further calculations. They just keep rounding off the results every single time. Keep in mind that all this, is my observation/experience and I'm not claiming it as fact and/or science.

So to demonstrate what I've described above, I made two projects in both REAPER and Adobe Audition, with a simple 48 kHz Kick Sample made by Audition's Tone Generator. I set the BPM to 116, turned snapping to measures/beats on, and snapped the Kick Sample to every beat on both DAWs' timelines (30 beats in total). And then measured the length between every single beat in Adobe Audition. As you can see below in the last column, the length between adjacent beats fluctuates by one sample (some beats last 24,828 samples, and some last 24,827) and to our eyes the frequency of this fluctuation may seem pretty random, but that's not the case at all. Again it's caused by rounding off the calculations results (see third column below) to allow the next beat to also land on the next absolute sample position.

Project Sample Rate: 48 kHz
Project Tempo: 116 BPM
All measurements are in samples of course

Code:
|==========|=====================|===============|  |================|
|  Length  | Theoretical Length  | Actual Length |  |     Length     |
| Between  |    Between Beats    | Between Beats |  | Differences of |
|  Beats   |       in DAWs       |    in DAWs    |  | Adjacent Beats |
|==========|=====================|===============|  |================|
| 01 to 02 |  24,827.58620689655 |     24,828    |  |     24,828     |
| 01 to 03 |  49,655.1724137931  |     49,655    |  |     24,827     |
| 01 to 04 |  74,482.75862068965 |     74,483    |  |     24,828     |
| 01 to 05 |  99,310.3448275862  |     99,310    |  |     24,827     |
| 01 to 06 | 124,137.9310344828  |    124,138    |  |     24,828     |
| 01 to 07 | 148,965.5172413793  |    148,966    |  |     24,828     |
| 01 to 08 | 173,793.1034482759  |    173,793    |  |     24,827     |
| 01 to 09 | 198,620.6896551724  |    198,621    |  |     24,828     |
| 01 to 10 | 223,448.275862069   |    223,448    |  |     24,827     |
| 01 to 11 | 248,275.8620689655  |    248,276    |  |     24,828     |
| 01 to 12 | 273,103.4482758621  |    273,103    |  |     24,827     |
| 01 to 13 | 297,931.0344827586  |    297,931    |  |     24,828     |
| 01 to 14 | 322,758.6206896552  |    322,759    |  |     24,828     |
| 01 to 15 | 347,586.2068965517  |    347,586    |  |     24,827     |
| 01 to 16 | 372,413.7931034483  |    372,414    |  |     24,828     |
| 01 to 17 | 397,241.3793103448  |    397,241    |  |     24,827     |
| 01 to 18 | 422,068.9655172414  |    422,069    |  |     24,828     |
| 01 to 19 | 446,896.5517241379  |    446,897    |  |     24,828     |
| 01 to 20 | 471,724.1379310345  |    471,724    |  |     24,827     |
| 01 to 21 | 496,551.724137931   |    496,552    |  |     24,828     |
| 01 to 22 | 521,379.3103448276  |    521,379    |  |     24,827     |
| 01 to 23 | 546,206.8965517241  |    546,207    |  |     24,828     |
| 01 to 24 | 571,034.4827586207  |    571,034    |  |     24,827     |
| 01 to 25 | 595,862.0689655172  |    595,862    |  |     24,828     |
| 01 to 26 | 620,689.6551724138  |    620,690    |  |     24,828     |
| 01 to 27 | 645,517.2413793103  |    645,517    |  |     24,827     |
| 01 to 28 | 670,344.8275862069  |    670,345    |  |     24,828     |
| 01 to 29 | 695,172.4137931034  |    695,172    |  |     24,827     |
| 01 to 30 | 720,000             |    720,000    |  |     24,828     |
|==========|=====================|===============|  |================|
Now as you can see in the following GIF and as I've said before, there's no sub-sample in Adobe Audition, all items snap exactly to absolute sample positions at all times. They simply don't have any other choice. So as a result of (let's call it ALWAYS ON SNAP TO ABSOLUTE SAMPLE POSITION PRIORITY boy that's a mouthful) most beats are TIME/RHYTHYMWISE off by a fraction of a sample. In fact ONLY the first and the last beat (first beat obviously at 0 sample mark, and 30th beat at 720,000 sample mark) are exactly aligned with absolute sample positions without the need for rounding off, and the remaining 28 beats between those two, have to be rounded off because none of them would snap to absolute sample positions otherwise, and that's because Adobe Audition prioritizes snapping to absolute sample position above all, and as a result, TIME/RHYTHYMWISE the beginning of each beat is ever so slightly off (less than a sample) to accommodate the subsequent beat with an absolute sample position, and that's the price we have to pay in the imperfect world of digital audio.



The problem with REAPER however, shown in the following GIF, is that it shows the measures/beats grid line as if we're living in a perfect world. In other words, when you snap your items to beat grid lines in REAPER, your items are (at least VISUALLY) landing on the perfect beat grid lines (the same isn't true for Audition as you saw in the GIF above) and as a result when you switch REAPER's timeline ruler to samples, you can clearly see that the beginning of our items which are snapped to beats are now shown between absolute sample positions and not snapped to them (again at least VISUALLY that's the case as you can clearly see in the GIF below). But I know that under the hood REAPER has to be snapping those items to absolute sample positions because there's simply no other alternative in the digital audio domain. But it visually fools us into thinking that an audio item can be placed between absolute sample positions and it also visually fools us into thinking that our items are perfectly snapped to measures/beats grid lines. When in reality most beats are TIME/RHYTHYMWISE off by a fraction of a sample because they need to snap to absolute sample positions, all because our project sample rate and the tempo we chose don't divide nicely, which of course is a part of digital audio life.



And another problem as you can see in this next GIF, is that the Big Clock displays absolute sample numbers, even though the play cursor clearly isn't at absolute sample position. And as soon as I jump to THE SAME sample number that the Big Clock is ALREADY displaying, you can clearly see that the play cursor jumps to the ACTUAL absolute sample position that the Big Clock's been displaying all along. So why don't play cursor and Play Cursor Position/Big Clock match to begin with? Why do Play Cursor Position and Big Clock display a rounded position of the play cursor? I think if the play cursor insists on fooling us into thinking that it can park itself between absolute sample positions, at least Play Cursor Position has to follow suit and display the non-rounded position, preferably accurate down to 0.001 sample. Consistency is appreciated.



And all of this, is why I asked for a global implementation of an OPTION that forces REAPER to only recognize absolute sample positions (AS AN OPT-IN FEATURE AND DISABLED BY DEFAULT of course), and for the majority of users who are okay with the current state, I think it's worthwhile to at least make the number that the Play Cursor Position displays accurate DOWN to 0.001 sample.

Last edited by limitless; 12-05-2020 at 11:04 AM.
limitless is offline   Reply With Quote
Old 12-05-2020, 10:39 AM   #29
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Quote:
Originally Posted by musicbynumbers View Post
I think this comes back to Reaper's super unique ability to have multiple sample rates in various audio items within the same project and also because of reaper's "honesty" in showing where the samples actual are when some DAWs visually round.

That above may not be what is causing your issue but I and many people I know have had various problems with midi/audio timing when copying and pasting a lot and getting drifting because of the above reason (which are not just this issue but similar ones documented elsewhere too).

I don't have a solution but the sample rate tickbox that locks the BPM to the sample rate helps though.

It's really quite a tricky one to solve "properly". I'm just hoping that there's a way that can work like an option that allowed reaper to simulate DAWs like cubase or protools even though it would break some other things maybe?
REAPER's honesty? I think if you read my post above this very post, you'll see that REAPER in fact visually fools us into thinking that items can be placed exactly on beat grid lines but then when you switch the timeline ruler to samples you'll see that items fall between absolute sample positions, when in fact under the hood I'm sure they must all snap to absolute sample positions, because in digital audio domain they simply don't have any other choice. So I don't know what you mean when you say "REAPER's honesty".
limitless is offline   Reply With Quote
Old 12-06-2020, 07:09 AM   #30
mlprod
Human being with feelings
 
Join Date: Jul 2015
Location: Stockholm, Sweden
Posts: 888
Default

Look, just use the snap to sample rate feature that is already there and you'll be fine!
__________________
Magnus Lindberg Productions - VRTKL Audio - Redmount Studios
magnuslindberg.com
mlprod is offline   Reply With Quote
Old 12-06-2020, 08:04 AM   #31
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 13,139
Default

Quote:
Originally Posted by mlprod View Post
Look, just use the snap to sample rate feature that is already there and you'll be fine!
To be clear, this is referring to: snap settings, near the bottom "Snap to project samplerate" (need to have a project samplerate set).
Justin is offline   Reply With Quote
Old 12-06-2020, 11:23 AM   #32
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Quote:
Originally Posted by Justin View Post
To be clear, this is referring to: snap settings, near the bottom "Snap to project samplerate" (need to have a project samplerate set).
But that's useful only when it can be implemented globally and from the very beginning of starting a project. Unfortunately you can't enable and save it as a default project setting. So it's not set and forget. Every time you start a new project you need to be aware that it's off.

And furthermore, even when it's on, you could still nudge stuff by a fraction of a sample if you chose to, which to me defeats the whole purpose of SNAP TO SAMPLE PROJECT option.

In my opinion when one chooses to have SNAP TO SAMPLE PROJECT option turned on, one is PRIORITIZING snapping to absolute sample positions ABOVE ALL, and therefore REAPER MUST change some of its behavior:

01. It shouldn't let you nudge anything by smaller amounts than a sample. Smaller lengths than a sample must become unavailable, including pixels.

02. It should prioritize SNAPPING TO ABSOLUTE SAMPLE POSITION above everything, which means it should also change its behavior regarding snap to measures/beats. So if my tempo is 116 and my sample rate is 48,000 all those beats that don't mathematically land on absolute sample positions, shouldn't visually fool us into thinking they can land between absolute sample positions just to satisfy us into thinking that our beats are perfectly snapped to beat/measures.

In other words, If one chooses to enable SNAP TO PROJECT SAMPLE RATE, one is prioritizing snapping to absolute sample positions ABOVE ALL, both visually and mathematically, which mathematically means items usually don't snap to beats/measures because they need to snap to absolute sample positions before they worry about snapping to beats/measures, which means TIMEWISE they WILL BE off by a fraction of a sample depending on which absolute sample position their end is closer to.

And this is only my opinion but I have a feeling that people who prioritize snapping to absolute sample position, usually don't mix and match items with different sample rates in the same project. I know I don't.

So if you could make SNAP TO PROJECT SAMPLE RATE option something that could be saved as default in PROJECT SETTINGS which should consequently mean we wouldn't have access to anything smaller than a sample length globally, which also means snapping to beats/measures would look imperfect, it would be AWESOME.

And again this will all be just an option for us sample accuracy obsessed people.

Last edited by limitless; 12-06-2020 at 11:28 AM.
limitless is offline   Reply With Quote
Old 12-06-2020, 11:35 AM   #33
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 3,364
Default

Quote:
Originally Posted by limitless View Post
But that's useful only when it can be implemented globally and from the very beginning of starting a project. Unfortunately you can't enable and save it as a default project setting. So it's not set and forget. Every time you start a new project you need to be aware that it's off.
Enable the option in the Snap/Grid Settings dialog then click the Save as default project settings button in the Project settings dialog.
cfillion is offline   Reply With Quote
Old 12-06-2020, 11:40 AM   #34
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Quote:
Originally Posted by cfillion View Post
Enable the option in the Snap/Grid Settings dialog then click the Save as default project settings button in the Project settings dialog.
Holly .... it workedddd. Thank youuu. Now I'll see if it also solves the problem I described in Post #1. Thank you really. This means a lot to me.
limitless is offline   Reply With Quote
Old 12-06-2020, 11:45 AM   #35
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 2,698
Default

Quote:
Originally Posted by limitless View Post
Unfortunately you can't enable and save it as a default project setting. So it's not set and forget. Every time you start a new project you need to be aware that it's off.

...

So if you could make SNAP TO PROJECT SAMPLE RATE option something that could be saved as default in PROJECT SETTINGS ...
It is saved here. But not when using "Save as default project settings" in the Project Settings window. This and other settings are not saved for some reason. But if you make a default project yourself and set it in REAPER Preferences -> Project -> "When creating new projects, use the following project file as a template:", everything works fine.
__________________
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 12-06-2020, 01:03 PM   #36
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Yesss, as you can see, now that I defaulted SNAP TO PROJECT SAMPLE RATE, my items ALWAYS snap to absolute sample positions. And just so you know, in the GIF below the play head is moving exactly one beat every time, and as you can see it sometimes lands behind the item and sometimes ahead of the item. This is PERFECT. This is exactly how it should be, and I'm so happy that thanks to you Justin and others I finally figured it out and fixed it.



And for the people who may be wondering if there is a sound difference between what I'm getting now and what I was getting before, I did a null test between the two, and unsurprisingly as I stated in my previous posts the result is complete and utter silence, the floor of Spectrum Analyzer was set to -450dB in fact.

Now let me see if the problem I described in the first post is also fixed.
limitless is offline   Reply With Quote
Old 12-06-2020, 01:17 PM   #37
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 3,364
Default

Quote:
Originally Posted by amagalma View Post
But not when using "Save as default project settings" in the Project Settings window.
That works here (tried in both v5 and v6).
cfillion is offline   Reply With Quote
Old 12-06-2020, 01:26 PM   #38
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Quote:
Originally Posted by cfillion View Post
That works here (tried in both v5 and v6).
Thanks to you, I can confirm it too. It saves here as default.
limitless is offline   Reply With Quote
Old 12-06-2020, 01:59 PM   #39
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 2,698
Default

Maybe it is not saved because I have set up a project in the project preferences?...
__________________
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 12-12-2020, 09:08 PM   #40
limitless
Human being with feelings
 
Join Date: Jun 2020
Posts: 61
Default

Now that my problem regarding forcing all samples to snap to absolute sample positions is solved, can you please tell me where these two scripts you kindly provided come in handy? I think I know the answer, but I just want to make sure that the answer in my head is actually the correct one. I think those two scripts come in handy for previous projects that did not have SNAP TO PROJECT SAMPLE RATE enabled from the get go. Is that a correct assumption?

And can you please explain the difference between the two scripts again? Thank you.

Would it then be fair to conclude that for previous projects, ONE COULD ESSENTIALLY GET THE SAME RESULT THAT THESE TWO SCRIPTS PROVIDE by first changing the item's position to 0, so that the item's beginning (its very first sample) is snapping to the first absolute sample position on the timeline (which is at the very beginning of the timeline), and then from there (assuming of course SNAP TO PROJECT SAMPLE RATE is enabled) one can easily change the item's position to wherever one wants, knowing that from that point on, the item will always snap to absolute sample positions? Is that a fair conclusion?

Quote:
Originally Posted by Justin View Post
Here's a Lua reascript that snaps the position:
Code:
-- snaps all items to their nearest sample offset based on current
-- project sample rate, or if unset, audio device samplerate

srate = reaper.GetSetProjectInfo(0, "PROJECT_SRATE_USE",0,0)>0 and
        reaper.GetSetProjectInfo(0, "PROJECT_SRATE",0,0)
        
if not srate then
  ok,sval = reaper.GetAudioDeviceInfo("SRATE","")
  srate = ok and tonumber(sval)
end

if srate then
  for t=1,reaper.GetNumTracks() do
    track = reaper.GetTrack(0,t-1)
    for i=1,reaper.GetTrackNumMediaItems(track) do
      item = reaper.GetTrackMediaItem(track,i-1)
      pos = tonumber(reaper.GetMediaItemInfo_Value(item,"D_POSITION"))
      newpos = math.floor(pos * srate + 0.5) / srate
      if newpos ~= pos then
        reaper.SetMediaItemInfo_Value(item,"D_POSITION",newpos);
      end
    end
  end
else
  reaper.MB("Unknown samplerate", "Error",0)
end
It is not easily implementable as a preference, because of a lot of potential side effects, but it's something to think about. I'll post another one that also snaps start offsets to the sample too (though the samplerate it uses must be the media samplerate rather than the project samplerate...)
Quote:
Originally Posted by Justin View Post
Here's one that snaps both position and media offset:
Code:
-- snaps all items to their nearest sample offset based on current
-- project sample rate, or if unset, audio device samplerate

-- snaps all take start offsets to their nearest sample offset 
-- based on the media samplerate

srate = reaper.GetSetProjectInfo(0, "PROJECT_SRATE_USE",0,0)>0 and
        reaper.GetSetProjectInfo(0, "PROJECT_SRATE",0,0)
        
if not srate then
  ok,sval = reaper.GetAudioDeviceInfo("SRATE","")
  srate = ok and tonumber(sval)
end

if srate and srate > 0 then
  for t=1,reaper.GetNumTracks() do
    track = reaper.GetTrack(0,t-1)
    for i=1,reaper.GetTrackNumMediaItems(track) do
      item = reaper.GetTrackMediaItem(track,i-1)
      pos = tonumber(reaper.GetMediaItemInfo_Value(item,"D_POSITION"))
      newpos = math.floor(pos * srate + 0.5) / srate
      if newpos ~= pos then
        reaper.SetMediaItemInfo_Value(item,"D_POSITION",newpos);
      end
      for tk=1,reaper.GetMediaItemNumTakes(item) do
        take = reaper.GetMediaItemTake(item,tk-1)
        if take ~= nil then
          src = reaper.GetMediaItemTake_Source(take)
          media_srate = src and reaper.GetMediaSourceSampleRate(src)
          if media_srate and media_srate > 1 then
            offs = reaper.GetMediaItemTakeInfo_Value(take,"D_STARTOFFS")
            newoffs = math.floor(offs * media_srate + 0.5) / media_srate
            if newoffs ~= offs then
              reaper.SetMediaItemTakeInfo_Value(take,"D_STARTOFFS",newoffs)
            end
          end
        end
      end
    end
  end
else
  reaper.MB("Unknown samplerate", "Error",0)
end

Last edited by limitless; 12-14-2020 at 08:10 PM.
limitless 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 06:12 AM.


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