When using a live audio source for the AKFFTTap like the microphone, the fft data is perfectly in sync until the app goes into the background and then returns. The fft data becomes several seconds delayed from from the live input from that point on. Is there a way to reset some pointer or reinit when this happens so that the fft is reading from the most recent sample window?
One solution that seems to fix the problem is to get a notification for UIApplicationWillResignActiveNotification and then call AudioKit.stop() and then call AudioKit.start() for UIApplicationDidBecomeActiveNotification. I'm not sure if this would be the recommended fix as I'm new to AudioKit. Maybe someone else has a better solution.
Related
I have implemented the opentok in my app, and did all necessary implementation which is required. I have been gone through sample code and did exactly same, by calling destination phone, the call reached perfectly, then issues comes.
Sometimes call connected to both device but most of the times not, receiver phone started the call with time counting but it has not been connected with voice chat in either way.
Some times loud speaker become active automatically in receiver phone and also by tapping it has not been disable.
Does anybody went through this situation and resolved it ? A
Any help will be appreciable.
Thanks.
If you're using callkit for voice calls then follow below solution to make your audio session active.
while making call or answering call :
Deactivate audio session.
initiate your audio session again.
answer/make call.
I have a CoreAudio based player that streams remote mp3s.
It uses NSURLConnection to retrieve the mp3 data -> uses AudioConverter to convert the stream into PCM -> and feeds the stream into an AUGraph to play audio.
The player works completely fine in my demo app(it only contains a play button), but when i add the player to another project, but when coupled with a project that already makes networking calls, and updates UI, the player fails to play audio past a few seconds.
Am possibly experiencing a threading issue? What are some preventative approaches that i can take or look into that can prevent this from happening?
You do not mention anything in your software architecture about buffering your data between receiving it via NSURLConnection and when you send it to your player.
Data will arrive in chunks with inconsistent arrival rates.
Please see these answers I posted regarding buffering and network jitter.
Network jitter
and
Network jitter and buffering queue
In a nutshell, you can receive data and immediately send it to your player because the next data may not arrive in time.
You don't mention the rate that the mp3 file is delivered. If it is delivered very quickly over a fast connection... are you buffering all of the data received or is it getting lost somewhere in your app? There is a chance that your problem is that you are receiving way too much data too fast and not properly buffering up the data received.
I'm using CocoaLibSpotify and the SPPlaybackManager to stream Spotify music to my app. It works very well overall, but I'm experiencing some issues with the playback during other network activity.
Procedure:
(During audio playback) I'm firing a regular ASIHTTPRequest to a server.
When the request has finished, I'm making a number of Spotify searches using SPSearch.
On many devices (in particular iPhone 3GS), I'm getting massive "stuttering"/"skips"/"pauses" in the playback while the Searches are performed.
Earlier, I used regular ASIHTTPRequests instead of the SPSearch class, so I'm quite sure it's got to do with the overall network activity.
Also, the playback issues may appear while doing some other network activity on the device, i.e. loading a number of emails in the Mail app.
Threading?
I'm guessing this is some kind of threading issue (i.e. the audio is played back on the main thread or something), but I'm not sure exactly how to approach the issue... I've tried invoking SPPlaybackManager#playTrack:: on a background thread, but I guess the setup wasn't 100% correct (since the issues remained).
Does anyone have any pointers as to how I should move forward?
Both the audio delivery and audio playback in the classes supplied with CocoaLibSpotify are run on (different) background threads. However, SPPlaybackManager is only intended to be an easy-to-follow example of dealing with audio playback using Core Audio - it hasn't been tested for, nor is it intended for, use during high CPU load and/or in environments very tight on resources.
All I can do is point you towards the standard debugging tools such as Instruments to trace and profile what's going on.
I have a video streaming app that is properly set up to play video via AirPlay while the device is locked or in the background. It works great. However, the one thing that doesn't work when the app goes into the background is the NSTimer I use to send an update back to a server once every 10 seconds. I've read through countless posts about NSTimers not working when an app is in the background. There are lots of proposed hacks and kludges, but I didn't find the proper way to do this, or if there even is a proper way.
However, since mine is an audio app where some background processing is permitted, I would expect there might be some way to periodically send a post to a remote server.
Is there a preferred way to do this?
Thanks,
Craig
I am using AVPlayer to play an audio stream, and it's possible to keep it playing in the background. I'm wondering how could I handle a situtation where the user loses internet connectivity, so that I could provide some feedback or maybe try to re-establish the playback after some seconds.
EDIT: I know that the question regards AVPlayer, but if you have an answer with MPMoviePlayerController it might be useful as well. Right now, by using MPMoviePlayerController, I'm trying to get the MPMovieFinishReasonPlaybackError case of the MPMoviePlayerPlaybackDidFinishReasonUserInfoKey, by subscribing to the MPMoviePlayerPlaybackDidFinishNotification but if f.e. my audio is playing in the background and I turn airplane mode on, I never get this notification; I only get MPMovieFinishReasonPlaybackEnded, and I don't know how to separate that from the case that the user stops the audio himself.
I tried looking around for the actual source but I remember reading somewhere that if the audio playback stops (for whatever reason) it kills the background thread. The person writing about the issue talked about possible feeding the stream some empty audio content to keep the thread alive. You might be able to send a local notification from a call back error notifying the user that the audio experienced an error and will have to be manually restarted from within the application. Haven't played around with the API enough to know which callback is the best one to use in this case. If I find the link I'm looking for I'll update.
EDIT: Here's Grant Pannell's take on audio streaming and multitasking.