Search code examples
tvossuperpowered

Can Superpowered be used to output 5.1 or 7.1 surround sound?


I'm experimenting with Superpowered on tvOS. I'd like to be able to output audio to more than just two stereo channels. Is this possible using the Superpowered SDK?

So far, what I've tried is modifying the included tvOS example as follows:

  • In ViewController.m, where Superpowered is initialized, I changed the value for the channels parameter from 2 to 6. (This is for 5.1 surround sound, which is what the connected output device supports.)

  • In audioHandler.mm, I added the following to audioProcessingCallback:

    SuperpoweredDeInterleave(stereoOutput, buffers[2], buffers[3], numberOfSamples);
    SuperpoweredDeInterleave(stereoOutput, buffers[4], buffers[5], numberOfSamples);
    

With these changes, I expected that the whoosh would be played through all 6 surround sound speakers, but it's only being played in the front left and right speakers. Is there anything else that I need to do to configure Superpowered for surround sound output?


Solution

  • Try this additionally, just before [audioIO start]:

    AVAudioSession *instance = [AVAudioSession sharedInstance];  
    NSLog(@"output channels: %ld", (long)instance.outputNumberOfChannels);  
    NSLog(@"max channels: %ld", (long)instance.maximumOutputNumberOfChannels);  
    BOOL r = [instance setPreferredOutputNumberOfChannels:instance.maximumOutputNumberOfChannels error:&error];  
    NSLog(@"set preferred channels: %d error: %@", r, error);  
    NSLog(@"output channels: %ld", (long)instance.outputNumberOfChannels);