Rss

Archives for : coreaudio

Brain Dump: v3 Audio Units

Thanks to the power of unemployment freeing up my daily schedule, I was able to put a lot of work into my talk about Media Frameworks and Swift. The first version of this debuted at Forward Swift in March and was limited to 30 minutes. With an hour to fill at CocoaConf Chicago last weekend, I needed a second demo. And the obvious place for it was to stop talking about v3 Audio Units and actually write one.

Audio Units logo

Background info: audio units are self-contained modules that do something with audio. There are several distinct types: generators that produce sound (like by synthesis or playing from a file), effects that take incoming sound and change it in some way, mixers that combine multiple sources, etc. These units are available in any application that supports the audio unit standard, so they’re seen in things like Logic and GarageBand. Prior to El Capitan and iOS 9, audio units were a Mac-only technology: the closest approximation on iOS was to have some other audio unit set up a “render callback”, meaning you’d provide a pointer to your own function, to be called whenever the downstream unit wanted to pull some samples, and you’d put your audio processing code in there.

We covered using audio units in chapters 7 and 8 of the Learning Core Audio book, but didn’t actually cover creating them. We didn’t do that for a number of reasons: the documentation and base C++ class from Apple was outdated and appeared to be broken, making your own AU was Mac-only, we’d already spent two chapters on audio units, and our editor was leaving and we decided to go pencils-down and ship the damn thing. So, wouldn’t you know it, the first review on iBooks basically ripped us for not covering how to create audio units and dismissed the rest of the book as one-star garbage (and in my own defense, that’s an opinion not shared by any of the other reviews on iBooks and Amazon).

But still, it has bugged me for years that I had never actually written an audio unit of my own. So if one good thing comes from my current flirtations with insolvency, it’s that goddammit, I’m finally writing a working audio unit.

So, iBooks reviewer whichdokta, this one’s for you. And in the immortal words of Elvis Costello, I Hope You’re Happy Now

Continue Reading >>

Render Unto C-sar

A few weeks back, I did a presentation at Forward Swift, the idea of which to explore how the media frameworks reveal some really interesting pain points in using Swift, and what this tells us about the language.

Slides are already up on Slideshare, and can be viewed here:



I’ll be doing this talk again at CocoaConf Chicago and an NDA event that will probably be announced next week. Forward Swift usually posts its videos eventually, and I’ll blog here once mine is available.

But I want to dig into one of the key points of the talk, because it came up again earlier this week…

Continue Reading >>

Spring 2017 Conferences

Quick note, before Early Bird pricing ends. I’m speaking at two conferences this Spring.

I’ll be at Forward Swift in San Francisco on March 2. There, I’m doing a talk called “Audio Frameworks and Swift: This Is Fine”. The idea of the talk is to look at how well Swift does and doesn’t work as a language for calling the iOS and Mac audio frameworks. This covers things like how to call the C-based frameworks (Audio Toolbox and the other higher-level parts of Core Audio) from Swift, and where you get into some real mismatches between the languages, and what to do about it. I covered this phenomenon on the blog a while back in Radio on the TV.

My plan is to write an audio reverser app to demo this, as I don’t think there’s a good way to do that in AV Foundation, meaning you’d want to use either Audio Converter Services or Extended Audio Files from Audio Toolbox. Plus, playing music backwards should make for a fun demo.

I’ll also be covering v3 Audio Units, which specifically prohibits you from using Swift in the “kernel” of your AU, since that’s called on a realtime thread and there are all sorts of ways that Swift is not quite yet ready for that kind of use, even though it’s billed as being a systems programming language. I’ll try to make this talk more about the language — what it can and can’t/shouldn’t do, what it’s good and bad at — than the frameworks, to try to make it more approachable. I don’t want this to be a draw only for the people who’ve read the Core Audio book and happen to be in SF that week (if I wanted that, we could just get a table at Super Duper and chat over burgers and beer).

Forward Swift early bird registration ends tomorrow, so hop on it if you’re so inclined.

I’ll be doing this talk again at CocoaConf Chicago on April 21-22, along with the Firebase talk I did at CocoaConfs DC and San Jose last Fall.

CocoaConf’s early bird ends on February 25.

Hope to see you at one or both of these.

Deleted Scene

I forgot that I wanted to get this joke reference into the Throwaways post, so here it is by itself:

Continue Reading >>

Throwaways

Janie had a blog the other week about her self-destructive tendencies, one of which is to do things that feel productive but aren’t. A lot of her problem is reading a bunch of background information prior to starting a major project, something that has so many unknowns it’s imposing.

I get it because I’ve been in the same situation and done the same thing, and it didn’t work. But an approach far more naive turned out to work better.

Continue Reading >>

Radio On The TV

