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
147 stars 10 forks source link

Are the hostTimeAtOutput argument of the ABLLinkSetTempo method has any restrictions? #50

Closed 0Dmitry closed 5 years ago

0Dmitry commented 5 years ago

I was playing with the LinkHut project. I changed the line where the the new tempo is applied to the link session(AudioEngine.m, line 215).

From this: ABLLinkSetTempo(sessionState, engineData.proposeBpm, hostTimeAtBufferBegin); To this: ABLLinkSetTempo(sessionState, engineData.proposeBpm, hostTimeAtBufferBegin + (UInt64)linkData->secondsToHostTime*5.0);

I also changed the decreaseBpm and increaseBpm methods so the changes to tempo are more rapid.

- (void)increaseBpm {
    _bpm += 60;//  instead of ++_bpm;
    _audioEngine.bpm = _bpm;
}

I thought that with these changes I would get a behaviour where every tempo change is postponed by 5 seconds. But it looks like the tempo still changes immediately after I tap on plus/minus buttons.

Can someone explain me what I am doing wrong?

fgo-ableton commented 5 years ago

Link does not schedule events. It immediately proposes the new tempo to the other peers. I can see how that is not obvious from the header comment. The host time given to ABLLinkSetTempo is used to let Link know, at which host time the new tempo is used by the client, in respect to audio hardware latency and position of the change in the current audio buffer. In general you should not schedule tempo changes with Link. Only commit a new tempo to the Link session once you actually use it. When setting a tempo before using it, it is possible for other peers on the network to schedule changes too - so it is not guaranteed, that the change will actually when you expect it. If your app requires scheduling, do that locally, and then commit the new tempo to Link when it is used by your app.

0Dmitry commented 5 years ago

Got it. Thanks for the reply.