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

No apps discovered to connect #19

Closed jkichline closed 8 years ago

jkichline commented 8 years ago

I've been trying to add Ableton Link to my app. Everything seems to work correctly and I'm calling the necessary methods at the right time. However, when I open the Ableton Link menu to connect to apps, none are ever displayed.

This is the full code of the implementation. I just open the settingViewController and enable Link with that.

//
//  AbletonLinkManager.m
//  OnSong
//
//  Created by Jason Kichline on 2/2/16.
//  Copyright © 2016 OnSong LLC. All rights reserved.
//

#import "AbletonLinkManager.h"
#import "OSMetronomeManager.h"
#include <mach/mach_time.h>

static void onSessionTempoChanged(Float64 bpm, void* context) {
    NSLog(@"Tempo changed to: %f", bpm);
}

@implementation AbletonLinkManager

-(id)init {
    self = [super init];
    if(self) {

        // Set up the Ableton Link Library
        float bpm = (float)(([OSMetronomeManager manager].metronome.BPM > [SongMetronome minimumBPM]) ? [OSMetronomeManager manager].metronome.BPM : [SongMetronome defaultBPM]);
        linkRef = ABLLinkNew(bpm, 4);
        ABLLinkSetSessionTempoCallback(linkRef, onSessionTempoChanged, (__bridge void *)self);

        // Listen for changes in application state to deal with turning it on and off
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil];

        // Listen for changes to BPM and set accordingly
        [[OSMetronomeManager manager].metronome addObserver:self forKeyPath:@"BPM" options:NSKeyValueChangeNewKey context:nil];
    }
    return self;
}

-(void)didBecomeActive:(NSNotification*)n {
    ABLLinkSetActive(linkRef, true);
}

-(void)didEnterBackground:(NSNotification*)n {
    ABLLinkSetActive(linkRef, false);
}

-(BOOL)isEnabled {
    return ABLLinkIsEnabled(linkRef);
}

-(BOOL)isConnected {
    return ABLLinkIsConnected(linkRef);
}

-(ABLLinkSettingsViewController*)settingsViewController {
    return [ABLLinkSettingsViewController instance:linkRef];
}

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context {
    if([keyPath isEqualToString:@"BPM"]) {
        ABLLinkProposeTempo(linkRef, [OSMetronomeManager manager].metronome.BPM, mach_absolute_time());
    }
}

-(void)dealloc {
    ABLLinkDelete(linkRef);
    [[OSMetronomeManager manager].metronome removeObserver:self forKeyPath:@"BPM"];
    [super dealloc];
}

+(BOOL)isSupported {
    return ([UIDevice currentDevice].systemVersion.floatValue >= 8);
}

+(void)load {
    if([self isSupported]) {
        [AbletonLinkManager manager];
    }
}

static AbletonLinkManager* __manager;
+(AbletonLinkManager*)manager {
    if(__manager == nil) {
        __manager = [[AbletonLinkManager alloc] init];
    }
    return __manager;
}

@end

Now, my app is doing other networking related tasks. Is Ableton setting up a Bonjour web service that may be conflicting? Is there any way to debug the networking stack to troubleshoot why this is failing? Is there just something that I have not set up correcting above?

brs-ableton commented 8 years ago

I don't see anything immediately obvious from the code. You say that it seems to be working other than the settings dialog? Do you mean that Link is working - tempo changes are propagated between apps, etc. but that the dialog always indicates 0 connections? Or is it not working at all? Does it connect to the LinkHut example app when run on the same device? Does LinkHut indicate that it is connected?

Link does not use Bonjour so that shouldn't be the issue. It does require UDP communication over port 20808, so if this is blocked by your router or a firewall that could be an issue. But the best way to determine if it's an actual network issue vs. something else is whether it works between two apps on the same device.

jkichline commented 8 years ago

In my case, the Link framework is running and I can access the Link settings dialog. Everything “appears” correctly, but it never links with any other apps. If I run the LinkHut example as a separate app, everything works properly and the apps are linked. As far as I can tell, link is not working although I am certain that tempo changes are being sent to the LinkKit framework but not being propagated to the network. I am able to get Link running with multiple apps on the same device and over the network, so it appears that something in my app is preventing Link from functioning but I’m not sure what would be conflicting.

On Mar 24, 2016, at 2:20 PM, Brent Shields notifications@github.com wrote:

I don't see anything immediately obvious from the code. You say that it seems to be working other than the settings dialog? Do you mean that Link is working - tempo changes are propagated between apps, etc. but that the dialog always indicates 0 connections? Or is it not working at all? Does it connect to the LinkHut example app when run on the same device? Does LinkHut indicate that it is connected?

Link does not use Bonjour so that shouldn't be the issue. It does require UDP communication over port 20808, so if this is blocked by your router or a firewall that could be an issue. But the best way to determine if it's an actual network issue vs. something else is whether it works between two apps on the same device.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/Ableton/LinkKit/issues/19#issuecomment-200958565

brs-ableton commented 8 years ago

I'm still a little unsure about the failure mode here, could you answer a few more questions please?

