I am very new to Objective-C, and I'm trying to update code that has been running iOS 7 for about 3 years. Two or two instances of AudioSessionSetProperty and AudioSessionInitialize appear in the code:
one
- (void)applicationDidFinishLaunching:(UIApplication *)application { AudioSessionInitialize(NULL,NULL,NULL,NULL); [[SCListener sharedListener] listen]; timer = [NSTimer scheduledTimerWithTimeInterval: 0.5 target: self selector: @selector(tick:) userInfo:nil repeats: YES]; // Override point for customization after app launch [window addSubview:viewController.view]; [window makeKeyAndVisible]; }
AND 2:
- (id)init { if ([super init] == nil){ return nil; } AudioSessionInitialize(NULL,NULL,NULL,NULL); Float64 rate=kSAMPLERATE; UInt32 size = sizeof(rate); AudioSessionSetProperty (kAudioSessionProperty_PreferredHardwareSampleRate, size, &rate); return self; }
For some reason, this code runs on iOS7 in a simulator, but not on a device running iOS7, and I suspect that these costs are the reason. I read Docs and related issues on this website and it seems to me that I need to use AVAudioSession . I tried to update the code for a long time, and I'm not sure how to switch to AVAudioSession . Does anyone know what these two methods should look like above?
Side note: I was able to track down an article that describes the transition: https://github.com/software-mariodiana/AudioBufferPlayer/wiki/Replacing-C-functions-deprecated-in-iOS-7 But I can not apply this to the above above code.
The code I'm trying to update is a small frequency detection application from git: https://github.com/jkells/sc_listener
Alternatively, if someone could point me to an example of a demo application that can detect frequencies on iOS devices, that would be awesome.
objective-c ios7 avaudiosession
John
source share