Skip to content
Merged
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
6 changes: 5 additions & 1 deletion App/DebugPreview.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#if DEBUG
import AudioIO
import Foundation
import Playback
import Shows
import ShowTakes
import StemFolder
Expand All @@ -17,13 +18,16 @@ import UIKit
/// - `-previewScreen takes`: the Show's Take list instead, with the Take playing in the mini player (#67).
/// - `-previewOutputs <n>`: plays to a silent fake interface with `n` outputs, pulled by a timer, instead of the real
/// output, so every meter moves without a sound.
/// - `-previewInterfaceName <name>`: names that fake interface, for screenshots ("X18/XR18"); otherwise it is
/// "Preview interface (silent)".
/// - `-previewAutoplay YES`: presses Play; `-previewPauseAfter <seconds>` pauses again after that long.
/// - `-previewLandscape YES`: turns an iPhone or iPad to landscape, for a Simulator with no window to turn.
enum DebugPreview {
static let device: FakeAudioDevice? = {
let outputs = UserDefaults.standard.integer(forKey: "previewOutputs")
guard outputs > 0 else { return nil }
let device = FakeAudioDevice(name: "Preview interface (silent)", inputChannelCount: 0, outputChannelCount: outputs)
let name = PreviewInterface.name(asked: UserDefaults.standard.string(forKey: "previewInterfaceName"))
let device = FakeAudioDevice(name: name, inputChannelCount: 0, outputChannelCount: outputs)
let thread = Thread {
while true {
_ = device.pull(frameCount: 1_600)
Expand Down
12 changes: 12 additions & 0 deletions Packages/SoundcheckKit/Sources/Playback/PreviewInterface.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// The name of the Debug preview's silent fake interface (#25). Screenshots ask for a real interface's name with
/// `-previewInterfaceName`, so the header reads "X18/XR18 · 18 out · 48 kHz" (docs/app-store/listing.md, open
/// question 8). Only the Debug build makes a fake interface; a Release build never uses this.
public enum PreviewInterface {
public static let silentName = "Preview interface (silent)"

/// The name asked for, or the silent name when none (or a blank one) is.
public static func name(asked: String?) -> String {
guard let asked, !asked.allSatisfy(\.isWhitespace) else { return silentName }
return asked
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Testing

@testable import Playback

/// The Debug preview's silent interface (#25) and its name for screenshots: the App Store frames read a real
/// interface's name, not "Preview interface (silent)" (docs/app-store/listing.md, open question 8).
@Suite("Preview interface name")
struct PreviewInterfaceTests {
@Test func keepsTheSilentNameWhenNoneIsAsked() {
#expect(PreviewInterface.name(asked: nil) == "Preview interface (silent)")
}

@Test func usesTheNameAskedFor() {
#expect(PreviewInterface.name(asked: "X18/XR18") == "X18/XR18")
}

@Test func aBlankNameKeepsTheSilentOne() {
#expect(PreviewInterface.name(asked: " ") == "Preview interface (silent)")
}
}
Loading