Repository: applidium/AudioModem Branch: master Commit: 97e6bc49be05 Files: 19 Total size: 69.1 KB Directory structure: gitextract_tenta55x/ ├── .gitignore ├── AMMainWindow.xib ├── AudioModem-Info.plist ├── AudioModem-Prefix.pch ├── AudioModem.xcodeproj/ │ └── project.pbxproj ├── Classes/ │ ├── AMAppDelegate.h │ ├── AMAppDelegate.m │ ├── AMPlayer.h │ ├── AMPlayer.m │ ├── AMRecorder.h │ ├── AMRecorder.m │ ├── AudioModem.h │ ├── AudioModem_Development.h │ ├── AudioModem_Production.h │ └── AudioModem_Staging.h ├── LICENSE ├── Modules/ │ ├── ADSharedMacros.h │ └── ADVersionInfo/ │ └── ADVersionInfo.m └── main.m ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ .DS_Store *.xcodeproj/*.pbxuser *.xcodeproj/*.mode1v3 *.xcodeproj/*.perspectivev3 *.xcodeproj/project.xcworkspace/ *.xcodeproj/xcuserdata/ build ================================================ FILE: AMMainWindow.xib ================================================ 1552 12C60 3084 1187.34 625.00 com.apple.InterfaceBuilder.IBCocoaTouchPlugin 2083 IBProxyObject IBUIButton IBUICustomObject IBUITextView IBUIView IBUIViewController IBUIWindow com.apple.InterfaceBuilder.IBCocoaTouchPlugin PluginDependencyRecalculationVersion IBFilesOwner IBCocoaTouchFramework IBFirstResponder IBCocoaTouchFramework IBCocoaTouchFramework 1316 {320, 480} 1 MSAxIDEAA NO NO IBUIScreenMetrics YES {320, 480} {480, 320} IBCocoaTouchFramework Retina 3.5 Full Screen 0 IBCocoaTouchFramework YES IBCocoaTouchFramework IBCocoaTouchFramework 274 292 {{40, 208}, {73, 44}} _NS:9 NO IBCocoaTouchFramework 0 0 1 Playing Playing Play 3 MQA 1 MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA 3 MC41AA 2 15 Helvetica-Bold 15 16 292 {{207, 208}, {73, 44}} _NS:9 NO IBCocoaTouchFramework 0 0 1 Record 1 MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA 292 {{40, 49}, {240, 128}} _NS:9 1 MC44MDAwMDAwMTE5IDAuODAwMDAwMDExOSAwLjgwMDAwMDAxMTkAA YES YES IBCocoaTouchFramework NO NO NO NO Hello world! 2 IBCocoaTouchFramework 1 14 Helvetica 14 16 292 {{40, 281}, {240, 128}} _NS:9 1 MC44MDAwMDAwMTE5IDAuODAwMDAwMDExOSAwLjgwMDAwMDAxMTkAA YES YES IBCocoaTouchFramework NO NO NO NO NO 2 IBCocoaTouchFramework {{0, 20}, {320, 460}} _NS:9 3 MQA 2 IBCocoaTouchFramework 1 1 IBCocoaTouchFramework NO delegate 4 rootViewController 8 window 5 dismissKeyboard: 7 22 playMessage: 7 12 recordMessage: 7 17 messageTextView 15 playButton 21 recordButton 23 recordButton 18 receiverTextView 20 playButton 24 0 2 -1 File's Owner -2 3 6 7 9 10 11 13 14 19 UIApplication com.apple.InterfaceBuilder.IBCocoaTouchPlugin UIResponder com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin AMPlayer com.apple.InterfaceBuilder.IBCocoaTouchPlugin AMRecorder com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin AMAppDelegate com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin UIControl com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin 24 AMAppDelegate UIResponder dismissKeyboard: id dismissKeyboard: dismissKeyboard: id window UIWindow window window UIWindow IBProjectSource ./Classes/AMAppDelegate.h AMPlayer NSObject playMessage: id playMessage: playMessage: id UITextView UIButton UIButton messageTextView UITextView playButton UIButton recordButton UIButton IBProjectSource ./Classes/AMPlayer.h AMRecorder NSObject recordMessage: id recordMessage: recordMessage: id UIButton UITextView UIButton playButton UIButton receiverTextView UITextView recordButton UIButton IBProjectSource ./Classes/AMRecorder.h 0 IBCocoaTouchFramework YES 3 2083 ================================================ FILE: AudioModem-Info.plist ================================================ CFBundleDevelopmentRegion fr CFBundleDisplayName ${PRODUCT_NAME} CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier com.applidium.${PRODUCT_NAME:rfc1034identifier} CFBundleInfoDictionaryVersion 6.0 CFBundleName ${PRODUCT_NAME} CFBundlePackageType APPL CFBundleShortVersionString 1.0 CFBundleSignature ???? CFBundleVersion 1.0 LSRequiresIPhoneOS NSMainNibFile AMMainWindow UIRequiredDeviceCapabilities armv7 UISupportedInterfaceOrientations UIInterfaceOrientationPortrait ================================================ FILE: AudioModem-Prefix.pch ================================================ // // Prefix header for all source files of the 'AudioQueueTest' target in the 'AudioQueueTest' project // #import #ifndef __IPHONE_3_0 #warning "This project uses features only available in iOS SDK 3.0 and later." #endif #ifdef __OBJC__ #import #import #endif #import "AudioModem.h" #import "ADSharedMacros.h" ================================================ FILE: AudioModem.xcodeproj/project.pbxproj ================================================ // !$*UTF8*$! { archiveVersion = 1; classes = { }; objectVersion = 46; objects = { /* Begin PBXBuildFile section */ 3C36C80816D6944700A94ADA /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C36C80716D6944700A94ADA /* Accelerate.framework */; }; 3C3D270316A0284C00CEC756 /* AMRecorder.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C3D270216A0284C00CEC756 /* AMRecorder.m */; }; 3C3D270616A0444200CEC756 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C3D270516A0444200CEC756 /* AudioToolbox.framework */; }; 3C3D270D16A06A6700CEC756 /* AMPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C3D270C16A06A6700CEC756 /* AMPlayer.m */; }; 3C75C6C416B68E4100F85EC3 /* AMMainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3C75C6C316B68E4100F85EC3 /* AMMainWindow.xib */; }; 7A0EC6541535D8ED00E5F54A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7A0EC6531535D8ED00E5F54A /* UIKit.framework */; }; 7A0EC6561535D8ED00E5F54A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7A0EC6551535D8ED00E5F54A /* Foundation.framework */; }; 7A0EC6581535D8ED00E5F54A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7A0EC6571535D8ED00E5F54A /* CoreGraphics.framework */; }; 7A189F8A1535FB5300A22149 /* AMAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A189F861535FB5300A22149 /* AMAppDelegate.m */; }; 7A189F931535FD5C00A22149 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 7A189F901535FD5C00A22149 /* main.m */; }; 7AFC5ED4155AA37F009D92A7 /* ADVersionInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFC5ED3155AA37F009D92A7 /* ADVersionInfo.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 3C36C80716D6944700A94ADA /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; }; 3C3CAE8F16DCC30400B5E98C /* AudioModem-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "AudioModem-Info.plist"; sourceTree = SOURCE_ROOT; }; 3C3CAE9016DCC30400B5E98C /* AudioModem-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "AudioModem-Prefix.pch"; sourceTree = SOURCE_ROOT; }; 3C3D270116A0284C00CEC756 /* AMRecorder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AMRecorder.h; sourceTree = ""; }; 3C3D270216A0284C00CEC756 /* AMRecorder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AMRecorder.m; sourceTree = ""; }; 3C3D270516A0444200CEC756 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; 3C3D270B16A06A6700CEC756 /* AMPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AMPlayer.h; sourceTree = ""; }; 3C3D270C16A06A6700CEC756 /* AMPlayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AMPlayer.m; sourceTree = ""; }; 3C75C6C316B68E4100F85EC3 /* AMMainWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AMMainWindow.xib; sourceTree = SOURCE_ROOT; }; 6F3B917C1589E79C00806754 /* ADSharedMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ADSharedMacros.h; path = Modules/ADSharedMacros.h; sourceTree = SOURCE_ROOT; }; 7A0EC64F1535D8ED00E5F54A /* AudioModem.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AudioModem.app; sourceTree = BUILT_PRODUCTS_DIR; }; 7A0EC6531535D8ED00E5F54A /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 7A0EC6551535D8ED00E5F54A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 7A0EC6571535D8ED00E5F54A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 7A189F851535FB5300A22149 /* AMAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AMAppDelegate.h; sourceTree = ""; }; 7A189F861535FB5300A22149 /* AMAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AMAppDelegate.m; sourceTree = ""; }; 7A189F901535FD5C00A22149 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = SOURCE_ROOT; }; 7A6BEEF9153700A30075E2A7 /* AudioModem_Development.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AudioModem_Development.h; sourceTree = ""; }; 7A6BEEFA153700C30075E2A7 /* AudioModem_Staging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AudioModem_Staging.h; sourceTree = ""; }; 7A6BEEFB153700CF0075E2A7 /* AudioModem_Production.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AudioModem_Production.h; sourceTree = ""; }; 7ABC1627153612960039E546 /* AudioModem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioModem.h; sourceTree = ""; }; 7AFC5ED3155AA37F009D92A7 /* ADVersionInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ADVersionInfo.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ 7A0EC64C1535D8ED00E5F54A /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( 3C36C80816D6944700A94ADA /* Accelerate.framework in Frameworks */, 3C3D270616A0444200CEC756 /* AudioToolbox.framework in Frameworks */, 7A0EC6541535D8ED00E5F54A /* UIKit.framework in Frameworks */, 7A0EC6561535D8ED00E5F54A /* Foundation.framework in Frameworks */, 7A0EC6581535D8ED00E5F54A /* CoreGraphics.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ 7A0EC6441535D8ED00E5F54A = { isa = PBXGroup; children = ( 7A189F7F1535FB5300A22149 /* Classes */, 7AFC5ED1155AA37F009D92A7 /* Modules */, 7A189F8F1535FD0D00A22149 /* Other Sources */, 7A189F951535FD6800A22149 /* Resources */, 7A0EC6521535D8ED00E5F54A /* Frameworks */, 7A0EC6501535D8ED00E5F54A /* Products */, ); sourceTree = ""; }; 7A0EC6501535D8ED00E5F54A /* Products */ = { isa = PBXGroup; children = ( 7A0EC64F1535D8ED00E5F54A /* AudioModem.app */, ); name = Products; sourceTree = ""; }; 7A0EC6521535D8ED00E5F54A /* Frameworks */ = { isa = PBXGroup; children = ( 3C36C80716D6944700A94ADA /* Accelerate.framework */, 3C3D270516A0444200CEC756 /* AudioToolbox.framework */, 7A0EC6531535D8ED00E5F54A /* UIKit.framework */, 7A0EC6551535D8ED00E5F54A /* Foundation.framework */, 7A0EC6571535D8ED00E5F54A /* CoreGraphics.framework */, ); name = Frameworks; sourceTree = ""; }; 7A189F7F1535FB5300A22149 /* Classes */ = { isa = PBXGroup; children = ( 7ABC1627153612960039E546 /* AudioModem.h */, 7A6BEEF9153700A30075E2A7 /* AudioModem_Development.h */, 7A6BEEFA153700C30075E2A7 /* AudioModem_Staging.h */, 7A6BEEFB153700CF0075E2A7 /* AudioModem_Production.h */, 7A189F851535FB5300A22149 /* AMAppDelegate.h */, 7A189F861535FB5300A22149 /* AMAppDelegate.m */, 3C3D270116A0284C00CEC756 /* AMRecorder.h */, 3C3D270216A0284C00CEC756 /* AMRecorder.m */, 3C3D270B16A06A6700CEC756 /* AMPlayer.h */, 3C3D270C16A06A6700CEC756 /* AMPlayer.m */, ); path = Classes; sourceTree = ""; }; 7A189F8F1535FD0D00A22149 /* Other Sources */ = { isa = PBXGroup; children = ( 7A189F901535FD5C00A22149 /* main.m */, 3C3CAE9016DCC30400B5E98C /* AudioModem-Prefix.pch */, ); name = "Other Sources"; path = AudioQueueTest; sourceTree = ""; }; 7A189F951535FD6800A22149 /* Resources */ = { isa = PBXGroup; children = ( 3C3CAE8F16DCC30400B5E98C /* AudioModem-Info.plist */, 3C75C6C316B68E4100F85EC3 /* AMMainWindow.xib */, ); name = Resources; path = AudioQueueTest; sourceTree = ""; }; 7AFC5ED1155AA37F009D92A7 /* Modules */ = { isa = PBXGroup; children = ( 6F3B917C1589E79C00806754 /* ADSharedMacros.h */, 7AFC5ED2155AA37F009D92A7 /* ADVersionInfo */, ); path = Modules; sourceTree = ""; }; 7AFC5ED2155AA37F009D92A7 /* ADVersionInfo */ = { isa = PBXGroup; children = ( 7AFC5ED3155AA37F009D92A7 /* ADVersionInfo.m */, ); path = ADVersionInfo; sourceTree = ""; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ 7A0EC64E1535D8ED00E5F54A /* AudioModem */ = { isa = PBXNativeTarget; buildConfigurationList = 7A0EC6671535D8ED00E5F54A /* Build configuration list for PBXNativeTarget "AudioModem" */; buildPhases = ( 7A0EC66A1535D91400E5F54A /* Inject git informations in Info.plist */, 7A0EC64B1535D8ED00E5F54A /* Sources */, 7A0EC64C1535D8ED00E5F54A /* Frameworks */, 7A0EC64D1535D8ED00E5F54A /* Resources */, ); buildRules = ( ); dependencies = ( ); name = AudioModem; productName = AudioQueueTest; productReference = 7A0EC64F1535D8ED00E5F54A /* AudioModem.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 7A0EC6461535D8ED00E5F54A /* Project object */ = { isa = PBXProject; attributes = { CLASSPREFIX = AM; LastUpgradeCheck = 0460; }; buildConfigurationList = 7A0EC6491535D8ED00E5F54A /* Build configuration list for PBXProject "AudioModem" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( en, ); mainGroup = 7A0EC6441535D8ED00E5F54A; productRefGroup = 7A0EC6501535D8ED00E5F54A /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( 7A0EC64E1535D8ED00E5F54A /* AudioModem */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ 7A0EC64D1535D8ED00E5F54A /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( 3C75C6C416B68E4100F85EC3 /* AMMainWindow.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ 7A0EC66A1535D91400E5F54A /* Inject git informations in Info.plist */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); name = "Inject git informations in Info.plist"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "GIT_COMMIT=`git rev-parse --short HEAD`\nGIT_BRANCH=`git symbolic-ref HEAD`\nGIT_STATUS=`git status --porcelain -z`\n/usr/libexec/PlistBuddy -c \"Delete :CFBundleGitCommit\" \"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}\" >/dev/null 2>&1\n/usr/libexec/PlistBuddy -c \"Delete :CFBundleGitBranch\" \"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}\" >/dev/null 2>&1\n/usr/libexec/PlistBuddy -c \"Delete :CFBundleGitStatus\" \"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}\" >/dev/null 2>&1\nif [ -n \"$GIT_COMMIT\" ]; then\n /usr/libexec/PlistBuddy -c \"Add :CFBundleGitCommit string \\\"${GIT_COMMIT}\\\"\" \"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}\"\nfi\nif [ -n \"$GIT_BRANCH\" ]; then\n /usr/libexec/PlistBuddy -c \"Add :CFBundleGitBranch string \\\"${GIT_BRANCH}\\\"\" \"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}\"\nfi\nif [ -n \"$GIT_STATUS\" ]; then\n /usr/libexec/PlistBuddy -c \"Add :CFBundleGitStatus string \\\"${GIT_STATUS}\\\"\" \"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}\"\nfi"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ 7A0EC64B1535D8ED00E5F54A /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( 7A189F8A1535FB5300A22149 /* AMAppDelegate.m in Sources */, 7A189F931535FD5C00A22149 /* main.m in Sources */, 7AFC5ED4155AA37F009D92A7 /* ADVersionInfo.m in Sources */, 3C3D270316A0284C00CEC756 /* AMRecorder.m in Sources */, 3C3D270D16A06A6700CEC756 /* AMPlayer.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ /* Begin XCBuildConfiguration section */ 7A0EC6651535D8ED00E5F54A /* Development */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = "CONFIGURATION=$(CONFIGURATION)"; GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 5.1; SDKROOT = iphoneos; }; name = Development; }; 7A0EC6681535D8ED00E5F54A /* Development */ = { isa = XCBuildConfiguration; buildSettings = { GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "AudioModem-Prefix.pch"; INFOPLIST_FILE = "$(SRCROOT)/AudioModem-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 5.1; PRODUCT_NAME = AudioModem; WRAPPER_EXTENSION = app; }; name = Development; }; 7A6BEEF51536FD400075E2A7 /* Staging */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_PREPROCESSOR_DEFINITIONS = "CONFIGURATION=$(CONFIGURATION)"; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 5.1; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; name = Staging; }; 7A6BEEF61536FD400075E2A7 /* Staging */ = { isa = XCBuildConfiguration; buildSettings = { GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "AudioModem-Prefix.pch"; INFOPLIST_FILE = "$(SRCROOT)/AudioModem-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 5.1; PRODUCT_NAME = AudioModem; WRAPPER_EXTENSION = app; }; name = Staging; }; 7A6BEEF71536FE3D0075E2A7 /* Production */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_PREPROCESSOR_DEFINITIONS = "CONFIGURATION=$(CONFIGURATION)"; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 5.1; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; name = Production; }; 7A6BEEF81536FE3D0075E2A7 /* Production */ = { isa = XCBuildConfiguration; buildSettings = { GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "AudioModem-Prefix.pch"; INFOPLIST_FILE = "$(SRCROOT)/AudioModem-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 5.1; PRODUCT_NAME = AudioModem; WRAPPER_EXTENSION = app; }; name = Production; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ 7A0EC6491535D8ED00E5F54A /* Build configuration list for PBXProject "AudioModem" */ = { isa = XCConfigurationList; buildConfigurations = ( 7A0EC6651535D8ED00E5F54A /* Development */, 7A6BEEF51536FD400075E2A7 /* Staging */, 7A6BEEF71536FE3D0075E2A7 /* Production */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Production; }; 7A0EC6671535D8ED00E5F54A /* Build configuration list for PBXNativeTarget "AudioModem" */ = { isa = XCConfigurationList; buildConfigurations = ( 7A0EC6681535D8ED00E5F54A /* Development */, 7A6BEEF61536FD400075E2A7 /* Staging */, 7A6BEEF81536FE3D0075E2A7 /* Production */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Production; }; /* End XCConfigurationList section */ }; rootObject = 7A0EC6461535D8ED00E5F54A /* Project object */; } ================================================ FILE: Classes/AMAppDelegate.h ================================================ // // AMAppDelegate.h // AudioModem // // Created by Tarek Belkahia on 11/01/13. // Copyright (c) 2013 Applidium. All rights reserved. // #import #import "AMRecorder.h" #import "AMPlayer.h" @interface AMAppDelegate : UIResponder { AMRecorder * _recorder; AMPlayer * _player; } @property (strong, nonatomic) IBOutlet UIWindow * window; @end ================================================ FILE: Classes/AMAppDelegate.m ================================================ // // AMAppDelegate.m // AudioModem // // Created by Tarek Belkahia on 11/01/13. // Copyright (c) 2013 Applidium. All rights reserved. // #import "AMAppDelegate.h" #import "ADSharedMacros.h" @implementation AMAppDelegate @synthesize window = _window; - (void)dealloc { [_window release]; [super dealloc]; } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [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:. } - (IBAction)dismissKeyboard:(id)sender { [_window.rootViewController.view endEditing:YES]; } @end ================================================ FILE: Classes/AMPlayer.h ================================================ // // AMPlayer.h // AudioModem // // Created by Tarek Belkahia on 11/01/13. // // #import #import #define kNumberBuffers 3 typedef struct { AudioStreamBasicDescription mDataFormat; AudioQueueRef mQueue; AudioQueueBufferRef mBuffers[kNumberBuffers]; SInt64 mCurrentPacket; UInt32 mNumPacketsToRead; UInt32 bufferByteSize; bool mIsRunning; const char * mMessage; UInt32 mMessageLength; float mTheta; id mSelf; } AQPlayState; @interface AMPlayer : NSObject @property (nonatomic, assign) AQPlayState playState; @property (retain, nonatomic) IBOutlet UIButton *recordButton; @property (retain, nonatomic) IBOutlet UIButton *playButton; @property (retain, nonatomic) IBOutlet UITextView *messageTextView; - (IBAction)playMessage:(id)sender; - (void)play:(NSString *)message; @end ================================================ FILE: Classes/AMPlayer.m ================================================ // // AMPlayer.m // AudioModem // // Created by Tarek Belkahia on 11/01/13. // // #import "AMPlayer.h" static const unsigned char ParityTable256[256] = { # define P2(n) n, n^1, n^1, n # define P4(n) P2(n), P2(n^1), P2(n^1), P2(n) # define P6(n) P4(n), P4(n^1), P4(n^1), P4(n) P6(0), P6(1), P6(1), P6(0) }; static unsigned char barkerbin[BARKER_LEN] = { 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0 }; void HandleOutputBuffer(void * inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer) { AQPlayState * pPlayState = (AQPlayState *)inUserData; if ( ! pPlayState->mIsRunning) { return; } // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% UInt32 numBytesToPlay = inBuffer->mAudioDataBytesCapacity; UInt32 numPackets = numBytesToPlay/pPlayState->mDataFormat.mBytesPerPacket; SInt16 * buffer = (SInt16 *)inBuffer->mAudioData; printf("playing from : %1.5f (#%lld)\n", pPlayState->mCurrentPacket/(float)SR, pPlayState->mCurrentPacket); printf("message length: %ld samples\n", pPlayState->mMessageLength); for(long i = pPlayState->mCurrentPacket; i < pPlayState->mCurrentPacket + numPackets; i++) { long idx = i % pPlayState->mMessageLength; short encoding = pPlayState->mMessage[idx]; buffer[i-pPlayState->mCurrentPacket] = (SInt16) (sin(2 * M_PI * FREQ * i / SR) * SHRT_MAX * encoding); } // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% inBuffer->mAudioDataByteSize = numPackets * 2; AudioQueueEnqueueBuffer(pPlayState->mQueue, inBuffer, 0, NULL); pPlayState->mCurrentPacket += numPackets; } @interface AMPlayer (Private) - (void)_setupAudioFormat; - (void)_deriveBufferSize:(Float64)seconds; - (void)_encodeMessage:(NSString *)message; @end @implementation AMPlayer - (void)dealloc { AudioQueueDispose(_playState.mQueue, true); [_messageTextView release]; [_playButton release]; [_recordButton release]; [super dealloc]; } - (IBAction)playMessage:(id)sender { if (_playState.mIsRunning) { AudioQueueStop(_playState.mQueue, true); _playState.mIsRunning = false; _playButton.selected = NO; _recordButton.enabled = YES; } else { printf("playing : \"%s\"\n", [_messageTextView.text cStringUsingEncoding:NSASCIIStringEncoding]); [self play:_messageTextView.text]; _playButton.selected = YES; _recordButton.enabled = NO; } } - (void)play:(NSString *)message { [self _setupAudioFormat]; _playState.mCurrentPacket = 0; [self _encodeMessage:message]; [self _deriveBufferSize:1.0f]; OSStatus status = noErr; status = AudioQueueNewOutput(&_playState.mDataFormat, HandleOutputBuffer, &_playState, NULL, NULL, 0, &_playState.mQueue); ADAssert(noErr == status, @"Could not create queue."); _playState.mIsRunning = YES; for (int i = 0; i < kNumberBuffers; i++) { AudioQueueAllocateBuffer(_playState.mQueue, _playState.bufferByteSize, &_playState.mBuffers[i]); HandleOutputBuffer(&_playState, _playState.mQueue, _playState.mBuffers[i]); } ADAssert(noErr == status, @"Could not allocate buffers."); status = AudioQueueStart(_playState.mQueue, NULL); ADAssert(noErr == status, @"Could not start playing."); } @end @implementation AMPlayer (Private) - (void)_setupAudioFormat { _playState.mDataFormat.mFormatID = kAudioFormatLinearPCM; _playState.mDataFormat.mSampleRate = 44100.0f; _playState.mDataFormat.mBitsPerChannel = 16; _playState.mDataFormat.mChannelsPerFrame = 1; _playState.mDataFormat.mFramesPerPacket = 1; _playState.mDataFormat.mBytesPerFrame = _playState.mDataFormat.mBytesPerPacket = _playState.mDataFormat.mChannelsPerFrame * sizeof(SInt16); _playState.mDataFormat.mReserved = 0; _playState.mDataFormat.mFormatFlags = kLinearPCMFormatFlagIsNonInterleaved | kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked ;//| kLinearPCMFormatFlagIsBigEndian; } - (void)_deriveBufferSize:(Float64)seconds { static const int maxBufferSize = 0x50000; int maxPacketSize = _playState.mDataFormat.mBytesPerPacket; if (maxPacketSize == 0) { UInt32 maxVBRPacketSize = sizeof(maxPacketSize); AudioQueueGetProperty(_playState.mQueue, kAudioQueueProperty_MaximumOutputPacketSize, &maxPacketSize, &maxVBRPacketSize); } Float64 numBytesForTime = round(_playState.mDataFormat.mSampleRate * maxPacketSize * seconds); _playState.bufferByteSize = (UInt32) MIN(numBytesForTime, maxBufferSize); } - (void)_encodeMessage:(NSString *)message { const char * str = [message cStringUsingEncoding:NSASCIIStringEncoding]; UInt32 length = message.length; UInt32 encodedLength = length * 12 + BARKER_LEN + 1; unsigned char * encodedMessage = (unsigned char *)calloc(encodedLength, sizeof(unsigned char)); char * bpsk = (char *)calloc(encodedLength * BIT_RATE, sizeof(char)); encodedMessage[0] = 1; for (int i = 1; i < BARKER_LEN+1; i++) { encodedMessage[i] = 1& ~(barkerbin[i-1] ^ encodedMessage[i-1]); } for (int i = BARKER_LEN+1; i < encodedLength; i++) { switch ((i-BARKER_LEN-1)%12) { case 0: case 10: case 11: encodedMessage[i] = 1& ~(0 ^ encodedMessage[i-1]); break; case 9: encodedMessage[i] = 1& ~(ParityTable256[str[(i-BARKER_LEN-1)/12]] ^ encodedMessage[i-1]); break; default: encodedMessage[i] = 1& ~((((unsigned char)str[(i-BARKER_LEN-1)/12] >> (8-((i-BARKER_LEN-1)%12)) & 0x01)) ^ encodedMessage[i-1]); break; } } #ifdef SHOW_ENCODED for (int i = 0; i < encodedLength; i++) { printf("%d", encodedMessage[i]); } printf("\n"); #endif for (int i = 0; i < encodedLength; i++) { for (int j = 0; j < SAMPLE_PER_BIT; j++) { bpsk[i*SAMPLE_PER_BIT+j] = 2* encodedMessage[i] - 1; } } #ifdef SHOW_BASEBAND for (int i = 0; i < SAMPLE_PER_BIT * encodedLength; i++) { printf("%+d\n", bpsk[i]); } #endif _playState.mMessageLength = encodedLength * SAMPLE_PER_BIT; _playState.mMessage = bpsk; } @end ================================================ FILE: Classes/AMRecorder.h ================================================ // // AMRecorder.h // AudioModem // // Created by Tarek Belkahia on 11/01/13. // // #import #import #include #include typedef struct { id mSelf; AudioStreamBasicDescription mDataFormat; AudioQueueRef mQueue; AudioQueueBufferRef mBuffers[kNumberBuffers]; UInt32 bufferByteSize; SInt64 mCurrentPacket; bool mIsRunning; } AQRecordState; @interface AMRecorder : NSObject @property (nonatomic, assign) AQRecordState recordState; @property (retain, nonatomic) IBOutlet UIButton *playButton; @property (retain, nonatomic) IBOutlet UIButton *recordButton; @property (retain, nonatomic) IBOutlet UITextView *receiverTextView; - (IBAction)recordMessage:(id)sender; - (void)startRecording; - (void)stopRecording; - (void)updateTextView; @end ================================================ FILE: Classes/AMRecorder.m ================================================ // // AMRecorder.m // AudioModem // // Created by Tarek Belkahia on 11/01/13. // // #import "AMRecorder.h" static const bool ParityTable256[256] = { # define P2(n) n, n^1, n^1, n # define P4(n) P2(n), P2(n^1), P2(n^1), P2(n) # define P6(n) P4(n), P4(n^1), P4(n^1), P4(n) P6(0), P6(1), P6(1), P6(0) }; static float bpf[SAMPLE_PER_BIT+1] = { +0.0055491, -0.0060955, +0.0066066, -0.0061506, +0.0033972, +0.0028618, -0.0130922, +0.0265188, -0.0409498, +0.0530505, -0.0590496, +0.0557252, -0.0414030, +0.0166718, +0.0154256, -0.0498328, +0.0804827, -0.1016295, +0.1091734, -0.1016295, +0.0804827, -0.0498328, +0.0154256, +0.0166718, -0.0414030, +0.0557252, -0.0590496, +0.0530505, -0.0409498, +0.0265188, -0.0130922, +0.0028618, +0.0033972, -0.0061506, +0.0066066, -0.0060955, +0.0055491 }; static float lpf[SAMPLE_PER_BIT+1] = { 0.0025649, 0.0029793, 0.0039200, 0.0054457, 0.0075875, 0.0103454, 0.0136865, 0.0175452, 0.0218251, 0.0264022, 0.0311308, 0.0358496, 0.0403893, 0.0445807, 0.0482632, 0.0512926, 0.0535482, 0.0549392, 0.0554092, 0.0549392, 0.0535482, 0.0512926, 0.0482632, 0.0445807, 0.0403893, 0.0358496, 0.0311308, 0.0264022, 0.0218251, 0.0175452, 0.0136865, 0.0103454, 0.0075875, 0.0054457, 0.0039200, 0.0029793, 0.0025649 }; static float barkerbin[BARKER_LEN] = { +1.0f, +1.0f, +1.0f, +1.0f, +1.0f, -1.0f, -1.0f, +1.0f, +1.0f, -1.0f, +1.0f, -1.0f, +1.0f }; static char strbuf[BIT_RATE] = {'\n'}; static float * barker; static float * fBuffer; static float * integral; static float * corr; void initReceiver(void) { long bufSize = SR; fBuffer = (float *)calloc(bufSize, sizeof(float)); integral = (float *)calloc(bufSize/SAMPLE_PER_BIT, sizeof(float)); corr = (float *)calloc(bufSize + BARKER_LEN*SAMPLE_PER_BIT, sizeof(float)); barker = (float *)calloc(BARKER_LEN*SAMPLE_PER_BIT, sizeof(float)); for (int i = 0; i < BARKER_LEN; i++) { vDSP_vfill(barkerbin+i, barker+i*SAMPLE_PER_BIT, 1, SAMPLE_PER_BIT); } } void HandleInputBuffer(void * inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer, const AudioTimeStamp * inStartTime, UInt32 inNumPackets, const AudioStreamPacketDescription * inPacketDesc) { AQRecordState * pRecordState = (AQRecordState *)inUserData; if (inNumPackets == 0 && pRecordState->mDataFormat.mBytesPerPacket != 0) { inNumPackets = inBuffer->mAudioDataByteSize / pRecordState->mDataFormat.mBytesPerPacket; } if ( ! pRecordState->mIsRunning) { return; } long sampleStart = pRecordState->mCurrentPacket; long sampleEnd = pRecordState->mCurrentPacket + inBuffer->mAudioDataByteSize / pRecordState->mDataFormat.mBytesPerPacket - 1; printf("buffer received : %1.6f from %1.6f (#%07ld) to %1.6f (#%07ld)\n", (sampleEnd - sampleStart + 1)/44100.0, sampleStart/44100.0, sampleStart, sampleEnd/44100.0, sampleEnd); // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% short * samples = (short *)inBuffer->mAudioData; long nsamples = sampleEnd - sampleStart + 1; bool found = NO; // Convert to float for (long i = 0; i < nsamples; i++) { fBuffer[i] = samples[i] / (float)SHRT_MAX; } // BPF vDSP_desamp(fBuffer, 1, bpf, fBuffer, nsamples, SAMPLE_PER_BIT+1); // Carrier present ? float m = 1.0f, max = 0.0f, mean = 0.0f; vDSP_meamgv(fBuffer, 1, &mean, nsamples); printf("mean %1.9f\n", mean); if (mean > 10e-5) { max = mean; vDSP_maxmgv(fBuffer, 1, &max, nsamples); printf("max %1.9f\n", max); printf("max/mean %1.9f\n", max/mean); // Delay Multiply vDSP_vmul(fBuffer, 1, fBuffer+SAMPLE_PER_BIT, 1, fBuffer, 1, nsamples-SAMPLE_PER_BIT); // LPF vDSP_desamp(fBuffer, 1, lpf, fBuffer, nsamples, SAMPLE_PER_BIT+1); // Time sync m = 1/max; vDSP_vsmul(barker, 1, &m, barker, 1, BARKER_LEN*SAMPLE_PER_BIT); #define FILTERS_DELAY (BARKER_LEN+2)*SAMPLE_PER_BIT vDSP_conv(fBuffer, 1, barker, 1, corr, 1, nsamples-FILTERS_DELAY, BARKER_LEN*SAMPLE_PER_BIT); #ifdef SHOW_CORR for (long i = 0; i < nsamples-FILTERS_DELAY; i++) { printf("%+1.8f\n", corr[i]); } #endif float cc = -1.0f; unsigned long cci = 0; vDSP_vsmul(corr, 1, &cc, corr, 1, nsamples-FILTERS_DELAY); vDSP_maxv(corr, 1, &cc, nsamples-FILTERS_DELAY); cc *= CORR_MAX_COEFF; vDSP_vthrsc(corr, 1, &cc, &cc, corr, 1, nsamples-FILTERS_DELAY); vDSP_maxvi(corr, 1, &cc, &cci, nsamples-FILTERS_DELAY); printf("corr %1.9f\n", cc); printf("idx %lu\n", cci); long j = -1; for (long i = 0; i < nsamples; i++) { if (corr[i] > 0) { if (j != i-1) { printf("Found frame starting at index %ld\n", i); } j = i; } } // Integration for (long i = 0; i < nsamples/SAMPLE_PER_BIT; i++) { if(cci+i*SAMPLE_PER_BIT < nsamples) { vDSP_sve(fBuffer+cci+i*SAMPLE_PER_BIT, 1, integral+i, SAMPLE_PER_BIT); } } // Decision #ifdef SHOW_FRAMES for (long i = 13; i < nsamples/SAMPLE_PER_BIT; i += 12) { if (integral[i]>0 || integral[i+10]>0 || integral[i+11]>0) { break; } printf("%d ", integral[i]>0); for (int j = i+1; j < i+9; j++) { printf("%d", integral[j]>0); } printf(" %d ", integral[i+9]>0); printf("%d", integral[i+10]>0); printf("%d", integral[i+11]>0); printf("\n"); } #endif int i = 13; char ch; short p; while (integral[i]<0 && integral[i+10]<0 && integral[i+11]<0) { ch = 0; for (int j = i+1; j < i+9; j++) { ch |= (integral[j]>0) << (8-j+i); } p = ParityTable256[ch]; printf("%c", ch); strbuf[(i-13)/12] = ch; i += 12; } printf("\n%d characters decoded\n", (i-13)/12); strbuf[(i-13)/12] = '\0'; } else { strbuf[0] = '('; strbuf[1] = 'N'; strbuf[2] = 'o'; strbuf[3] = ' '; strbuf[4] = 's'; strbuf[5] = 'i'; strbuf[6] = 'g'; strbuf[7] = 'n'; strbuf[8] = 'a'; strbuf[9] = 'l'; strbuf[10] = ')'; strbuf[11] = '\0'; } [(AMRecorder *)pRecordState->mSelf performSelectorOnMainThread:@selector(updateTextView) withObject:nil waitUntilDone:NO]; // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% pRecordState->mCurrentPacket += inNumPackets; AudioQueueEnqueueBuffer(pRecordState->mQueue, inBuffer, 0, NULL); if (pRecordState->mIsRunning) { [(AMRecorder *)pRecordState->mSelf stopRecording]; } } @interface AMRecorder (Private) - (void)_setupAudioFormat; - (void)_deriveBufferSize:(Float64)seconds; @end @implementation AMRecorder - (void)dealloc { AudioQueueDispose(_recordState.mQueue, true); [_recordButton release]; [_receiverTextView release]; [_playButton release]; [super dealloc]; } - (void)startRecording { [self _setupAudioFormat]; _recordState.mCurrentPacket = 0; _recordState.mSelf = self; initReceiver(); OSStatus status = noErr; status = AudioQueueNewInput(&_recordState.mDataFormat, HandleInputBuffer, &_recordState, NULL, NULL, 0, &_recordState.mQueue); ADAssert(noErr == status, @"Could not create queue."); [self _deriveBufferSize:1.0f]; for (int i = 0; i < kNumberBuffers; i++) { AudioQueueAllocateBuffer(_recordState.mQueue, _recordState.bufferByteSize, &_recordState.mBuffers[i]); AudioQueueEnqueueBuffer(_recordState.mQueue, _recordState.mBuffers[i], 0, NULL); } ADAssert(noErr == status, @"Could not allocate buffers."); _recordState.mIsRunning = YES; status = AudioQueueStart(_recordState.mQueue, NULL); ADAssert(noErr == status, @"Could not start recording."); _receiverTextView.text = @"(Recording...)"; } - (void)stopRecording { if (_recordState.mIsRunning) { AudioQueueStop(_recordState.mQueue, true); _recordState.mIsRunning = false; _recordButton.enabled = YES; _playButton.enabled = YES; } } - (void)updateTextView { _receiverTextView.text = [NSString stringWithCString:strbuf encoding:NSASCIIStringEncoding]; } - (IBAction)recordMessage:(id)sender { [self startRecording]; _playButton.enabled = NO; _recordButton.enabled = NO; } @end @implementation AMRecorder (Private) - (void)_setupAudioFormat { _recordState.mDataFormat.mFormatID = kAudioFormatLinearPCM; _recordState.mDataFormat.mSampleRate = 44100.0f; _recordState.mDataFormat.mBitsPerChannel = 16; _recordState.mDataFormat.mChannelsPerFrame = 1; _recordState.mDataFormat.mFramesPerPacket = 1; _recordState.mDataFormat.mBytesPerFrame = _recordState.mDataFormat.mBytesPerPacket = _recordState.mDataFormat.mChannelsPerFrame * sizeof(SInt16); _recordState.mDataFormat.mReserved = 0; _recordState.mDataFormat.mFormatFlags = kLinearPCMFormatFlagIsNonInterleaved | kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked ;//| kLinearPCMFormatFlagIsBigEndian; } - (void)_deriveBufferSize:(Float64)seconds { static const int maxBufferSize = 0x50000; int maxPacketSize = _recordState.mDataFormat.mBytesPerPacket; if (maxPacketSize == 0) { UInt32 maxVBRPacketSize = sizeof(maxPacketSize); AudioQueueGetProperty(_recordState.mQueue, kAudioQueueProperty_MaximumOutputPacketSize, &maxPacketSize, &maxVBRPacketSize); } Float64 numBytesForTime = round(_recordState.mDataFormat.mSampleRate * maxPacketSize * seconds); _recordState.bufferByteSize = (UInt32) MIN(numBytesForTime, maxBufferSize); } @end ================================================ FILE: Classes/AudioModem.h ================================================ // // AudioModem.h // AudioModem // // Created by Romain Goyet on 11/04/12. // Copyright (c) 2012 Applidium. All rights reserved. // // CPP magic to include the file named "AudioModem_$(CONFIGURATION).h" #define str_(x) #x #define str2_(x) str_(x) #define cat_(x,y) x ## y #define cat2_(x,y) cat_(x,y) #define ENVIRONMENT_HEADER str2_(cat2_(AudioModem_, CONFIGURATION.h)) #include ENVIRONMENT_HEADER #define kNumberBuffers 3 #define SR 44100 #define FREQ (SR*8/18) #define BIT_RATE (SR/36) #define SAMPLE_PER_BIT (SR/BIT_RATE) #define SAMPLE_PER_BYTE (8 * SAMPLE_PER_BIT) #define BARKER_LEN 13 #define CORR_MAX_COEFF 0.9 //#define SHOW_FRAMES //#define SHOW_CORR //#define SHOW_BASEBAND //#define SHOW_ENCODED ================================================ FILE: Classes/AudioModem_Development.h ================================================ // // AudioModem_Development.h // AudioModem // // Created by Romain Goyet on 12/04/12. // Copyright (c) 2012 Applidium. All rights reserved. // #warning Building in development environment #define ADUseLogs #define ADUseAsserts #define ADUseIgnoreUnusedParameters // Define your development environment below ================================================ FILE: Classes/AudioModem_Production.h ================================================ // // AudioModem_Production.h // AudioModem // // Created by Romain Goyet on 12/04/12. // Copyright (c) 2012 Applidium. All rights reserved. // // Define your production environment below ================================================ FILE: Classes/AudioModem_Staging.h ================================================ // // AudioModem_Staging.h // AudioModem // // Created by Romain Goyet on 12/04/12. // Copyright (c) 2012 Applidium. All rights reserved. // #warning Building in staging environment #define ADUseLogs #define ADUseAsserts #define ADUseIgnoreUnusedParameters // Define your staging environment below ================================================ FILE: LICENSE ================================================ Copyright (c) 2013, Applidium All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Applidium nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: Modules/ADSharedMacros.h ================================================ // // ADSharedMacros.h // AppLibrary // // Created by Adrien on 20/08/10. // Copyright 2010 Applidium. All rights reserved. // #ifdef ADUseLogs #define ADLog(format, ...) NSLog(format, ## __VA_ARGS__) #else #define ADLog(format, ...) #endif #ifdef ADUseAsserts #define ADAssert(format, ...) NSAssert(format, ## __VA_ARGS__) #else #define ADAssert(format, ...) #endif #ifdef ADUseIgnoreUnusedParameters #define ADIgnoreUnusedParameter(parameter) (void)parameter; #else #define ADIgnoreUnusedParameter(parameter) #endif ================================================ FILE: Modules/ADVersionInfo/ADVersionInfo.m ================================================ @interface ADVersionInfo : NSObject @end @implementation ADVersionInfo + (void)load { if ([[[UIDevice currentDevice] name] hasSuffix:@"DEBUG"]) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_displayVersionInfo:) name:UIApplicationDidFinishLaunchingNotification object:nil]; } } + (void)_displayVersionInfo:(NSNotification *)notification { NSDictionary * infoDict = [[NSBundle mainBundle] infoDictionary]; NSString * bundleVersion = [infoDict objectForKey:@"CFBundleVersion"]; NSString * gitCommit = [infoDict objectForKey:@"CFBundleGitCommit"]; NSString * gitBranch = [infoDict objectForKey:@"CFBundleGitBranch"]; NSString * gitStatus = [infoDict objectForKey:@"CFBundleGitStatus"]; NSString * buildDate = [NSString stringWithFormat:@"%s", __DATE__]; UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"Build Infos" message:[NSString stringWithFormat:@"V. %@, built %@ | Commit %@ on %@ | Status %@", bundleVersion, buildDate, gitCommit, gitBranch, gitStatus] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; [alertView release]; } @end ================================================ FILE: main.m ================================================ // // main.m // AudioModem // // Created by Romain Goyet on 11/04/12. // Copyright (c) 2012 Applidium. All rights reserved. // #import #import "AMAppDelegate.h" int main(int argc, char *argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AMAppDelegate class])); } }