Ableton / LinkKit

iOS SDK for Ableton Link, a new technology that synchronizes musical beat, tempo, and phase across multiple applications running on one or more devices.
http://ableton.github.io/linkkit
Other
149 stars 10 forks source link

ABLLinkSetTempo does nothing #22

Closed luismartimor closed 8 years ago

luismartimor commented 8 years ago

I've been implementing Link these days and seems to work perfect except for one thing. ABLLinkSetTempo does absolutely nothing. Here is the code relating to the problem. tempoChange is setted only when the user changes the tempo in my app. Why is this tempo proposal ignored ?

const UInt64 hostTimeAtBufferBegin = inTimeStamp->mHostTime + soundStructPointerArray[0].outputLatency;
    const ABLLinkTimelineRef timeline =
    ABLLinkCaptureAudioTimeline(soundStructPointerArray[0].ablLink);
    if (soundStructPointerArray[0].tempoChange) {
        ABLLinkSetTempo(timeline, soundStructPointerArray[0].tempoChange, hostTimeAtBufferBegin);
        soundStructPointerArray[0].tempoChange=0;
    }
brs-ableton commented 8 years ago

Hi @mekeo,

Just so it's clear, you're using the LinkKit 2.0.0-Beta-1 release, which is a pre-release (not ready for production yet). I expect that we'll have a production-ready 2.0.0 release relatively soon, so if you can wait a little bit it makes sense to build on this but I just wanted to make sure you're aware.

As to your question, I think the problem is that you're not committing the modified timeline after you change it. ABLLinkSetTempo modifies the timeline that you pass to it, but the Link session does not change until you actually commit a modified timeline using ABLLinkCommitAudioTimeline. You can call the commit function unconditionally at the end of your audio callback because if the timeline hasn't changed it will be a no-op.

We've made the API more transactional in this 2.0 version for a couple of reasons:

luismartimor commented 8 years ago

Perfect answer, thanks!