In my iOS game I notice the speaker volume automatically decreases while I'm recording with the mic. I'm using the following C# code in Unity 3D to record a short piece of input from the mic and then analyze audioSrc to see if there was any blowing. I repeat this for a short while.
audioSrc.clip = Microphone.Start (null, false, 5, FREQUENCY);
The whole time I'm also playing some background music, and it is during the execution of the above command that the music volume drops for a bit and then comes back right after recording stops.
I'm not sure if this is specific to Unity 3D on iOS only, or whether this is behaviour common to iOS applications. I haven't noticed the same behaviour on Android. Does anybody know of a way I can prevent this on iOS? If necessary I can execute Objective-C code from Unity to call the iOS APIs.
It's not so much that the volume is decreased, rather it is that iOS has switched the output to earphone, away from speakers. Unity has now included a "Player Setting" for iOS called "Force iOS Speakers when Recording" turn this on.
I'm pretty sure that decreasing the audio while recording is default iOS behaviour.
Related
I've got a MIDISampler that is triggered by a MIDICallbackInstrument. I don't want my app to work in the background since it is an interactive ear training game. Unfortunately if I disable "Audio, AirPlay, and Picture in Picture" I get the following error:
CheckError.swift:CheckError(_:):176:kMIDINotPermitted: Have you enabled the audio background mode in your ios app?
Also the sampler plays fixed pitch sine waves instead of samples.
The solution would be to just turn on the audio background mode though it is not needed. Everything works fine, no errors. Unfortunately Apple is rejecting my app in that case since it's not using background audio.
Does anyone know a work around for this?
You need background audio enabled for MIDISampler. As long as your app is stopping the audio engine when the app moves into the background, they should allow it. I would explain your use case and appeal the rejection.
I'd like to develop a music visualizer app for tvOS which has the ability to listen to whatever background audio is playing (like Spotify, Pandora, etc.). Does anyone know if this is even possible on iOS/tvOS? In other words, there would have to be some functionality that allows the system audio output to be treated like an audio input.
I imagine that it would be the same functionality as doing a screen recording capture, at least the audio part.
My goal is to be able to do this programatically (Objective-C) so that the user doesn't have to do anything, it just "works" out of the box, so to speak.
Thanks
I want to record screen audio with permission for audio processing "Input.installTap" type of code definitely works for me but I want to eliminate outside voices like the human voice or background noises. I think if I stop to microphone it might be work but, I couldn't find any answer yet.
is it possible with anything?
Have you considered using ReplayKit and disabling the microphone?? (available in iOS already, and I believe macOS from 11.0+).
Check out also the WWDC Big Sur Sample Code.
I would like to play a sound and use the AVSpeechSynthesizer to speak out some strings. The point is that I want these to happen when the device is already locked and then some events happen which triggers them.
I've found lots of info about how to play sound on the background, but this means that playback starts when the app is active and then the playback could continue, if the screen is being locked (after the start of playback). I've done all the tricks but can't hear a sound, which is triggered when the device is locked (and app is already on the background). However this works with iOS 8.3 simulator almost out-of-the-box, but not with a device.
So how to resolve this? Should I actually use some notification stuff to produce the desired outcome? I'm not too familiar with the notifications, so is there any other workarounds or is the notifications way easier than I think?
Cheers,
Mikko
When I have an AVAudioRecorder Session active - (when I'm recording audio) I can't activate AirPlay mirroring on the device. Airplay mirroring just deactivates while the app is running and switches it back on when the app exits. This post seems to suggest there is no way around this.
My thoughts are to try:
using a lower level recording framework
or outputting a separate window to external display, rather than mirroring (I've tried this, it doesn't work).
Is there another way around this, or do you know whether either of these methods are known to work?
Using AudioQueue to record (like Apple's Sample Code Speak Here) rather than the AVRecorder works. A bit more work to implement, but recording continues on or off Airplay mirroring.