Dive into the technical aspects of audio on your device, including codecs, format support, and customization options.

Audio Documentation

Post

Replies

Boosts

Views

Activity

AVSpeechSynthesizer delegate not being called
I have this code: class SpeechSynthesizerDelegate: NSObject, AVSpeechSynthesizerDelegate { func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didFinish utterance: AVSpeechUtterance) { print("Speech finished.") } func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didCancel utterance: AVSpeechUtterance) { print("Speech canceled.") } func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didStart utterance: AVSpeechUtterance) { print("Speech started.") } func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didPause utterance: AVSpeechUtterance) { print("Speech paused.") ... that I try to use like this let synthesizer = AVSpeechSynthesizer() let delegate = SpeechSynthesizerDelegate() synthesizer.delegate = delegate but when I call synthesizer.speak(utterance) the delegate methods are not being called. I am running this on Mac OS ventura. How can I fix this?
0
0
272
Jul ’24
AVSpeechSynthesizer does not play any sound
I am running the code sample here https://developer.apple.com/documentation/avfoundation/speech_synthesis/ in a REPL on Mac OS Ventura import AVFoundation // Create an utterance. let utterance = AVSpeechUtterance(string: "The quick brown fox jumped over the lazy dog.") // Configure the utterance. utterance.rate = 0.57 utterance.pitchMultiplier = 0.8 utterance.postUtteranceDelay = 0.2 utterance.volume = 0.8 // Retrieve the British English voice. let voice = AVSpeechSynthesisVoice(language: "en-GB") // Assign the voice to the utterance. utterance.voice = voice // Create a speech synthesizer. let synthesizer = AVSpeechSynthesizer() // Tell the synthesizer to speak the utterance. synthesizer.speak(utterance) It runs without errors but I don't hear any sound and the call to synthesizer.speak returns immediately. How can I fix this? Note I am running in REPL so synthesizer is not going out of scope and getting garbage collected.
0
0
234
Jul ’24
Analog To Digital hardware
HI, I'm developing an iOS app that accepts an audio signal as input with the goal of analyzing the signal. For my experiment I purchased a cheap ADC-DAC produced by Sabrent. It works well but the sampling rate is 44.1 khz but I need at least something more (96 khz). I'm looking around but I find many DACs used to connect headphones. Can any of you suggest me an ADC-DAC, preferably not too expensive with a sampling rate of at least 96khz, working with iphones?
0
0
266
Jul ’24
Music app stops playing when switching to the background
Music app stops playing when switching to the background In apps that play music or music files, if you move to the home screen or run another app while the app is running, the music playback stops. Our app does not have the code to stop playing when switching to the background. We are guessing that some people experience this and others do not. We usually guide users to reboot their devices and try again. How can this phenomenon be improved in the code? Or is this a bug or error in the OS?
1
0
462
Jul ’24
Integrating Spatial Audio
I'm looking for a sample code project on integrating Spatial Audio into my app, Tunda Island, a music-loving, make friends and dating app. I have gone as far as purchasing a book "Exploring MusicKit" by Rudrank Riyam but to no avail.
1
0
560
Feb ’24
API or SDK for Integrating Audible Files in iOS App
Hello Apple Community, I am developing an iOS app and would like to add a feature that allows users to play and organize Audible.com files within the app. Does Audible or the App Store provide any API or SDK for third-party apps to access and manage Audible content? If so, could you please provide some guidance on how to integrate it into my app? Thank you for your assistance! Best regards, Yes it labs
0
0
447
Jul ’24
Help Needed with AVAudioSession in Unity for Consistent Sound Output on iOS Devices
Hello, I hope this message finds you well. I am currently working on a Unity-based iOS application that requires continuous microphone input while also producing sound outputs. For this we need to use iOS echo cancellation, so some sounds need to be played via the iOS layer w/ echo cancellation, I am manually setting up the Audio Session after the app starts. Using the .playAndRecord mode of AVAudioSession. However, I am facing an issue where the volume of the sound output is inconsistent across different iOS devices and scenarios. The process is quite simple, for each AudioClip we are about to play via unity, we copy the buffer data to our iOS Swift layer, which then does all the processing then plays the audio via the native layer. Here are the specific issues I am encountering: The volume level for the game sound effects fluctuate between a normal audible volume and a very low volume. The sound output behaves differently depending on whether the app is launched with the device at full volume or on mute, and if the app is put into background and in foreground afterwards. The volume inconsistency affects my game negatively, as it is very hard to hear some audios, regardless of the device or its initial volume state. I have followed the basic setup for AVAudioSession as per the documentation, but the inconsistencies persist. I'm also aware that Unity uses FMOD to set up the audio routing in iOS, we configure our custom routing after that. We tried tweaking the output volume prior to playing an audio so there isn't much discrepancy, this seems to align the output volume, however there is still some places where the volume is super low, I've looked into the waveforms in Unity and they all seem consistent, there is no reason why the volume would take a dip. private var audioPlayer = AVAudioPlayerNode() @objc public func Play() { audioPlayer.volume = AVAudioSession.sharedInstance().outputVolume * 0.25 audioPlayer.play() } We also explored changing the audio session options to see if we had any luck but unfortunately nothing has changed. private func ConfigAudioSession() { let audioSession = AVAudioSession.sharedInstance(); do { try audioSession.setCategory(.playAndRecord, options: [.mixWithOthers, .allowBluetooth, .defaultToSpeaker]); try audioSession.setMode(.spokenAudio) try audioSession.setActive(true); } catch { //Treat error } } Could anyone provide guidance or suggest best practices to ensure a stable and consistent volume output in this scenario? Any advice on this issue would be greatly appreciated. Thank you in advance for your help!
0
0
575
Jul ’24
Two audio streams from specific built-in microphones?
I have an iPad Pro 12.9". I am looking to make an app which can take a simultaneous audio recording from two different microphones at the same time. I want to be able to specify which of the 5 built-in microphones each audio stream should use - ideally one should be from the microphone on the left side of the iPad, and the other should be from one of the mics at the top of the iPad. Is this possible to achieve with the API? The end goal here is to be able to use the two audio streams and do some DSP on the recordings to determine the approximate direction a particular sound comes from.
0
0
445
Jul ’24
iOS18 web audio lock foucs and not release
在我们App中,打开一个H5页面,使用webplayer播放H5中的视频。 然后再去播放App的播放器,播放视频、或音频文件, 都存在抢不到音频焦点问题,声音响一下就停了,播放器还在运行。 尝试在每次App播放都先调用setCategory、setActive也不生效。 这个问题,在beta1~beta3都存在。 请问,webkit的 player做了什么处理,会一直锁定着音频焦点,App要怎么处理才能把焦点拿过来? In our App, open an H5 page and use webplayer to play the video in H5. Then go to the PlayApp player to play the video or audio file. There is a problem of not being able to grab the audio focus. The sound stops as soon as it sounds, but the player is still running. Trying to call setCategory and setActive every time in AppPlay does not work either. This problem exists in beta1~beta3. I would like to ask, what processing has been done by the webkit player to keep the audio focus locked? How can the app handle it so that it can take the focus?
1
0
512
Jul ’24
tvOS inherit system settings
I'm a newby at tvOS and want to know, if it is possible to override some system settings. Especially I want to override the output to audio devices. For the moment (using Apple TV 4K and tvOS 17) you can only select one device (TV, eARC, airPods) and I need a possibility to set a simultaneous output to airPods and TV or eARC. Is such a programming possible?
0
0
339
Jul ’24
PHASE on Vision OS 2.0 beta in Unity
Hi, I'm looking to implement PHASEStreamNode in Unity, but the current provided PHASE library for Unity doesn't contain this new typos of nodes yet. https://developer.apple.com/documentation/phase/phasestreamnode When you will be looking into releasing the beta of the Unity Plugins as well? This is very important for spatial audio in Unity to be consistent with Apple's standards. Best, Antonio
1
1
480
Jul ’24
Audio recording issue in my App after updating to iOS 17.2.1 and it exists even now
In my iOS app, I've the functionality to record audio and video using the AVFoundation framework. While audio recording works smoothly on some devices, such as iPads and certain others, I'm encountering issues with newer models like iPhone 14, 14 Pro, and 15 series. Specifically, when attempting to initiate audio recording by tapping the microphone icon, the interface becomes unresponsive and remains static. This issue surfaced following an update to iOS 17.2.1. It seems to affect only a subset of devices, despite video recording functioning correctly across all devices.
0
0
349
Jul ’24
Volume API returns 0
I am working on a VoIP based PTT app. Uses 'voip' apns notification type to get to know about new incoming PTT call. When my app receives a PTT call, the app plays audio. But the call audio is not heard. While checking the phone volume, the API [[AVAudioSession sharedInstance] outputVolume] returns 0. But clearly the phone volume is not zero. On checking the phone volume by pressing side volume button, the volume is above 50%. This behavior is observed in both app foreground and background scenario. Why does the API return zero volume level ? Is there any other reason why the app volume is not heard ?
0
0
458
Jul ’24
Looking for the simplest possible remoteIO example
I have an app (iPhone / iPad) that currently uses miniaudio and I'd to transition to a pure CoreAudio solution, and I cannot for the life of me get it to work. I want to set up a remoteIO with microphone and speaker callbacks, so that I get a callback when the microphone (USB microphone at 384kHz, mono) has samples for me, and I get a callback when the speakers (49kHz, stereo) need more samples. It should be insanely simple. It's Objective C as I have never got round to Swift and can't see it happening this late in life, but that shouldn't change things. So if anyone can tell me what I'm doing wrong here it would be GREATLY appreciated. My playbackCallback is never being fired, only the recordCallback. `-(void) launchRemoteIOandSleep { NSError *error; [ [AVAudioSession sharedInstance] setPreferredIOBufferDuration:(1024.0f / 48000.0f) error:&error ]; OSStatus status; AudioComponentInstance audioUnit; // set up callback structures - different sanity clauses to identify in breakpoints renderCallBackHandle sanityClause666; sanityClause666.remoteIO = audioUnit; sanityClause666.sanityCheck666 = 666; renderCallBackHandle sanityClause667; sanityClause667.remoteIO = audioUnit; sanityClause667.sanityCheck666 = 667; // set up audio formats AudioStreamBasicDescription audioFormatInput; FillOutASBDForLPCM(audioFormatInput,384000.0,1,16,16,0,0,0); AudioStreamBasicDescription audioFormatOutput; FillOutASBDForLPCM(audioFormatOutput,48000.0,2,16,16,0,0,0); // set up callback structs AURenderCallbackStruct callbackStructRender; callbackStructRender.inputProc = playbackCallback; callbackStructRender.inputProcRefCon = &sanityClause666; AURenderCallbackStruct callbackStructRecord; callbackStructRecord.inputProc = recordCallback; callbackStructRecord.inputProcRefCon = &sanityClause667; // grab remoteIO AudioComponentDescription desc; desc.componentType = kAudioUnitType_Output; desc.componentSubType = kAudioUnitSubType_RemoteIO; desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; AudioComponent component = AudioComponentFindNext(NULL, &desc); // Get audio unit status = AudioComponentInstanceNew(component, &audioUnit); checkStatus(status); // Enable IO for both recording and playback // this enables the OUTPUT side of the OUTPUT bus which is the speaker (I thnk ... ) UInt32 flag = 1; status = AudioUnitSetProperty(audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, kOutputBus, &flag, sizeof(flag)); checkStatus(status); // this enables the INPUT side of the INPUT bus which is the mic (I thnk ... ) flag = 1; status = AudioUnitSetProperty(audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, kInputBus, &flag, sizeof(flag)); checkStatus(status); // Apply format - INPUT bus of OUTPUT SCOPE which is my samples into remoteIO status = AudioUnitSetProperty(audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, kInputBus, &audioFormatOutput, sizeof(audioFormatOutput)); checkStatus(status); // Apply format - OUTPUT bus of INPUT SCOPE which is where I pick up my samples from mic status = AudioUnitSetProperty(audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, kOutputBus, &audioFormatInput, sizeof(audioFormatInput)); checkStatus(status); // set output callback status = AudioUnitSetProperty(audioUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Output, kInputBus, &callbackStructRender, sizeof(callbackStructRender)); checkStatus(status); // Set input callback status = AudioUnitSetProperty(audioUnit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Input, kOutputBus, &callbackStructRecord, sizeof(callbackStructRecord)); checkStatus(status); // Disable buffer allocation for the recorder flag = 0; status = AudioUnitSetProperty(audioUnit, kAudioUnitProperty_ShouldAllocateBuffer, kAudioUnitScope_Input, kInputBus, &flag, sizeof(flag)); // Initialise status = AudioUnitInitialize(audioUnit); checkStatus(status); status = AudioOutputUnitStart(audioUnit); checkStatus(status); [ self waitForAudioStabilisation ]; while (1) sleep(2); }`
1
0
273
Jul ’24
All SystemSoundID
In the AudioServicesPlaySystemSound function of AudioToolbox, you can enter the corresponding SystemSoundID to play some sound effects that come with the system. However, I can't be sure what sound effect each number corresponds to, so I want to know all the sound effects in visionOS and its corresponding SystemSoundID.
0
1
444
Jul ’24