|
1 | 1 | -- @description Perfect Timing! - Audio Quantizer |
2 | 2 | -- @author 80icio |
3 | | --- @version 0.31 |
4 | | --- @changelog - FIxed detection with 1 bar and 1/2 bar grid settings when analyzed items start is not on the grid |
| 3 | +-- @version 0.32 |
| 4 | +-- @changelog |
| 5 | +-- - Improved grid drawing when using the internal Visualizer. |
| 6 | +-- - Fixed trigger line thickness to correctly correspond to quarter notes in the Edit window and the Visualizer. |
5 | 7 | -- @link Forum thread https://forum.cockos.com/showthread.php?t=288964 |
6 | 8 | -- @about |
7 | 9 | -- # PERFECT TIMING! |
|
17 | 19 | -- * Multisized GUI |
18 | 20 | -- * Works with fixed lanes |
19 | 21 |
|
20 | | - |
21 | | ------------------------------vars vars vars!----------------------------------- |
| 22 | +------vars vars vars!----------------------------------- |
22 | 23 | ------------------------------------------------------------------------------- |
23 | 24 | ------------------------------------------------------------------------------- |
24 | 25 | local r = reaper |
@@ -1475,6 +1476,14 @@ end |
1475 | 1476 | ---------------------------------reduce by grid ---------------------- |
1476 | 1477 |
|
1477 | 1478 | function Create_Grid_table() |
| 1479 | + |
| 1480 | + local function beatc(beatpos) |
| 1481 | + local retval, measures, cml, fullbeats, cdenom = r.TimeMap2_timeToBeats(0, beatpos) |
| 1482 | + local _, division, _, _ = r.GetSetProjectGrid(0,false) |
| 1483 | + beatpos = r.TimeMap2_beatsToTime(0, fullbeats +(division*2*(cdenom/4))) |
| 1484 | + return beatpos |
| 1485 | + end |
| 1486 | + |
1478 | 1487 | grid_dist = (srate*(Gtolerance_v/1000)) |
1479 | 1488 |
|
1480 | 1489 | local blockline = first_sel_item_start |
@@ -1504,22 +1513,15 @@ function Create_Grid_table() |
1504 | 1513 | end |
1505 | 1514 | end |
1506 | 1515 |
|
1507 | | - |
1508 | 1516 | while (blockline <= first_sel_item_end) do |
1509 | 1517 |
|
1510 | | - function beatc(beatpos) |
1511 | | - local retval, measures, cml, fullbeats, cdenom = r.TimeMap2_timeToBeats(0, beatpos) |
1512 | | - local _, division, _, _ = r.GetSetProjectGrid(0,false) |
1513 | | - beatpos = r.TimeMap2_beatsToTime(0, fullbeats +(division*2*(cdenom/4))) |
1514 | | - return beatpos |
1515 | | - end |
1516 | | - |
1517 | 1518 | blockline = beatc(blockline) |
1518 | | - |
| 1519 | + local blocklineQN = r.TimeMap2_timeToQN( 0, blockline ) |
1519 | 1520 | h = h + 1 |
1520 | 1521 |
|
1521 | 1522 | Grid_blocks_Ruler[h] = floor(((blockline - first_sel_item_start)*srate)) |
1522 | | - if fmod(blockline,0.5) == 0 then |
| 1523 | + |
| 1524 | + if abs(floor(blocklineQN)- blocklineQN)<1e-13 then |
1523 | 1525 | Grid_blocks_Ruler_thickness[h] = 2 |
1524 | 1526 | else |
1525 | 1527 | Grid_blocks_Ruler_thickness[h] = 1 |
@@ -1583,10 +1585,11 @@ end |
1583 | 1585 | ---------------------------------------------------------------------------------- |
1584 | 1586 | function Trig_line_thickness(input) |
1585 | 1587 | QN_lineTHICK = {} |
1586 | | - |
1587 | 1588 | for i=1, #input, 2 do |
1588 | | - local gridcheck = fmod(r.TimeMap2_timeToQN(0,(input[i]/first_srate)+ first_sel_item_start),1) |
1589 | | - if gridcheck <= (divis*2) then |
| 1589 | + local gridcheck = r.TimeMap2_timeToQN(0,(input[i]/first_srate)+ first_sel_item_start) |
| 1590 | + gridcheck = abs(floor(gridcheck)-gridcheck) |
| 1591 | + |
| 1592 | + if (gridcheck <= (divis*2) or gridcheck >= 1-(divis*2)) and GridScan then |
1590 | 1593 | QN_lineTHICK[i] = 2 |
1591 | 1594 | else |
1592 | 1595 | QN_lineTHICK[i] = 1 |
|
0 commit comments