RomeoDespres/reapy

FR: Add time_to_beat and beat_to_time method to take class

Closed this issue · 2 comments

Currently, we have time_to_ppq and ppq_to_beat from the native reaper API, and same for reversed.
It would be convenient to provide a time_to_beat and beat_to_time function to the Take class.

The workaround currently is to define the following function

def time_to_beat(take, t):
return take.ppq_to_beat(take.time_to_ppq(t))

As you can see, the take argument is completely unnecessary except for the calling of two methods. Thus if we simply implement this method into Take class, we only need to provide t as the only argument, which is consistent with the two native methods used above.

Thanks for the suggestion. Please note it is quite easy to compute time-beats conversions, as shown below. Still, it may be a good idea to add it to the Project class, instead of having everyone recode the same thing.

def time_to_beats(project, t):
    return project.bpm * t / 60

Well... just figured out Project.time_to_beats and its counterpart already exist!... I guess this closes this issue then.