Skip to content

Claude: add support for multichannel interfaces on iOS/iPadOS#3746

Open
rdica wants to merge 3 commits into
jamulussoftware:mainfrom
rdica:multichannel-ios
Open

Claude: add support for multichannel interfaces on iOS/iPadOS#3746
rdica wants to merge 3 commits into
jamulussoftware:mainfrom
rdica:multichannel-ios

Conversation

@rdica

@rdica rdica commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Short description of changes

Adds support for external multichannel interfaces and provides ability to choose inputs on iOS/iPadOS devices.

CHANGELOG: Added support for external multichannel interfaces and ability to choose inputs on iOS/iPadOS devices.

Context: Fixes an issue?

Fixes: 3735

Does this change need documentation? What needs to be documented and how?

I don't know.

Status of this Pull Request

What is missing until this pull request can be merged?

This absolutely needs testing as I have no means to do so.

I don't really expect this to work but hopefully it provides a starting point.

Claude summary:
What was missing: src/sound/coreaudio-ios/sound.mm hardcoded a 2-channel (stereo) input format on the RemoteIO audio unit and never queried AVAudioSession for a device's actual channel count, so any external multichannel interface (USB/Lightning audio interface) was silently truncated to its first two channels.

Changes (src/sound/coreaudio-ios/sound.{h,mm}):

  • Negotiate channel count via AVAudioSession.maximumInputNumberOfChannels / setPreferredInputNumberOfChannels: / inputNumberOfChannels whenever a device is selected (SwitchDevice).
  • Split the single audio format into separate input (now iNumInChan-wide) and output (still stereo, since iOS playback is always 2-channel) AudioStreamBasicDescriptions applied to the RemoteIO unit.
  • GetAvailableInOutDevices() now lists every AVAudioSessionPortDescription in availableInputs (built-in mic, headset, external interfaces) instead of just "default" vs "built-in mic".
  • Added UpdateInputChannelInfo() to populate per-channel names (from AVAudioSessionChannelDescription) and clamp the current selection when the device changes.
  • processBufferList() now indexes the interleaved N-channel buffer using the user-selected left/right channel instead of assuming channel 0/1.
  • Implemented GetNumInputChannels, GetInputChannelName, SetLeft/RightInputChannel, GetLeft/RightInputChannel overrides — these plug straight into the existing generic channel-selection UI in clientsettingsdlg.cpp, which is already gated on __APPLE__ (true for iOS) and just was never exercised because the backend always reported 2 channels.

No GUI changes were needed — the settings dialog's channel-selection frame already supports any platform reporting more than 2 channels.

Caveat: I don't have macOS/Xcode in this environment to actually build and run on a device, so this hasn't been compiled or tested against real hardware — please build it in Xcode and verify with an actual multichannel interface (e.g. plugged in via USB-C/Lightning) before merging.

END Summary

Checklist

  • I've verified that this Pull Request follows the general code principles
  • I tested my code and it does what I want
  • My code follows the style guide
  • I waited some time after this Pull Request was opened and all GitHub checks completed without errors.
  • I've filled all the content above

@ann0see

ann0see commented Jun 20, 2026

Copy link
Copy Markdown
Member

I suggest to check any IPA files created by the CI

@ann0see ann0see self-assigned this Jun 20, 2026
@ann0see

ann0see commented Jun 20, 2026

Copy link
Copy Markdown
Member

Please check if you got an email from apple inviting you to test. Once it's approved, you should be able to test on your iDevice.

@pljones pljones left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've no iOS or macOS devices but the change looks coherent and compiles okay, so the API calls clearly exist.

We could do with more iOS and macOS testers, at least. This kind of thing does demonstrate how useful AI tools can be: but you still need to check that what you got is what you wanted.

@ann0see

ann0see commented Jun 20, 2026

Copy link
Copy Markdown
Member

Please do NOT merge this before we validated it does what it should do.

@ann0see ann0see left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll need to review this. Review will follow.

// channels we support (the actual channel count is only known once an
// input device has been selected and negotiated, see UpdateInputChannelInfo)
buffer.mNumberChannels = iNumInChan;
buffer.mData = malloc ( 256 * sizeof ( Float32 ) * MAX_NUM_IN_OUT_CHANNELS ); // max size

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stuff like this must be checked for memory bugs.

Comment thread src/sound/coreaudio-ios/sound.mm Outdated
break;
}

strDriverNames[lNumDevs] = QString ( "in: %1/out: System Default" ).arg ( QString::fromNSString ( port.portName ) );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be translatable...


for ( int i = 0; i < iNumInChan; i++ )
{
QString strChanName = QString ( "Channel %1" ).arg ( i + 1 );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translation

if ( ( iNewChan >= 0 ) && ( iNewChan < iNumInChan ) )
{
iSelInputLeftChannel = iNewChan;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't give a failure if out of bounds? Does this follow the style on other OS?

Co-authored-by: ann0see <20726856+ann0see@users.noreply.github.com>
@pljones

pljones commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Per @ann0see's comments, get the LLM to check for coherency of approach with the other OS audio layer implementations, (rather than just a targeted fix). If might throw up some other things.

It's always worth a starting a new conversation with the LLM - maybe a different model - to get a review, explicitly for comparison with the rest of the project for consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants