Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Swift 3 example to perform detection on audio stream #287

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions examples/iOS/Swift3/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'Snowboy-example' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!

# Pods for Snowboy-example
pod 'AudioKit', '~> 3.7'
end
12 changes: 12 additions & 0 deletions examples/iOS/Swift3/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
PODS:
- AudioKit (3.7)

DEPENDENCIES:
- AudioKit (~> 3.7)

SPEC CHECKSUMS:
AudioKit: 73c43705575e483623bf3cf306f823a8677aebdd

PODFILE CHECKSUM: ac124ee7ff9a3c042fe17e4e0042986346b21512

COCOAPODS: 1.2.1
435 changes: 435 additions & 0 deletions examples/iOS/Swift3/Snowboy-example.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 17 additions & 37 deletions ...cuserdatad/xcschemes/SnowboyTest.xcscheme → ...rdatad/xcschemes/Snowboy-example.xcscheme
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -14,10 +14,10 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "04F91B951E522B6F00BEF6E3"
BuildableName = "SnowboyTest.app"
BlueprintName = "SnowboyTest"
ReferencedContainer = "container:SnowboyTest.xcodeproj">
BlueprintIdentifier = "6D66978C1EE7694D00109B9E"
BuildableName = "Snowboy-example.app"
BlueprintName = "Snowboy-example"
ReferencedContainer = "container:Snowboy-example.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
Expand All @@ -28,34 +28,14 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "04F91BAC1E522B6F00BEF6E3"
BuildableName = "SnowboyTestTests.xctest"
BlueprintName = "SnowboyTestTests"
ReferencedContainer = "container:SnowboyTest.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "04F91BB71E522B6F00BEF6E3"
BuildableName = "SnowboyTestUITests.xctest"
BlueprintName = "SnowboyTestUITests"
ReferencedContainer = "container:SnowboyTest.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "04F91B951E522B6F00BEF6E3"
BuildableName = "SnowboyTest.app"
BlueprintName = "SnowboyTest"
ReferencedContainer = "container:SnowboyTest.xcodeproj">
BlueprintIdentifier = "6D66978C1EE7694D00109B9E"
BuildableName = "Snowboy-example.app"
BlueprintName = "Snowboy-example"
ReferencedContainer = "container:Snowboy-example.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
Expand All @@ -75,10 +55,10 @@
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "04F91B951E522B6F00BEF6E3"
BuildableName = "SnowboyTest.app"
BlueprintName = "SnowboyTest"
ReferencedContainer = "container:SnowboyTest.xcodeproj">
BlueprintIdentifier = "6D66978C1EE7694D00109B9E"
BuildableName = "Snowboy-example.app"
BlueprintName = "Snowboy-example"
ReferencedContainer = "container:Snowboy-example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
Expand All @@ -94,10 +74,10 @@
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "04F91B951E522B6F00BEF6E3"
BuildableName = "SnowboyTest.app"
BlueprintName = "SnowboyTest"
ReferencedContainer = "container:SnowboyTest.xcodeproj">
BlueprintIdentifier = "6D66978C1EE7694D00109B9E"
BuildableName = "Snowboy-example.app"
BlueprintName = "Snowboy-example"
ReferencedContainer = "container:Snowboy-example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
Expand Down
14 changes: 2 additions & 12 deletions ...rdatad/xcschemes/xcschememanagement.plist → ...rdatad/xcschemes/xcschememanagement.plist
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,15 @@
<dict>
<key>SchemeUserState</key>
<dict>
<key>SnowboyTest.xcscheme</key>
<key>Snowboy-example.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>04F91B951E522B6F00BEF6E3</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>04F91BAC1E522B6F00BEF6E3</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>04F91BB71E522B6F00BEF6E3</key>
<key>6D66978C1EE7694D00109B9E</key>
<dict>
<key>primary</key>
<true/>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
type = "0"
version = "2.0">
</Bucket>
58 changes: 58 additions & 0 deletions examples/iOS/Swift3/Snowboy-example/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// AppDelegate.swift
// Snowboy-example
//
// Created by Chashmeet Singh on 2017-06-07.
// Copyright © 2017 Chashmeet Singh. All rights reserved.
//

import UIKit
import AudioKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

var session = AVAudioSession.sharedInstance()
var error: Error?
try? session.setCategory(AVAudioSessionCategoryPlayAndRecord)
try? session.setMode(AVAudioSessionModeMeasurement)
var doChangeDefaultRoute: UInt32 = 1
// AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, MemoryLayout<doChangeDefaultRoute>.size, doChangeDefaultRoute)
try? session.setActive(true)
if error != nil {
print("ERROR\(error?.localizedDescription)")
}

return true
}

func applicationWillResignActive(_ application: UIApplication) {
// 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 invalidate graphics rendering callbacks. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// 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.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
// 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.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

25 changes: 0 additions & 25 deletions ...xcassets/AppIcon.appiconset/Contents.json → ...xcassets/AppIcon.appiconset/Contents.json
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand Down Expand Up @@ -40,16 +30,6 @@
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
Expand Down Expand Up @@ -79,11 +59,6 @@
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
}
],
"info" : {
Expand Down
File renamed without changes.
26 changes: 26 additions & 0 deletions examples/iOS/Swift3/Snowboy-example/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11134" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>NSMicrophoneUsageDescription</key>
<string>Need to use microphone</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
Expand All @@ -33,8 +31,6 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
Expand All @@ -43,5 +39,7 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>NSMicrophoneUsageDescription</key>
<string>test</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// Copyright © 2017 Bi, Sheng. All rights reserved.
//

#ifndef SnowboyTest_Bridging_Header_h
#define SnowboyTest_Bridging_Header_h
#ifndef Snowboy_example_Bridging_Header_h
#define Snowboy_example_Bridging_Header_h

#import "SnowboyWrapper.h"

#endif /* SnowboyTest_Bridging_Header_h */
#endif /* Snowboy-example-Bridging-Header.h */
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ -(int)runDetection:(NSArray*)data length:(int)length
for (int i = 0; i < count; ++i) {
dataArray[i] = [[data objectAtIndex:i] floatValue];
}

int detected = snowboy->RunDetection(dataArray, length);
free(dataArray);
free(dataArray);
return detected;
}

Expand Down
Loading