What is the supported format for compressed 4-channel audio in iOS?

First of all, I'm a noob in iOS and an audio program, so bear with me if I don't use the correct technical terms, but I will do my best!

What we want to do:

In the iOS application we are developing, we want to be able to play sounds on all four outputs in order to have a mini surround sound system. That is, we want the left and right channels to be played through the headphones, and the center and center sound are played through the audio equipment connected to the lightning port. Since the audio files will be streamed / downloaded from the remote server, using the original audio files (PCM) is not an option.

Problem:

Apple, starting with iOS 6, made it possible to play an audio file using a multi-line configuration ... and this is the lattice and exactly what we need ... but when we try to play audio with 4 channels, the file is AAC-encoded and encapsulated in a file format m4a (or CAF), we get the following error:

ERROR: [0x19deee000] AVAudioFile.mm:86: AVAudioFileImpl: error 1718449215 (Which is the status code for "kAudioFileUnsupportedDataFormatError")

We get the same error when instead we use the same sound that is encoded as lossless (ALAC), but we do not get this error when playing the same audio for encoding (PCM format).

We do not get an error when using a stereo audio file, or in the 5.1 audio file format, or in the 4-channel, both in AAC and ALAC.

What we tried:

  • Coding

Apple, Mac OS X: afconvert, :

afconvert -v -f 'm4af' -d "aac@44100" 4ch_master.caf 4ch_44100_AAC.m4a

afconvert -v -f 'caff' -d "alac@44100" 4ch_master.caf 4ch_44100_ALAC.caf

.

, afinfo (PCM):

File:           4ch_master.caf
File type ID:   caff
Num Tracks:     1
----
Data format:     4 ch,  44100 Hz, 'lpcm' (0x0000000C) 16-bit little-endian signed integer
                no channel layout.
estimated duration: 582.741338 sec
audio bytes: 205591144
audio packets: 25698893
bit rate: 2822400 bits per second
packet size upper bound: 8
maximum packet size: 8
audio data file offset: 4096
optimized
audio 25698893 valid frames + 0 priming + 0 remainder = 25698893
source bit depth: I16

AAC:

File:           4ch_44100_AAC.m4a
File type ID:   m4af
Num Tracks:     1
----
Data format:     4 ch,  44100 Hz, 'aac ' (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
Channel layout: Quadraphonic
estimated duration: 582.741338 sec
audio bytes: 18338514
audio packets: 25099
bit rate: 251730 bits per second
packet size upper bound: 1039
maximum packet size: 1039
audio data file offset: 106496
optimized
audio 25698893 valid frames + 2112 priming + 371 remainder = 25701376
source bit depth: I16
format list:
[ 0] format:      4 ch,  44100 Hz, 'aac ' (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
Channel layout: Quadraphonic
----

:

File:           4ch_44100_ALAC.caf
File type ID:   caff
Num Tracks:     1
----
Data format:     4 ch,  44100 Hz, 'alac' (0x00000001) from 16-bit source, 4096 frames/packet
Channel layout: 4.0 (C L R Cs)
estimated duration: 582.741338 sec
audio bytes: 83333400
audio packets: 6275
bit rate: 1143862 bits per second
packet size upper bound: 16777
maximum packet size: 16777
audio data file offset: 20480
optimized
audio 25698893 valid frames + 0 priming + 3507 remainder = 25702400
source bit depth: I16
----

, 505 WWDC12, API AVAudioPlayer. , , . , , API AVAudioEngine, 502 WWDC14, . 4- ( ), , , scheduleFile, (. Swift , ):

var playerNode: AVAudioPlayerNode!
...
...
let audioFileToPlay = AVAudioFile(forReading: URLOfTheAudioFle)
playerNode.scheduleFile(audioFileToPlay, atTime: nil, completionHandler: nil)

- , ?

+4
1

, Apple, , :

", Apple Developer (DTS). , , ".

0

Source: https://habr.com/ru/post/1610909/


All Articles