├── .gitignore
├── LICENSE
├── README.md
├── ggwave-objc.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ ├── IDEWorkspaceChecks.plist
│ │ └── swiftpm
│ │ └── Package.resolved
└── xcuserdata
│ └── ggerganov.xcuserdatad
│ └── xcschemes
│ └── xcschememanagement.plist
└── ggwave-objc
├── AppDelegate.h
├── AppDelegate.m
├── Assets.xcassets
├── AccentColor.colorset
│ └── Contents.json
├── AppIcon.appiconset
│ └── Contents.json
└── Contents.json
├── Base.lproj
├── LaunchScreen.storyboard
└── Main.storyboard
├── Info.plist
├── SceneDelegate.h
├── SceneDelegate.m
├── ViewController.h
├── ViewController.m
└── main.m
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | ggwave-objc.xcodeproj/project.xcworkspace/xcuserdata/
3 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Georgi Gerganov
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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ggwave-objc
2 |
3 | Minimal Objective-C app for iOS using [ggwave](https://github.com/ggerganov/ggwave)
4 |
5 |
6 |
7 |
8 |
9 |
10 | ## Usage
11 |
12 | ```bash
13 | git clone https://github.com/ggerganov/ggwave-objc
14 | open ggwave-objc/ggwave-objc.xcodeproj
15 | ```
16 |
--------------------------------------------------------------------------------
/ggwave-objc.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 52;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 187DC34926340BE60049F4BF /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 187DC34826340BE60049F4BF /* AppDelegate.m */; };
11 | 187DC34C26340BE60049F4BF /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 187DC34B26340BE60049F4BF /* SceneDelegate.m */; };
12 | 187DC34F26340BE60049F4BF /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 187DC34E26340BE60049F4BF /* ViewController.m */; };
13 | 187DC35226340BE60049F4BF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 187DC35026340BE60049F4BF /* Main.storyboard */; };
14 | 187DC35426340BE90049F4BF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 187DC35326340BE90049F4BF /* Assets.xcassets */; };
15 | 187DC35726340BE90049F4BF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 187DC35526340BE90049F4BF /* LaunchScreen.storyboard */; };
16 | 187DC35A26340BE90049F4BF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 187DC35926340BE90049F4BF /* main.m */; };
17 | 187DC36326340C110049F4BF /* ggwave in Frameworks */ = {isa = PBXBuildFile; productRef = 187DC36226340C110049F4BF /* ggwave */; };
18 | /* End PBXBuildFile section */
19 |
20 | /* Begin PBXFileReference section */
21 | 187DC34426340BE60049F4BF /* ggwave-objc.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ggwave-objc.app"; sourceTree = BUILT_PRODUCTS_DIR; };
22 | 187DC34726340BE60049F4BF /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
23 | 187DC34826340BE60049F4BF /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
24 | 187DC34A26340BE60049F4BF /* SceneDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SceneDelegate.h; sourceTree = ""; };
25 | 187DC34B26340BE60049F4BF /* SceneDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SceneDelegate.m; sourceTree = ""; };
26 | 187DC34D26340BE60049F4BF /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
27 | 187DC34E26340BE60049F4BF /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
28 | 187DC35126340BE60049F4BF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
29 | 187DC35326340BE90049F4BF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
30 | 187DC35626340BE90049F4BF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
31 | 187DC35826340BE90049F4BF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
32 | 187DC35926340BE90049F4BF /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
33 | /* End PBXFileReference section */
34 |
35 | /* Begin PBXFrameworksBuildPhase section */
36 | 187DC34126340BE60049F4BF /* Frameworks */ = {
37 | isa = PBXFrameworksBuildPhase;
38 | buildActionMask = 2147483647;
39 | files = (
40 | 187DC36326340C110049F4BF /* ggwave in Frameworks */,
41 | );
42 | runOnlyForDeploymentPostprocessing = 0;
43 | };
44 | /* End PBXFrameworksBuildPhase section */
45 |
46 | /* Begin PBXGroup section */
47 | 187DC33B26340BE60049F4BF = {
48 | isa = PBXGroup;
49 | children = (
50 | 187DC34626340BE60049F4BF /* ggwave-objc */,
51 | 187DC34526340BE60049F4BF /* Products */,
52 | );
53 | sourceTree = "";
54 | };
55 | 187DC34526340BE60049F4BF /* Products */ = {
56 | isa = PBXGroup;
57 | children = (
58 | 187DC34426340BE60049F4BF /* ggwave-objc.app */,
59 | );
60 | name = Products;
61 | sourceTree = "";
62 | };
63 | 187DC34626340BE60049F4BF /* ggwave-objc */ = {
64 | isa = PBXGroup;
65 | children = (
66 | 187DC34726340BE60049F4BF /* AppDelegate.h */,
67 | 187DC34826340BE60049F4BF /* AppDelegate.m */,
68 | 187DC34A26340BE60049F4BF /* SceneDelegate.h */,
69 | 187DC34B26340BE60049F4BF /* SceneDelegate.m */,
70 | 187DC34D26340BE60049F4BF /* ViewController.h */,
71 | 187DC34E26340BE60049F4BF /* ViewController.m */,
72 | 187DC35026340BE60049F4BF /* Main.storyboard */,
73 | 187DC35326340BE90049F4BF /* Assets.xcassets */,
74 | 187DC35526340BE90049F4BF /* LaunchScreen.storyboard */,
75 | 187DC35826340BE90049F4BF /* Info.plist */,
76 | 187DC35926340BE90049F4BF /* main.m */,
77 | );
78 | path = "ggwave-objc";
79 | sourceTree = "";
80 | };
81 | /* End PBXGroup section */
82 |
83 | /* Begin PBXNativeTarget section */
84 | 187DC34326340BE60049F4BF /* ggwave-objc */ = {
85 | isa = PBXNativeTarget;
86 | buildConfigurationList = 187DC35D26340BE90049F4BF /* Build configuration list for PBXNativeTarget "ggwave-objc" */;
87 | buildPhases = (
88 | 187DC34026340BE60049F4BF /* Sources */,
89 | 187DC34126340BE60049F4BF /* Frameworks */,
90 | 187DC34226340BE60049F4BF /* Resources */,
91 | );
92 | buildRules = (
93 | );
94 | dependencies = (
95 | );
96 | name = "ggwave-objc";
97 | packageProductDependencies = (
98 | 187DC36226340C110049F4BF /* ggwave */,
99 | );
100 | productName = "ggwave-objc";
101 | productReference = 187DC34426340BE60049F4BF /* ggwave-objc.app */;
102 | productType = "com.apple.product-type.application";
103 | };
104 | /* End PBXNativeTarget section */
105 |
106 | /* Begin PBXProject section */
107 | 187DC33C26340BE60049F4BF /* Project object */ = {
108 | isa = PBXProject;
109 | attributes = {
110 | LastUpgradeCheck = 1240;
111 | TargetAttributes = {
112 | 187DC34326340BE60049F4BF = {
113 | CreatedOnToolsVersion = 12.4;
114 | };
115 | };
116 | };
117 | buildConfigurationList = 187DC33F26340BE60049F4BF /* Build configuration list for PBXProject "ggwave-objc" */;
118 | compatibilityVersion = "Xcode 9.3";
119 | developmentRegion = en;
120 | hasScannedForEncodings = 0;
121 | knownRegions = (
122 | en,
123 | Base,
124 | );
125 | mainGroup = 187DC33B26340BE60049F4BF;
126 | packageReferences = (
127 | 187DC36126340C110049F4BF /* XCRemoteSwiftPackageReference "ggwave-spm" */,
128 | );
129 | productRefGroup = 187DC34526340BE60049F4BF /* Products */;
130 | projectDirPath = "";
131 | projectRoot = "";
132 | targets = (
133 | 187DC34326340BE60049F4BF /* ggwave-objc */,
134 | );
135 | };
136 | /* End PBXProject section */
137 |
138 | /* Begin PBXResourcesBuildPhase section */
139 | 187DC34226340BE60049F4BF /* Resources */ = {
140 | isa = PBXResourcesBuildPhase;
141 | buildActionMask = 2147483647;
142 | files = (
143 | 187DC35726340BE90049F4BF /* LaunchScreen.storyboard in Resources */,
144 | 187DC35426340BE90049F4BF /* Assets.xcassets in Resources */,
145 | 187DC35226340BE60049F4BF /* Main.storyboard in Resources */,
146 | );
147 | runOnlyForDeploymentPostprocessing = 0;
148 | };
149 | /* End PBXResourcesBuildPhase section */
150 |
151 | /* Begin PBXSourcesBuildPhase section */
152 | 187DC34026340BE60049F4BF /* Sources */ = {
153 | isa = PBXSourcesBuildPhase;
154 | buildActionMask = 2147483647;
155 | files = (
156 | 187DC34F26340BE60049F4BF /* ViewController.m in Sources */,
157 | 187DC34926340BE60049F4BF /* AppDelegate.m in Sources */,
158 | 187DC35A26340BE90049F4BF /* main.m in Sources */,
159 | 187DC34C26340BE60049F4BF /* SceneDelegate.m in Sources */,
160 | );
161 | runOnlyForDeploymentPostprocessing = 0;
162 | };
163 | /* End PBXSourcesBuildPhase section */
164 |
165 | /* Begin PBXVariantGroup section */
166 | 187DC35026340BE60049F4BF /* Main.storyboard */ = {
167 | isa = PBXVariantGroup;
168 | children = (
169 | 187DC35126340BE60049F4BF /* Base */,
170 | );
171 | name = Main.storyboard;
172 | sourceTree = "";
173 | };
174 | 187DC35526340BE90049F4BF /* LaunchScreen.storyboard */ = {
175 | isa = PBXVariantGroup;
176 | children = (
177 | 187DC35626340BE90049F4BF /* Base */,
178 | );
179 | name = LaunchScreen.storyboard;
180 | sourceTree = "";
181 | };
182 | /* End PBXVariantGroup section */
183 |
184 | /* Begin XCBuildConfiguration section */
185 | 187DC35B26340BE90049F4BF /* Debug */ = {
186 | isa = XCBuildConfiguration;
187 | buildSettings = {
188 | ALWAYS_SEARCH_USER_PATHS = NO;
189 | CLANG_ANALYZER_NONNULL = YES;
190 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
191 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
192 | CLANG_CXX_LIBRARY = "libc++";
193 | CLANG_ENABLE_MODULES = YES;
194 | CLANG_ENABLE_OBJC_ARC = YES;
195 | CLANG_ENABLE_OBJC_WEAK = YES;
196 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
197 | CLANG_WARN_BOOL_CONVERSION = YES;
198 | CLANG_WARN_COMMA = YES;
199 | CLANG_WARN_CONSTANT_CONVERSION = YES;
200 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
201 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
202 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
203 | CLANG_WARN_EMPTY_BODY = YES;
204 | CLANG_WARN_ENUM_CONVERSION = YES;
205 | CLANG_WARN_INFINITE_RECURSION = YES;
206 | CLANG_WARN_INT_CONVERSION = YES;
207 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
208 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
209 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
210 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
211 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
212 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
213 | CLANG_WARN_STRICT_PROTOTYPES = YES;
214 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
215 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
216 | CLANG_WARN_UNREACHABLE_CODE = YES;
217 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
218 | COPY_PHASE_STRIP = NO;
219 | DEBUG_INFORMATION_FORMAT = dwarf;
220 | ENABLE_STRICT_OBJC_MSGSEND = YES;
221 | ENABLE_TESTABILITY = YES;
222 | GCC_C_LANGUAGE_STANDARD = gnu11;
223 | GCC_DYNAMIC_NO_PIC = NO;
224 | GCC_NO_COMMON_BLOCKS = YES;
225 | GCC_OPTIMIZATION_LEVEL = 0;
226 | GCC_PREPROCESSOR_DEFINITIONS = (
227 | "DEBUG=1",
228 | "$(inherited)",
229 | );
230 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
231 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
232 | GCC_WARN_UNDECLARED_SELECTOR = YES;
233 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
234 | GCC_WARN_UNUSED_FUNCTION = YES;
235 | GCC_WARN_UNUSED_VARIABLE = YES;
236 | IPHONEOS_DEPLOYMENT_TARGET = 14.4;
237 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
238 | MTL_FAST_MATH = YES;
239 | ONLY_ACTIVE_ARCH = YES;
240 | SDKROOT = iphoneos;
241 | };
242 | name = Debug;
243 | };
244 | 187DC35C26340BE90049F4BF /* Release */ = {
245 | isa = XCBuildConfiguration;
246 | buildSettings = {
247 | ALWAYS_SEARCH_USER_PATHS = NO;
248 | CLANG_ANALYZER_NONNULL = YES;
249 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
250 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
251 | CLANG_CXX_LIBRARY = "libc++";
252 | CLANG_ENABLE_MODULES = YES;
253 | CLANG_ENABLE_OBJC_ARC = YES;
254 | CLANG_ENABLE_OBJC_WEAK = YES;
255 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
256 | CLANG_WARN_BOOL_CONVERSION = YES;
257 | CLANG_WARN_COMMA = YES;
258 | CLANG_WARN_CONSTANT_CONVERSION = YES;
259 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
260 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
261 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
262 | CLANG_WARN_EMPTY_BODY = YES;
263 | CLANG_WARN_ENUM_CONVERSION = YES;
264 | CLANG_WARN_INFINITE_RECURSION = YES;
265 | CLANG_WARN_INT_CONVERSION = YES;
266 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
267 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
268 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
269 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
270 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
271 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
272 | CLANG_WARN_STRICT_PROTOTYPES = YES;
273 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
274 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
275 | CLANG_WARN_UNREACHABLE_CODE = YES;
276 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
277 | COPY_PHASE_STRIP = NO;
278 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
279 | ENABLE_NS_ASSERTIONS = NO;
280 | ENABLE_STRICT_OBJC_MSGSEND = YES;
281 | GCC_C_LANGUAGE_STANDARD = gnu11;
282 | GCC_NO_COMMON_BLOCKS = YES;
283 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
284 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
285 | GCC_WARN_UNDECLARED_SELECTOR = YES;
286 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
287 | GCC_WARN_UNUSED_FUNCTION = YES;
288 | GCC_WARN_UNUSED_VARIABLE = YES;
289 | IPHONEOS_DEPLOYMENT_TARGET = 14.4;
290 | MTL_ENABLE_DEBUG_INFO = NO;
291 | MTL_FAST_MATH = YES;
292 | SDKROOT = iphoneos;
293 | VALIDATE_PRODUCT = YES;
294 | };
295 | name = Release;
296 | };
297 | 187DC35E26340BE90049F4BF /* Debug */ = {
298 | isa = XCBuildConfiguration;
299 | buildSettings = {
300 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
301 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
302 | CODE_SIGN_STYLE = Automatic;
303 | DEVELOPMENT_TEAM = P8JZH34X63;
304 | INFOPLIST_FILE = "ggwave-objc/Info.plist";
305 | LD_RUNPATH_SEARCH_PATHS = (
306 | "$(inherited)",
307 | "@executable_path/Frameworks",
308 | );
309 | PRODUCT_BUNDLE_IDENTIFIER = "ggerganov.ggwave-objc";
310 | PRODUCT_NAME = "$(TARGET_NAME)";
311 | TARGETED_DEVICE_FAMILY = "1,2";
312 | };
313 | name = Debug;
314 | };
315 | 187DC35F26340BE90049F4BF /* Release */ = {
316 | isa = XCBuildConfiguration;
317 | buildSettings = {
318 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
319 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
320 | CODE_SIGN_STYLE = Automatic;
321 | DEVELOPMENT_TEAM = P8JZH34X63;
322 | INFOPLIST_FILE = "ggwave-objc/Info.plist";
323 | LD_RUNPATH_SEARCH_PATHS = (
324 | "$(inherited)",
325 | "@executable_path/Frameworks",
326 | );
327 | PRODUCT_BUNDLE_IDENTIFIER = "ggerganov.ggwave-objc";
328 | PRODUCT_NAME = "$(TARGET_NAME)";
329 | TARGETED_DEVICE_FAMILY = "1,2";
330 | };
331 | name = Release;
332 | };
333 | /* End XCBuildConfiguration section */
334 |
335 | /* Begin XCConfigurationList section */
336 | 187DC33F26340BE60049F4BF /* Build configuration list for PBXProject "ggwave-objc" */ = {
337 | isa = XCConfigurationList;
338 | buildConfigurations = (
339 | 187DC35B26340BE90049F4BF /* Debug */,
340 | 187DC35C26340BE90049F4BF /* Release */,
341 | );
342 | defaultConfigurationIsVisible = 0;
343 | defaultConfigurationName = Release;
344 | };
345 | 187DC35D26340BE90049F4BF /* Build configuration list for PBXNativeTarget "ggwave-objc" */ = {
346 | isa = XCConfigurationList;
347 | buildConfigurations = (
348 | 187DC35E26340BE90049F4BF /* Debug */,
349 | 187DC35F26340BE90049F4BF /* Release */,
350 | );
351 | defaultConfigurationIsVisible = 0;
352 | defaultConfigurationName = Release;
353 | };
354 | /* End XCConfigurationList section */
355 |
356 | /* Begin XCRemoteSwiftPackageReference section */
357 | 187DC36126340C110049F4BF /* XCRemoteSwiftPackageReference "ggwave-spm" */ = {
358 | isa = XCRemoteSwiftPackageReference;
359 | repositoryURL = "https://github.com/ggerganov/ggwave-spm";
360 | requirement = {
361 | kind = upToNextMajorVersion;
362 | minimumVersion = 0.2.0;
363 | };
364 | };
365 | /* End XCRemoteSwiftPackageReference section */
366 |
367 | /* Begin XCSwiftPackageProductDependency section */
368 | 187DC36226340C110049F4BF /* ggwave */ = {
369 | isa = XCSwiftPackageProductDependency;
370 | package = 187DC36126340C110049F4BF /* XCRemoteSwiftPackageReference "ggwave-spm" */;
371 | productName = ggwave;
372 | };
373 | /* End XCSwiftPackageProductDependency section */
374 | };
375 | rootObject = 187DC33C26340BE60049F4BF /* Project object */;
376 | }
377 |
--------------------------------------------------------------------------------
/ggwave-objc.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ggwave-objc.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ggwave-objc.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved:
--------------------------------------------------------------------------------
1 | {
2 | "pins" : [
3 | {
4 | "identity" : "ggwave-spm",
5 | "kind" : "remoteSourceControl",
6 | "location" : "https://github.com/ggerganov/ggwave-spm",
7 | "state" : {
8 | "revision" : "5fba9d067bc480910589699d306320f12e8ea814",
9 | "version" : "0.4.0"
10 | }
11 | }
12 | ],
13 | "version" : 2
14 | }
15 |
--------------------------------------------------------------------------------
/ggwave-objc.xcodeproj/xcuserdata/ggerganov.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | ggwave-objc.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/ggwave-objc/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // ggwave-objc
4 | //
5 | // Created by Georgi Gerganov on 24.04.21.
6 | //
7 |
8 | #import
9 |
10 | @interface AppDelegate : UIResponder
11 |
12 |
13 | @end
14 |
15 |
--------------------------------------------------------------------------------
/ggwave-objc/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // ggwave-objc
4 | //
5 | // Created by Georgi Gerganov on 24.04.21.
6 | //
7 |
8 | #import "AppDelegate.h"
9 |
10 | @interface AppDelegate ()
11 |
12 | @end
13 |
14 | @implementation AppDelegate
15 |
16 |
17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
18 | // Override point for customization after application launch.
19 | return YES;
20 | }
21 |
22 |
23 | #pragma mark - UISceneSession lifecycle
24 |
25 |
26 | - (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
27 | // Called when a new scene session is being created.
28 | // Use this method to select a configuration to create the new scene with.
29 | return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
30 | }
31 |
32 |
33 | - (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet *)sceneSessions {
34 | // Called when the user discards a scene session.
35 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
36 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
37 | }
38 |
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/ggwave-objc/Assets.xcassets/AccentColor.colorset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "colors" : [
3 | {
4 | "idiom" : "universal"
5 | }
6 | ],
7 | "info" : {
8 | "author" : "xcode",
9 | "version" : 1
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/ggwave-objc/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "scale" : "2x",
6 | "size" : "20x20"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "scale" : "3x",
11 | "size" : "20x20"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "scale" : "2x",
16 | "size" : "29x29"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "scale" : "3x",
21 | "size" : "29x29"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "scale" : "2x",
26 | "size" : "40x40"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "scale" : "3x",
31 | "size" : "40x40"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "scale" : "2x",
36 | "size" : "60x60"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "scale" : "3x",
41 | "size" : "60x60"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "scale" : "1x",
46 | "size" : "20x20"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "scale" : "2x",
51 | "size" : "20x20"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "scale" : "1x",
56 | "size" : "29x29"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "scale" : "2x",
61 | "size" : "29x29"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "scale" : "1x",
66 | "size" : "40x40"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "scale" : "2x",
71 | "size" : "40x40"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "scale" : "1x",
76 | "size" : "76x76"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "scale" : "2x",
81 | "size" : "76x76"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "scale" : "2x",
86 | "size" : "83.5x83.5"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "scale" : "1x",
91 | "size" : "1024x1024"
92 | }
93 | ],
94 | "info" : {
95 | "author" : "xcode",
96 | "version" : 1
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/ggwave-objc/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/ggwave-objc/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/ggwave-objc/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/ggwave-objc/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSMicrophoneUsageDescription
6 | This app requires microphone access in order to receive audio messages
7 | CFBundleDevelopmentRegion
8 | $(DEVELOPMENT_LANGUAGE)
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | $(PRODUCT_BUNDLE_PACKAGE_TYPE)
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UIApplicationSceneManifest
26 |
27 | UIApplicationSupportsMultipleScenes
28 |
29 | UISceneConfigurations
30 |
31 | UIWindowSceneSessionRoleApplication
32 |
33 |
34 | UISceneConfigurationName
35 | Default Configuration
36 | UISceneDelegateClassName
37 | SceneDelegate
38 | UISceneStoryboardFile
39 | Main
40 |
41 |
42 |
43 |
44 | UIApplicationSupportsIndirectInputEvents
45 |
46 | UILaunchStoryboardName
47 | LaunchScreen
48 | UIMainStoryboardFile
49 | Main
50 | UIRequiredDeviceCapabilities
51 |
52 | armv7
53 |
54 | UISupportedInterfaceOrientations
55 |
56 | UIInterfaceOrientationPortrait
57 | UIInterfaceOrientationLandscapeLeft
58 | UIInterfaceOrientationLandscapeRight
59 |
60 | UISupportedInterfaceOrientations~ipad
61 |
62 | UIInterfaceOrientationPortrait
63 | UIInterfaceOrientationPortraitUpsideDown
64 | UIInterfaceOrientationLandscapeLeft
65 | UIInterfaceOrientationLandscapeRight
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/ggwave-objc/SceneDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // SceneDelegate.h
3 | // ggwave-objc
4 | //
5 | // Created by Georgi Gerganov on 24.04.21.
6 | //
7 |
8 | #import
9 |
10 | @interface SceneDelegate : UIResponder
11 |
12 | @property (strong, nonatomic) UIWindow * window;
13 |
14 | @end
15 |
16 |
--------------------------------------------------------------------------------
/ggwave-objc/SceneDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // SceneDelegate.m
3 | // ggwave-objc
4 | //
5 | // Created by Georgi Gerganov on 24.04.21.
6 | //
7 |
8 | #import "SceneDelegate.h"
9 |
10 | @interface SceneDelegate ()
11 |
12 | @end
13 |
14 | @implementation SceneDelegate
15 |
16 |
17 | - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
18 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
19 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
20 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
21 | }
22 |
23 |
24 | - (void)sceneDidDisconnect:(UIScene *)scene {
25 | // Called as the scene is being released by the system.
26 | // This occurs shortly after the scene enters the background, or when its session is discarded.
27 | // Release any resources associated with this scene that can be re-created the next time the scene connects.
28 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
29 | }
30 |
31 |
32 | - (void)sceneDidBecomeActive:(UIScene *)scene {
33 | // Called when the scene has moved from an inactive state to an active state.
34 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
35 | }
36 |
37 |
38 | - (void)sceneWillResignActive:(UIScene *)scene {
39 | // Called when the scene will move from an active state to an inactive state.
40 | // This may occur due to temporary interruptions (ex. an incoming phone call).
41 | }
42 |
43 |
44 | - (void)sceneWillEnterForeground:(UIScene *)scene {
45 | // Called as the scene transitions from the background to the foreground.
46 | // Use this method to undo the changes made on entering the background.
47 | }
48 |
49 |
50 | - (void)sceneDidEnterBackground:(UIScene *)scene {
51 | // Called as the scene transitions from the foreground to the background.
52 | // Use this method to save data, release shared resources, and store enough scene-specific state information
53 | // to restore the scene back to its current state.
54 | }
55 |
56 |
57 | @end
58 |
--------------------------------------------------------------------------------
/ggwave-objc/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // ggwave-objc
4 | //
5 | // Created by Georgi Gerganov on 24.04.21.
6 | //
7 |
8 | #import
9 |
10 | #import
11 | #import
12 |
13 | #define NUM_BUFFERS 3
14 |
15 | typedef struct
16 | {
17 | int ggwaveId;
18 | bool isCapturing;
19 | UILabel * labelReceived;
20 |
21 | AudioQueueRef queue;
22 | AudioStreamBasicDescription dataFormat;
23 | AudioQueueBufferRef buffers[NUM_BUFFERS];
24 | } StateInp;
25 |
26 | typedef struct
27 | {
28 | bool isPlaying;
29 | int ggwaveId;
30 | int offset;
31 | int totalBytes;
32 | NSMutableData * waveform;
33 | UILabel * labelStatus;
34 |
35 | AudioQueueRef queue;
36 | AudioStreamBasicDescription dataFormat;
37 | AudioQueueBufferRef buffers[NUM_BUFFERS];
38 | } StateOut;
39 |
40 | @interface ViewController : UIViewController
41 | {
42 | StateInp stateInp;
43 | StateOut stateOut;
44 | }
45 |
46 | @end
47 |
--------------------------------------------------------------------------------
/ggwave-objc/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // ggwave-objc
4 | //
5 | // Created by Georgi Gerganov on 24.04.21.
6 | //
7 |
8 | #import "ViewController.h"
9 |
10 | #import "ggwave/ggwave.h"
11 |
12 | #define NUM_BYTES_PER_BUFFER 16*1024
13 |
14 | // the text message to transmit:
15 | const char* kDefaultMessageToSend = "Hello iOS!";
16 |
17 | // callback used to process captured audio
18 | void AudioInputCallback(void * inUserData,
19 | AudioQueueRef inAQ,
20 | AudioQueueBufferRef inBuffer,
21 | const AudioTimeStamp * inStartTime,
22 | UInt32 inNumberPacketDescriptions,
23 | const AudioStreamPacketDescription * inPacketDescs);
24 |
25 | // callback used to playback generated audio
26 | void AudioOutputCallback(void * inUserData,
27 | AudioQueueRef outAQ,
28 | AudioQueueBufferRef outBuffer);
29 |
30 | @interface ViewController ()
31 |
32 | @property (weak, nonatomic) IBOutlet UILabel *labelStatusInp;
33 | @property (weak, nonatomic) IBOutlet UILabel *labelReceived;
34 | @property (weak, nonatomic) IBOutlet UILabel *labelStatusOut;
35 | @property (weak, nonatomic) IBOutlet UILabel *labelMessageToSend;
36 | @property (weak, nonatomic) IBOutlet UIButton *buttonToggleCapture;
37 |
38 | @end
39 |
40 | @implementation ViewController
41 |
42 | - (void)setupAudioFormat:(AudioStreamBasicDescription*)format
43 | {
44 | //format->mSampleRate = 48000.0; // it seems that sometimes 48kHz is not supported by the device
45 | format->mSampleRate = 44100.0;
46 | format->mFormatID = kAudioFormatLinearPCM;
47 | format->mFramesPerPacket = 1;
48 | format->mChannelsPerFrame = 1;
49 | format->mBytesPerFrame = 2;
50 | format->mBytesPerPacket = 2;
51 | format->mBitsPerChannel = 16;
52 | format->mReserved = 0;
53 | format->mFormatFlags = kLinearPCMFormatFlagIsSignedInteger;
54 | }
55 |
56 | - (void)viewDidLoad {
57 | [super viewDidLoad];
58 |
59 | // initialize audio format
60 |
61 | [self setupAudioFormat:&stateInp.dataFormat];
62 | [self setupAudioFormat:&stateOut.dataFormat];
63 |
64 | // initialize the GGWave instances:
65 |
66 | // RX
67 | {
68 | ggwave_Parameters parameters = ggwave_getDefaultParameters();
69 |
70 | // this will cause the ggwave instance to resample the input to the default sample rate (48kHz)
71 | parameters.sampleRateInp = stateInp.dataFormat.mSampleRate;
72 |
73 | parameters.sampleFormatInp = GGWAVE_SAMPLE_FORMAT_I16;
74 | parameters.sampleFormatOut = GGWAVE_SAMPLE_FORMAT_I16;
75 |
76 | stateInp.ggwaveId = ggwave_init(parameters);
77 |
78 | printf("GGWave capture instance initialized - instance id = %d\n", stateInp.ggwaveId);
79 | }
80 |
81 | // TX
82 | {
83 | ggwave_Parameters parameters = ggwave_getDefaultParameters();
84 |
85 | // this will cause the ggwave instance to resample the output to the configured sample rate
86 | parameters.sampleRateOut = stateOut.dataFormat.mSampleRate;
87 |
88 | parameters.sampleFormatInp = GGWAVE_SAMPLE_FORMAT_I16;
89 | parameters.sampleFormatOut = GGWAVE_SAMPLE_FORMAT_I16;
90 |
91 | stateOut.ggwaveId = ggwave_init(parameters);
92 |
93 | printf("GGWave playback instance initialized - instance id = %d\n", stateOut.ggwaveId);
94 | }
95 |
96 | // uncomment to disable internal logging from ggwave
97 | //ggwave_setLogFile(NULL);
98 |
99 | // UI
100 |
101 | stateInp.labelReceived = _labelReceived;
102 | stateOut.labelStatus = _labelStatusOut;
103 | _labelMessageToSend.text = [@"Message to send: " stringByAppendingString:[NSString stringWithFormat:@"%s", kDefaultMessageToSend]];
104 | }
105 |
106 | -(IBAction) stopCapturing
107 | {
108 | printf("Stop capturing\n");
109 |
110 | _labelStatusInp.text = @"Status: Idle";
111 | _labelReceived.text = @"Received: ";
112 |
113 | stateInp.isCapturing = false;
114 |
115 | AudioQueueStop(stateInp.queue, true);
116 | for (int i = 0; i < NUM_BUFFERS; i++) {
117 | AudioQueueFreeBuffer(stateInp.queue, stateInp.buffers[i]);
118 | }
119 |
120 | AudioQueueDispose(stateInp.queue, true);
121 | }
122 |
123 | - (IBAction)toggleCapture:(id)sender {
124 | if (stateInp.isCapturing) {
125 | [self stopCapturing];
126 | [sender setTitle:@"Start Capturing" forState:UIControlStateNormal];
127 |
128 | return;
129 | }
130 |
131 | // initiate audio capturing
132 | // the GGWave analysis is performed in the capture callback
133 |
134 | printf("Start capturing\n");
135 |
136 | OSStatus status = AudioQueueNewInput(&stateInp.dataFormat,
137 | AudioInputCallback,
138 | &stateInp,
139 | CFRunLoopGetCurrent(),
140 | kCFRunLoopCommonModes,
141 | 0,
142 | &stateInp.queue);
143 |
144 | if (status == 0) {
145 | for (int i = 0; i < NUM_BUFFERS; i++) {
146 | AudioQueueAllocateBuffer(stateInp.queue, NUM_BYTES_PER_BUFFER, &stateInp.buffers[i]);
147 | AudioQueueEnqueueBuffer (stateInp.queue, stateInp.buffers[i], 0, NULL);
148 | }
149 |
150 | stateInp.isCapturing = true;
151 | status = AudioQueueStart(stateInp.queue, NULL);
152 | if (status == 0) {
153 | _labelStatusInp.text = @"Status: Capturing";
154 | [sender setTitle:@"Stop Capturing" forState:UIControlStateNormal];
155 | }
156 | }
157 |
158 | if (status != 0) {
159 | [self stopCapturing];
160 | }
161 | }
162 |
163 | -(IBAction) stopPlayback
164 | {
165 | printf("Stop playback\n");
166 |
167 | _labelStatusOut.text = @"Status: Idle";
168 |
169 | stateOut.isPlaying = false;
170 |
171 | for (int i = 0; i < NUM_BUFFERS; i++) {
172 | AudioQueueFreeBuffer(stateOut.queue, stateOut.buffers[i]);
173 | }
174 |
175 | AudioQueueDispose(stateOut.queue, true);
176 | }
177 |
178 |
179 | - (IBAction)togglePlayback:(id)sender {
180 | if (stateOut.isPlaying) {
181 | [self stopPlayback];
182 | [sender setTitle:@"Send Message" forState:UIControlStateNormal];
183 |
184 | return;
185 | }
186 |
187 | // prepare audio message using GGWave
188 | {
189 | const char * payload = kDefaultMessageToSend;
190 | const int len = (int) strlen(payload);
191 |
192 | const int n = ggwave_encode(stateOut.ggwaveId, payload, len, GGWAVE_PROTOCOL_AUDIBLE_FAST, 10, NULL, 1);
193 |
194 | stateOut.waveform = [NSMutableData dataWithLength:sizeof(char)*n];
195 |
196 | const int ret = ggwave_encode(stateOut.ggwaveId, payload, len, GGWAVE_PROTOCOL_AUDIBLE_FAST, 10, [stateOut.waveform mutableBytes], 0);
197 |
198 | if (ret > n) {
199 | printf("failed to encode the message '%s', n = %d, ret = %d\n", payload, n, ret);
200 | return;
201 | }
202 |
203 | stateOut.offset = 0;
204 | stateOut.totalBytes = n;
205 | }
206 |
207 | // initiate playback
208 |
209 | printf("Send message\n");
210 |
211 | OSStatus status = AudioQueueNewOutput(&stateOut.dataFormat,
212 | AudioOutputCallback,
213 | &stateOut,
214 | CFRunLoopGetCurrent(),
215 | kCFRunLoopCommonModes,
216 | 0,
217 | &stateOut.queue);
218 |
219 | if (status == 0) {
220 | stateOut.isPlaying = true;
221 | for (int i = 0; i < NUM_BUFFERS && stateOut.isPlaying; i++) {
222 | AudioQueueAllocateBuffer(stateOut.queue, NUM_BYTES_PER_BUFFER, &stateOut.buffers[i]);
223 | AudioOutputCallback(&stateOut, stateOut.queue, stateOut.buffers[i]);
224 | }
225 |
226 | status = AudioQueueStart(stateOut.queue, NULL);
227 | if (status == 0) {
228 | _labelStatusOut.text = @"Status: Playing audio";
229 | }
230 | }
231 |
232 | if (status != 0) {
233 | [self stopPlayback];
234 | }
235 | }
236 |
237 | @end
238 |
239 |
240 | //
241 | // Callback implmentation
242 | //
243 |
244 | void AudioInputCallback(void * inUserData,
245 | AudioQueueRef inAQ,
246 | AudioQueueBufferRef inBuffer,
247 | const AudioTimeStamp * inStartTime,
248 | UInt32 inNumberPacketDescriptions,
249 | const AudioStreamPacketDescription * inPacketDescs)
250 | {
251 | StateInp * stateInp = (StateInp*)inUserData;
252 |
253 | if (!stateInp->isCapturing) {
254 | printf("Not capturing, returning\n");
255 | return;
256 | }
257 |
258 | char decoded[256];
259 |
260 | // analyze captured audio
261 | int ret = ggwave_ndecode(stateInp->ggwaveId, (char *)inBuffer->mAudioData, inBuffer->mAudioDataByteSize, decoded, 256);
262 |
263 | // check if a message has been received
264 | if (ret > 0) {
265 | decoded[ret] = 0; // null terminate the string
266 | stateInp->labelReceived.text = [@"Received: " stringByAppendingString:[NSString stringWithFormat:@"%s", decoded]];
267 | }
268 |
269 | // put the buffer back in the queue
270 | AudioQueueEnqueueBuffer(stateInp->queue, inBuffer, 0, NULL);
271 | }
272 |
273 | void AudioOutputCallback(void * inUserData,
274 | AudioQueueRef outAQ,
275 | AudioQueueBufferRef outBuffer)
276 | {
277 | StateOut* stateOut = (StateOut*)inUserData;
278 | if (!stateOut->isPlaying) {
279 | printf("Not playing, returning\n");
280 | return;
281 | }
282 |
283 | int nRemainingBytes = stateOut->totalBytes - stateOut->offset;
284 |
285 | // check if there is any audio left to play
286 | if (nRemainingBytes > 0) {
287 | int nBytesToPush = MIN(nRemainingBytes, NUM_BYTES_PER_BUFFER);
288 |
289 | memcpy(outBuffer->mAudioData, [stateOut->waveform mutableBytes] + stateOut->offset, nBytesToPush);
290 | outBuffer->mAudioDataByteSize = nBytesToPush;
291 |
292 | OSStatus status = AudioQueueEnqueueBuffer(stateOut->queue, outBuffer, 0, NULL);
293 | if (status != 0) {
294 | printf("Failed to enqueue audio data\n");
295 | }
296 |
297 | stateOut->offset += nBytesToPush;
298 | } else {
299 | // no audio left - stop playback
300 | if (stateOut->isPlaying) {
301 | printf("Stopping playback\n");
302 | AudioQueueStop(stateOut->queue, false);
303 | stateOut->isPlaying = false;
304 | stateOut->labelStatus.text = @"Status: Idle";
305 | }
306 |
307 | AudioQueueFreeBuffer(stateOut->queue, outBuffer);
308 | }
309 | }
310 |
--------------------------------------------------------------------------------
/ggwave-objc/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // ggwave-objc
4 | //
5 | // Created by Georgi Gerganov on 24.04.21.
6 | //
7 |
8 | #import
9 | #import "AppDelegate.h"
10 |
11 | int main(int argc, char * argv[]) {
12 | NSString * appDelegateClassName;
13 | @autoreleasepool {
14 | // Setup code that might create autoreleased objects goes here.
15 | appDelegateClassName = NSStringFromClass([AppDelegate class]);
16 | }
17 | return UIApplicationMain(argc, argv, nil, appDelegateClassName);
18 | }
19 |
--------------------------------------------------------------------------------