tags:

views:

26

answers:

3

I have an mp3 playing application written in C# which I would like to port to OSX.

As it uses DirectShow to play mp3 I realise that I will need to recode the audio playback part. I found Apple's playfile sample which uses AUGraph.

The Binding Cocoa section of http://www.mono-project.com/MonoMac mentions the "much simpler AudioToolBox API".

Can anyone point me at sample code for using the AudioToolBox from C# or preferably using AUGraph from C#.

Is porting my code to monomac the best approach or would I be better taking the plunge and recoding in Objective C.

A: 

AUGraph is part of Core Audio. It is used to assemble a graph of Audio units and can be used for audio playback. Core Audio is a low level framework that has a C API.
Maybe you can use QTKit (a cocoa wrapper around QuickTime) from Mono.

In my opinion it is always the best approach to work with a platforms "native" technology. (Which would be Objective-C and Cocoa for Mac OS X). Apple has a nice sample that shows how to create a media player using QTKit: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/QTKitApplicationTutorial/Introduction/Introduction.html%23//apple_ref/doc/uid/TP40008155-CH1-SW1

weichsel
MonoMac *is* Cocoa. It's no different from using e.g. MacRuby.
mhutch
A: 

The page you linked does say that AudioToolbox (i.e. CoreAudio) is fully bound. I don't know of any samples but it shouldn't be hard to port C code.

Alternatively you could go onto the mono-osx mailing list and request a binding of QTKit, or even do this binding yourself. I hear that the MonoMac binding generator makes it quite easy to bind Objective-C APIs.

It's going to be much quicker and easier to use your existing C# code and knowledge, even if you do have to do some bindings yourself.

mhutch