Pos_To_Time() Function. (Midi)

Well we’ve already covered this one:

 delay = delay * 100 / 256 * .01  

The *100 and *0.01 cancel each other out so just delay/256 is needed.

And I assume the other part is converting a Tick value into a Delay value, correct? If so your “local delay = tick*256/TPL” looks correct to me.


I see both these above give you an answer in difference formats. The first will turn a Delay into a “Fraction of Line” and the second one converts Ticks in Renoise Delay value. I guess you are then going to convert this into Fraction of Line, as with the original Delay value. Correct?

If so that is again a simple divide by 256 BUT you are adding extra work by going to Delay value then Fraction of Line value. If you only want the final Fraction very simply Tick/TPL.


For this do just use Tick/TPL.

Normalised as in quantised to Delay column? OK…

-- Tick to delay  
function export_tick_to_delay(tick, tpl)  
 if tick > tpl then return false end  
 delay = tick * 256 / tpl  
 return math.floor(delay + .5) --Round** - This rounds up and leaves the integer yeah?  
 local delay = delay / 256 -- This will give you 0.xx value.  
 ??return math.max(0, math.min(local delay, 256))?? --What is purpose of this line?  

May have the command wrong as have copied it from a section of earlier code you posted I assume does this but if you want quantised to the Delay column you are going to have to convert to the Delay (as you did) then Round Off, removing decimal places, then do the covert to fraction from that. Hopefully you get what I am trying to do with the addition above even if I’ve got the code wrong as have to admit haven’t even looked properly at the API. Also changed a couple of your constant labels around. Delay used for when it is the same as a Delay value inported direct from Renoise, Local Delay for the 0.xx fractional value you want at the end.

Hope I’m making sense and not just rambling like a madman!

Cheers. I think I got it.