With the book done, and taking time off from conferences, I’ve wanted to do some coding of my own, to catch up on stuff I’ve missed out on over the last year or so. Naturally, top of the agenda is tvOS, and the various changes to the media frameworks.

So to warm up, I decided to take my old web radio project from the CocoaConf Core Audio class, and port it to tvOS. I figured that along the way, I’d also rewrite it in Swift and update some of the crustier parts of the code.

tl;dr: it works fine, but there are things I’d do differently a second time around.

Radio On The TV main UI

Continue Reading >>

Entropy

Confession: I have no idea whether the code examples from Learning Core Audio work on El Capitan and iOS 9. Maybe? Probably most of them? But I’m in a really conflicted state with where that book is.

The book came out in early 2012, which now makes it about four years old. It took about two years off and on to write, 2010 and 2011, with a big push to wrap it up at the end of 2011 because our editor was leaving Pearson to go to Apple. Looking at my mail history, I was approached about replacing Mike Lee on the book in late 2009, so the small amount of material that he and Kevin Avila wrote probably dates back to earlier in that year.

The point of this all being, the book is old now. The stated system requirements are Xcode 4.2, Lion (Mac OS X 10.7), and iOS 5. The examples in the first few chapters that use Foundation instead of Core Foundation actually use manual retain, release and the NSAutoreleasePool because the book largely pre-dates ARC (we did finally ARC-ify those examples in the April 2014 update to the downloadable sample code, at the cost of no longer matching the written material in the book).

So now what?

Continue Reading >>

AV WWDC, part 1: Hot Dog… The AVMovie

I attended WWDC for the first time since 2011, thanks largely to the fact that working for Rev means I need to go out to the office in San Francisco every 6 weeks anyways, so why not make it that week and put my name in the ticket lottery. I probably won’t make a habit of returning to WWDC, and the short supply of tickets makes that a given anyways, but it was nice to be back just this once.

Being there for work, my first priority was making use of unique-to-attendee resources, like the one-on-one UI design reviews and the developers in the labs. The latter can be hit-or-miss based on your problem… we didn’t get any silver bullet for our graphics code, but scored a crucial answer in Core Audio. We’ve found we have to fall back to the software encoder because the hardware encoder (kAppleHardwareAudioCodecManufacturer) would cause ExtAudioFileWrite() to sometimes fail with OSStatus -66570 (kExtAudioFileError_AsyncWriteBufferOverflow). So I asked about that and was told “oh yeah, we don’t support hardware encoding anymore… the new devices don’t need it and the property is just ignored”. I Slacked this to my boss and his reaction was “would be nice if that were in the documentation!” True enough, but at least that’s one wall we can stop banging our head against.

Speaking of media, now that everyone’s had their fill of “Crusty” and the Protocol-Oriented Programming session, I’m going to post a few blogs about media-related sessions.

Continue Reading >>

ARC-ing Learning Core Audio

Pearson has just posted an update to the Learning Core Audio sample code, available from the book’s home page (look under the “Downloads” tab).

Basically, this update is all about making it easier to work with the download zip. Specifically:

  • All projects now use “Latest” (OS X | iOS) as their Base SDK: We had been specifying old SDKs that are no longer included in Xcode 5.1, so some readers got hung up on what they needed to do to resolve the “Missing Base SDK” message.

  • All Foundation projects now use Automatic Reference Counting (ARC): Not as big a deal in our book as you might think, because the middle half the book is all Core Foundation and doesn’t even need ARC, but we had some readers insist the book was broken because they got build errors on [foo release] and didn’t know what to do (either remove the manual memory-management lines or just turn off ARC). This has the unfortunate effect of making the download code no longer match the book text, and adding some nuisance __bridge casts, but ARC is so entrenched at this point, it’s for the best.

  • Each project now has a README.txt file If individual examples have to get updated in the future, we can log those changes here.

  • Re-colored the “piano key” buttons in CH11_MIDIWifiSource Because iOS 7 made them look like poorly-colored labels

There are no errata fixes in this go-round, nor any content changes. It’s just about making the download more useful. Might be the last time we need to update it? We’ll see.

Conferences Are Coming

Fall’s coming, evenings are getting shorter (sorry, Southern Hemisphere, but roll with me here), and the Fall conferences are gearing up. Last week was CocoaConf Portland, and here’s me teaching the iPad Productivity APIs class (from the CocoaConf Flickr):

Chris Adamson in iPad Productivity workshop

One thing I need to get in before the jump: CocoaConf organizer Dave Klein was on episode 15 of the My Appventure podcast, and the show notes page linked above has a 20% off code for the next three CocoaConfs: Columbus, OH (Sept. 27-8), Boston, MA (Oct. 25-6), and Atlanta, GA (Nov. 15-6). I’m teaching all-day classes the day before each of these: iPad Productivity in Columbus, and Core Audio in Boston and Atlanta.

Continue Reading >>