Re: Real-time buffer playback in Swift?
Re: Real-time buffer playback in Swift?
- Subject: Re: Real-time buffer playback in Swift?
- From: Ian Kemmish <email@hidden>
- Date: Tue, 16 Sep 2014 20:23:36 +0100
On 16 Sep 2014, at 14:56 -0400, Rob Nikander <email@hidden> wrote:
> On Tue, Sep 16, 2014 at 8:10 AM, Paul Davis <email@hidden>
> wrote:
>>
>>
>> I'm puzzled why you think this is possible. Last time I read about this,
>> Apple's position was that realtime (i.e. low latency) audio still required
>> C/C++.
>>
>
> Do you remember where you read that? I've not seen such a statement, and I
> too was just wondering if I could write an AudioUnit render callback in
> Swift.
An AudioUnit render callback is an interrupt handler, to all practical intents and purposes. To risk typing a generalisation on the Internet: If the language you're using lets you write interrupt handlers, then you can write a render callback in it; if it doesn't, you can't.
Does Swift let you do that? If, as stated earlier in this thread it doesn't let you take the address of a function (because that's unsafe), then clearly it cannot.
In addition, Apple's propaganda for Swift suggests that it's a just-in-time compiled language, which might mean trying to run the compiler the first time your callback gets called back, which in turn would require allocating memory, which in turn breaks the commandment that thou shalt not do anything which might conceivably block during real-time code.
The easiest way out of this design decision you've taken would seem to be to write all of the real-time code in C and then either i) find a way of importing an arbitrary C library into a Swift project, or ii) put it all in a separate server process and have your Swift code talk to your C code via your favourite kind of IPC. (Back when the world was young I wrote graphics and window bindings for various interpreted languages like APL, Forth and Lisp, and I had to adopt both of these approaches in different circumstances.)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ian Kemmish 18 Durham Close, Biggleswade, Beds SG18 8HZ
email@hidden Tel: +44 1767 601361 Mob: +44 7952 854387
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden