This works correctly on every set of inputs I've given it so far (some thousands).
One slight issue is that the function prints compositions to the console, rather than returning them in an array.
A quick and ugly fix is to pass some variable "comps" into and out of the function N2N(). Then, replace the two disp() calls with "comps = [comps;cell]" and "comps = [comps;n]", respectively. I'm sure there's a much neater way of doing this, though.
This is absolutely excellent! I'll never use Windows Movie Maker again!
Just one thing to note is that a few more usage examples might be useful. For example, framerate is set using: "aid=aopen('-f','foo','-d',32);" ... not "aid=aopen('-f','foo','-d','32');" or "aid=aopen('-f','foo','-d 32');" etc.
This may be obvious, but it could save some people a little time.