All right, I finally managed to get something to work that both is simple and does what it's supposed to do: playing MIDI files in the background
and looping them. This was after a dozen Frankenstein constructions which either worked but produced all kinds of menacing warnings in both the compiler and the console, or didn't work at all. I tried callback functions, and apparently these only work if the movie is used inside an NSMovieView object, so there is not really an advantage in using them...
My final solution consists of a dummy window created in IB with a NSMovieView inside it, and a class "SongController" which controls the movie inside the view. Because the game doesn't use any nib files by itself, I had to create a NSWindowController to invoke the window. Now I can make the music loop simply by setting [myNSMovieView setLoopMode:NSQTMovieLoopingPlayback]. However, this is only true if the "Visible at launch time" attribute of the window is set, otherwise it - again - won't loop. Luckily the window is behind the actual game display, so there is no need to hide it.
The upside of all these experiments is that I learned a lot about Cocoa programming
Now there is only one problem left before I can use this system to play songs in the game: how can I reach the ObjectiveC methods of the movie controller class I created, from within the old fashioned C code of the game itself? The movie controller is an object created by the window manager. All I need is some way to send commands to this object, but how?
I will probably need to 'export' a reference to the object when its 'awakeFromNib' method is called, but how can I reach this reference from the outside, and how do I call ObjectiveC methods from within the C code?
