Skip to content

Commit

Permalink
🔥 Remove dead framework code (#45)
Browse files Browse the repository at this point in the history
* 🔥 Remove dead framework code

* 🎨 Reduce public API surface
  • Loading branch information
loafofpiecrust authored Sep 30, 2019
1 parent 218713c commit 4d92887
Show file tree
Hide file tree
Showing 14 changed files with 270 additions and 685 deletions.
4 changes: 2 additions & 2 deletions RWFramework/RWFramework/Playlist/Asset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import GEOSwift
*/
public class Asset: Codable {
public let id: Int
public let tags: [Int]
/// URL pointing to the associated media file, relative to the project server
let file: String
/// Duration of the asset in seconds
let length: Double?
let createdDate: Date
public let tags: [Int]
let weight: Double
let description: String
let submitted: Bool?
Expand Down Expand Up @@ -66,7 +66,7 @@ extension Asset {
}
}

struct AssetPool: Codable {
public struct AssetPool: Codable {
let assets: [Asset]
let date: Date
}
4 changes: 2 additions & 2 deletions RWFramework/RWFramework/Playlist/AssetFilter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import GEOSwift
Multiple assets with the same priority will be sorted by
project-level ordering preferences.
*/
enum AssetPriority: Int, CaseIterable {
public enum AssetPriority: Int, CaseIterable {
/// Discard the asset always
case discard = -1

Expand All @@ -21,7 +21,7 @@ enum AssetPriority: Int, CaseIterable {
}

/// Filter applied to assets as candidates for a specific track
protocol AssetFilter {
public protocol AssetFilter {
/// Determines whether the given asset should be played on a particular track.
/// - returns: .discard to skip the asset, otherwise rank it
func keep(_ asset: Asset, playlist: Playlist, track: AudioTrack) -> AssetPriority
Expand Down
4 changes: 2 additions & 2 deletions RWFramework/RWFramework/Playlist/AudioTrack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class AudioTrack: Codable {
var previousAsset: Asset? = nil
var currentAsset: Asset? = nil
var state: TrackState? = nil
fileprivate var isPlaying: Bool = false
private(set) var isPlaying: Bool = false

let player = AVAudioPlayerNode()

Expand Down Expand Up @@ -578,4 +578,4 @@ private class WaitingForAsset: TimedTrackState {
self.track.fadeInNextAsset()
}
}
}
}
48 changes: 48 additions & 0 deletions RWFramework/RWFramework/Playlist/Geometry.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import CoreLocation
import GEOSwift
import AVFoundation

struct ShapeData: Codable {
let coordinates: [[Double]]
Expand All @@ -13,6 +14,53 @@ extension CLLocation {
func toWaypoint() -> Waypoint {
return Waypoint(latitude: coordinate.latitude, longitude: coordinate.longitude)!
}

func bearingToLocationRadian(_ destinationLocation: CLLocation) -> Double {
let lat1 = self.coordinate.latitude.degreesToRadians
let lon1 = self.coordinate.longitude.degreesToRadians

let lat2 = destinationLocation.coordinate.latitude.degreesToRadians
let lon2 = destinationLocation.coordinate.longitude.degreesToRadians

let dLon = lon2 - lon1

let y = sin(dLon) * cos(lat2)
let x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(dLon)
let radiansBearing = atan2(y, x)

return radiansBearing
}

func bearingToLocationDegrees(_ destinationLocation: CLLocation) -> Double {
return bearingToLocationRadian(destinationLocation).radiansToDegrees
}

func toAudioPoint() -> AVAudio3DPoint {
let coord = self.coordinate
let mult = 1.0
return AVAudio3DPoint(
x: Float(coord.longitude * mult),
y: 0.0,
z: -Float(coord.latitude * mult)
)
}

func toAudioPoint(relativeTo other: CLLocation) -> AVAudio3DPoint {
let latCoord = CLLocation(latitude: self.coordinate.latitude, longitude: other.coordinate.longitude)
let lngCoord = CLLocation(latitude: other.coordinate.latitude, longitude: self.coordinate.longitude)
let latDist = latCoord.distance(from: other)
let lngDist = lngCoord.distance(from: other)
let latDir = (self.coordinate.latitude - other.coordinate.latitude).sign
let latMult = latDir == .plus ? -1.0 : 1.0
let lngDir = (self.coordinate.longitude - other.coordinate.longitude).sign
let lngMult = lngDir == .plus ? 1.0 : -1.0
let mult = 0.1
return AVAudio3DPoint(
x: Float(lngDist * lngMult * mult),
y: 0.0,
z: Float(latDist * latMult * mult)
)
}
}

extension Double {
Expand Down
Loading

0 comments on commit 4d92887

Please sign in to comment.