Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-08-2012, 07:30 AM   #1 (permalink)
Registered Member
 
Join Date: Jan 2012
Location: Lahore, Pakistan
Posts: 26
saqibjaan is on a distinguished road
Send a message via Skype™ to saqibjaan
Default Microphone code doesn't run on iPhone device

I am trying to run the following code on my device with no success. Although the code works perfectly on Simulator. I have been following this tutorial. It simply crash on device.

Tutorial: Detecting When A User Blows Into The Mic | Mobile Orchard

Code is:

@interface MicBlowViewController : UIViewController
{
AVAudioRecorder *recorder;
NSTimer *levelTimer;
double lowPassResults;
}

- (void)levelTimerCallbackNSTimer *)timer;

@end



- (void)viewDidLoad
{
[super viewDidLoad];

NSURL *url = [NSURL fileURLWithPath:@"/dev/null"];

NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat: 44100.0], AVSampleRateKey,
[NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey,
[NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
[NSNumber numberWithInt: AVAudioQualityMax], AVEncoderAudioQualityKey,
nil];

NSError *error;

recorder = [[AVAudioRecorder alloc] initWithURL:url settings:settings error:&error];

if (recorder)
{
[recorder prepareToRecord];
recorder.meteringEnabled = YES;
[recorder record];
levelTimer = [NSTimer scheduledTimerWithTimeInterval: 3
target: self
selector: @selector(levelTimerCallback
userInfo: nil
repeats: YES];
}
else
NSLog(@"%@", [error description]);
}


- (void)levelTimerCallbackNSTimer *)timer
{
[recorder updateMeters];

const double ALPHA = 0.05;
double peakPowerForChannel = pow(10, (0.05 * [recorder peakPowerForChannel:0]));
lowPassResults = ALPHA * peakPowerForChannel + (1.0 - ALPHA) * lowPassResults;

if (lowPassResults < 0.95)
NSLog(@"Mic blow detected");
}
saqibjaan is offline   Reply With Quote
Old 02-08-2012, 08:51 AM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

The error message & stack trace from the crash would be helpful.. just FYI
smithdale87 is offline   Reply With Quote
Old 02-08-2012, 11:53 AM   #3 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by smithdale87 View Post
The error message & stack trace from the crash would be helpful.. just FYI
As well as the specific source line on which it crashes.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Old 02-09-2012, 12:40 AM   #4 (permalink)
Registered Member
 
Join Date: Jan 2012
Location: Lahore, Pakistan
Posts: 26
saqibjaan is on a distinguished road
Send a message via Skype™ to saqibjaan
Default Microphone code doesn't run on iPhone device

I am using iPhone configuration utility to see NSLog statements. From there, I see the following lines. I am sharing the first 2 lines.


unknown com.apple.launchd[1] <Warning>: (UIKitApplication:com.yourcompany.MicBlow[0xe0ef]) Job appears to have crashed: Bus error

unknown SpringBoard[27] <Warning>: Application 'MicBlow' exited abnormally with signal 10: Bus error

Last edited by saqibjaan; 02-09-2012 at 12:47 AM.
saqibjaan is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, microphone

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 392
12 members and 380 guests
7twenty7, chiataytuday, fiftysixty, gmarro, iOS.Lover, KennyChong, kilobytedump, Leslie80, Matrix23, ryantcb, stanny, xerohuang
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,669
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, dedeys78
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:22 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0