DEADBEEF
DEADBEEF

Reputation: 2290

How to use Core Audio in Swift language

I'm starting using Swift for my new audio app and I need to use Apple Core Audio library.

Let's be honest, Swift is a great language and I love it but as soon as we have to use C, pointers and other stuff it becomes really annoying to use it.

In order to make it a clear and clean interface I would to know you thoughts about interfacing Core Audio and Swift.

I thought to use C++ (for the convenients std::vector and more) or C but both require using bridging.

So my questions are:

  1. Do you use pure Swift or C/C++Bridge when you use Core Audio?
  2. Which one will be the faster?

Upvotes: 4

Views: 614

Answers (1)

DEADBEEF
DEADBEEF

Reputation: 2290

I think I found the answers so I will leave it here if somebody is interested

  1. The bridge approach is preferred. As invalidname (Chris Adamson) said in media framework talk you have to Render unto Caesar the things that are Caesar's, and unto God the things that are God's i.e use C for C API and Swift for swifty things.
  2. Talking about performance I found an article which discusses about it. The conclusion is that for primitive type there is no problem by making all the type conversion, calling C function and making the backward type conversion. But for some type like String/char*, struct and more complicated type you could encoure performance decrease.

Btw don't hesitate to add more things if you think it could help other people.

Upvotes: 2

Related Questions