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

Initial BPM and ABLinkNew() #44

Closed BlipGit closed 2 years ago

BlipGit commented 6 years ago

During my app's startup sequence, I call ABLinkNew() with a fixed default value of 120BPM. This is because the app is unable to determine the preferred tempo until the user has loaded a project (set).

Later, when the user loads a project, the app does not propose a tempo change to the ABL session but instead uses the session's current tempo. This means the app will confirm to requirement "TEMPO-3: When connected, loading a new document should not change the Link session tempo".

My problem: When a new peer connects to the session and requests the tempo, it gets the default value of 120BPM rather than the current tempo of the peer which started the session. Obviously, this occurs because the session was initialized with 120BPM and no peer has since proposed a tempo change.

My question: Is there a way the app can ask the API 'am I the only peer in this session'? If so, it then it knows it's the master and it may propose the session's tempo even when loading a new set/project.

I've tried using ABLLinkIsConnected() for this purpose, but it can return false for a short time when the peer's initially connecting and therefore gives 'false negatives'.

fgo-ableton commented 6 years ago

ABLLinkSetActive can help you here. When Link is not active it will not search for peers on the network or propose tempo changes. So if you activate Link only after loading the project and committing the project tempo to Link, the peers on the network should be able determine the correct tempo. ABLLinkIsConnected is not designed for this use case. The returned value is being dependent on asynchronous input from the network and can change in between to function calls on the API.

msedd commented 4 years ago

I have a similar issue. I develop a stage lighting app. My app starts the ABLinkNew() with 120 bpm. And if an audio app is connecting, they get my 120 bpm and this is mostly the wrong value. The flow is very difficult to ensure that not the light control BPM settings change the sound. Are there any recommendations on how I should do it right?

fgo-ableton commented 4 years ago

Internally Link adapts the tempo of the oldest existing session that is found on the network. So if you init Link with 120 bpm, and then activate it while other peers are running at a different tempo, it should never push the inital tempo to the others. If the tempo is set while Link is active, it will propagate to other peers. So you should make sure, to never call ABLLinkSetTempo with an active Link session, if the tempo is not meant to propagate to other peers.

msedd commented 4 years ago

Yes, I never use ABLLinkSetTempo in my app, I only consume BTM and beat. But the initialization is sometimes wrong, depends on who is starting the link session first. For my case, it would be nice if I could initialize a link session without BPM or an additional master/slave role.

fgo-ableton commented 4 years ago

What do you mean by "depends on who is starting the link session first"? Link always uses the tempo of the session that is started first, as the longest running app is the one, that is most likely playing. So if a music app is running and you start your app, the music app should not be affected. Internally Link always requires a tempo, so it is unfortunately not possible to init it without bpm.

msedd commented 4 years ago

Maybe someone starts my app and Ableton Link is already enabled in the settings (maybe from the last time). Then he starts the DJ software/hardware or activates Ableton Link. Then my (default) BPM effects the music. I could image that customers don't understand the reason.

I tested the last days a lot with different music software (Ableton Live, Traktor, DJay (iOS)) In Traktor and DJay the Master BPM ist synchronized over Ableton Link. But if I start a new song it doesn't change the Master BPM. In sync mode, the song BPM will be adapted.
This means:

  1. the audio is to slow or to fast (sync + link) or
  2. the audio and the lighting is not in sync (link)

But maybe this is an issue from the music software. Manually Switching a TRAKTOR Deck to Master Breaks Ableton LINK Synchronization

fgo-ableton commented 4 years ago

I see. Link does not distinguish the kind of app, nor does it determine if the apps that have enabled Link are actually playing audio or video. So IMHO the current behavior is just fine. And it is also consistent with what other apps should do: https://ableton.github.io/linkkit/#test-plan

msedd commented 4 years ago

Thank you! I have already have tested with this plan. This is really a big help.