Quote:
Originally Posted by Kaxaze music
I am going this route
Code:
--to set the grid to triplet if the project is set to triplet
local retval1, gridSize = reaper.GetSetProjectGrid(0, false)
local biggestTripletGrid = 0.16666666666667
if gridSize == biggestTripletGrid or gridSize == biggestTripletGrid / 2 or gridSize == biggestTripletGrid / 4 or gridSize == biggestTripletGrid / 8 then
reaper.SetMIDIEditorGrid(gridSize)
reaper.ShowConsoleMsg("true")
else
reaper.ShowConsoleMsg("false")
end
but it always prints "false" to the console that means it doesn't executes the "reaper.SetMIDIEditorGrid(gridSize)" function
|
There were 2 problems in your example:
1. The value you assigned to the "biggestTripletGrid" variable is a rounded number while Reaper holds a number with a higher number of decimals stored within the "gridSize" variable. That's why your comparison of "gridSize" and "biggestTripletGrid" always fails.
2. The "SetMIDIEditorGrid" function has 2 parameters and the first one is the project (set 0 for active project) and the 2nd one is grid size.
Corrected below (sets MIDI editor grid to 1/4 triplet):
Code:
--to set the grid to triplet if the project is set to triplet
local retval1, gridSize = reaper.GetSetProjectGrid(0, false)
local biggestTripletGrid = 1/3
if gridSize == biggestTripletGrid or gridSize == biggestTripletGrid / 2 or gridSize == biggestTripletGrid / 4 or gridSize == biggestTripletGrid / 8 then
reaper.SetMIDIEditorGrid(0, gridSize)
reaper.ShowConsoleMsg("true")
else
reaper.ShowConsoleMsg("false")
end