├── picture1.png
├── Audio Shift
├── audio1.m4a
├── audio2.m4a
├── ViewController.h
├── AppDelegate.h
├── main.m
├── ShiftModel.h
├── ViewController.m
├── Images.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Info.plist
├── Base.lproj
│ ├── Main.storyboard
│ └── LaunchScreen.xib
├── AppDelegate.m
└── ShiftModel.m
├── Audio Shift.xcodeproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── project.pbxproj
├── .gitignore
├── Audio ShiftTests
├── Info.plist
└── Audio_ShiftTests.m
├── LICENSE
└── README.md
/picture1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vaberer/audio_time_shifting/HEAD/picture1.png
--------------------------------------------------------------------------------
/Audio Shift/audio1.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vaberer/audio_time_shifting/HEAD/Audio Shift/audio1.m4a
--------------------------------------------------------------------------------
/Audio Shift/audio2.m4a:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Vaberer/audio_time_shifting/HEAD/Audio Shift/audio2.m4a
--------------------------------------------------------------------------------
/Audio Shift.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Audio Shift/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // Audio Shift
4 | //
5 | // Created by Patrik Vaberer on 5/27/15.
6 | // Copyright (c) 2015 Patrik Vaberer. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/Audio Shift/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // Audio Shift
4 | //
5 | // Created by Patrik Vaberer on 5/27/15.
6 | // Copyright (c) 2015 Patrik Vaberer. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/Audio Shift/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // Audio Shift
4 | //
5 | // Created by Patrik Vaberer on 5/27/15.
6 | // Copyright (c) 2015 Patrik Vaberer. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | build/
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | xcuserdata
13 | *.xccheckout
14 | *.moved-aside
15 | DerivedData
16 | *.hmap
17 | *.ipa
18 | *.xcuserstate
19 |
20 | # CocoaPods
21 | #
22 | # We recommend against adding the Pods directory to your .gitignore. However
23 | # you should judge for yourself, the pros and cons are mentioned at:
24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
25 | #
26 | #Pods/
27 |
--------------------------------------------------------------------------------
/Audio Shift/ShiftModel.h:
--------------------------------------------------------------------------------
1 | //
2 | // ShiftModel.h
3 | // Audio Shift
4 | //
5 | // Created by Patrik Vaberer on 5/27/15.
6 | // Copyright (c) 2015 Patrik Vaberer. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_CLASS_AVAILABLE_IOS(8_0) @interface ShiftModel : NSObject
12 |
13 | /**
14 | Process the cross-corelation to determine time shift between two audio files.
15 | Sample rate and file format must be equal.
16 | @param audioURL1 First audio file
17 | @param audioURL2 Second audio file
18 | @return Time shift in seconds. If the vaule is DBL_MIN, it could not find out the time shift.
19 | */
20 | + (double)getTimeShiftFirstAudioURL:(NSURL *)audioURL1 secondAudio:(NSURL *)audioURL2;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/Audio Shift/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // Audio Shift
4 | //
5 | // Created by Patrik Vaberer on 5/27/15.
6 | // Copyright (c) 2015 Patrik Vaberer. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "ShiftModel.h"
11 | @interface ViewController ()
12 |
13 | @end
14 |
15 | @implementation ViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 |
20 | NSURL *audioURL1 = [[NSBundle mainBundle] URLForResource:@"audio2" withExtension:@"m4a"];
21 | NSURL *audioURL2 = [[NSBundle mainBundle] URLForResource:@"audio1" withExtension:@"m4a"];;
22 |
23 |
24 | [ShiftModel getTimeShiftFirstAudioURL:audioURL1 secondAudio:audioURL2];
25 |
26 |
27 | }
28 |
29 |
30 |
31 | @end
32 |
--------------------------------------------------------------------------------
/Audio Shift/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/Audio ShiftTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | vaberer.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Audio ShiftTests/Audio_ShiftTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // Audio_ShiftTests.m
3 | // Audio ShiftTests
4 | //
5 | // Created by Patrik Vaberer on 5/27/15.
6 | // Copyright (c) 2015 Patrik Vaberer. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface Audio_ShiftTests : XCTestCase
13 |
14 | @end
15 |
16 | @implementation Audio_ShiftTests
17 |
18 | - (void)setUp {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown {
24 | // Put teardown code here. This method is called after the invocation of each test method in the class.
25 | [super tearDown];
26 | }
27 |
28 | - (void)testExample {
29 | // This is an example of a functional test case.
30 | XCTAssert(YES, @"Pass");
31 | }
32 |
33 | - (void)testPerformanceExample {
34 | // This is an example of a performance test case.
35 | [self measureBlock:^{
36 | // Put the code you want to measure the time of here.
37 | }];
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Patrik Vaberer
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/Audio Shift/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | vaberer.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Audio Time Shifting
2 | 
3 |
4 | Follow me: [@vaberer](https://twitter.com/vaberer)
5 |
6 | I like ★. Do not forget to ★ this project.
7 |
8 |
9 | Determining a time shift between two audio files.
10 |
11 | The result of the function is a number in seconds:
12 |
13 |
14 |
15 |
16 | Demnostration of finding time shift between two audio files in Objective-C compatible with iOS8.
17 |
18 | Sample code contains two audio files i na Bundle in which we perform a cross-correlation
19 | and determine time shift is seconds.
20 |
21 | We were recording a youtube song where the second audio - ```audio2.m4a``` is shifted in 3 minutes.
22 |
23 | The code is also optimalized by 50 times. We presume that sample rate and file formats of two audio files are equal.
24 |
25 |
Author
26 |
27 | Patrik Vaberer, patrik@toptal.com
28 | LinkedIn
29 | Blog
30 |
31 | Thanks to:
32 | Tomas Milo
33 |