I finally got Traktor to sync with something else - Reaper - using MIDI Clock (running on Mac OS X, on the same machine). Here's how I did it..

  • Start Traktor.
  • Start Reaper.
  • Open Reaper Preferences, select Devices > MIDI Devices.
  • Double click "Traktor Virtual Input" and select "use this device" and "send midi clock to this device".
  • In Traktor, open the sync panel thing up the top by clicking the metronome.
  • Click "EXT" button - this tells traktor to listen for MIDI Clock.

Now get a track (with an accurate grid!) loaded into a Traktor deck. In Reaper, set up something locked to the Reaper beat grid - for example, an audio or midi loop.

Press play in Reaper so your loop plays forever. In Traktor, the sync panel should show a tempo similar to the tempo in Reaper. You'll notice that it wavers about a bit. Press play on your gridded track and click Sync.

The Traktor deck should be roughly in sync with Reaper! (In fact, it is loose enough that it sounds a bit like a real DJ is nudging it.)

Questions:

  • If we send the MIDI over a network or MIDI connection to a different machine, will this sync well enough to bother with?
  • Can we sync two copies of Traktor (on different machines) this way?

If you have problems (or corrections), comment below so we can determine what I really did to make this work.

It seemed like it should be easy, and it was, but finding out how was hard. So I am posting what I did here in the hope that the next person wanting to do it finds the info they need here.

What I wanted to do


I had a Cocoa document-based app. I.e. I had followed my nose with Cocoa, and ended up with an app that supported multiple documents. Documents are represented by in subclass of NSDocument called MyDocument.

I wanted to support viewing and changing properties of the document from AppleScript.

Note that I wanted to support 10.5+, so the techniques here may not be appropriate for older versions.

How I ended up getting it working


  1. Specify things in the app's Info.plist:
    NSAppleSriptEnabled = YES

    OSAScriptingDefinition = MyApp.sdef


  2. Made an sdef file, which includes all the framework supplied stuff, and that MyDocument extends the framework document, and has a property, refered to by the key numBananas:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">

    <!-- declare the namespace for using XInclude so we can include the standard suite -->
    <dictionary xmlns:xi="http://www.w3.org/2003/XInclude">

    <!-- use XInclude to include the standard suite -->
    <xi:include href="file:///System/Library/ScriptingDefinitions/CocoaStandard.sdef" xpointer="xpointer(/dictionary/suite)"/>

    <suite name="MyApp Suite" code="LfMS" description="MyApp application specific scripting facilities.">

    <class-extension extends="document" code="docu">
    <cocoa class="MyDocument"/>
    <property name="number of bananas" code="Bana" type="integer" access="rw" description="The number of bananas in this document" >
    <cocoa key="numBananas"/>
    </property>
    </class-extension>

    </suite>

    </dictionary>

  3. Implement KVC accessors for the property. These looked (sortof) like:
    -(NSNumber*)numBananas
    {
    return [NSNumber numberWithInt:bananas];
    }

    -(void)setNumBananas:(NSNumber*)value
    {
    bananas = [value intValue];
    }



This was all that it took, and now I can enumerate all the docs, set their number of channels etc etc.

Apologies to all my regular readers if this is slightly outside your sphere of interest!