Monday, January 07, 2008

Ninjammer

Ninjam is a fantastic invention. It allows for people to connect from across the world via the internet and play music. How is the internet latency compensated? Well, the interval is stretched and expressed as a musical measure of time in beats in relation to a master tempo streamed from a Ninjam server. How beautiful.

I get the feeling that Ninjam is made for those people playing so-called traditional instruments; think guitars, bass, piano, cello etc. However, i have a need to jam on Ninjam using Ableton live. Of course, synchronisation becomes a big issue - even the slightest jolt of the internal metronome on Live, and the whole feel and rhythm is completely out, and also very difficult to correct without stopping the sequencer. Additionally, everything drifts out of time - always.

I am aware of the fact that there is a Windows version of the Ninjam client that generates a MIDI beat clock signal from the master ninjam metronome, allowing for a tight synchronisation between a host sequencer and the Ninjam interface.

But i have not found such a tool for Mac OS X.

I have constructed a simple Max/MSP patch that acts as a "quick fix" to the problem by generating a MIDI beat clock signal.

How does it work? Let us review some important facts about Ninjam and MIDI beat clock.

Ninjam always works with an interval divided up into a given number of beats based on a master metronome. I assume that all parties hear this master metronome in some form if they are wanting to; otherwise, what is the point of Ninjam if we are all out of sync. Thus, it can be said that the master metronome is the tempo authority when it comes to all parties in a jam. The metronome outputs at a rate of one click per quarter note. The client knows the current tempo of the Ninjam metronome. This tempo does not change all the time.

MIDI beat clock operates as an analogy of a tempo speed (ie. unlike timcode). MIDI beat clock generates / accepts 24 pulse per quarter note (and sends the byte 248 this often).

So. The audio output of the metronome stream from Ninjam is fed into the patch. A threshold is set, above which signifies a pulse. This threshold will trigger a 248 byte once per quarter-note click from the Ninjam metronome. This byte is then echoed 23 times and fed into a MIDI output. The interval between the echoes is calculated based on the master BPM tempo in the Ninjam client.

This system may not always be perfect. However, because the patch is simply reacting to the metronome and not generating its own metronome counter so to speak, the MIDI clock stream is constantly adjusting and on average it actually sounds relatively good. There is no audible drift over long periods of time because of this self-correcting sort of mechanism.

Finally, the start byte (250) is always latched out on a quarter note pulse from the Ninjam metronome.

The MIDI beat clock signal can be internally routed to Ableton Live for example.

The major limitation with this setup is that the signal one transmits to other Ninjam users must be mono.





Download the patch / collective here: http://milkcrate.com.au/_other/downloads/max_patches/ninjammer.zip

7 comments:

adam said...

the standard ninjam servers are indeed occupied be rock men and jazz men ;) it's hard to play with the former & i guess it's easier to play withe the latter. still ther are some people more electronic-oriented (and using Live or anything similar).
ninjam is free also as a server, so why not having your own server? on the other hand a have a friend opening his own server form time to time for jams. and yes - we use Live ;)

David said...

can you post a runtime of the patch? I don't own Max/MSP, and I don't think I can port this over to Reaktor :(

Sebastian Tomczak said...

David -- You can download the patch / collective in the link down the bottom of the post. But i won't say that it works 100% yet! Very much an experiment.

Adam -- It is good to hear that you use Live with Ninjam. Do you sync? If so, how?

David said...

oops, didn't see the link somehow. So... I went and made my own version of the patch using a trial copy of Max. My version worked, but lost the beat about 6 or 8 measures in. Will try yours. I have no reliable way, so far, to sync properly.

Sebastian Tomczak said...

david, i only added the patch just then, today! ;-)

but. as i said. this is an experiment. no guarantees.

cheers,

PHobik2000 said...

Have you tried Reaper? It has a Ninjam plugin and it's a DAW, and VST host.

Google is your friend, but try this link:
http://www.kvraudio.com/forum/viewtopic.php?t=202377&postdays=0&postorder=asc&start=15

Sebastian Tomczak said...

Hi there, I'm running OS X and as far as I understand, reaper on OS X is not even in its beta stage.

But thanks for the link.