Giter Site home page Giter Site logo

Comments (5)

leo150 avatar leo150 commented on September 26, 2024 2

I've found a solution for this issue, it's to provide correct channelLayout to AVAudioFormat.init in case number of channels is more than 2 (in AudioCodec.swift). For example, for 4 channels it's AVAudioChannelLayout(layoutTag: kAudioChannelLayoutTag_AudioUnit_4). I also tried to create AudioChannelLayout using custom mChannelDescriptions to discard selected channels, but AVAudioFormat was always nil. Next need to limit number of channels for outputFormat to min(inSourceFormat.mChannelsPerFrame, 2) (in AudioCodecSettings.swift). After that connecting an external mixer and streaming works fine. Will prepare a PR.

from haishinkit.swift.

mkrn avatar mkrn commented on September 26, 2024 1

Sorry, no idea yet. It may be invalid.. maybe some special microphone

from haishinkit.swift.

shogo4405 avatar shogo4405 commented on September 26, 2024

Indeed, it doesn't support 3-channel or 4-channel audio. While it's not causing a crash, I believe it should display an error for unsupported cases. Do you know how to capture in 3 channels or more on an iPhone or iPad?

from haishinkit.swift.

shogo4405 avatar shogo4405 commented on September 26, 2024

It seems that AVAssetWriterInput doesn't support 4 channels. Even when forcibly setting it to 2 channels, recording didn't work. Therefore, I made adjustments to prevent crashes. Now, you can handle it using delegate?.recorder(self, errorOccurred: .failedToCreateAssetWriterInput). #1268

from haishinkit.swift.

leo150 avatar leo150 commented on September 26, 2024

We have a subset of users who use external audio devices. Mostly musicians and djs. They use audio mixers that they connect to the phones using DIN (MIDI) cables with lightning or USB-C adapters. MIDI supports up to 16 channels. This way, the input audio format looks like this:
Screenshot 2023-08-24 at 3 37 22 PM
It has 4 channels and while it doesn't crash, AV can't instantiate AVAudioFormat with this ASBD. I have EvermixBox4 (evermix does no longer exist) and was able to get the above format. Some users have iRig Pro Duo, PreSonus Audiobox USB96, Focusrite Clarett2Pro USB. I think any mixer with DIN output should reproduce the issue.

I'm wondering if we could to use Audio Toolbox in this case and discard extra channels with kAudioConverterChannelMap. Ideally could let the user to select what channels to discard. Still looking into this, would be happy to help to debug this.

from haishinkit.swift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.