Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
finnvoor committed Apr 5, 2024
1 parent 9a90cd3 commit 348e85a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Sources/PlaydateKit/Core/Sound.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ public enum Sound {

// MARK: Public

/// Returns `true` if player is playing a sample, `false` if not.
public var isPlaying: Bool {
sampleplayer.isPlaying.unsafelyUnwrapped(playerPointer) == 1
}

/// Assigns sample to player.
@discardableResult public func setSample(path: StaticString) -> Bool {
if let samplePointer {
Expand All @@ -183,20 +188,14 @@ public enum Sound {
if let samplePointer {
sample.freeSample(samplePointer)
}

samplePointer = sample.load(path)
guard samplePointer != nil else { return false }

sampleplayer.setSample(playerPointer, samplePointer)
return true
}


/// Returns `true` if player is playing a sample, `false` if not.
public var isPlaying: Bool {
sampleplayer.isPlaying.unsafelyUnwrapped(playerPointer) == 1
}

/// Stops playing the sample.
public func stop() {
sampleplayer.stop.unsafelyUnwrapped(playerPointer)
Expand Down

0 comments on commit 348e85a

Please sign in to comment.