Audio recording with timer [closed] - iphone

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to take a photo and as soon as i do that, the audio should start recording automatically for say, 3 seconds.
Those 3 seconds should be counted down by a timer which appears on the left side of the screen, after the photo is taken.
So, then i have to combine the image and audio together and save it in a private directory.
Could someone tell me how do i do this by using the AVFoundation and Audio Toolbox frameworks?

I don't normally work with AVFoundation so I don't know the exact method/class names (I filled in my own), but a workaround to this would be having a recurring NSTimer beginning when the recording originally starts. Something like this:
#interface
int rec_time;
NSTimer *timer;
Recorder *recorder;
#end
#implementation
-(void)beginRecording {
[recorder startRecording];
timer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:#selector(recordingTime)
userInfo:nil
repeats:YES];
}
-(int)recordingTime {
if (rec_time >= 10) {
[recorder endRecording];
[timer invalidate];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"You recorded for too long!";
return;
}
rec_time = rec_time + 1;
}
#end
Also
AVAudioRecorder has the following method:
- (BOOL)recordForDuration:(NSTimeInterval)duration
I think that will do the trick!
http://developer.apple.com/library/ios/#documentation/AVFoundation/Reference/AVAudioRecorder_ClassReference/Reference/Reference.html#//apple_ref/doc/uid/TP40008238

Related

Set delay animation for UIPicker? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
If I have this code below to tell the UIPicker if nothing is selected to set the feet to 1, How can I delay this action a few seconds?
// If feet values are zero.
if (([feetPicker selectedRowInComponent:0] == 0 & [feetPicker selectedRowInComponent:1] == 0)){
// Set to one foot.
[feetPicker selectRow:1
inComponent:1
animated:YES];
}
[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:#selector(fireMethod) userInfo:nil repeats:NO];
The above code can be placed whenever you want to start the timer.
-(void)fireMethod {
// If feet values are zero.
if (([feetPicker selectedRowInComponent:0] == 0 & [feetPicker selectedRowInComponent:1] == 0)){
// Set to one foot.
[feetPicker selectRow:1
inComponent:1
animated:YES];
}
}

Decrease points with respect to NSTimer [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
How to decrease points every seconds (for eg. Question 1: having 10 points) with respect to NSTimer ?
I have decrease to this points till 15 seconds only.
Thanks in advance.
Put this in your interface
#interface ViewController : UIViewController {
NSTimer *timer;
int seconds;
}
#property(nonatomic, strong) NSTimer *timer;
And this in your implementation where you need it
- (void)viewDidLoad
{
[super viewDidLoad];
self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:#selector(timerTick:) userInfo:nil repeats:YES];
seconds = 1;
}
- (void)timerTick:(id)sender{
NSLog(#"%d",seconds);
if (seconds == 15) {
[self.timer invalidate];
}
seconds++;
}

How to repeat a UILocalNotification Sound [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
How can I repeat a UILocalNotification sound?
-(IBAction) scheduleNotification1 {
local1 = [[UILocalNotification alloc] init];
// create date/time information
local1.fireDate = [NSDate dateWithTimeIntervalSinceNow:2];
local1.timeZone = [NSTimeZone defaultTimeZone];
// set notification details
local1.alertBody = #"2!";
local1.alertAction = #"View";
//local1.soundName = UILocalNotificationDefaultSoundName;
//local1.soundName = #"alarmsound.caf";
local1.soundName = #"29.mp3";
// set the badge on the app icon
local1.applicationIconBadgeNumber = 1;
// local1.repeatInterval =NSSecondCalendarUnit;//// NSMinuteCalendarUnit;
//local1.repeatInterval =1 ;
// Gather any custom data you need to save with the notification
NSDictionary *customInfo = [NSDictionary dictionaryWithObject:#"ABCD2" forKey:#"yourKey1"];
local1.userInfo = customInfo;
// Schedule it!
[[UIApplication sharedApplication] scheduleLocalNotification:local1];
//[local1 release];
}
Please provide some sample code.
Sorry a7mad, I am afraid to say that but it is not Possible to Repeat the sound of UILocal Notification.I hope you have checked Other Questions Of SO. All of them have Negative result.
I can give you a suggestion to Call an Alert View Or ActionSheet on Click of "View" Button of LocalNotification and Continue your actions on that Controller as they can be controlled...

How to detect voice in my iPhone app? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to fire some method on voice detection.
For Example,
Just like in PragDuck app, When user starts speaking duck starts its animation.
How can I detect users voice?
Use AVAudioRecorder - Audio Metering - checkout out this tutorial - dettect when a user blows into mic http://mobileorchard.com/tutorial-detecting-when-a-user-blows-into-the-mic/
Quick Example:
_audioRecorder.meteringEnabled = YES;
//1. This method will get the current mic activity and will format it to a 0 - 1 scale.
-(void)checkRecordingMeters:(NSTimer *)timer
{
[_audioRecorder updateMeters];
const double ALPHA = 0.2;
float peakPower = [_audioRecorder peakPowerForChannel:0];
double peakPowerForChannel = pow(10, (0.05 * peakPower));
lowPassResults = ALPHA * peakPowerForChannel + (1.0 - ALPHA) * lowPassResults;
NSLog(#"Meters: %f" , peakPower);
NSLog(#"lowPassResults: %f \n" , lowPassResults);
}
//2. Call this method to run a loop timer to check the current mic activity
-(void)enableMettering:(BOOL)enable
{
if(enable)
{
levelTimer = [[NSTimer scheduledTimerWithTimeInterval:0.03
target:self
selector:#selector(checkRecordingMeters:)
userInfo:nil
repeats:YES] retain];
}
else
{
[levelTimer invalidate];
[levelTimer release];
}
}
You may use AudioQueue to record and add a simple threshold filter to ignore environment noise. For lower latency, you may use AudioUnit.

Label adds up to players score at GameOver Scene: Objective-C [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
So I've seen it everywhere in apps/games and other things its when you score or you get game over and the score number adds up to your score from zero. I want it so in about 1 second a label goes from the text: 0 to and integer that is stored with the players score.
Create a UILabel to display the score, and use an NSTimer to update the UILabel's text property. Apple doesn't ship a class that will do it all for you.
You need two variables; the currentScore and the current score being displayed. You will also need a timer to handle updating the ui.
When your score changes, update currentScore to the final score you want. Then start a timer that increments the displayedScore until it gets there i.e.
-(void)scoreUpdater:(NSTimer *)timer {
// Update the score
displayScore ++;
[scoreLabel setText:[NSString stringWithFormat:#"%i", displayScore]];
// Have we got there yet?
if (displayScore == currentScore) {
[scoreTimer invalidate];
[scoreTimer release];
scoreTimer = nil;
}
}
I would go by using an NSOperation that sleeps and add the points (actually it may work even without sleeping). Something like:
NSInvocationOperation *op = [[NSInvocationOperation alloc] initWithTarget:self
selector:#selector(updateScore)
object:nil];
[queue addOperation:[op autorelease]];
-(void)updateScore {
while (tot < 1.0) {
displayingScore += score*incr;
tot += incr;
// update score label to displayingScore
[NSThread sleepForTimeInterval:0.05];
}
}