Look at 2etime’s YouTube channel. There should be enough there to get you going and then some.
edit: this was meant to be an answer to another post, please delete or disregard this. Apologies. It seems that I can’t delete my own posts.
Post
Replies
Boosts
Views
Activity
A total noob here, but my hunch is that the code takes too long to run on the GPU, and is thus terminated for that reason. I did some searching on google to verify my hunch, and the results seemed encouraging enough for me to post this answer.
Hello!
I have struggled with this problem too today. I don't know if this is the solution for you, but the symptoms sound similar.
The problem is with sandbox permissions.
You seem to have enabled the sandbox, as well as set the value for Audio Input to 'Yes' for your app.
This is a good step on the way, but not the complete recipe for success.
Next you need to implement in code the process of getting authorisation to use the microphone (or other channels) from the user.
For an absolute dummy proof of concept, you will need this variable and function:
var autorised = false
func setupCaptureSession() {
autorised = true
}
Then before you do anything to do with the audio input initialisation, add this to the function that sets up the audio:
switch AVCaptureDevice.authorizationStatus(for: .audio) {
case .authorized:
print("Authorised")
setupCaptureSession()
case .denied:
print("Denied")
case .notDetermined:
AVCaptureDevice.requestAccess(for: .audio) { granted in
if granted {
self.setupCaptureSession()
}
}
case .restricted:
print("Restricted")
default:
print("Unexpected Value")
}
while !autorised {
usleep(250000)
}
This is absolutely a dummy solution, but it shows the steps needed. I would rather move the audio initialisation code inside the setup function instead of waiting for the authorised value to change.
But wait! This will crash your app with the message that you need to set a usage reason in your applications Info.plist.
The key you are looking for is:
Privacy - Microphone Usage Description
This absolutely needs a value, or your app will crash when you ask for permission to use the microphone. I would suggest to put a proper description to begin with, or you may forget and get the app rejected when you at one point try to submit it to the App Store.
I had silence from the microphone all day. Even turning off the sandbox made no difference. I had to ask the user (me, myself and I) for permission to use the microphone.