IOS How to install specific channels of a USB device to an audio player? AVFoundation

I work with AVAudioplayer and AVAudiosession. I have an iPad and an audio interface (sound card).

This audio interface has 4 outputs (2 stereo), a lightning rod and it receives energy from iDevice, works great.

Ive encoded a simple play () stop () AVAudioplayer that works fine, but I need to assign a specific channel of the audio interface (1-2 and 3-4). My idea is to send two audio (A and B) to each output / channel (1-2 or 3-4).

I read the AVAudioplayer documentation and it says: it is channelAssignmentsintended for asign channels for an audio player.

The problem is that I created an AVAudiosession that receives data from a connected USBport device (sound card). And I got:

let route = AVAudioSession.sharedInstance().currentRoute

for port in route.outputs {
    if port.portType == AVAudioSessionPortUSBAudio {
        let portChannels = port.channels
        let sessionOutputs = route.outputs
        let dataSource = port.dataSources
        dataText.text = String(portChannels) + "\n" + String(sessionOutputs) + "\n" + String(dataSource)
    }
}

Log: outputs

play()?

+4
1

Wow - , AVAudioPlayer , AVPlayer iOS 4. 2016 , AVAudioPlayer channelAssignments, AVPlayer .

, A B AVAudioPlayer, .

  • (player(A) player(B)) channelAssignments , ,

  • , AB , channelAssignments , , .

: session.outputNumberOfChannels 4?

, , 4- io , , API , - . AVAudioSessionCategoryMultiRoute, - 2- , usb, 4 , .

(, RemoteIO), AVAudioEngine , .

0

All Articles