Old 10-01-2022, 02:03 PM   #1
DrakeSoft
Human being with feelings
 
Join Date: Feb 2020
Posts: 21
Default Values returned by TimeMap_GetMeasureInfo

Hi,

I have a midi track with the following properties:
Tempo: 120.0 bpm, Time Signature: 4/4 Ticks Per Minute: 115200.0 Ticks Per Micro Second: 1.92 PPQ: 960

Each measure consists of 4 quarter notes.

When I call

Code:
  local measure_start_pos = reaper.TimeMap_GetMeasureInfo(0, measure) -- retruns value in QN (Quarter Notes)
  local measure_end_pos = reaper.TimeMap_GetMeasureInfo(0, measure + 1) -- retruns value in QN (Quarter Notes)
I get the following for measure_start_pos and measure_end_po:

Measure: 0 QN:0.0 QN:2.0
Measure: 1 QN:2.0 QN:4.0
Measure: 2 QN:4.0 QN:6.0
Measure: 3 QN:6.0 QN:8.0
Measure: 4 QN:8.0 QN:10.0
Measure: 5 QN:10.0 QN:12.0
Measure: 6 QN:12.0 QN:14.0
Measure: 7 QN:14.0 QN:16.0

I was expecting :

Measure: 0 QN:0.0 QN:4.0
Measure: 1 QN:4.0 QN:8.0
Measure: 2 QN:8.0 QN:12.0

to reflect the four quarter notes per measure. Can anyone explain why measure 1 begins at 2.0 instead of 4.0?
Maybe I am misinterpreting something here.

Last edited by DrakeSoft; 10-01-2022 at 02:07 PM. Reason: Added code tags
DrakeSoft is offline   Reply With Quote
Old 10-02-2022, 03:59 AM   #2
DrakeSoft
Human being with feelings
 
Join Date: Feb 2020
Posts: 21
Default Relationship between PPQ, QN and Time

From what I can determine. The image below shows the relationship between QN, PPQ and time. But QN seems to be the same as time. Is this correct?

DrakeSoft is offline   Reply With Quote
Old 10-02-2022, 01:16 PM   #3
DrakeSoft
Human being with feelings
 
Join Date: Feb 2020
Posts: 21
Default Understanding values returned by TimeMap_GetMeasureInfo

I notice that if I change the temp to 60 BPM then TimeMap_GetMeasureInfo returns what I would expect:

Measure: 0 Start QN:0.0 End QN:4.0 Project Time from QN: 0.0
Measure: 1 Start QN:4.0 End QN:8.0 Project Time from QN: 1.0
Measure: 2 Start QN:8.0 End QN:12.0 Project Time from QN: 2.0
Measure: 3 Start QN:12.0 End QN:16.0 Project Time from QN: 3.0
DrakeSoft is offline   Reply With Quote
Old 10-07-2022, 01:53 AM   #4
DrakeSoft
Human being with feelings
 
Join Date: Feb 2020
Posts: 21
Default value returned by reaper.TimeMap_GetMeasureInfo

I found the problem:

I had copied the code

Code:
 local measure_start_pos = reaper.TimeMap_GetMeasureInfo(0, measure) -- retruns value in QN (Quarter Notes)
  local measure_end_pos = reaper.TimeMap_GetMeasureInfo(0, measure + 1) -- retruns value in QN (Quarter Notes)
from someone else's script, but the function signature is as follows:

Code:
number retval, number qn_start, number qn_end, integer timesig_num, integer timesig_denom, number tempo = reaper.TimeMap_GetMeasureInfo(ReaProject proj, integer measure)
The returns multiple values and the retval is not actually the start of measure time in QN, that actually follows in the second value. Retval seems to correspond to the project time and not the QN time. So it should be:

Code:
  local retval_0, measure_start_pos, measure_end_pos = reaper.TimeMap_GetMeasureInfo(0, measure)
This gives the expected output for 120 BPM:




and also for 60 BPM:


Last edited by DrakeSoft; 10-07-2022 at 02:09 AM.
DrakeSoft 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 12:51 PM.


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