leolabs / ableton-js

Control Ableton Live with Node.js
MIT License
368 stars 46 forks source link

Is the current_song_time format in ms? #10

Closed dasantonym closed 4 years ago

dasantonym commented 4 years ago

I just started out with this module so maybe I am missing something, but I noticed this:

I subscribe to 'current_song_time' like this:

const ableton = new Ableton()
ableton.song.addListener('current_song_time', t => console.log('Time:', t))

The Ableton doc is at 120bpm and I step to clock time 3.1.1 which gives me the output Time: 8.

The specs say this:

Live.Song.Song.current_song_time Property
Get/Set access to the songs current playing position in ms.

Shouldn't the output be Time: 4000 for this setup? The value seems somehow fixed to the bar counter, not the implicit time value. When I change the signature and tempo, the output stays the same.

leolabs commented 4 years ago

Hey @dasantonym, the current_song_time is measured in beats, starting at 0. So if your song is in 4/4, 8 relates to 3.1.1, 16 relates to 5.1.1 and so on. To get the time in milliseconds, you'd have to divide the number by your bpm and multiply it by 60000. So 8 at 120 bpm would be 8 / 120 * 60000 = 4000. This will get tricky, however, when you have projects with an automated speed curve.

I hope this helps. If you have any questions, feel free to ask :)

dasantonym commented 4 years ago

No that's all fine as beats are exactly what I need. I was just confused because I was looking at the (unofficial) API docs for reference. So I did some more research and it really seems that the documentation is wrong at https://julienbayle.studio/PythonLiveAPI_documentation/Live10.0.2.xml.

Thanks for the quick response and this fantastic module!