// A SONG as the CASSETTE (owner, 7 Nov 2026: "can't this be a single song // face? Tapping on them keeps moving to the next song."): the bare cassette // (`BareCassette`, `CassetteParts.swift`) holding one song, offered on the song // table beside the single (`song.cassette`), and the player's own face on // Listening (`PlayerFace.cassette`). Its label says the song's title by hand // and, under the red rule, "artist / album"; its counter the song's length // at rest and the time into it while the player holds it. A tap anywhere on // it plays or pauses the song — never moves the deck — and while it plays // the hubs turn and the packs wind through the song. On the player's own // card (`now_playing`, Listening's) the left hub steps back a song and the // right hub on; a drag across the window scrubs. // // Every word is the card's: `title`, `subtitle` or `artist`, `album`, // `length` (the core's clock, "4:02") or `duration` (seconds, the player's). import CottonPaper import CottonValues import SwiftUI public enum SongCassetteFaceCatalogue { public static let stock: FaceStock = .own public static let ground: FaceGround = .tolex public static let face = Face(id: "song.cassette", specimens: [ Specimen("still", harbour), Specimen("playing", player, play: TrackPlay(held: true, playing: true, elapsed: 134, duration: 242)), Specimen("long", long), ]) { card, _, _ in TrackPlaying(card: card) { player in BareCassette(words: SongCassette.words(card, play: player.play), play: player.play.onTheSong, toggle: player.toggle, seek: player.seek) } } /// An invented song off an invented album, as the Songs deck holds it. public static let harbour = DeckCard(face: .songCassette, fields: [ "title": .text("Harbour Lights"), "subtitle": .text("The Night Ferries"), "album": .text("Coastline"), "length": .text("4:02"), ]) /// The same song as Listening's player holds it. public static let player = DeckCard(face: .songCassette, fields: [ "title": .text("Harbour Lights"), "artist": .text("The Night Ferries"), "album": .text("Coastline"), "duration": .number(242), "now_playing": .text("specimen-song"), ]) /// A long title, a long artist and a long album. public static let long = DeckCard(face: .songCassette, fields: [ "title": .text("The Slow Train Home Through Sixteen Lanterns"), "subtitle": .text("Mara Vance and the Quiet Part of the Album Orchestra"), "album": .text("Sixteen Lanterns and the Blue Hour Sessions"), "length": .text("1:12:40"), ]) } /// A song's card as the cassette says it. enum SongCassette { /// The card's place saying it is the player's own (Listening's). static let player = "now_playing" /// Its words; its length the card's, else the player's while it holds it. static func words(_ card: DeckCard, play: TrackPlay = .still) -> CassetteWords { let seconds = card.fields["duration"]?.number ?? (play.held ? play.duration : 0) let byline = [card.text("subtitle") ?? card.text("artist"), card.text("album")].compactMap { $0 }.filter { !$0.isEmpty } return CassetteWords( title: card.text("title"), byline: byline.isEmpty ? nil : byline.joined(separator: " / "), length: card.text("length") ?? (seconds > 0 ? TrackClock.said(seconds) : nil), steps: card.text(player) != nil, songs: [CassetteSong(title: card.text("title"), seconds: seconds)]) } } extension TrackPlay { /// Where the player stands with the one song on a song's tape: the song /// it holds is the tape's first, its length the player's. var onTheSong: TrackPlay { var play = self if play.held { play.song = 0 } return play } }