Permalink
Browse files

Finished renaming to AudioEmailer

  • Loading branch information...
1 parent f11a4b4 commit d89849ba06eba9a26022c1965031e5c615bea222 @jpsim committed May 30, 2012
Oops, something went wrong.
@@ -40,18 +40,18 @@
E83D32DD1576CF2E00B35A5C /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
E83D32DF1576CF2E00B35A5C /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
E83D32E11576CF2E00B35A5C /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
- E83D32E51576CF2E00B35A5C /* AudioEmailer-Info.plist */ = {isa = PBXFileReference; path = "AudioEmailer-Info.plist"; sourceTree = "<group>"; };
+ E83D32E51576CF2E00B35A5C /* AudioEmailer-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "AudioEmailer-Info.plist"; sourceTree = "<group>"; };
E83D32E71576CF2E00B35A5C /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
E83D32E91576CF2E00B35A5C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
- E83D32EB1576CF2E00B35A5C /* AudioEmailer-Prefix.pch */ = {isa = PBXFileReference; path = "AudioEmailer-Prefix.pch"; sourceTree = "<group>"; };
+ E83D32EB1576CF2E00B35A5C /* AudioEmailer-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AudioEmailer-Prefix.pch"; sourceTree = "<group>"; };
E83D32EC1576CF2E00B35A5C /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
E83D32ED1576CF2E00B35A5C /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
E83D32EF1576CF2E00B35A5C /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
E83D32F01576CF2E00B35A5C /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
E83D32F31576CF2E00B35A5C /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/ViewController.xib; sourceTree = "<group>"; };
E83D32FA1576CF2E00B35A5C /* AudioEmailerTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AudioEmailerTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
E83D32FB1576CF2E00B35A5C /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; };
- E83D33031576CF2E00B35A5C /* AudioEmailerTests-Info.plist */ = {isa = PBXFileReference; path = "AudioEmailerTests-Info.plist"; sourceTree = "<group>"; };
+ E83D33031576CF2E00B35A5C /* AudioEmailerTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "AudioEmailerTests-Info.plist"; sourceTree = "<group>"; };
E83D33051576CF2E00B35A5C /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
E83D33071576CF2E00B35A5C /* AudioTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AudioTests.h; sourceTree = "<group>"; };
E83D33081576CF2E00B35A5C /* AudioTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AudioTests.m; sourceTree = "<group>"; };
@@ -91,8 +91,8 @@
isa = PBXGroup;
children = (
E83D331F1576DF8800B35A5C /* BarGauge */,
- E83D32E31576CF2E00B35A5C /* Audio */,
- E83D33011576CF2E00B35A5C /* AudioTests */,
+ E83D32E31576CF2E00B35A5C /* AudioEmailer */,
+ E83D33011576CF2E00B35A5C /* AudioEmailerTests */,
E83D32DC1576CF2E00B35A5C /* Frameworks */,
E83D32DA1576CF2E00B35A5C /* Products */,
);
@@ -120,7 +120,7 @@
name = Frameworks;
sourceTree = "<group>";
};
- E83D32E31576CF2E00B35A5C /* Audio */ = {
+ E83D32E31576CF2E00B35A5C /* AudioEmailer */ = {
isa = PBXGroup;
children = (
E83D32EC1576CF2E00B35A5C /* AppDelegate.h */,
@@ -130,7 +130,7 @@
E83D32F21576CF2E00B35A5C /* ViewController.xib */,
E83D32E41576CF2E00B35A5C /* Supporting Files */,
);
- path = Audio;
+ path = AudioEmailer;
sourceTree = "<group>";
};
E83D32E41576CF2E00B35A5C /* Supporting Files */ = {
@@ -144,14 +144,14 @@
name = "Supporting Files";
sourceTree = "<group>";
};
- E83D33011576CF2E00B35A5C /* AudioTests */ = {
+ E83D33011576CF2E00B35A5C /* AudioEmailerTests */ = {
isa = PBXGroup;
children = (
E83D33071576CF2E00B35A5C /* AudioTests.h */,
E83D33081576CF2E00B35A5C /* AudioTests.m */,
E83D33021576CF2E00B35A5C /* Supporting Files */,
);
- path = AudioTests;
+ path = AudioEmailerTests;
sourceTree = "<group>";
};
E83D33021576CF2E00B35A5C /* Supporting Files */ = {
@@ -452,6 +452,7 @@
E83D330E1576CF2E00B35A5C /* Release */,
);
defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
};
E83D330F1576CF2E00B35A5C /* Build configuration list for PBXNativeTarget "AudioEmailerTests" */ = {
isa = XCConfigurationList;
@@ -460,6 +461,7 @@
E83D33111576CF2E00B35A5C /* Release */,
);
defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
@@ -0,0 +1,19 @@
+//
+// AppDelegate.h
+// Audio
+//
+// Created by Jean-Pierre Simard on 12-05-30.
+// Copyright (c) 2012 Magnetic Bear Studios. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@class ViewController;
+
+@interface AppDelegate : UIResponder <UIApplicationDelegate>
+
+@property (strong, nonatomic) UIWindow *window;
+
+@property (strong, nonatomic) ViewController *viewController;
+
+@end
@@ -0,0 +1,55 @@
+//
+// AppDelegate.m
+// Audio
+//
+// Created by Jean-Pierre Simard on 12-05-30.
+// Copyright (c) 2012 Magnetic Bear Studios. All rights reserved.
+//
+
+#import "AppDelegate.h"
+
+#import "ViewController.h"
+
+@implementation AppDelegate
+
+@synthesize window = _window;
+@synthesize viewController = _viewController;
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+ // Override point for customization after application launch.
+ self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
+ self.window.rootViewController = self.viewController;
+ [self.window makeKeyAndVisible];
+ return YES;
+}
+
+- (void)applicationWillResignActive:(UIApplication *)application
+{
+ // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+ // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+}
+
+- (void)applicationDidEnterBackground:(UIApplication *)application
+{
+ // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+ // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+}
+
+- (void)applicationWillEnterForeground:(UIApplication *)application
+{
+ // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
+}
+
+- (void)applicationDidBecomeActive:(UIApplication *)application
+{
+ // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+}
+
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
+}
+
+@end
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,25 @@
+//
+// ViewController.h
+// Audio
+//
+// Created by Jean-Pierre Simard on 12-05-30.
+// Copyright (c) 2012 Magnetic Bear Studios. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import <AVFoundation/AVFoundation.h>
+#import "F3BarGauge.h"
+#import <MessageUI/MessageUI.h>
+
+@interface ViewController : UIViewController <AVAudioRecorderDelegate, MFMailComposeViewControllerDelegate> {
+ AVAudioRecorder *recorder;
+ AVAudioPlayer *player;
+ NSTimer *levelTimer;
+}
+- (IBAction)record:(id)sender;
+- (IBAction)play:(id)sender;
+- (IBAction)stopRecording:(id)sender;
+- (IBAction)emailRecording:(id)sender;
+@property (weak, nonatomic) IBOutlet F3BarGauge *levelMeter;
+
+@end
@@ -0,0 +1,128 @@
+//
+// ViewController.m
+// Audio
+//
+// Created by Jean-Pierre Simard on 12-05-30.
+// Copyright (c) 2012 Magnetic Bear Studios. All rights reserved.
+//
+
+#import "ViewController.h"
+#define kdBOffset 40
+#define kMeterRefresh 0.03
+
+@interface ViewController ()
+
+@end
+
+@implementation ViewController
+@synthesize levelMeter;
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+ // Do any additional setup after loading the view, typically from a nib.
+ AVAudioSession *audioSession = [AVAudioSession sharedInstance];
+ NSError *err = nil;
+
+ [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&err];
+
+ if (err) { /* handle error */ }
+
+ err = nil;
+
+ [audioSession setActive:YES error:&err];
+
+ if (err) { /* handle error */ }
+
+ NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
+
+ NSURL *url = [NSURL fileURLWithPath:[documentsDirectory stringByAppendingPathComponent:@"recording.m4a"]];
+ NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithInt:kAudioFormatMPEG4AAC], AVFormatIDKey,
+ [NSNumber numberWithFloat:44100.0], AVSampleRateKey,
+ [NSNumber numberWithInt:1], AVNumberOfChannelsKey, nil];
+
+ recorder = [[AVAudioRecorder alloc] initWithURL:url
+ settings:settings error:&err];
+
+ if (!recorder) { /* handle error */ }
+
+ [recorder setDelegate:self];
+}
+
+- (void)viewDidUnload
+{
+ [self setLevelMeter:nil];
+ [super viewDidUnload];
+ // Release any retained subviews of the main view.
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ return (interfaceOrientation == UIInterfaceOrientationPortrait);
+}
+
+- (IBAction)record:(id)sender {
+ [recorder pause];
+ [recorder prepareToRecord];
+ recorder.meteringEnabled = YES;
+ [recorder record];
+ [recorder updateMeters];
+ levelTimer = [[NSTimer alloc] initWithFireDate:[NSDate dateWithTimeIntervalSinceNow:0.0] interval:kMeterRefresh target:self selector:@selector(levelTimerCallback:) userInfo:nil repeats:YES];
+ [[NSRunLoop currentRunLoop] addTimer:levelTimer forMode:NSDefaultRunLoopMode];
+}
+
+- (IBAction)play:(id)sender {
+ NSError *error;
+ player = [[AVAudioPlayer alloc] initWithContentsOfURL:recorder.url error:&error];
+ [player play];
+}
+
+- (IBAction)stopRecording:(id)sender {
+ [recorder stop];
+ [levelTimer invalidate];
+}
+
+- (void)levelTimerCallback:(NSTimer *)timer {
+ [recorder updateMeters];
+ levelMeter.value = ([recorder averagePowerForChannel:0]+kdBOffset)/kdBOffset;
+ levelMeter.holdPeak = TRUE;
+}
+
+- (IBAction)emailRecording:(id)sender {
+ MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
+ picker.mailComposeDelegate = self;
+
+ // Attach an image to the email
+ NSData *myData = [NSData dataWithContentsOfURL:recorder.url];
+ [picker addAttachmentData:myData mimeType:@"audio/mp4a-latm" fileName:@"bji-recording.m4a"];
+
+ // Fill out the email body text
+ [picker setMessageBody:@"" isHTML:NO];
+ [self presentModalViewController:picker animated:YES];
+}
+
+- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
+{
+ // Notifies users about errors associated with the interface
+ switch (result)
+ {
+ case MFMailComposeResultCancelled:
+ NSLog(@"Result: canceled");
+ break;
+ case MFMailComposeResultSaved:
+ NSLog(@"Result: saved");
+ break;
+ case MFMailComposeResultSent:
+ NSLog(@"Result: sent");
+ break;
+ case MFMailComposeResultFailed:
+ NSLog(@"Result: failed");
+ break;
+ default:
+ NSLog(@"Result: not sent");
+ break;
+ }
+ [self dismissModalViewControllerAnimated:YES];
+}
+@end
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
Oops, something went wrong.

0 comments on commit d89849b

Please sign in to comment.