When you launch your app and LinkHut on the same device, does the Link settings dialog in LinkHut indicate 0 or 1 connected apps? Does the Link settings dialog in your app match what LinkHut shows?

Your app is just logging incoming tempo changes without handling them, so it's expected that it would not follow the tempo of LinkHut when connected. But it seems like you're expecting that when your app changes tempo, LinkHut should follow. If either or both of the apps are showing "0 connected apps" then that is the problem and we should figure that out before worrying about tempo.

If, on the other hand, they are both showing "1 connected app" and you are verifying that ABLLinkProposeTempo is being called as expected, then we have more of a mystery on our hands. Can you clarify which of these cases we're dealing with?

jkichline commented 8 years ago

The issue is that I can run a sample app like Loopy HD and LinkHut or another Link-enabled app like “Link To MIDI” and the Link settings dialog will show “1 Connected App”. However, if I enabled Ableton Link inside of our app, and run a Link-enabled apps (like Loopy HD or Link To MIDI”), OnSong will never show as connecting to those apps although they will connect to each other.

I’ve tried disabling a lot of network-related connections in the app but it still will fail to find other apps. I’m sure once it can be connected that I would be able to propose a tempo change, but the problem is that it’s never “linking” to other apps.

On Apr 12, 2016, at 11:57 AM, Brent Shields notifications@github.com wrote:

I'm still a little unsure about the failure mode here, could you answer a few more questions please?

When you launch your app and LinkHut on the same device, does the Link settings dialog in LinkHut indicate 0 or 1 connected apps? Does the Link settings dialog in your app match what LinkHut shows?

Your app is just logging incoming tempo changes without handling them, so it's expected that it would not follow the tempo of LinkHut when connected. But it seems like you're expecting that when your app changes tempo, LinkHut should follow. If either or both of the apps are showing "0 connected apps" then that is the problem and we should figure that out before worrying about tempo.

If, on the other hand, they are both showing "1 connected app" and you are verifying that ABLLinkProposeTempo is being called as expected, then we have more of a mystery on our hands. Can you clarify which of these cases we're dealing with?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/Ableton/LinkKit/issues/19#issuecomment-208979213

jkichline commented 8 years ago

Brent:

Is there some kind of networking dependency that Link relies on? My app has a number of components that relying on network services like AsyncSocket, GCDWebServer, LIFX lighting, etc… I feel like something is conflicting with Ableton Link, perhaps a duplicate dependency, that is causing the link to fail.

I have tried launching both the LinkHut app and our app on the same device and both apps show “0 Connected Apps”. They never find each other, but other Link-enabled apps do connect as they should.

On Apr 12, 2016, at 11:57 AM, Brent Shields notifications@github.com wrote:

I'm still a little unsure about the failure mode here, could you answer a few more questions please?

When you launch your app and LinkHut on the same device, does the Link settings dialog in LinkHut indicate 0 or 1 connected apps? Does the Link settings dialog in your app match what LinkHut shows?

Your app is just logging incoming tempo changes without handling them, so it's expected that it would not follow the tempo of LinkHut when connected. But it seems like you're expecting that when your app changes tempo, LinkHut should follow. If either or both of the apps are showing "0 connected apps" then that is the problem and we should figure that out before worrying about tempo.

If, on the other hand, they are both showing "1 connected app" and you are verifying that ABLLinkProposeTempo is being called as expected, then we have more of a mystery on our hands. Can you clarify which of these cases we're dealing with?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/Ableton/LinkKit/issues/19#issuecomment-208979213

brs-ableton commented 8 years ago

Link uses the boost::asio library for networking, so that's a dependency. It uses UDP multicast over port 20808, so any library that may interfere with communication on this port with this protocol would cause problems for Link.

peteblues commented 8 years ago

I’m running the LinkHut sample app in the iPhone simulator, but can’t see any apps to connect either. I’m running Live on the same machine.

  1. can I run LinkHut in the iphone/ipad simulator?
  2. can I connect to Live on the same machine?

Peter

On Mar 24, 2016, at 11:20 AM, Brent Shields notifications@github.com wrote:

I don't see anything immediately obvious from the code. You say that it seems to be working other than the settings dialog? Do you mean that Link is working - tempo changes are propagated between apps, etc. but that the dialog always indicates 0 connections? Or is it not working at all? Does it connect to the LinkHut example app when run on the same device? Does LinkHut indicate that it is connected?

Link does not use Bonjour so that shouldn't be the issue. It does require UDP communication over port 20808, so if this is blocked by your router or a firewall that could be an issue. But the best way to determine if it's an actual network issue vs. something else is whether it works between two apps on the same device.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/Ableton/LinkKit/issues/19#issuecomment-200958565

brs-ableton commented 8 years ago

@peteblues Yes and Yes. Those things should both work. When you run LinkHut in the simulator, do you get a dialog about allowing incoming network connections?

peteblues commented 8 years ago

It’s working fine now. I must have had some starter hiccups.

Peter

Quoting Brent Shields notifications@github.com:

@peteblues Yes and Yes. Those things should both work. When you run
LinkHut in the simulator, do you get a dialog about allowing
incoming network connections?


You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/Ableton/LinkKit/issues/19#issuecomment-219757728