getting pcm audio for visualization via Spotify iOS SDK

We’re currently looking at taking our music visualization software that’s been around for many years to an iOS app that plays music via the new iOS Spotify SDK — check out to see our visuals such as G-Force and Aeon.

Anyway, we have the demo projects in the Spotify iOS SDK all up and running and things look good, but the major step forward is to get access to the audio pcm so we can sent it into our visual engines, etc.

  • Spotify iOS SDK Swift display all (!) playlists (20+)
  • Spotify API for ios: download , save , access tracks from ios spotify api
  • Spotify: Login using the web api not accepting redirect url
  • Opening spotify app from my iphone app
  • -canOpenURL: failed for URL: “spotify:” - error: “(null)”
  • How to properly handle token refresh with Spotify SDK and Swift 3. Error Code=3840
  • Could a Spotify dev or someone in the know kindly suggest what possibilities are available to get a hold of the pcm audio? The audio pcm block can be as simple as a circular buffer of a few thousand of the latest samples (that we would use to FFT, etc).

    Thanks in advance!

    Solutions Collect From Internet About “getting pcm audio for visualization via Spotify iOS SDK”

    Subclass SPTCoreAudioController and do one of two things:

    1. Override connectOutputBus:ofNode:toInputBus:ofNode:inGraph:error: and use AudioUnitAddRenderNotify() to add a render callback to destinationNode‘s audio unit. The callback will be called as the output node is rendered and will give you access to the audio as it’s leaving for the speakers. Once you’ve done that, make sure you call super‘s implementation for the Spotify iOS SDK’s audio pipeline to work correctly.

    2. Override attemptToDeliverAudioFrames:ofCount:streamDescription:. This gives you access to the PCM data as it’s produced by the library. However, there’s some buffering going on in the default pipeline so the data given in this callback might be up to half a second behind what’s going out to the speakers, so I’d recommend using suggestion 1 over this. Call super here to continue with the default pipeline.

    Once you have your custom audio controller, initialise an SPTAudioStreamingController with it and you should be good to go.

    I actually used suggestion 1 to implement iTunes’ visualiser API in my Mac OS X Spotify client that was built with CocoaLibSpotify. It’s not working 100% smoothly (I think I’m doing something wrong with runloops and stuff), but it drives G-Force and Whitecap pretty well. You can find the project here, and the visualiser stuff is in VivaCoreAudioController.m. The audio controller class in CocoaLibSpotify and that project is essentially the same as the one in the new iOS SDK.