• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Real-time buffer playback in Swift?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Real-time buffer playback in Swift?


  • Subject: Re: Real-time buffer playback in Swift?
  • From: Robert Thompson <email@hidden>
  • Date: Wed, 17 Sep 2014 14:44:53 -0400

I’m on the same track as Charles and I encourage him to stay with this list and see it through — everyone will be the better for it.

My origins of programming are C/C++ based all the way back to Zortech C++ so that’s not a problem — what is a problem is when there are difficult ways to navigate the C Audio API and anyone has a mindset to stay there and there only and not try to help others move forward.

I think it’s in everyone’s best interest to encourage pushing Swift and the New AV… APIs to the limit and the best Mentors from the C API domain will be those of a mature mindset who want to help the nextgen move forward.

~ Robert Thompson

On Sep 16, 2014, at 4:56 PM, Charles Constant <email@hidden> wrote:

Since the new AV stuff just wraps CoreAudio, I'll probably start with Swift, and if the performance is unacceptable, rewrite the portions I need to in C. I think you get access to underlying data structures, so hopefully I can mix and match.

I should perhaps just heed the multiple warnings in this thread, but the new API looks simple enough that I think it will only be a few wasted days if I scrap it.

> If I was writing a sound editor (chortle - inside joke) and it was focused only on OS X

Well, I see on Wikipedia that you have reason to sound confident :) 

On Tue, Sep 16, 2014 at 1:22 PM, Paul Davis <email@hidden> wrote:
I think we did get a little side-tracked here. The API you're talking about ... AV* ... probably/possibly can be used from Swift because of the amount of buffering it allows. However, the underlying CoreAudio API (and AudioUnits along with it) relies on callbacks that must execute in more or less hard realtime. The AV stuff is essentially a simplifcation and buffer-ication layer on top of CoreAudio to help apps with some common less-than-realtime goals.

If I was writing a sound editor (chortle - inside joke) and it was focused only on OS X, I'd be planning to use CoreAudio, not the AV* layer(s). But your mileage may vary,

On Tue, Sep 16, 2014 at 4:15 PM, Charles Constant <email@hidden> wrote:
Re: "real time", "render callback"

It's very possible that I have a misunderstanding of the correct terminology here. What I need to do in my project is not get such low latency that someone could monitor vocals etc. 

All I need to do is mix some buffers together from memory on the fly, and update the position of the playhead. The WWDC video for Session 502 makes this seem possible (I could be wrong) by 
1) repeatedly enqueing buffer segments (presumably the thing starts playing after you send it the first one) 
and then 
2) only updating some variable that represents the playhead frame. 

This is just my impression. This is my first day with this API so I'm not positive by any means that I understand it, and I never did get Swift to use callbacks, so in that case I don't claim it should work.

You definitely seem more confident than I am here, I'd be interested to get you take on that session.

On Tue, Sep 16, 2014 at 12:45 PM, Paul Davis <email@hidden> wrote:


On Tue, Sep 16, 2014 at 3:41 PM, Charles Constant <email@hidden> wrote:
> the fact that you can't use a swift function for the render callback given the API design 
> does seem indicative of the sort of message apple may want to send here ....

Swift may well be inherently inappropriate for render callbacks, but I imagine Swift's inability to create a CFunctionPointers has far-enough reaching effects that some of them wouldn't involve performance.

> 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++.

Well, evidently it's because *I* hadn't read that : ) If that's their position, I'm glad I stopped trying. I'm quite sure queuing up scheduled segments, and handling menial tasks in the completion callbacks, should be okay in the *new* API though, since the WWDC examples were all Obj-C and presumably Swift performance should wind up comparable to Obj-C.

You have examples of render callbacks implemented in Objective C?

People misunderstand the issue of language choice. It isn't about the *amount* of work that needs doing. It is about invisible, unpredictable overhead that the language runtime library may incur outside your control.

This is why objective C has never been acceptable for render callbacks, and why any language that attempts to remove the "pain" of C or C++ is also likely not acceptable (though there could be an exception at some point).
 



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
References: 
 >Real-time buffer playback in Swift? (From: Charles Constant <email@hidden>)
 >Re: Real-time buffer playback in Swift? (From: Paul Davis <email@hidden>)
 >Re: Real-time buffer playback in Swift? (From: Rob Nikander <email@hidden>)
 >Re: Real-time buffer playback in Swift? (From: Paul Davis <email@hidden>)
 >Re: Real-time buffer playback in Swift? (From: Charles Constant <email@hidden>)
 >Re: Real-time buffer playback in Swift? (From: Paul Davis <email@hidden>)
 >Re: Real-time buffer playback in Swift? (From: Charles Constant <email@hidden>)
 >Re: Real-time buffer playback in Swift? (From: Paul Davis <email@hidden>)
 >Re: Real-time buffer playback in Swift? (From: Charles Constant <email@hidden>)

  • Prev by Date: Re: Real-time buffer playback in Swift?
  • Next by Date: Re: Real-time buffer playback in Swift?
  • Previous by thread: Re: Real-time buffer playback in Swift?
  • Next by thread: Re: Real-time buffer playback in Swift?
  • Index(es):
    • Date
    • Thread