diff --git a/backups/before-classic-library-20261103-085620/KJamsClone/Importer.swift b/backups/before-classic-library-20261103-085620/KJamsClone/Importer.swift deleted file mode 100644 index 0b023d1..0000000 --- a/backups/before-classic-library-20261103-085620/KJamsClone/Importer.swift +++ /dev/null @@ -1,64 +0,0 @@ -import Foundation -import CryptoKit -import AVFoundation - -struct Importer { - let media: URL - func run(_ urls: [URL], library: Library) throws { - try FileManager.default.createDirectory(at: media, withIntermediateDirectories: true) - var files = urls - var temporary = [URL]() - defer { for url in temporary { try? FileManager.default.removeItem(at: url) } } - for zip in urls where zip.pathExtension.lowercased() == "zip" { - let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true) - temporary.append(folder) - // Validate names before extraction; reject path traversal and symlinks afterwards. - let details = try process(["-Z", "-l", zip.path]) - guard !details.split(separator: "\n").contains(where: { $0.hasPrefix("l") }) else { throw LibraryError.message("ZIP symlinks are unsupported") } - let list = try process(["-Z1", zip.path]) - let names = list.split(separator: "\n").map(String.init) - guard !names.isEmpty, names.allSatisfy({ !$0.hasPrefix("/") && !$0.split(separator: "/").contains("..") && !$0.contains("\\") }) else { throw LibraryError.message("Unsafe or empty ZIP") } - _ = try process(["-q", zip.path, "-d", folder.path]) - let extracted = FileManager.default.enumerator(at: folder, includingPropertiesForKeys: [.isSymbolicLinkKey,.isRegularFileKey])! - for case let url as URL in extracted { - let values = try url.resourceValues(forKeys: [.isSymbolicLinkKey,.isRegularFileKey]) - guard values.isSymbolicLink != true else { throw LibraryError.message("ZIP symlinks are unsupported") } - if values.isRegularFile == true { files.append(url) } - } - } - for cdg in files.filter({ $0.pathExtension.lowercased() == "cdg" }) { - let siblings = try FileManager.default.contentsOfDirectory(at:cdg.deletingLastPathComponent(),includingPropertiesForKeys:nil) - if let audio = siblings.first(where: { ["mp3","wav","m4a"].contains($0.pathExtension.lowercased()) && $0.deletingPathExtension().lastPathComponent.caseInsensitiveCompare(cdg.deletingPathExtension().lastPathComponent) == .orderedSame }) { files.append(audio) } - } - var imported = 0 - for audio in Set(files) where ["mp3","wav","m4a"].contains(audio.pathExtension.lowercased()) { - let siblings = try FileManager.default.contentsOfDirectory(at: audio.deletingLastPathComponent(), includingPropertiesForKeys: nil) - let cdg = siblings.first { $0.pathExtension.lowercased() == "cdg" && $0.deletingPathExtension().lastPathComponent.caseInsensitiveCompare(audio.deletingPathExtension().lastPathComponent) == .orderedSame } - let hash = SHA256.hash(data: try Data(contentsOf: audio)).map { String(format: "%02x", $0) }.joined() - let dest = media.appendingPathComponent(hash + "." + audio.pathExtension.lowercased()) - if !FileManager.default.fileExists(atPath: dest.path) { try FileManager.default.copyItem(at: audio, to: dest) } - var graphics: String? - if let cdg { - let target = media.appendingPathComponent(hash + ".cdg") - if !FileManager.default.fileExists(atPath: target.path) { try FileManager.default.copyItem(at: cdg, to: target) } - graphics = target.path - } - imported += 1 - let metadata = AVURLAsset(url:audio).commonMetadata - func tag(_ key: AVMetadataKey) -> String { metadata.first { $0.commonKey == key }?.stringValue ?? "" } - let taggedTitle = tag(.commonKeyTitle) - try library.add(title:taggedTitle.isEmpty ? audio.deletingPathExtension().lastPathComponent : taggedTitle,audio:dest.path,cdg:graphics,artist:tag(.commonKeyArtist),album:tag(.commonKeyAlbumName),label:tag(.commonKeyPublisher)) - } - guard imported > 0 else { throw LibraryError.message("No audio found. Keep the MP3 and matching CDG together, or import an MP3+G ZIP.") } - } - private func process(_ arguments: [String]) throws -> String { - let task = Process(); task.executableURL = URL(fileURLWithPath: "/usr/bin/unzip"); task.arguments = arguments - let out = Pipe(); task.standardOutput = out - let err = FileHandle.nullDevice; task.standardError = err - try task.run() - let bytes = out.fileHandleForReading.readDataToEndOfFile(); task.waitUntilExit() - guard task.terminationStatus == 0 else { throw LibraryError.message("Cannot read ZIP archive") } - return String(decoding: bytes, as: UTF8.self) - } -} diff --git a/backups/before-classic-library-20261103-085620/KJamsClone/KJamsCloneApp.swift b/backups/before-classic-library-20261103-085620/KJamsClone/KJamsCloneApp.swift deleted file mode 100644 index 4678872..0000000 --- a/backups/before-classic-library-20261103-085620/KJamsClone/KJamsCloneApp.swift +++ /dev/null @@ -1,940 +0,0 @@ -import SwiftUI -import UniformTypeIdentifiers - -enum EntityKind: String, Identifiable { - case singer, venue - var id: String { rawValue } - var title: String { self == .singer ? "Singer" : "Venue" } - var table: String { self == .singer ? "singers" : "venues" } -} - -@MainActor final class AppModel: ObservableObject { - @Published var songs = [Song]() - @Published var singers = [PersonPlace]() - @Published var singerSongIDs = [Int64:[Int64]]() - var newSingerSongs = Set() - @Published var venues = [PersonPlace]() - @Published var venueSingers = [PersonPlace]() - @Published var playlists = [PersonPlace]() - @Published var queue = [QueueEntry]() - @Published var history = [Performance]() - @Published private(set) var currentVenue: Int64? - @Published var selectedSinger: Int64? - @Published var autoAdvance = true - @Published var error: String? - @Published var creating: EntityKind? - let player = Player() - private(set) var library: Library? - let root: URL - var currentVenueName: String { venues.first { $0.id == currentVenue }?.name ?? "No venue selected" } - init(storageURL: URL? = nil) { - root = storageURL ?? FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0].appendingPathComponent("KJamsClone") - perform { - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - library = try Library(url:root.appendingPathComponent("Library.sqlite")); try refresh() - } - player.onFinished = { [weak self] in - guard let self, self.autoAdvance, !self.queue.isEmpty else { return } - self.playQueueNext() - } - } - func perform(_ work: () throws -> Void) { do { try work() } catch { self.error = error.localizedDescription } } - func refresh() throws { - guard let library else { throw LibraryError.message("Library unavailable") } - songs = try library.songs(); singers = try library.entities("singers"); venues = try library.entities("venues") - singerSongIDs = try library.singerSongIDs() - playlists = try library.entities("playlists"); currentVenue = try library.currentVenue() - venueSingers = try currentVenue.map { try library.members(of:$0) } ?? singers - if let selectedSinger, !venueSingers.contains(where: { $0.id == selectedSinger }) { self.selectedSinger = nil } - queue = try library.queue(venue:currentVenue); history = try library.history(venue:currentVenue) - } - func chooseVenue(_ id: Int64?) { - perform { - guard let library else { throw LibraryError.message("Library unavailable") } - try library.selectVenue(id); selectedSinger = nil; try refresh() - } - } - func membership(singer: Int64, included: Bool) { - perform { - guard let library, let currentVenue else { throw LibraryError.message("Select a current venue first") } - try library.setMembership(singer:singer,venue:currentVenue,included:included); try refresh() - } - } - @discardableResult func createEntity(_ kind: EntityKind, name: String) throws -> Int64 { - guard let library else { throw LibraryError.message("Library unavailable") } - let trimmed = name.trimmingCharacters(in:.whitespacesAndNewlines) - try library.addEntity(kind.table,name:trimmed) - guard let entity = try library.entities(kind.table).first(where: { $0.name == trimmed }) else { throw LibraryError.message("Could not load new entry") } - if kind == .singer { - if let currentVenue { try library.setMembership(singer:entity.id,venue:currentVenue,included:true) } - selectedSinger = entity.id - } else { try library.selectVenue(entity.id); selectedSinger = nil } - try refresh(); return entity.id - } - func beginSinger(song: Int64? = nil) { newSingerSongs = Set(song.map { [$0] } ?? []); creating = .singer } - func songs(for singer: Int64) -> [Song] { - (singerSongIDs[singer] ?? []).compactMap { id in songs.first { $0.id == id } } - } - func assign(_ song: Int64, to singer: Int64, included: Bool = true) { - perform { - guard let library else { throw LibraryError.message("Library unavailable") } - if included { try library.assignSong(song,singer:singer) } else { try library.removeSingerSong(song,singer:singer) } - try refresh() - } - } - func createSinger(name: String, venue: Int64, songs: Set) throws -> Int64 { - guard let library else { throw LibraryError.message("Library unavailable") } - guard venues.contains(where: { $0.id == venue }) else { throw LibraryError.message("Choose a venue first") } - let name = name.trimmingCharacters(in:.whitespacesAndNewlines) - try library.execute("BEGIN IMMEDIATE") - let id: Int64 - do { - try library.addEntity("singers",name:name) - guard let singer = try library.entities("singers").first(where: { $0.name == name }) else { throw LibraryError.message("Could not load singer") } - id = singer.id - try library.setMembership(singer:id,venue:venue,included:true) - for song in songs { try library.assignSong(song,singer:id) } - try library.selectVenue(venue);try library.execute("COMMIT") - } catch { try? library.execute("ROLLBACK");throw error } - try refresh();selectedSinger = id;return id - } - func rename(_ table: String, id: Int64, name: String) { perform { try library?.rename(table,id:id,name:name); try refresh() } } - func delete(_ table: String, id: Int64) { perform { try library?.deleteEntity(table,id:id); try refresh() } } - func preference(_ song: Int64) -> SongPreference { - guard let library, let selectedSinger else { return .init() } - return (try? library.preference(song:song,singer:selectedSinger)) ?? .init() - } - func savePreference(song: Int64, value: SongPreference) { - perform { - guard let library, let selectedSinger else { throw LibraryError.message("Select a singer to save their song preferences") } - try library.savePreference(song:song,singer:selectedSinger,value:value); try refresh() - } - } - func play(_ song: Song, singer: Int64? = nil) throws { - guard let library else { throw LibraryError.message("Library unavailable") } - let singer = singer ?? selectedSinger - if let singer, let currentVenue, try !library.members(of:currentVenue).contains(where: { $0.id == singer }) { throw LibraryError.message("This singer is not in the current venue") } - let preference = try singer.map { try library.preference(song:song.id,singer:$0) } ?? SongPreference() - try player.load(song,preference:preference) - do { try library.record(song.id,singer:singer,venue:currentVenue); selectedSinger = singer; try refresh() } - catch { player.stop(); throw error } - } - func enqueue(_ song: Int64) { perform { try library?.enqueue(song:song,singer:selectedSinger,venue:currentVenue); try refresh() } } - func playQueueNext() { - perform { - guard let row = queue.first, let song = songs.first(where: { $0.id == row.songID }) else { return } - // Explicitly clear selection for unassigned queue entries. - selectedSinger = row.singerID - try play(song,singer:row.singerID); try library?.removeQueue(row.id); try refresh() - } - } - func moveQueue(_ id: Int64, by offset: Int) { perform { if let currentVenue { try library?.moveQueue(id,venue:currentVenue,by:offset); try refresh() } } } - func removeQueue(_ id: Int64) { perform { try library?.removeQueue(id); try refresh() } } - func createPlaylist(_ name: String) { perform { try library?.addEntity("playlists",name:name); try refresh() } } - func addToPlaylist(_ playlist: Int64, song: Int64) { perform { try library?.addToPlaylist(playlist,song:song); try refresh() } } - func importFiles(_ urls: [URL]) { perform { guard let library else { throw LibraryError.message("Library unavailable") }; try Importer(media:root.appendingPathComponent("Media")).run(urls,library:library); try refresh() } } -} -@main struct KJamsCloneApp: App { - @StateObject private var model = AppModel() - var body: some Scene { - Window("KJamsClone", id: "main") { - LibraryView(model: model).frame(minWidth: 1060, minHeight: 680).preferredColorScheme(.dark) - }.defaultSize(width: 1260, height: 840) - .commands { - CommandGroup(replacing: .newItem) { - Button("New Singer…") { model.beginSinger() }.keyboardShortcut("n", modifiers: [.command, .shift]) - Button("New Venue…") { model.creating = .venue }.keyboardShortcut("n", modifiers: [.command, .option]) - } - } - Window("Video", id: "lyrics") { - LyricsView(player: model.player).frame(minWidth: 480, minHeight: 320).preferredColorScheme(.dark) - }.defaultSize(width: 600, height: 400) - } -} -private enum Classic { - static let frame = Color(red: 0.15, green: 0.15, blue: 0.15) - static let navy = Color(red: 0.008, green: 0.065, blue: 0.16) - static let blue = Color(red: 0.015, green: 0.17, blue: 0.42) - static let header = Color(white: 0.115) - static let line = Color(white: 0.42) -} -struct LyricsView: View { - @ObservedObject var player: Player - var body: some View { - ZStack { - Color.black - if let image = player.image { - Image(decorative: image, scale: 1).interpolation(.none).resizable().aspectRatio(1.5, contentMode: .fit) - } - } - } -} -/// This is another view of the same published CGImage used by the Video window. -/// It owns no decoder, audio player or clock, so seeking/pause/tempo stay identical. -private struct SidebarVideoMonitor: View { - let player: Player - var body: some View { - VStack(alignment: .leading, spacing: 7) { - Label("Video Monitor", systemImage: "tv") - .font(.system(size: 11, weight: .medium)).foregroundStyle(.white.opacity(0.7)) - LyricsView(player: player) - .aspectRatio(1.5, contentMode: .fit) - .clipped() - .overlay(Rectangle().strokeBorder(.white.opacity(0.25), lineWidth: 1)) - .accessibilityLabel("Video monitor, synchronized with the Video window") - }.frame(maxWidth: .infinity) - } -} -private struct SilverSquareStyle: ButtonStyle { - func makeBody(configuration: Configuration) -> some View { - configuration.label.foregroundStyle(Color(white: 0.25)).padding(.horizontal, 6).padding(.vertical, 3) - .background(LinearGradient(colors: [Color(white: 0.95), Color(white: 0.64)], startPoint: .top, endPoint: .bottom), in: RoundedRectangle(cornerRadius: 4)) - .overlay(RoundedRectangle(cornerRadius: 4).strokeBorder(Color(white: 0.45), lineWidth: 1.5)) - .overlay(RoundedRectangle(cornerRadius: 3).strokeBorder(.white.opacity(0.7)).padding(3)) - .opacity(configuration.isPressed ? 0.7 : 1) - } -} -private struct SilverButton: View { - let symbol: String - let label: String - var size: CGFloat = 40 - var active = false - var enabled = true - let action: () -> Void - var body: some View { - Button(action: action) { - Image(systemName: symbol).font(.system(size: size * 0.41, weight: .semibold)) - .foregroundStyle(active ? Color.blue : Color(white: 0.24)) - .frame(width: size, height: size) - .background(LinearGradient(colors: [.white, Color(white: 0.85), Color(white: 0.63)], startPoint: .top, endPoint: .bottom), in: Circle()) - .overlay(Circle().strokeBorder(Color(white: 0.45), lineWidth: 1.5)) - .overlay(Circle().strokeBorder(.white.opacity(0.65), lineWidth: 1).padding(3)) - .shadow(color: .black.opacity(0.7), radius: 1, y: 1) - }.buttonStyle(.plain).disabled(!enabled).opacity(enabled ? 1 : 0.72) - .help(label).accessibilityLabel(label) - } -} -struct LibraryView: View { - @ObservedObject var model: AppModel - @State private var selected: Int64? - @State private var search = "" - @State private var name = "" - @State private var importing = false - @State private var source = "Library" - @State private var singersExpanded = true - @State private var expandedSingers = Set() - @State private var songPickerSinger: PersonPlace? - @Environment(\.openWindow) private var openWindow - private var visibleSongs: [Song] { model.songs.filter { search.isEmpty || ($0.title+" "+$0.artist+" "+$0.album).localizedCaseInsensitiveContains(search) } } - private var selectedSong: Song? { model.songs.first { $0.id == selected } } - var body: some View { - VStack(spacing: 0) { - TransportView(player: model.player, search: $search, hasSelection: selectedSong != nil, - play: playSelected, next: playNext, display: { openWindow(id: "lyrics") }) - .padding(.horizontal, 18).padding(.top, 18).padding(.bottom, 22) - HSplitView { - sidebar.frame(minWidth: 190, idealWidth: 220, maxWidth: 240) - VStack(spacing: 12) { - if source == "Library" { songTable } - else if source == "Queue" { queuePane } - else if source == "History" { historyPane } - else if source == "Playlists" { playlistPane } - else if source == "Singer Songs" { singerSongPane } - else { directory } - detailPanel.frame(height: 135) - }.padding(.leading, 12).frame(minWidth: 780) - }.padding(.horizontal, 18) - footer.padding(.horizontal, 18).padding(.vertical, 12) - } - .background(Classic.frame) - .sheet(item: $model.creating) { kind in - AddEntitySheet(model: model, kind: kind) { id in - if kind == .singer { model.selectedSinger = id;expandedSingers.insert(id);singersExpanded = true;source = "Singer Songs" } else { model.chooseVenue(id) } - } - } - .sheet(item:$songPickerSinger) { singer in SingerSongsSheet(model:model,singer:singer) } - .fileImporter(isPresented: $importing, allowedContentTypes: [.audio, .zip, UTType(filenameExtension: "cdg") ?? .data], allowsMultipleSelection: true) { result in - switch result { - case .success(let urls): model.importFiles(urls) - case .failure(let error): model.error = error.localizedDescription - } - } - .alert("KJamsClone", isPresented: Binding(get: { model.error != nil }, set: { if !$0 { model.error = nil } })) { - Button("OK") { model.error = nil } - } message: { Text(model.error ?? "") } - } - private func sourceCount(_ source: String) -> Int { - switch source { - case "Library": return model.songs.count - case "Singers": return model.venueSingers.count - case "Venues": return model.venues.count - case "Queue": return model.queue.count - case "History": return model.history.count - default: return model.playlists.count - } - } - private var sidebar: some View { - VStack(alignment:.leading,spacing:0) { - Text("Source").font(.system(size:15,weight:.semibold)).padding(.horizontal,10).frame(height:31) - .frame(maxWidth:.infinity,alignment:.leading).background(Classic.header) - ScrollView { - VStack(spacing:0) { - sourceRow("Library",icon:"music.note.house.fill",color:.yellow) - HStack(spacing:5) { - Button { singersExpanded.toggle() } label: { Image(systemName:singersExpanded ? "chevron.down" : "chevron.right").font(.system(size:10)).frame(width:12) }.buttonStyle(.plain).accessibilityLabel("Expand singers") - Button { source = "Singers" } label: { HStack { Image(systemName:"person.2.fill").foregroundStyle(.green);Text("Singers");Spacer();Text("\(model.venueSingers.count)").font(.caption).foregroundStyle(.secondary) } }.buttonStyle(.plain) - Button { model.beginSinger() } label: { Image(systemName:"plus.circle.fill").foregroundStyle(.green) }.buttonStyle(.plain).help("New singer and songs") - }.padding(.horizontal,10).frame(height:34).background(source == "Singers" ? Color.blue.opacity(0.65) : .clear) - if singersExpanded { - Text(model.currentVenueName).font(.system(size:10)).foregroundStyle(.secondary).lineLimit(1).padding(.leading,30).frame(maxWidth:.infinity,alignment:.leading).padding(.vertical,4) - ForEach(model.venueSingers) { singer in sidebarSinger(singer) } - if model.venueSingers.isEmpty { Text("Add a singer with +").font(.caption).foregroundStyle(.secondary).padding(8) } - } - sourceRow("Venues",icon:"building.2.fill",color:.cyan) - sourceRow("Queue",icon:"list.number",color:.orange) - sourceRow("History",icon:"clock.arrow.circlepath",color:.purple) - sourceRow("Playlists",icon:"music.note.list",color:.mint) - } - } - SidebarVideoMonitor(player:model.player).padding(10) - }.foregroundStyle(.white).background(Classic.navy).overlay(Rectangle().stroke(Classic.line,lineWidth:1)) - } - private func sourceRow(_ title: String, icon: String, color: Color) -> some View { - Button { source = title } label: { - HStack(spacing:10) { - Image(systemName:icon).foregroundStyle(color).frame(width:22) - Text(title).font(.system(size:16,weight:.medium));Spacer() - Text("\(sourceCount(title))").font(.system(size:11)).foregroundStyle(.white.opacity(0.6)) - }.padding(.horizontal,12).frame(height:34).contentShape(Rectangle()) - .background(source == title ? Color(red:0,green:0.36,blue:1) : .clear) - }.buttonStyle(.plain) - } - private func sidebarSinger(_ singer: PersonPlace) -> some View { - VStack(alignment:.leading,spacing:0) { - HStack(spacing:5) { - Button { - if expandedSingers.contains(singer.id) { expandedSingers.remove(singer.id) } else { expandedSingers.insert(singer.id) } - } label: { Image(systemName:expandedSingers.contains(singer.id) ? "chevron.down" : "chevron.right").font(.system(size:9)).frame(width:12) }.buttonStyle(.plain).accessibilityLabel("Expand \(singer.name)’s songs") - Button { model.selectedSinger = singer.id;source = "Singer Songs" } label: { - HStack(spacing:5) { Text(singer.name).lineLimit(1);Spacer();Text("\(model.singerSongIDs[singer.id]?.count ?? 0)").font(.system(size:10)).foregroundStyle(.secondary) } - }.buttonStyle(.plain) - Button { model.selectedSinger = singer.id;songPickerSinger = singer;expandedSingers.insert(singer.id) } label: { Image(systemName:"plus").font(.system(size:10,weight:.bold)) }.buttonStyle(.plain).help("Add songs to \(singer.name)") - }.font(.system(size:13,weight:.medium)).padding(.leading,25).padding(.trailing,12).frame(height:29) - .background(model.selectedSinger == singer.id && source == "Singer Songs" ? Color.blue.opacity(0.25) : .clear) - if expandedSingers.contains(singer.id) { - ForEach(model.songs(for:singer.id)) { song in - Button { model.selectedSinger = singer.id;selected = song.id;source = "Singer Songs" } label: { - Label(song.title,systemImage:"music.note").font(.system(size:11)).lineLimit(1).frame(maxWidth:.infinity,alignment:.leading).padding(.leading,44).padding(.trailing,8).frame(height:25) - }.buttonStyle(.plain) - .contextMenu { - Button("Play for \(singer.name)") { model.selectedSinger = singer.id;model.perform { try model.play(song,singer:singer.id) } } - Button("Queue for \(singer.name)") { model.selectedSinger = singer.id;model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Button("Remove from Singer",role:.destructive) { model.assign(song.id,to:singer.id,included:false) } - } - } - if model.songs(for:singer.id).isEmpty { Text("No songs · use +").font(.system(size:10)).foregroundStyle(.secondary).padding(.leading,44).padding(.vertical,5) } - } - } - } - private var singerSongPane: some View { - VStack(alignment:.leading,spacing:12) { - if let singer = model.singers.first(where:{ $0.id == model.selectedSinger }) { - HStack { Text("\(singer.name)’s Songs").font(.headline);Spacer();Button("Add Songs…") { songPickerSinger = singer } } - Text("At \(model.currentVenueName). Song assignments follow this singer across venues.").font(.caption).foregroundStyle(.secondary) - ScrollView { - VStack(spacing:10) { - ForEach(model.songs(for:singer.id)) { song in - HStack { - Text(song.title).lineLimit(1);Spacer() - Button("Play") { model.selectedSinger = singer.id;model.perform { try model.play(song,singer:singer.id) } } - Button("Queue") { model.selectedSinger = singer.id;model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Button("Remove") { model.assign(song.id,to:singer.id,included:false) } - }.padding(8).background(.white.opacity(0.035)).contentShape(Rectangle()).onTapGesture { selected = song.id } - } - if model.songs(for:singer.id).isEmpty { Text("Add library songs with Add Songs… or the + beside this singer in the sidebar.").foregroundStyle(.secondary).padding(.top,25) } - } - } - } else { Text("Choose a singer from the sidebar.").foregroundStyle(.secondary);Spacer() } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - private var songTable: some View { - GeometryReader { geometry in - ScrollView(.horizontal) { - VStack(spacing: 0) { - tableHeader(width: max(geometry.size.width, 790)) - ScrollView(.vertical) { - LazyVStack(spacing: 0) { - ForEach(visibleSongs) { song in songRow(song, width: max(geometry.size.width, 790)) } - }.frame(maxWidth: .infinity, alignment: .topLeading) - } - }.frame(width: max(geometry.size.width, 790), height: geometry.size.height) - } - }.background(Classic.navy).overlay(Rectangle().stroke(Classic.line, lineWidth: 1)) - } - private func widths(_ total: CGFloat) -> [CGFloat] { - [42, max(200, total - 598), 100, 100, 76, 86, 72, 122] - } - private func tableHeader(width: CGFloat) -> some View { - let sizes = widths(width) - return HStack(spacing: 0) { - ForEach(Array(["PLI", "Song Name", "Artist", "Album", "Label", "Key Adjust", "Tempo", "Rating"].enumerated()), id: \.offset) { index, title in - Text(title).font(.system(size: 13, weight: .medium)).lineLimit(1) - .padding(.leading, 7).frame(width: sizes[index], height: 30, alignment: .leading) - .overlay(alignment: .trailing) { Rectangle().fill(Classic.line).frame(width: 1).padding(.vertical, 4) } - } - }.foregroundStyle(.white).background(Classic.header) - .overlay(alignment: .bottom) { Rectangle().fill(Color(white: 0.65)).frame(height: 1) } - } - private func cellText(_ song: Song, column: Int) -> String { - switch column { - case 2: return song.artist.isEmpty ? "—" : song.artist - case 3: return song.album.isEmpty ? "—" : song.album - case 4: return song.label.isEmpty ? (song.cdg == nil ? "Audio" : URL(fileURLWithPath:song.audio).pathExtension.uppercased()+"+G") : song.label - case 5: return String(format:"%+.0f",model.preference(song.id).pitch) - default: return String(format:"%.0f%%",model.preference(song.id).tempo*100) - } - } - private func songRow(_ song: Song, width: CGFloat) -> some View { - let sizes = widths(width) - return HStack(spacing: 0) { - Image(systemName: song.cdg == nil ? "music.note" : "music.note.tv") - .foregroundStyle(.white.opacity(0.75)).frame(width: sizes[0]) - Text(song.title).lineLimit(1).padding(.leading, 7).frame(width: sizes[1], alignment: .leading) - ForEach(2..<7) { index in - Text(cellText(song, column: index)) - .foregroundStyle(.white.opacity(0.5)).padding(.leading, 7).frame(width: sizes[index], alignment: .leading) - } - Menu { - ForEach(0..<6) { value in - Button(value == 0 ? "Unrated" : String(repeating: "★", count: value)) { - model.perform { try model.library?.rate(song.id, value); try model.refresh() } - } - } - } label: { - Text(song.rating == 0 ? "☆☆☆☆☆" : String(repeating: "★", count: song.rating) + String(repeating: "☆", count: 5 - song.rating)) - .font(.system(size: 13)).foregroundStyle(song.rating == 0 ? Color.gray : Color.yellow) - }.menuStyle(.borderlessButton).frame(width: sizes[7] - 14).padding(.horizontal, 7).help("Set song rating") - }.font(.system(size: 13)).foregroundStyle(.white).frame(height: 30) - .background(selected == song.id ? Color(red: 0, green: 0.28, blue: 0.72) : .clear) - .contentShape(Rectangle()).onTapGesture(count: 2) { selected = song.id; playSelected() } - .onTapGesture { selected = song.id } - .contextMenu { - Button("Play") { selected = song.id; playSelected() } - Menu("Add to Singer") { - ForEach(model.venueSingers) { singer in Button(singer.name) { model.assign(song.id,to:singer.id);model.selectedSinger = singer.id;expandedSingers.insert(singer.id) } } - Divider();Button("New Singer + This Song…") { model.beginSinger(song:song.id) } - } - Button("Add to Current Venue Queue") { model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Menu("Add to Playlist") { ForEach(model.playlists) { playlist in Button(playlist.name) { model.addToPlaylist(playlist.id,song:song.id) } } } - } - } - @State private var managingRoster = false - @State private var rosterNewName = "" - @State private var editingEntity: PersonPlace? - @State private var renameText = "" - @State private var pendingDelete: PersonPlace? - private var directory: some View { - VStack(alignment:.leading,spacing:0) { - HStack { - Text(source == "Singers" ? "Singers · \(model.currentVenueName)" : "Venues").font(.headline) - Spacer() - if source == "Singers" { Button("Manage Venue Singers…") { managingRoster = true }.disabled(model.currentVenue == nil) } - Button(source == "Singers" ? "New Singer…" : "New Venue…") { if source == "Singers" { model.beginSinger() } else { model.creating = .venue } } - }.padding(12).background(Classic.header) - ScrollView { - VStack(alignment:.leading,spacing:0) { - if source == "Singers" && model.venueSingers.isEmpty { - Text("No singers at this venue. Add a singer or use Manage Venue Singers to include existing singers.").foregroundStyle(.secondary).padding() - } - ForEach(source == "Singers" ? model.venueSingers : model.venues) { entity in - HStack { - Button { - if source == "Singers" { model.selectedSinger = entity.id } else { model.chooseVenue(entity.id) } - } label: { - HStack { - Image(systemName:source == "Singers" ? "person.fill" : "building.2.fill") - Text(entity.name); Spacer() - if entity.id == (source == "Singers" ? model.selectedSinger : model.currentVenue) { - Text(source == "Singers" ? "Selected" : "Current venue").font(.caption).foregroundStyle(.cyan) - Image(systemName:"checkmark.circle.fill").foregroundStyle(.cyan) - } - }.contentShape(Rectangle()) - }.buttonStyle(.plain) - Button("Rename") { renameText = entity.name; editingEntity = entity } - Button("Delete",role:.destructive) { pendingDelete = entity } - }.padding(12) - } - } - } - HStack { - TextField(source == "Singers" ? "Singer name" : "Venue name",text:$name).textFieldStyle(.roundedBorder).onSubmit(addEntity) - Button(source == "Singers" ? "Add Singer" : "Add Venue",action:addEntity).disabled(name.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - }.padding(12) - }.foregroundStyle(.white).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - .sheet(isPresented:$managingRoster) { rosterSheet } - .sheet(item:$editingEntity) { entity in - VStack(alignment:.leading,spacing:16) { - Text("Rename \(source == "Singers" ? "Singer" : "Venue")").font(.headline) - TextField("Name",text:$renameText).textFieldStyle(.roundedBorder) - HStack { Button("Cancel") { editingEntity = nil }; Spacer(); Button("Save") { model.rename(source == "Singers" ? "singers" : "venues",id:entity.id,name:renameText); editingEntity = nil }.disabled(renameText.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) } - }.padding(24).frame(width:360) - } - .confirmationDialog("Delete \(pendingDelete?.name ?? "entry")? Historical plays are kept. Venue memberships and queued entries for it will be removed.",isPresented:Binding(get:{ pendingDelete != nil },set:{ if !$0 { pendingDelete = nil } })) { - Button("Delete",role:.destructive) { if let entity = pendingDelete { model.delete(source == "Singers" ? "singers" : "venues",id:entity.id) }; pendingDelete = nil } - } - } - private var rosterSheet: some View { - VStack(alignment:.leading,spacing:16) { - Text("Singers at \(model.currentVenueName)").font(.title2.bold()) - Text("A singer can belong to any number of venues. Unchecking removes them from this venue only.").foregroundStyle(.secondary) - ScrollView { - VStack(alignment:.leading,spacing:12) { - ForEach(model.singers) { singer in - Toggle(singer.name,isOn:Binding(get:{ model.venueSingers.contains { $0.id == singer.id } },set:{ model.membership(singer:singer.id,included:$0) })) - } - }.frame(maxWidth:.infinity,alignment:.leading) - }.frame(minHeight:120,maxHeight:280) - HStack { - TextField("New singer name",text:$rosterNewName).textFieldStyle(.roundedBorder) - Button("Add") { model.perform { _ = try model.createEntity(.singer,name:rosterNewName); rosterNewName = "" } }.disabled(rosterNewName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - Spacer(); Button("Done") { managingRoster = false }.keyboardShortcut(.defaultAction) - } - }.padding(24).frame(width:460) - } - private var detailPanel: some View { - VStack(alignment:.leading,spacing:9) { - HStack(spacing:10) { - Picker("Current venue",selection:Binding(get:{ model.currentVenue },set:{ model.chooseVenue($0) })) { - Text("Select venue…").tag(nil as Int64?) - ForEach(model.venues) { Text($0.name).tag(Optional($0.id)) } - } - Button { model.creating = .venue } label: { Image(systemName:"plus.circle.fill") }.buttonStyle(.plain).help("Add venue") - Picker("Singer",selection:$model.selectedSinger) { - Text("None").tag(nil as Int64?) - ForEach(model.venueSingers) { Text($0.name).tag(Optional($0.id)) } - } - Button { model.beginSinger() } label: { Image(systemName:"plus.circle.fill") }.buttonStyle(.plain).help("Add singer") - Menu("Add to Singer") { - ForEach(model.venueSingers) { singer in Button(singer.name) { if let selected { model.assign(selected,to:singer.id);model.selectedSinger = singer.id;expandedSingers.insert(singer.id) } } } - Divider();Button("New Singer + Song…") { model.beginSinger(song:selected) } - }.disabled(selected == nil) - Button("Queue") { if let selected { model.enqueue(selected) } }.disabled(selected == nil || model.currentVenue == nil) - } - PlaybackSettings(player:model.player,model:model,selectedSong:selected) - SeekBar(player:model.player) - }.padding(12).frame(maxWidth:.infinity,maxHeight:.infinity) - .background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - @State private var playlistName = "" - @State private var selectedPlaylist: Int64? - private var queuePane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { Text("Queue · \(model.currentVenueName)").font(.headline); Spacer(); Toggle("Auto play next",isOn:$model.autoAdvance).toggleStyle(.checkbox); Button("Play Next") { model.playQueueNext() }.disabled(model.queue.isEmpty) } - ScrollView { - VStack(spacing:0) { - ForEach(Array(model.queue.enumerated()),id:\.element.id) { index,row in - HStack { - Text("\(index+1)").foregroundStyle(.secondary).frame(width:24) - Text(row.singer).frame(width:140,alignment:.leading) - Text(row.title).lineLimit(1); Spacer() - Button { model.moveQueue(row.id,by:-1) } label: { Image(systemName:"arrow.up") }.disabled(index == 0) - Button { model.moveQueue(row.id,by:1) } label: { Image(systemName:"arrow.down") }.disabled(index == model.queue.count-1) - Button("Remove") { model.removeQueue(row.id) } - }.padding(.vertical,8) - } - if model.queue.isEmpty { Text("Choose a venue and singer, select a library song, then click Queue Song.").foregroundStyle(.secondary).padding(.top,30) } - } - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - @State private var historyAllVenues = false - private var displayedHistory: [Performance] { - if historyAllVenues { return (try? model.library?.history(venue:nil,singer:model.selectedSinger)) ?? [] } - return model.history.filter { model.selectedSinger == nil || $0.singer == model.singers.first(where: { $0.id == model.selectedSinger })?.name } - } - private var historyPane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { Text("History · \(historyAllVenues || model.currentVenue == nil ? "All venues" : model.currentVenueName)").font(.headline); Spacer(); Toggle("All venues",isOn:$historyAllVenues).toggleStyle(.checkbox) } - ScrollView { - LazyVStack(alignment:.leading,spacing:12) { - ForEach(displayedHistory) { row in - HStack { Text(row.date).font(.system(.caption,design:.monospaced)); Text(row.singer).frame(width:130,alignment:.leading); Text(row.song); Spacer(); Text(row.venue).foregroundStyle(.secondary) } - } - } - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - private var playlistPane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { - Picker("Playlist",selection:$selectedPlaylist) { Text("Choose…").tag(nil as Int64?); ForEach(model.playlists) { Text($0.name).tag(Optional($0.id)) } } - TextField("New playlist name",text:$playlistName).textFieldStyle(.roundedBorder) - Button("Create") { model.createPlaylist(playlistName); selectedPlaylist = model.playlists.first { $0.name == playlistName.trimmingCharacters(in:.whitespacesAndNewlines) }?.id; playlistName = "" }.disabled(playlistName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - if let selectedPlaylist { - Button("Rename") { model.rename("playlists",id:selectedPlaylist,name:playlistName); playlistName = "" }.disabled(playlistName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - Button("Delete",role:.destructive) { model.delete("playlists",id:selectedPlaylist); self.selectedPlaylist = nil } } - } - ScrollView { - if let selectedPlaylist { - let ids = (try? model.library?.playlistSongIDs(selectedPlaylist)) ?? [] - VStack(alignment:.leading,spacing:10) { - ForEach(ids,id:\.self) { id in - if let song = model.songs.first(where: { $0.id == id }) { - HStack { - Text(song.title); Spacer() - Button("Play") { model.perform { try model.play(song) } } - Button("Queue") { model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Button("Remove") { model.perform { try model.library?.removeFromPlaylist(selectedPlaylist,song:id); try model.refresh() } } - } - } - } - } - } - Text("Add songs using the library row’s context menu.").foregroundStyle(.secondary).padding(.top,20) - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - private var footer: some View { - HStack { - Button { importing = true } label: { Image(systemName: "plus").font(.system(size: 20, weight: .bold)).frame(width: 32, height: 24) } - .help("Import audio, MP3+G or ZIP").accessibilityLabel("Import songs") - RepeatButton(player: model.player).padding(.leading, 12) - Spacer() - Text("\(visibleSongs.count) \(visibleSongs.count == 1 ? "Song" : "Songs")").font(.system(size: 14, weight: .medium)) - Spacer() - Button { openWindow(id: "lyrics") } label: { Image(systemName: "rectangle.on.rectangle").frame(width: 32, height: 24) } - .help("Open video window").accessibilityLabel("Open video window") - }.buttonStyle(SilverSquareStyle()) - } - private func playSelected() { - guard let song = selectedSong else { return } - model.perform { try model.play(song) } - } - private func playNext() { - guard !visibleSongs.isEmpty else { return } - let index = visibleSongs.firstIndex { $0.id == selected } ?? -1 - selected = visibleSongs[(index + 1) % visibleSongs.count].id; playSelected() - } - private func addEntity() { - model.perform { - let kind: EntityKind = source == "Singers" ? .singer : .venue - let id = try model.createEntity(kind, name: name) - if kind == .singer { model.selectedSinger = id } else { model.chooseVenue(id) } - name = "" - } - } -} -private struct SingerSongsSheet: View { - @ObservedObject var model: AppModel - let singer: PersonPlace - @Environment(\.dismiss) private var dismiss - @State private var search = "" - @State private var importing = false - var body: some View { - VStack(alignment:.leading,spacing:14) { - Text("Songs for \(singer.name)").font(.title2.bold()) - Text("Tick songs to add them to this singer. Unticking removes only the assignment.").font(.callout).foregroundStyle(.secondary) - TextField("Search library",text:$search).textFieldStyle(.roundedBorder) - ScrollView { - LazyVStack(alignment:.leading,spacing:12) { - ForEach(model.songs.filter { search.isEmpty || $0.title.localizedCaseInsensitiveContains(search) }) { song in - Toggle(song.title,isOn:Binding(get:{ model.singerSongIDs[singer.id]?.contains(song.id) == true },set:{ model.assign(song.id,to:singer.id,included:$0) })).toggleStyle(.checkbox) - } - if model.songs.isEmpty { Text("Your library is empty. Import audio or MP3+G below.").foregroundStyle(.secondary) } - }.frame(maxWidth:.infinity,alignment:.leading) - }.frame(height:270) - HStack { Button("Import Songs…") { importing = true };Spacer();Button("Done") { dismiss() }.keyboardShortcut(.defaultAction) } - }.padding(24).frame(width:520) - .fileImporter(isPresented:$importing,allowedContentTypes:[.audio,.zip,UTType(filenameExtension:"cdg") ?? .data],allowsMultipleSelection:true) { result in - switch result { case .success(let urls):model.importFiles(urls);case .failure(let error):model.error = error.localizedDescription } - } - } -} -private struct AddEntitySheet: View { - @ObservedObject var model: AppModel - let kind: EntityKind - let saved: (Int64) -> Void - @Environment(\.dismiss) private var dismiss - @State private var name = "" - @State private var error: String? - @State private var venue: Int64? - @State private var songs = Set() - @State private var search = "" - @FocusState private var focused: Bool - var body: some View { - VStack(alignment:.leading,spacing:16) { - Text(kind == .singer ? "New Singer + Songs" : "New Venue").font(.title2.bold()) - TextField("\(kind.title) name",text:$name).textFieldStyle(.roundedBorder).focused($focused).onSubmit(save) - if kind == .singer { - Picker("Venue",selection:$venue) { Text("Choose a venue…").tag(nil as Int64?);ForEach(model.venues) { Text($0.name).tag(Optional($0.id)) } } - Text(venue == nil ? "Create a venue first, then add a singer to it." : "This singer will join the selected venue and become active.").font(.caption).foregroundStyle(.secondary) - Text("Add songs now (optional)").font(.headline) - TextField("Search library",text:$search).textFieldStyle(.roundedBorder) - ScrollView { - LazyVStack(alignment:.leading,spacing:10) { - ForEach(model.songs.filter { search.isEmpty || $0.title.localizedCaseInsensitiveContains(search) }) { song in - Toggle(song.title,isOn:Binding(get:{ songs.contains(song.id) },set:{ if $0 { songs.insert(song.id) } else { songs.remove(song.id) } })).toggleStyle(.checkbox) - } - if model.songs.isEmpty { Text("No library songs yet. You can add songs from the singer’s + button after importing.").font(.callout).foregroundStyle(.secondary) } - }.frame(maxWidth:.infinity,alignment:.leading) - }.frame(height:190) - } - if let error { Text(error).foregroundStyle(.red).font(.callout) } - HStack { Spacer();Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction) - Button(kind == .singer ? "Add Singer & Songs" : "Add Venue",action:save).keyboardShortcut(.defaultAction) - .disabled(name.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty || (kind == .singer && venue == nil)) - } - }.padding(24).frame(width:kind == .singer ? 500 : 360) - .onAppear { focused = true;venue = model.currentVenue ?? model.venues.first?.id;songs = model.newSingerSongs } - } - private func save() { - do { - let id: Int64 - if kind == .singer { guard let venue else { throw LibraryError.message("Choose a venue") };id = try model.createSinger(name:name,venue:venue,songs:songs) } - else { id = try model.createEntity(kind,name:name) } - saved(id);dismiss() - } catch { self.error = error.localizedDescription } - } -} -private struct TransportView: View { - @ObservedObject var player: Player - @Binding var search: String - let hasSelection: Bool - let play: () -> Void - let next: () -> Void - let display: () -> Void - var body: some View { - HStack(alignment: .top, spacing: 28) { - VStack(spacing: 15) { - HStack(spacing: 7) { - SilverButton(symbol: "backward.fill", label: "Back 10 seconds", size: 35, enabled: player.duration > 0) { player.seek(player.time - 10) } - SilverButton(symbol: player.playing ? "pause.fill" : "play.fill", label: player.playing ? "Pause" : "Play", size: 49, enabled: hasSelection || player.duration > 0) { - if player.duration > 0 { player.toggle() } else { play() } - } - SilverButton(symbol: "stop", label: "Stop", size: 46, enabled: player.duration > 0) { player.stop() } - SilverButton(symbol: "forward.fill", label: "Forward 10 seconds", size: 35, enabled: player.duration > 0) { player.seek(player.time + 10) } - SilverButton(symbol: "forward.end.fill", label: "Play next song", size: 26, enabled: hasSelection, action: next) - } - HStack(spacing: 9) { - Image(systemName: "speaker.fill").font(.system(size: 11)) - Slider(value: $player.volume, in: 0...1).controlSize(.small).tint(.gray).accessibilityLabel("Volume") - Image(systemName: "speaker.wave.3.fill").font(.system(size: 12)) - }.frame(width: 180) - }.frame(width: 220) - NowPlayingWaveform(player: player).padding(.top, 4) - HStack(spacing: 12) { - TextField("Search", text: $search).textFieldStyle(.plain).font(.system(size: 16)) - .padding(.horizontal, 8).frame(width: 145, height: 28).background(Color(white: 0.07), in: RoundedRectangle(cornerRadius: 5)) - .overlay(RoundedRectangle(cornerRadius: 5).stroke(.white.opacity(0.1))) - SilverButton(symbol: "eye", label: "Open video window", size: 48, action: display) - }.padding(.top, 15) - }.foregroundStyle(.white).frame(height: 114) - } -} -private struct NowPlayingWaveform: View { - @ObservedObject var player: Player - @State private var mixer = false - private var progress: Double { player.duration > 0 ? min(1,max(0,player.time/player.duration)) : 0 } - private func clock(_ value: Double) -> String { let n = max(0,Int(value));return String(format:"%d:%02d",n/60,n%60) } - private func bandColor(_ index: Int) -> Color { - guard player.waveformBands.indices.contains(index) else { return .cyan } - let band = player.waveformBands[index] - let largest = max(0.000001,max(band.low,max(band.mid,band.high))) - let low = Double(band.low/largest),mid = Double(band.mid/largest),high = Double(band.high/largest) - return Color(red:min(1,low+mid*0.18+high*0.65),green:min(1,low*0.18+mid+high*0.2),blue:min(1,low*0.22+mid*0.28+high)) - } - var body: some View { - VStack(alignment:.leading,spacing:5) { - Text(player.duration > 0 ? player.title : "Ready to play").font(.system(size:13,weight:.semibold)).foregroundStyle(Color(white:0.94)) - .lineLimit(1).truncationMode(.middle).frame(maxWidth:.infinity,alignment:.leading).help(player.title) - GeometryReader { geometry in - Canvas { context,size in - let top: CGFloat = 10,plotHeight = size.height-top,mid = top+plotHeight/2 - var centre = Path();centre.move(to:CGPoint(x:0,y:mid));centre.addLine(to:CGPoint(x:size.width,y:mid)) - context.stroke(centre,with:.color(.white.opacity(0.13)),lineWidth:0.5) - if player.duration > 0 { - let step = [1.0,2,5,10,15,30,60,120,300,600,1800,3600].first { $0 >= player.duration/5 } ?? 3600 - for t in stride(from:0.0,through:player.duration,by:step/4) { - let x = size.width*t/player.duration - let major = abs(t/step-(t/step).rounded()) < 0.001 - var tick = Path();tick.move(to:CGPoint(x:x,y:top));tick.addLine(to:CGPoint(x:x,y:size.height)) - context.stroke(tick,with:.color(major ? .yellow.opacity(0.65) : .white.opacity(0.16)),lineWidth:major ? 0.8 : 0.5) - if major && x < size.width-25 { - context.draw(Text(clock(t)).font(.system(size:8,design:.monospaced)).foregroundColor(.gray),at:CGPoint(x:x+3,y:3),anchor:.leading) - } - } - } - if !player.waveform.isEmpty { - let count = max(1,Int(size.width/2)),step = size.width/CGFloat(count) - for bar in 0.. 0,geometry.size.width > 0 else { return } - player.seek(min(1,max(0,value.location.x/geometry.size.width))*player.duration) - }).help("Frequency colours: bass red, mids green, treble blue. Click to seek.") - .accessibilityLabel("Audio waveform").accessibilityValue("\(clock(player.time)) of \(clock(player.duration))") - .accessibilityAdjustableAction { direction in if direction == .increment { player.seek(player.time+5) } else if direction == .decrement { player.seek(player.time-5) } } - }.frame(height:44) - HStack(spacing:5) { - Circle().fill(player.playing ? Color.green : Color.orange).frame(width:4,height:4) - Text(player.duration == 0 ? "NO TRACK LOADED" : player.playing ? "PLAYING" : "PAUSED").tracking(1) - if player.waveformUnavailable { Text("· Waveform unavailable").foregroundStyle(.secondary) } - Spacer(minLength:0) - Button("EQ / TONE") { mixer.toggle() }.buttonStyle(.plain).foregroundStyle(.white.opacity(0.85)) - .padding(.horizontal,6).padding(.vertical,2).background(.white.opacity(0.08),in:RoundedRectangle(cornerRadius:3)) - .popover(isPresented:$mixer) { ToneMixerView(player:player) } - Text("\(clock(player.time)) / \(clock(player.duration))").monospacedDigit().padding(.leading,5) - }.font(.system(size:9,weight:.medium)).foregroundStyle(Color(white:0.6)) - }.padding(.horizontal,12).padding(.vertical,9).frame(maxWidth:.infinity).frame(height:104) - .background(Color(red:0.025,green:0.028,blue:0.035)).overlay(Rectangle().strokeBorder(Color(white:0.24),lineWidth:1)) - } -} -private struct ToneKnob: View { - let title: String - @Binding var value: Double - let range: ClosedRange - var filter = false - @State private var initial: Double? - private var fraction: Double { min(1,max(0,(value-range.lowerBound)/(range.upperBound-range.lowerBound))) } - private var display: String { - if filter { return abs(value) < 0.01 ? "OFF" : value < 0 ? "LOW PASS" : "HIGH PASS" } - return String(format:"%+.1f dB",value) - } - var body: some View { - VStack(spacing:4) { - ZStack { - Circle().trim(from:0,to:0.75).stroke(Color(white:0.21),style:StrokeStyle(lineWidth:4,lineCap:.round)).rotationEffect(.degrees(135)) - Circle().trim(from:0,to:0.75*fraction).stroke(Color(white:0.48),style:StrokeStyle(lineWidth:3,lineCap:.round)).rotationEffect(.degrees(135)) - Circle().fill(LinearGradient(colors:[Color(white:0.19),Color(white:0.09)],startPoint:.top,endPoint:.bottom)).padding(6).overlay(Circle().stroke(.black.opacity(0.65),lineWidth:1.5).padding(6)) - Capsule().fill(.white).frame(width:2,height:12).offset(y:-13).rotationEffect(.degrees(-135+270*fraction)) - }.frame(width:50,height:50).contentShape(Circle()) - .gesture(DragGesture(minimumDistance:0).onChanged { gesture in - if initial == nil { initial = value } - value = min(range.upperBound,max(range.lowerBound,(initial ?? value)-Double(gesture.translation.height)/130*(range.upperBound-range.lowerBound))) - }.onEnded { _ in initial = nil }) - .simultaneousGesture(TapGesture(count:2).onEnded { value = 0 }) - .accessibilityElement().accessibilityLabel(title).accessibilityValue(display) - .accessibilityAdjustableAction { direction in - let change = (range.upperBound-range.lowerBound)/24 - value = min(range.upperBound,max(range.lowerBound,value+(direction == .increment ? change : -change))) - }.help("Drag up/down to adjust. Double-click to reset.") - Text(title).font(.system(size:10,weight:.bold)).foregroundStyle(Color(white:0.6)) - Text(display).font(.system(size:8,design:.monospaced)).foregroundStyle(Color(white:0.45)) - } - } -} -private struct StereoMeter: View { - @ObservedObject var player: Player - private func normal(_ level: Float) -> Double { max(0,min(1,(20*log10(Double(max(level,0.000001)))+60)/60)) } - var body: some View { - HStack(spacing:3) { - ForEach(0..<2) { channel in - VStack(spacing:2) { - ForEach((0..<24).reversed(),id:\.self) { segment in - let on = Double(segment)/24 < normal(channel == 0 ? player.leftLevel : player.rightLevel) - Rectangle().fill(on ? (segment > 21 ? Color.red : segment > 17 ? Color.yellow : Color.green) : Color.black.opacity(0.5)) - } - } - } - }.frame(width:23,height:125).accessibilityLabel("Stereo output levels") - } -} -private struct MixerFader: View { - @Binding var value: Double - var body: some View { - GeometryReader { geometry in - let travel = geometry.size.height-22 - ZStack(alignment:.top) { - VStack { ForEach(0..<7) { _ in Rectangle().fill(.white.opacity(0.09)).frame(height:1);Spacer(minLength:0) } }.padding(.vertical,11) - Capsule().fill(.black.opacity(0.8)).frame(width:5).padding(.vertical,8) - RoundedRectangle(cornerRadius:5).fill(LinearGradient(colors:[Color(white:0.45),Color(white:0.23)],startPoint:.top,endPoint:.bottom)) - .frame(width:45,height:20).overlay(Rectangle().fill(.white.opacity(0.15)).frame(width:18,height:1)) - .offset(y:(1-value)*travel) - }.frame(maxWidth:.infinity).contentShape(Rectangle()) - .gesture(DragGesture(minimumDistance:0).onChanged { value = min(1,max(0,1-Double(($0.location.y-11)/travel))) }) - }.frame(width:56,height:135).accessibilityLabel("Master volume").accessibilityValue("\(Int(value*100)) percent") - .accessibilityAdjustableAction { direction in value = min(1,max(0,value+(direction == .increment ? 0.05 : -0.05))) } - } -} -private struct ToneMixerView: View { - @ObservedObject var player: Player - var body: some View { - VStack(spacing:14) { - HStack { Text("TONE / MIXER").font(.system(size:12,weight:.bold));Spacer();Toggle("EQ",isOn:$player.toneEnabled).toggleStyle(.switch).controlSize(.mini) } - HStack(alignment:.top,spacing:28) { - VStack(spacing:8) { - ToneKnob(title:"HIGH",value:$player.highGain,range:-12...12) - ToneKnob(title:"MID",value:$player.midGain,range:-12...12) - ToneKnob(title:"LOW",value:$player.lowGain,range:-12...12) - } - VStack(spacing:15) { - ToneKnob(title:"FILTER",value:$player.filter,range:-1...1,filter:true) - HStack(spacing:20) { StereoMeter(player:player);MixerFader(value:$player.volume) } - Text(player.volume <= 0 ? "−∞ dB" : String(format:"%+.1f dB",20*log10(player.volume))).font(.system(size:10,design:.monospaced)).foregroundStyle(.secondary) - } - }.padding(.horizontal,15) - HStack { Text("Drag knobs · Double-click to reset").font(.system(size:9)).foregroundStyle(.secondary);Spacer();Button("Reset EQ") { player.resetTone() }.controlSize(.small) } - }.padding(18).frame(width:270).background(Color(white:0.105)).preferredColorScheme(.dark) - } -} -private struct PlaybackSettings: View { - @ObservedObject var player: Player - @ObservedObject var model: AppModel - let selectedSong: Int64? - @State private var personalRating = 0 - var body: some View { - HStack(spacing:10) { - Text("Key") - Picker("Key",selection:$player.pitch) { ForEach(-12..<13) { Text(String(format:"%+d",$0)).tag(Double($0)) } }.labelsHidden().frame(width:70) - Text("Tempo") - Slider(value:$player.tempo,in:0.5...1.5,step:0.05).frame(width:85) - Text(String(format:"%.0f%%",player.tempo*100)).monospacedDigit().frame(width:40) - Text("Rating") - Picker("Singer rating",selection:$personalRating) { ForEach(0..<6) { Text($0 == 0 ? "Unrated" : String(repeating:"★",count:$0)).tag($0) } }.labelsHidden().frame(width:88).help("Singer-specific song rating") - Button("Save for Singer") { - if let song = player.currentSongID ?? selectedSong { model.savePreference(song:song,value:.init(pitch:player.pitch,tempo:player.tempo,rating:personalRating)) } - }.disabled(model.selectedSinger == nil || (player.currentSongID == nil && selectedSong == nil)) - Menu { - Button("Reset key / tempo") { player.pitch = 0; player.tempo = 1 } - ForEach([-1.0,-0.5,0,0.5,1.0],id:\.self) { offset in Button(String(format:"Graphics offset %+.1fs",offset)) { player.graphicsOffset = offset } } - } label: { Image(systemName:"slider.horizontal.3") }.menuStyle(.borderlessButton).frame(width:22).help("Playback settings") - }.font(.system(size:11)) - .onChange(of:model.selectedSinger) { _ in loadRating() } - .onChange(of:player.currentSongID) { _ in loadRating() } - .onChange(of:selectedSong) { _ in loadRating() } - } - private func loadRating() { if let song = player.currentSongID ?? selectedSong { personalRating = model.preference(song).rating } else { personalRating = 0 } } -} -private struct SeekBar: View { - @ObservedObject var player: Player - private func clock(_ seconds: Double) -> String { let n = Int(seconds); return String(format: "%d:%02d", n / 60, n % 60) } - var body: some View { - HStack(spacing: 10) { - Text(clock(player.time)) - Slider(value: Binding(get: { player.time }, set: { player.seek($0) }), in: 0...max(1, player.duration)) - .controlSize(.mini).tint(.gray).disabled(player.duration == 0).accessibilityLabel("Playback position") - Text(clock(player.duration)) - }.font(.system(size: 10, design: .monospaced)).foregroundStyle(.white.opacity(0.65)) - } -} -private struct RepeatButton: View { - @ObservedObject var player: Player - var body: some View { - Button { player.repeating.toggle() } label: { - Image(systemName: "repeat").font(.system(size: 18, weight: .semibold)) - .foregroundStyle(player.repeating ? Color.blue : Color(white: 0.25)).frame(width: 32, height: 24) - }.help(player.repeating ? "Repeat song: on" : "Repeat song: off").accessibilityLabel("Repeat song").accessibilityValue(player.repeating ? "On" : "Off") - } -} diff --git a/backups/before-classic-library-20261103-085620/KJamsClone/Library.swift b/backups/before-classic-library-20261103-085620/KJamsClone/Library.swift deleted file mode 100644 index de9da0c..0000000 --- a/backups/before-classic-library-20261103-085620/KJamsClone/Library.swift +++ /dev/null @@ -1,219 +0,0 @@ -import Foundation -import SQLite3 - -struct Song: Identifiable, Hashable { - var id: Int64 - var title: String - var audio: String - var cdg: String? - var rating: Int - var plays: Int - var artist: String = "" - var album: String = "" - var label: String = "" -} -struct PersonPlace: Identifiable, Hashable { var id: Int64; var name: String } -struct SongPreference: Equatable { - var pitch: Double = 0 - var tempo: Double = 1 - var rating: Int = 0 -} -struct Performance: Identifiable { - var id: Int64 - var song: String - var singer: String - var venue: String - var date: String -} -struct QueueEntry: Identifiable { - var id: Int64 - var songID: Int64 - var singerID: Int64? - var title: String - var singer: String -} -enum LibraryError: LocalizedError { - case message(String) - var errorDescription: String? { if case .message(let s) = self { return s }; return nil } -} -final class Library { - private var db: OpaquePointer? - init(url: URL) throws { - guard sqlite3_open(url.path, &db) == SQLITE_OK else { throw LibraryError.message("Cannot open library") } - try execute("PRAGMA foreign_keys=ON") - try execute("CREATE TABLE IF NOT EXISTS songs(id INTEGER PRIMARY KEY,title TEXT NOT NULL,audio TEXT UNIQUE NOT NULL,cdg TEXT,rating INTEGER NOT NULL DEFAULT 0 CHECK(rating BETWEEN 0 AND 5),plays INTEGER NOT NULL DEFAULT 0)") - try execute("CREATE TABLE IF NOT EXISTS singers(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS venues(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS history(id INTEGER PRIMARY KEY,song INTEGER REFERENCES songs(id),singer INTEGER REFERENCES singers(id),venue INTEGER REFERENCES venues(id),played TEXT DEFAULT CURRENT_TIMESTAMP)") - // Additive migration: preserve older libraries and infer existing memberships from history. - for column in ["artist", "album", "label"] { - if try !columns("songs").contains(column) { try execute("ALTER TABLE songs ADD COLUMN \(column) TEXT NOT NULL DEFAULT ''") } - } - try execute("CREATE TABLE IF NOT EXISTS venue_singers(venue INTEGER NOT NULL REFERENCES venues(id) ON DELETE CASCADE,singer INTEGER NOT NULL REFERENCES singers(id) ON DELETE CASCADE,PRIMARY KEY(venue,singer))") - if try schemaVersion() < 3 { try execute("INSERT OR IGNORE INTO venue_singers SELECT DISTINCT venue,singer FROM history WHERE venue IS NOT NULL AND singer IS NOT NULL") } - try execute("CREATE TABLE IF NOT EXISTS settings(key TEXT PRIMARY KEY,value TEXT)") - try execute("CREATE TABLE IF NOT EXISTS preferences(song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,singer INTEGER NOT NULL REFERENCES singers(id) ON DELETE CASCADE,pitch REAL NOT NULL DEFAULT 0 CHECK(pitch BETWEEN -12 AND 12),tempo REAL NOT NULL DEFAULT 1 CHECK(tempo BETWEEN 0.5 AND 1.5),rating INTEGER NOT NULL DEFAULT 0 CHECK(rating BETWEEN 0 AND 5),PRIMARY KEY(song,singer))") - try execute("CREATE TABLE IF NOT EXISTS queue(id INTEGER PRIMARY KEY,venue INTEGER REFERENCES venues(id) ON DELETE CASCADE,song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,singer INTEGER REFERENCES singers(id) ON DELETE CASCADE,position INTEGER NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS playlists(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS playlist_songs(playlist INTEGER NOT NULL REFERENCES playlists(id) ON DELETE CASCADE,song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,position INTEGER NOT NULL,PRIMARY KEY(playlist,song))") - try execute("CREATE TABLE IF NOT EXISTS singer_songs(singer INTEGER NOT NULL REFERENCES singers(id) ON DELETE CASCADE,song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,position INTEGER NOT NULL,PRIMARY KEY(singer,song))") - if try schemaVersion() < 4 { - try execute("INSERT OR IGNORE INTO singer_songs(singer,song,position) SELECT singer,song,MIN(id) FROM history WHERE singer IS NOT NULL AND song IS NOT NULL GROUP BY singer,song") - try execute("INSERT OR IGNORE INTO singer_songs(singer,song,position) SELECT singer,song,0 FROM preferences") - } - try execute("PRAGMA user_version=4") - } - deinit { sqlite3_close(db) } - private func statement(_ sql: String, _ values: [String?]) throws -> OpaquePointer { - var s: OpaquePointer? - guard sqlite3_prepare_v2(db, sql, -1, &s, nil) == SQLITE_OK, let s else { throw error() } - for (i,v) in values.enumerated() { - let code = v.map { sqlite3_bind_text(s, Int32(i + 1), $0, -1, unsafeBitCast(-1, to: sqlite3_destructor_type.self)) } ?? sqlite3_bind_null(s, Int32(i + 1)) - if code != SQLITE_OK { sqlite3_finalize(s); throw error() } - } - return s - } - private func error() -> LibraryError { .message(String(cString: sqlite3_errmsg(db))) } - func execute(_ sql: String, _ values: [String?] = []) throws { - let s = try statement(sql, values); defer { sqlite3_finalize(s) } - guard sqlite3_step(s) == SQLITE_DONE else { throw error() } - } - func songs() throws -> [Song] { - let s = try statement("SELECT id,title,audio,cdg,rating,plays,artist,album,label FROM songs ORDER BY title COLLATE NOCASE", []); defer { sqlite3_finalize(s) } - var result = [Song]() - while true { - let code = sqlite3_step(s); if code == SQLITE_DONE { break }; guard code == SQLITE_ROW else { throw error() } - result.append(Song(id: sqlite3_column_int64(s,0), title: String(cString: sqlite3_column_text(s,1)), audio: String(cString: sqlite3_column_text(s,2)), cdg: sqlite3_column_text(s,3).map { String(cString:$0) }, rating: Int(sqlite3_column_int(s,4)), plays: Int(sqlite3_column_int(s,5)), artist: text(s,6), album: text(s,7), label: text(s,8))) - } - return result - } - func add(title: String, audio: String, cdg: String?, artist: String = "", album: String = "", label: String = "") throws { - try execute("INSERT INTO songs(title,audio,cdg,artist,album,label) VALUES(?,?,?,?,?,?) ON CONFLICT(audio) DO UPDATE SET cdg=COALESCE(excluded.cdg,songs.cdg),artist=CASE WHEN excluded.artist!='' THEN excluded.artist ELSE songs.artist END,album=CASE WHEN excluded.album!='' THEN excluded.album ELSE songs.album END,label=CASE WHEN excluded.label!='' THEN excluded.label ELSE songs.label END", [title,audio,cdg,artist,album,label]) - } - func rate(_ id: Int64, _ rating: Int) throws { try execute("UPDATE songs SET rating=? WHERE id=?", [String(rating),String(id)]) } - func entities(_ table: String) throws -> [PersonPlace] { - precondition(["singers","venues","playlists"].contains(table)) - let s = try statement("SELECT id,name FROM \(table) ORDER BY name", []); defer { sqlite3_finalize(s) } - var rows = [PersonPlace]() - while sqlite3_step(s) == SQLITE_ROW { rows.append(.init(id: sqlite3_column_int64(s,0), name: String(cString: sqlite3_column_text(s,1)))) } - return rows - } - func addEntity(_ table: String, name: String) throws { - precondition(["singers","venues","playlists"].contains(table)) - let name = name.trimmingCharacters(in: .whitespacesAndNewlines) - guard !name.isEmpty else { throw LibraryError.message("Enter a name") } - try execute("INSERT OR IGNORE INTO \(table)(name) VALUES(?)", [name]) - } - func record(_ song: Int64, singer: Int64?, venue: Int64?) throws { - try execute("BEGIN IMMEDIATE") - do { - if let singer { try assignSong(song,singer:singer) } - try execute("INSERT INTO history(song,singer,venue) VALUES(?,?,?)", [String(song),singer.map(String.init),venue.map(String.init)]) - try execute("UPDATE songs SET plays=plays+1 WHERE id=?", [String(song)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK"); throw error } - } - - private func text(_ s: OpaquePointer, _ index: Int32) -> String { sqlite3_column_text(s,index).map { String(cString:$0) } ?? "" } - private func schemaVersion() throws -> Int { - let s = try statement("PRAGMA user_version",[]); defer { sqlite3_finalize(s) } - return sqlite3_step(s) == SQLITE_ROW ? Int(sqlite3_column_int(s,0)) : 0 - } - private func columns(_ table: String) throws -> Set { - let s = try statement("PRAGMA table_info(\(table))", []); defer { sqlite3_finalize(s) } - var result = Set(); while sqlite3_step(s) == SQLITE_ROW { result.insert(text(s,1)) }; return result - } - func members(of venue: Int64) throws -> [PersonPlace] { - let s = try statement("SELECT singers.id,singers.name FROM singers JOIN venue_singers ON singers.id=venue_singers.singer WHERE venue=? ORDER BY name", [String(venue)]); defer { sqlite3_finalize(s) } - var result = [PersonPlace](); while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),name:text(s,1))) }; return result - } - func setMembership(singer: Int64, venue: Int64, included: Bool) throws { - try execute(included ? "INSERT OR IGNORE INTO venue_singers(venue,singer) VALUES(?,?)" : "DELETE FROM venue_singers WHERE venue=? AND singer=?", [String(venue),String(singer)]) - if !included { try execute("DELETE FROM queue WHERE venue=? AND singer=?",[String(venue),String(singer)]) } - } - func currentVenue() throws -> Int64? { - let s = try statement("SELECT venues.id FROM venues JOIN settings ON CAST(settings.value AS INTEGER)=venues.id WHERE settings.key='currentVenue'", []); defer { sqlite3_finalize(s) } - return sqlite3_step(s) == SQLITE_ROW ? sqlite3_column_int64(s,0) : nil - } - func selectVenue(_ id: Int64?) throws { - if let id { - guard try entities("venues").contains(where: { $0.id == id }) else { throw LibraryError.message("Venue no longer exists") } - } - try execute("INSERT INTO settings(key,value) VALUES('currentVenue',?) ON CONFLICT(key) DO UPDATE SET value=excluded.value",[id.map(String.init)]) - } - func rename(_ table: String, id: Int64, name: String) throws { - precondition(["singers","venues","playlists"].contains(table)) - let name = name.trimmingCharacters(in:.whitespacesAndNewlines) - guard !name.isEmpty else { throw LibraryError.message("Enter a name") } - try execute("UPDATE \(table) SET name=? WHERE id=?",[name,String(id)]) - } - func deleteEntity(_ table: String, id: Int64) throws { - precondition(["singers","venues","playlists"].contains(table)) - try execute("BEGIN IMMEDIATE") - do { - if table == "singers" { try execute("UPDATE history SET singer=NULL WHERE singer=?",[String(id)]) } - if table == "venues" { - try execute("UPDATE history SET venue=NULL WHERE venue=?",[String(id)]) - try execute("DELETE FROM settings WHERE key='currentVenue' AND value=?",[String(id)]) - } - try execute("DELETE FROM \(table) WHERE id=?",[String(id)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK"); throw error } - } - func preference(song: Int64, singer: Int64) throws -> SongPreference { - let s = try statement("SELECT pitch,tempo,rating FROM preferences WHERE song=? AND singer=?",[String(song),String(singer)]); defer { sqlite3_finalize(s) } - guard sqlite3_step(s) == SQLITE_ROW else { return .init() } - return .init(pitch:sqlite3_column_double(s,0),tempo:sqlite3_column_double(s,1),rating:Int(sqlite3_column_int(s,2))) - } - func savePreference(song: Int64, singer: Int64, value: SongPreference) throws { - try execute("INSERT INTO preferences(song,singer,pitch,tempo,rating) VALUES(?,?,?,?,?) ON CONFLICT(song,singer) DO UPDATE SET pitch=excluded.pitch,tempo=excluded.tempo,rating=excluded.rating",[String(song),String(singer),String(value.pitch),String(value.tempo),String(value.rating)]) - } - func history(venue: Int64?, singer: Int64? = nil) throws -> [Performance] { - let s = try statement("SELECT history.id,COALESCE(songs.title,'Deleted song'),COALESCE(singers.name,'—'),COALESCE(venues.name,'—'),played FROM history LEFT JOIN songs ON songs.id=history.song LEFT JOIN singers ON singers.id=history.singer LEFT JOIN venues ON venues.id=history.venue WHERE (? IS NULL OR history.venue=?) AND (? IS NULL OR history.singer=?) ORDER BY history.id DESC",[venue.map(String.init),venue.map(String.init),singer.map(String.init),singer.map(String.init)]); defer { sqlite3_finalize(s) } - var result = [Performance](); while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),song:text(s,1),singer:text(s,2),venue:text(s,3),date:text(s,4))) }; return result - } - func enqueue(song: Int64, singer: Int64?, venue: Int64?) throws { - guard let venue else { throw LibraryError.message("Select a current venue before adding to its queue") } - if let singer, try !members(of:venue).contains(where: { $0.id == singer }) { throw LibraryError.message("Add this singer to the current venue first") } - try execute("BEGIN IMMEDIATE") - do { - if let singer { try assignSong(song,singer:singer) } - try execute("INSERT INTO queue(venue,song,singer,position) VALUES(?,?,?,(SELECT COALESCE(MAX(position),0)+1 FROM queue WHERE venue=?))",[String(venue),String(song),singer.map(String.init),String(venue)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK");throw error } - } - func queue(venue: Int64?) throws -> [QueueEntry] { - guard let venue else { return [] } - let s = try statement("SELECT queue.id,queue.song,queue.singer,songs.title,COALESCE(singers.name,'No singer') FROM queue JOIN songs ON songs.id=queue.song LEFT JOIN singers ON singers.id=queue.singer WHERE queue.venue=? ORDER BY queue.position,queue.id",[String(venue)]); defer { sqlite3_finalize(s) } - var result = [QueueEntry](); while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),songID:sqlite3_column_int64(s,1),singerID:sqlite3_column_type(s,2) == SQLITE_NULL ? nil : sqlite3_column_int64(s,2),title:text(s,3),singer:text(s,4))) }; return result - } - func removeQueue(_ id: Int64) throws { try execute("DELETE FROM queue WHERE id=?",[String(id)]) } - func moveQueue(_ id: Int64, venue: Int64, by offset: Int) throws { - var rows = try queue(venue:venue) - guard let index = rows.firstIndex(where: { $0.id == id }), rows.indices.contains(index+offset) else { return } - rows.swapAt(index,index+offset) - try execute("BEGIN IMMEDIATE") - do { for (i,row) in rows.enumerated() { try execute("UPDATE queue SET position=? WHERE id=?",[String(i),String(row.id)]) }; try execute("COMMIT") } - catch { try? execute("ROLLBACK"); throw error } - } - func addToPlaylist(_ playlist: Int64, song: Int64) throws { - try execute("INSERT OR IGNORE INTO playlist_songs(playlist,song,position) VALUES(?,?,(SELECT COALESCE(MAX(position),0)+1 FROM playlist_songs WHERE playlist=?))",[String(playlist),String(song),String(playlist)]) - } - func playlistSongIDs(_ playlist: Int64) throws -> [Int64] { - let s = try statement("SELECT song FROM playlist_songs WHERE playlist=? ORDER BY position",[String(playlist)]); defer { sqlite3_finalize(s) } - var ids = [Int64](); while sqlite3_step(s) == SQLITE_ROW { ids.append(sqlite3_column_int64(s,0)) }; return ids - } - func removeFromPlaylist(_ playlist: Int64, song: Int64) throws { try execute("DELETE FROM playlist_songs WHERE playlist=? AND song=?",[String(playlist),String(song)]) } - func assignSong(_ song: Int64, singer: Int64) throws { - try execute("INSERT OR IGNORE INTO singer_songs(singer,song,position) VALUES(?,?,(SELECT COALESCE(MAX(position),0)+1 FROM singer_songs WHERE singer=?))",[String(singer),String(song),String(singer)]) - } - func removeSingerSong(_ song: Int64, singer: Int64) throws { - try execute("DELETE FROM singer_songs WHERE singer=? AND song=?",[String(singer),String(song)]) - } - func singerSongIDs() throws -> [Int64:[Int64]] { - let s = try statement("SELECT singer,song FROM singer_songs ORDER BY singer,position,song",[]); defer { sqlite3_finalize(s) } - var result = [Int64:[Int64]]() - while sqlite3_step(s) == SQLITE_ROW { result[sqlite3_column_int64(s,0),default:[]].append(sqlite3_column_int64(s,1)) } - return result - } -} diff --git a/backups/before-classic-library-20261103-085620/KJamsClone/Player.swift b/backups/before-classic-library-20261103-085620/KJamsClone/Player.swift deleted file mode 100644 index 1cff467..0000000 --- a/backups/before-classic-library-20261103-085620/KJamsClone/Player.swift +++ /dev/null @@ -1,228 +0,0 @@ -import SwiftUI -import AVFoundation - -/// CDG follows consumed source frames, so tempo adjustment preserves graphics timing. -@MainActor final class Player: ObservableObject { - @Published var image: CGImage? - @Published private(set) var waveform = [Float]() - @Published private(set) var waveformBands = [WaveformBands]() - @Published var lowGain: Double = 0 { didSet { updateTone() } } - @Published var midGain: Double = 0 { didSet { updateTone() } } - @Published var highGain: Double = 0 { didSet { updateTone() } } - @Published var filter: Double = 0 { didSet { updateTone() } } - @Published var toneEnabled = true { didSet { updateTone() } } - @Published private(set) var leftLevel: Float = 0 - @Published private(set) var rightLevel: Float = 0 - private let tone = AVAudioUnitEQ(numberOfBands:4) - private let meter = AudioLevelMeter() - private var metering = false - @Published private(set) var waveformLoading = false - @Published private(set) var waveformUnavailable = false - private var waveformTask: Task? - private var waveformGeneration = UUID() - @Published var playing = false - @Published var time: Double = 0 - @Published var duration: Double = 0 - @Published var title = "Select a song" - @Published var volume: Double = 0.8 { didSet { engine.mainMixerNode.outputVolume = Float(volume) } } - @Published var repeating = false - @Published var pitch: Double = 0 { didSet { effect.pitch = Float(pitch * 100) } } - @Published var tempo: Double = 1 { didSet { effect.rate = Float(tempo) } } - @Published var graphicsOffset: Double = 0 - private(set) var currentSongID: Int64? - var onFinished: (() -> Void)? - private let engine = AVAudioEngine() - private let node = AVAudioPlayerNode() - private let effect = AVAudioUnitTimePitch() - private var file: AVAudioFile? - private var anchor: Double = 0 - private var generation = UUID() - private var cdg = Data() - private var decoder = CDGDecoder() - private var timer: Timer? - init() { engine.attach(node); engine.attach(effect); engine.attach(tone); updateTone() } - func resetTone() { lowGain = 0; midGain = 0; highGain = 0; filter = 0; toneEnabled = true } - private func updateTone() { - AudioTone.configure(tone,sampleRate:file?.processingFormat.sampleRate ?? 44100,low:lowGain,mid:midGain,high:highGain,filter:filter,enabled:toneEnabled) - } - func load(_ song: Song, preference: SongPreference = .init()) throws { - stop() - do { - let loaded = try AVAudioFile(forReading:URL(fileURLWithPath:song.audio)) - let graphics = try song.cdg.map { try Data(contentsOf:URL(fileURLWithPath:$0)) } ?? Data() - guard loaded.length > 0 else { throw LibraryError.message("Audio file is empty") } - engine.connect(node,to:effect,format:loaded.processingFormat) - engine.connect(effect,to:tone,format:loaded.processingFormat) - engine.connect(tone,to:engine.mainMixerNode,format:loaded.processingFormat) - file = loaded; cdg = graphics; decoder = CDGDecoder() - duration = Double(loaded.length)/loaded.processingFormat.sampleRate - title = song.title; currentSongID = song.id - pitch = preference.pitch; tempo = preference.tempo - updateTone() - let meter = self.meter - engine.mainMixerNode.installTap(onBus:0,bufferSize:1024,format:nil) { buffer, _ in meter.consume(buffer) } - metering = true - engine.mainMixerNode.outputVolume = Float(volume) - engine.prepare(); try engine.start() - schedule(at:0,play:true); startTimer(); tick() - analyseWaveform(URL(fileURLWithPath:song.audio)) - } catch { stop(); throw error } - } - private func analyseWaveform(_ url: URL) { - let token = UUID(); waveformGeneration = token; waveformLoading = true - waveformTask = Task.detached(priority: .utility) { [weak self] in - let result: Result - do { result = .success(try AudioWaveform.analyse(url: url, cancelled: { Task.isCancelled })) } - catch { result = .failure(error) } - guard !Task.isCancelled else { return } - await MainActor.run { [weak self] in - guard let self, self.waveformGeneration == token else { return } - self.waveformLoading = false - switch result { - case .success(let analysis): self.waveform = analysis.levels; self.waveformBands = analysis.bands - case .failure: self.waveformUnavailable = true - } - } - } - } - private func schedule(at seconds: Double, play: Bool) { - guard let file else { return } - generation = UUID(); let token = generation - node.stop() - let rate = file.processingFormat.sampleRate - let start = min(file.length,max(0,AVAudioFramePosition(seconds*rate))) - anchor = Double(start)/rate; time = anchor - guard start < file.length else { playing = false; render(); return } - node.scheduleSegment(file,startingFrame:start,frameCount:AVAudioFrameCount(min(file.length-start,Int64(UInt32.max))),at:nil,completionCallbackType:.dataPlayedBack) { [weak self] _ in - Task { @MainActor in - guard let self, self.generation == token else { return } - if self.repeating { self.schedule(at:0,play:true) } - else { - self.playing = false; self.time = self.duration; self.render() - self.timer?.invalidate(); self.timer = nil; self.onFinished?() - } - } - } - if play { node.play() }; playing = play; render() - } - private func startTimer() { - timer?.invalidate() - timer = Timer.scheduledTimer(withTimeInterval:1.0/30,repeats:true) { [weak self] _ in Task { @MainActor in self?.tick() } } - } - func toggle() { - guard file != nil else { return } - if playing { tick(); node.pause(); playing = false } - else if time >= duration { schedule(at:0,play:true); startTimer() } - else { node.play(); playing = true; startTimer() } - } - func stop() { - waveformTask?.cancel(); waveformTask = nil; waveformGeneration = UUID() - waveform = []; waveformBands = []; waveformLoading = false; waveformUnavailable = false - generation = UUID(); timer?.invalidate(); timer = nil; node.stop(); engine.stop() - if metering { engine.mainMixerNode.removeTap(onBus:0); metering = false } - meter.reset(); leftLevel = 0; rightLevel = 0 - engine.disconnectNodeOutput(node); engine.disconnectNodeOutput(effect); engine.disconnectNodeOutput(tone) - file = nil; playing = false; time = 0; anchor = 0; duration = 0; image = nil; currentSongID = nil; title = "Select a song" - } - func seek(_ value: Double) { - guard file != nil, value.isFinite else { return } - schedule(at:min(max(value,0),duration),play:playing); startTimer() - } - private func render() { decoder.render(cdg,at:max(0,time+graphicsOffset)); image = cdg.isEmpty ? nil : decoder.image() } - private func tick() { - let levels = meter.snapshot() - leftLevel = playing ? levels.0 : 0; rightLevel = playing ? levels.1 : 0 - if playing, let file, let renderTime = node.lastRenderTime, let playerTime = node.playerTime(forNodeTime:renderTime) { - time = min(duration,max(0,anchor+Double(playerTime.sampleTime)/file.processingFormat.sampleRate)) - } - render() - } -} - -/// Streams fixed-size PCM chunks into a bounded RMS envelope, independent of playback. -/// A separate AVAudioFile keeps analysis away from the player's scheduling/read position. -enum AudioWaveform { - struct Analysis { var levels: [Float]; var bands: [WaveformBands] } - static func read(url: URL, bins: Int = 1024, cancelled: () -> Bool = { false }) throws -> [Float] { - try analyse(url:url,bins:bins,cancelled:cancelled).levels - } - static func analyse(url: URL, bins: Int = 1024, cancelled: () -> Bool = { false }) throws -> Analysis { - guard bins > 0 else { return .init(levels:[],bands:[]) } - let file = try AVAudioFile(forReading: url, commonFormat: .pcmFormatFloat32, interleaved: false) - guard file.length > 0, let buffer = AVAudioPCMBuffer(pcmFormat: file.processingFormat, frameCapacity: 16384) else { return .init(levels:[],bands:[]) } - var energy = [Double](repeating: 0, count: bins) - var counts = [Int](repeating: 0, count: bins) - var position: Int64 = 0 - let channels = Int(file.processingFormat.channelCount) - let rate = file.processingFormat.sampleRate - let lowAlpha = exp(-2*Double.pi*250/rate), highAlpha = exp(-2*Double.pi*2500/rate) - var lowState = [Double](repeating:0,count:channels), highState = lowState - var lows = [Double](repeating:0,count:bins), mids = lows, highs = lows - while position < file.length { - if cancelled() { throw CancellationError() } - try file.read(into: buffer, frameCount: AVAudioFrameCount(min(16384, file.length-position))) - let frames = Int(buffer.frameLength) - guard frames > 0, let data = buffer.floatChannelData else { break } - for frame in 0.. 0 ? sqrt($0/Double($1)) : 0 } - let peak = rms.max() ?? 0 - let levels = peak > 0 ? rms.map { Float(pow(min(1,$0/peak),0.7)) } : [Float](repeating:0,count:bins) - let bands = (0.. (Float,Float) { lock.lock();defer { lock.unlock() };return levels } - func reset() { lock.lock();levels = (0,0);lock.unlock() } -} diff --git a/backups/before-classic-library-20261103-085620/KJamsCloneTests/KJamsCloneTests.swift b/backups/before-classic-library-20261103-085620/KJamsCloneTests/KJamsCloneTests.swift deleted file mode 100644 index 3348584..0000000 --- a/backups/before-classic-library-20261103-085620/KJamsCloneTests/KJamsCloneTests.swift +++ /dev/null @@ -1,364 +0,0 @@ -import XCTest -import AVFoundation -@testable import KJamsClone - -final class KJamsCloneTests: XCTestCase { - func packet(_ instruction: UInt8, _ data: [UInt8]) -> [UInt8] { [9,instruction,0,0] + Array((data + Array(repeating: 0,count:16)).prefix(16)) + [0,0,0,0] } - func testPresetTileXORAndInvalidCoordinates() { - var d = CDGDecoder() - d.apply(packet(1,[3,0])); XCTAssertEqual(d.pixels[0],3) - d.apply(packet(6,[0,5,1,1] + Array(repeating:63,count:12))) - XCTAssertEqual(d.pixels[12*300+6],5) - d.apply(packet(38,[0,5,1,1] + Array(repeating:63,count:12))) - XCTAssertEqual(d.pixels[12*300+6],0) - let old = d.pixels; d.apply(packet(6,[1,2,31,63])); XCTAssertEqual(d.pixels,old) - } - func testSeekAndTruncatedPacket() { - var d = CDGDecoder() - let data = Data(packet(1,[2,0]) + packet(1,[7,0]) + [9]) - d.render(data,at:1); XCTAssertEqual(d.pixels[0],7); XCTAssertEqual(d.packetIndex,2) - d.render(data,at:1.0/300); XCTAssertEqual(d.pixels[0],2) - d.render(data,at:0); XCTAssertEqual(d.pixels[0],0) - } - func testPaletteBorderScrollAndImage() { - var d = CDGDecoder() - d.apply(packet(30,[63,63])); XCTAssertEqual(d.palette[0],0xFFFFFFFF) - d.apply(packet(2,[4])); XCTAssertEqual(d.pixels[0],4); XCTAssertEqual(d.pixels[12*300+6],0) - d.apply(packet(20,[3,16,0])); XCTAssertEqual(d.pixels[100*300],3) - d.apply(packet(24,[0,32,0])); XCTAssertEqual(d.pixels[100*300+294],3) - XCTAssertEqual(d.image()?.width,288) - } - func testSQLitePersistenceDedupRatingsAndHistory() throws { - let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at: folder,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:folder) } - let url = folder.appendingPathComponent("test.sqlite") - do { - let db = try Library(url:url) - try db.add(title:"Singer's Song",audio:"/test.mp3",cdg:nil) - try db.add(title:"Duplicate",audio:"/test.mp3",cdg:"/test.cdg") - let song = try XCTUnwrap(db.songs().first) - try db.rate(song.id,5); XCTAssertThrowsError(try db.rate(song.id,6)) - try db.addEntity("singers",name:"O'Neil"); try db.addEntity("venues",name:"Hall") - try db.record(song.id,singer:db.entities("singers").first?.id,venue:db.entities("venues").first?.id) - } - let reopened = try Library(url:url); let songs = try reopened.songs() - XCTAssertEqual(songs.count,1); XCTAssertEqual(songs[0].rating,5); XCTAssertEqual(songs[0].plays,1); XCTAssertEqual(songs[0].cdg,"/test.cdg") - XCTAssertEqual(try reopened.entities("singers").first?.name,"O'Neil") - } - func testPairedImportAndContentDedup() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let audio = root.appendingPathComponent("Test.mp3"), cdg = root.appendingPathComponent("Test.CDG") - try Data([1,2,3]).write(to:audio); try Data(packet(1,[2,0])).write(to:cdg) - let db = try Library(url:root.appendingPathComponent("test.sqlite")) - let importer = Importer(media:root.appendingPathComponent("Media")) - try importer.run([audio],library:db); try importer.run([audio],library:db) - XCTAssertEqual(try db.songs().count,1) - XCTAssertNotNil(try db.songs().first?.cdg) - } - - func testZippedMP3GImportAndUnsafeArchiveRejection() throws { - let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:folder,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:folder) } - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let db = try Library(url:folder.appendingPathComponent("db.sqlite")) - let importer = Importer(media:folder.appendingPathComponent("Media")) - try importer.run([fixtures.appendingPathComponent("Demo.zip")],library:db) - let song = try XCTUnwrap(db.songs().first) - XCTAssertEqual(song.title,"Demo"); XCTAssertNotNil(song.cdg) - XCTAssertTrue(FileManager.default.fileExists(atPath:song.audio)) - XCTAssertThrowsError(try importer.run([fixtures.appendingPathComponent("Unsafe.zip")],library:db)) - } - @MainActor func testMP3PlaybackPauseAndSeek() throws { - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let player = Player() - defer { player.stop() } - try player.load(Song(id:1,title:"Demo",audio:fixtures.appendingPathComponent("Demo.mp3").path,cdg:fixtures.appendingPathComponent("Demo.cdg").path,rating:0,plays:0)) - XCTAssertGreaterThan(player.duration,3.9); XCTAssertTrue(player.playing) - player.toggle(); XCTAssertFalse(player.playing) - player.seek(2); XCTAssertEqual(player.time,2,accuracy:0.05); XCTAssertNotNil(player.image) - player.seek(0.1); XCTAssertEqual(player.time,0.1,accuracy:0.05) - } - @MainActor func testCreateSingerAndVenueThroughAppModel() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - defer { try? FileManager.default.removeItem(at: root) } - let model = AppModel(storageURL: root) - XCTAssertNil(model.error) - let singer = try model.createEntity(.singer, name: " Alex ") - let venue = try model.createEntity(.venue, name: "Town Hall") - XCTAssertEqual(model.singers.first?.name, "Alex") - XCTAssertEqual(model.venues.first?.name, "Town Hall") - XCTAssertEqual(try model.createEntity(.singer, name: "Alex"), singer) - XCTAssertEqual(model.singers.count, 1) - XCTAssertThrowsError(try model.createEntity(.venue, name: " ")) - let reopened = AppModel(storageURL: root) - XCTAssertEqual(reopened.singers.first?.id, singer) - XCTAssertEqual(reopened.venues.first?.id, venue) - } - - @MainActor func testVenuesShareSingersAndRememberSelection() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - defer { try? FileManager.default.removeItem(at:root) } - let model = AppModel(storageURL:root) - let hall = try model.createEntity(.venue,name:"Hall") - let alex = try model.createEntity(.singer,name:"Alex") - let club = try model.createEntity(.venue,name:"Club") - XCTAssertTrue(model.venueSingers.isEmpty) - model.membership(singer:alex,included:true) - XCTAssertEqual(model.venueSingers.map(\.id),[alex]) - model.chooseVenue(hall); XCTAssertEqual(model.venueSingers.map(\.id),[alex]) - model.chooseVenue(club); model.membership(singer:alex,included:false) - XCTAssertTrue(model.venueSingers.isEmpty) - let reopened = AppModel(storageURL:root) - XCTAssertEqual(reopened.currentVenue,club); XCTAssertTrue(reopened.venueSingers.isEmpty) - reopened.chooseVenue(hall); XCTAssertEqual(reopened.venueSingers.map(\.id),[alex]) - XCTAssertEqual(reopened.singers.count,1) - } - func testMigrationAndMembershipRemovalDoesNotReappear() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let url = root.appendingPathComponent("db.sqlite") - var singer: Int64 = 0, venue: Int64 = 0 - do { - let db = try Library(url:url) - try db.add(title:"Song",audio:"/a.mp3",cdg:nil) - try db.addEntity("singers",name:"Alex"); try db.addEntity("venues",name:"Hall") - singer = try XCTUnwrap(db.entities("singers").first?.id); venue = try XCTUnwrap(db.entities("venues").first?.id) - try db.record(XCTUnwrap(db.songs().first?.id),singer:singer,venue:venue) - try db.execute("PRAGMA user_version=1") - } - do { - let migrated = try Library(url:url) - XCTAssertEqual(try migrated.members(of:venue).map(\.id),[singer]) - try migrated.setMembership(singer:singer,venue:venue,included:false) - } - let reopened = try Library(url:url) - XCTAssertTrue(try reopened.members(of:venue).isEmpty) - XCTAssertEqual(try reopened.history(venue:venue).count,1) - } - func testQueuePlaylistsPreferencesAndDeletion() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let db = try Library(url:root.appendingPathComponent("db.sqlite")) - try db.add(title:"First",audio:"/1.mp3",cdg:nil) - try db.add(title:"Second",audio:"/2.mp3",cdg:nil) - let songs = try db.songs() - try db.addEntity("singers",name:"Alex"); try db.addEntity("venues",name:"Hall"); try db.addEntity("venues",name:"Club") - let singer = try XCTUnwrap(db.entities("singers").first?.id) - let hall = try XCTUnwrap(db.entities("venues").first(where: { $0.name == "Hall" })?.id) - let club = try XCTUnwrap(db.entities("venues").first(where: { $0.name == "Club" })?.id) - XCTAssertThrowsError(try db.enqueue(song:songs[0].id,singer:singer,venue:hall)) - try db.setMembership(singer:singer,venue:hall,included:true) - try db.enqueue(song:songs[0].id,singer:singer,venue:hall); try db.enqueue(song:songs[1].id,singer:singer,venue:hall) - XCTAssertTrue(try db.queue(venue:club).isEmpty) - let second = try XCTUnwrap(db.queue(venue:hall).last) - try db.moveQueue(second.id,venue:hall,by:-1) - XCTAssertEqual(try db.queue(venue:hall).first?.songID,songs[1].id) - let preference = SongPreference(pitch:3,tempo:0.85,rating:4) - try db.savePreference(song:songs[0].id,singer:singer,value:preference) - XCTAssertEqual(try db.preference(song:songs[0].id,singer:singer),preference) - XCTAssertThrowsError(try db.savePreference(song:songs[0].id,singer:singer,value:.init(pitch:99))) - try db.addEntity("playlists",name:"Party") - let playlist = try XCTUnwrap(db.entities("playlists").first?.id) - try db.addToPlaylist(playlist,song:songs[0].id); try db.addToPlaylist(playlist,song:songs[0].id) - XCTAssertEqual(try db.playlistSongIDs(playlist),[songs[0].id]) - try db.record(songs[0].id,singer:singer,venue:hall) - try db.rename("singers",id:singer,name:"Alex Jones") - XCTAssertEqual(try db.history(venue:hall).first?.singer,"Alex Jones") - try db.deleteEntity("singers",id:singer) - XCTAssertTrue(try db.queue(venue:hall).isEmpty) - XCTAssertEqual(try db.history(venue:hall).count,1) - try db.selectVenue(hall); try db.deleteEntity("venues",id:hall) - XCTAssertNil(try db.currentVenue()); XCTAssertEqual(try db.history(venue:nil).count,1) - } - @MainActor func testTempoSourceClockPauseAndResume() async throws { - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let player = Player(); defer { player.stop() } - let song = Song(id:1,title:"Demo",audio:fixtures.appendingPathComponent("Demo.mp3").path,cdg:fixtures.appendingPathComponent("Demo.cdg").path,rating:0,plays:0) - try player.load(song,preference:.init(pitch:2,tempo:1.5,rating:3)) - XCTAssertEqual(player.pitch,2); XCTAssertEqual(player.tempo,1.5) - try await Task.sleep(nanoseconds:500_000_000) - XCTAssertGreaterThan(player.time,0.45); XCTAssertLessThan(player.time,1.3) - player.toggle(); let paused = player.time - try await Task.sleep(nanoseconds:100_000_000) - XCTAssertEqual(player.time,paused,accuracy:0.025) - player.seek(1.5); player.toggle() - try await Task.sleep(nanoseconds:200_000_000) - XCTAssertGreaterThan(player.time,1.6); XCTAssertNotNil(player.image) - } - func testNewTestMediaMetadataAndCDGPairImport() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let db = try Library(url:root.appendingPathComponent("db.sqlite")) - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let importer = Importer(media:root.appendingPathComponent("Media")) - try importer.run([fixtures.appendingPathComponent("TestTrack.cdg")],library:db) - let song = try XCTUnwrap(db.songs().first) - XCTAssertEqual(song.title,"MP3 Plus G Test") - XCTAssertEqual(song.artist,"KJamsClone Test Generator") - XCTAssertNotNil(song.cdg) - let bytes = try Data(contentsOf:fixtures.appendingPathComponent("TestTrack.cdg")) - XCTAssertEqual(bytes.count,20*300*24) - var decoder = CDGDecoder(); decoder.render(bytes,at:2) - XCTAssertTrue(decoder.pixels.contains(1)); XCTAssertTrue(decoder.pixels.contains(2)) - } - @MainActor func testAutomaticVenueQueueAdvancesAndRecordsSinger() async throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - defer { try? FileManager.default.removeItem(at:root) } - let model = AppModel(storageURL:root); defer { model.player.stop() } - _ = try model.createEntity(.venue,name:"Test Hall") - _ = try model.createEntity(.singer,name:"Alex") - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - model.importFiles([fixtures.appendingPathComponent("Demo.zip")]) - let song = try XCTUnwrap(model.songs.first) - model.enqueue(song.id); model.enqueue(song.id); model.playQueueNext() - XCTAssertEqual(model.queue.count,1); XCTAssertEqual(model.history.count,1) - model.player.seek(model.player.duration-0.1) - for _ in 0..<25 { - if model.queue.isEmpty { break } - try await Task.sleep(nanoseconds:100_000_000) - } - XCTAssertNil(model.error); XCTAssertTrue(model.queue.isEmpty) - XCTAssertEqual(model.history.count,2); XCTAssertEqual(model.history.first?.singer,"Alex") - } - func testWaveformRepresentsSilenceAndSignalInTimeOrder() throws { - let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:folder,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:folder) } - let url = folder.appendingPathComponent("signal.wav") - let format = try XCTUnwrap(AVAudioFormat(standardFormatWithSampleRate:8000,channels:1)) - do { - let file = try AVAudioFile(forWriting:url,settings:format.settings) - let buffer = try XCTUnwrap(AVAudioPCMBuffer(pcmFormat:format,frameCapacity:4096)); buffer.frameLength = 4096 - let samples = try XCTUnwrap(buffer.floatChannelData?[0]) - for i in 0..<4096 { samples[i] = i < 2048 ? 0 : Float(sin(Double(i)*0.2)*0.5) } - try file.write(from:buffer) - } - let envelope = try AudioWaveform.read(url:url,bins:32) - XCTAssertEqual(envelope.count,32) - XCTAssertTrue(envelope.prefix(16).allSatisfy { $0 == 0 }) - XCTAssertTrue(envelope.suffix(16).allSatisfy { $0 > 0.8 && $0 <= 1 }) - XCTAssertThrowsError(try AudioWaveform.read(url:url,cancelled:{true})) - } - @MainActor func testWaveformAnalysisAndStopClearsTrackData() async throws { - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let player = Player(); defer { player.stop() } - try player.load(Song(id:1,title:"Demo",audio:fixtures.appendingPathComponent("Demo.mp3").path,cdg:nil,rating:0,plays:0)) - player.toggle() - for _ in 0..<50 { - if !player.waveformLoading { break } - try await Task.sleep(nanoseconds:20_000_000) - } - XCTAssertEqual(player.waveform.count,1024) - XCTAssertFalse(player.waveformUnavailable) - player.stop() - XCTAssertTrue(player.waveform.isEmpty) - XCTAssertFalse(player.waveformLoading) - try await Task.sleep(nanoseconds:50_000_000) - XCTAssertTrue(player.waveform.isEmpty) - } - - @MainActor func testConnectedSingerCreationAndSharedRepertoire() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - defer { try? FileManager.default.removeItem(at:root) } - let model = AppModel(storageURL:root) - let hall = try model.createEntity(.venue,name:"Hall") - try model.library?.add(title:"Song",audio:"/sample.mp3",cdg:nil);try model.refresh() - let song = try XCTUnwrap(model.songs.first?.id) - let alex = try model.createSinger(name:" Alex ",venue:hall,songs:[song]) - XCTAssertEqual(model.selectedSinger,alex);XCTAssertEqual(model.currentVenue,hall) - XCTAssertEqual(model.venueSingers.map(\.id),[alex]);XCTAssertEqual(model.songs(for:alex).map(\.id),[song]) - XCTAssertThrowsError(try model.createSinger(name:"Broken",venue:hall,songs:[999999])) - XCTAssertFalse(try XCTUnwrap(model.library).entities("singers").contains { $0.name == "Broken" }) - let club = try model.createEntity(.venue,name:"Club");model.membership(singer:alex,included:true) - XCTAssertEqual(model.songs(for:alex).map(\.id),[song]) - model.assign(song,to:alex);XCTAssertEqual(model.songs(for:alex).count,1) - let reopened = AppModel(storageURL:root) - XCTAssertEqual(reopened.currentVenue,club);XCTAssertEqual(reopened.songs(for:alex).map(\.id),[song]) - reopened.assign(song,to:alex,included:false) - XCTAssertTrue(AppModel(storageURL:root).songs(for:alex).isEmpty) - } - func testQueueRemembersSingerSongWithoutDuplicatingAssignment() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let db = try Library(url:root.appendingPathComponent("db.sqlite")) - try db.addEntity("singers",name:"Alex");try db.addEntity("venues",name:"Hall") - try db.add(title:"Song",audio:"/a.mp3",cdg:nil) - let singer = try XCTUnwrap(db.entities("singers").first?.id),venue = try XCTUnwrap(db.entities("venues").first?.id),song = try XCTUnwrap(db.songs().first?.id) - try db.setMembership(singer:singer,venue:venue,included:true) - try db.enqueue(song:song,singer:singer,venue:venue);try db.enqueue(song:song,singer:singer,venue:venue) - XCTAssertEqual(try db.singerSongIDs()[singer],[song]);XCTAssertEqual(try db.queue(venue:venue).count,2) - try db.removeSingerSong(song,singer:singer) - XCTAssertNil(try db.singerSongIDs()[singer]);XCTAssertEqual(try db.songs().count,1) - } - func testFrequencyBandsDistinguishBassAndTreble() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let url = root.appendingPathComponent("bands.wav") - let format = try XCTUnwrap(AVAudioFormat(standardFormatWithSampleRate:16000,channels:1)) - do { - let file = try AVAudioFile(forWriting:url,settings:format.settings) - let buffer = try XCTUnwrap(AVAudioPCMBuffer(pcmFormat:format,frameCapacity:8192));buffer.frameLength = 8192 - for i in 0..<8192 { buffer.floatChannelData![0][i] = Float(sin(Double(i)*2*Double.pi*(i < 4096 ? 80 : 6000)/16000)*0.2) } - try file.write(from:buffer) - } - let analysis = try AudioWaveform.analyse(url:url,bins:32) - XCTAssertGreaterThan(analysis.bands[8].low,analysis.bands[8].high*3) - XCTAssertGreaterThan(analysis.bands[24].high,analysis.bands[24].low*3) - } - private func toneRMS(frequency: Double, low: Double = 0, filter: Double = 0, enabled: Bool = true) throws -> Double { - let engine = AVAudioEngine(),node = AVAudioPlayerNode(),eq = AVAudioUnitEQ(numberOfBands:4) - let format = try XCTUnwrap(AVAudioFormat(standardFormatWithSampleRate:44100,channels:1)) - engine.attach(node);engine.attach(eq);engine.connect(node,to:eq,format:format);engine.connect(eq,to:engine.mainMixerNode,format:format) - AudioTone.configure(eq,sampleRate:44100,low:low,mid:0,high:0,filter:filter,enabled:enabled) - try engine.enableManualRenderingMode(.offline,format:format,maximumFrameCount:1024) - let input = try XCTUnwrap(AVAudioPCMBuffer(pcmFormat:format,frameCapacity:32768));input.frameLength = 32768 - for i in 0..<32768 { input.floatChannelData![0][i] = Float(sin(Double(i)*2*Double.pi*frequency/44100)*0.1) } - node.scheduleBuffer(input);try engine.start();node.play();defer { node.stop();engine.stop() } - let output = try XCTUnwrap(AVAudioPCMBuffer(pcmFormat:format,frameCapacity:1024)) - var energy: Double = 0,count = 0 - for block in 0..<12 { - let status = try engine.renderOffline(1024,to:output) - XCTAssertEqual(status,.success) - if block >= 2 { for i in 0.. - - - - - - \ No newline at end of file diff --git a/backups/before-kjmix-20261103-100337/KJamsClone/CDG.swift b/backups/before-kjmix-20261103-100337/KJamsClone/CDG.swift deleted file mode 100644 index 6b4625f..0000000 --- a/backups/before-kjmix-20261103-100337/KJamsClone/CDG.swift +++ /dev/null @@ -1,68 +0,0 @@ -import Foundation -import CoreGraphics - -/// CD+G packet decoder. Packet parity is ignored; malformed coordinates are rejected. -struct CDGDecoder { - private(set) var pixels = [UInt8](repeating: 0, count: 300 * 216) - private(set) var palette = [UInt32](repeating: 0x000000FF, count: 16) - private(set) var packetIndex = 0 - private(set) var horizontalOffset = 0 - private(set) var verticalOffset = 0 - private var transparent: UInt8? - mutating func render(_ data: Data, at seconds: Double) { - let target = min(data.count / 24, max(0, Int(max(0, seconds) * 300))) - if target < packetIndex { self = CDGDecoder() } - while packetIndex < target { - apply(Array(data[(packetIndex * 24)..<(packetIndex * 24 + 24)])) - packetIndex += 1 - } - } - mutating func apply(_ packet: [UInt8]) { - guard packet.count == 24, packet[0] & 63 == 9 else { return } - let d = packet[4..<20].map { Int($0 & 63) } - switch packet[1] & 63 { - case 1: - if d[1] == 0 { pixels = .init(repeating: UInt8(d[0] & 15), count: pixels.count) } - case 2: - for y in 0..<216 { for x in 0..<300 where x < 6 || x >= 294 || y < 12 || y >= 204 { pixels[y * 300 + x] = UInt8(d[0] & 15) } } - case 6, 38: - let row = d[2] & 31, col = d[3] & 63 - guard row < 18, col < 50 else { return } - for y in 0..<12 { for x in 0..<6 { - let color = UInt8(d[(y + 4)] & (1 << (5 - x)) == 0 ? d[0] & 15 : d[1] & 15) - let i = (row * 12 + y) * 300 + col * 6 + x - if packet[1] & 63 == 38 { pixels[i] ^= color } else { pixels[i] = color } - } } - case 20, 24: - horizontalOffset = min(d[1] & 7, 5); verticalOffset = min(d[2] & 15, 11) - let hx = (d[1] >> 4) & 3, vy = (d[2] >> 4) & 3 - let dx = hx == 1 ? 6 : hx == 2 ? -6 : 0 - let dy = vy == 1 ? 12 : vy == 2 ? -12 : 0 - let old = pixels - for y in 0..<216 { for x in 0..<300 { - let sx = x - dx, sy = y - dy - if packet[1] & 63 == 24 || (sx >= 0 && sx < 300 && sy >= 0 && sy < 216) { - pixels[y * 300 + x] = old[((sy + 216) % 216) * 300 + (sx + 300) % 300] - } else { pixels[y * 300 + x] = UInt8(d[0] & 15) } - } } - case 28: transparent = UInt8(d[0] & 15) - case 30, 31: - let start = packet[1] & 63 == 30 ? 0 : 8 - for i in 0..<8 { - let v = (d[i * 2] << 6) | d[i * 2 + 1] - palette[start + i] = UInt32(((v >> 8) & 15) * 17) << 24 | UInt32(((v >> 4) & 15) * 17) << 16 | UInt32((v & 15) * 17) << 8 | 255 - } - default: break - } - } - func image() -> CGImage? { - var rgba = [UInt8](); rgba.reserveCapacity(288 * 192 * 4) - for y in 12..<204 { for x in 6..<294 { - let index = pixels[(y + verticalOffset) * 300 + x + horizontalOffset] - let c = palette[Int(index)] - rgba += [UInt8((c >> 24) & 255), UInt8((c >> 16) & 255), UInt8((c >> 8) & 255), index == transparent ? 0 : 255] - } } - guard let provider = CGDataProvider(data: Data(rgba) as CFData) else { return nil } - return CGImage(width: 288, height: 192, bitsPerComponent: 8, bitsPerPixel: 32, bytesPerRow: 288 * 4, space: CGColorSpaceCreateDeviceRGB(), bitmapInfo: CGBitmapInfo(rawValue: CGImageAlphaInfo.last.rawValue), provider: provider, decode: nil, shouldInterpolate: false, intent: .defaultIntent) - } -} diff --git a/backups/before-kjmix-20261103-100337/KJamsClone/Importer.swift b/backups/before-kjmix-20261103-100337/KJamsClone/Importer.swift deleted file mode 100644 index 69e8fd7..0000000 --- a/backups/before-kjmix-20261103-100337/KJamsClone/Importer.swift +++ /dev/null @@ -1,68 +0,0 @@ -import Foundation -import CryptoKit -import AVFoundation - -struct Importer { - let media: URL - func run(_ urls: [URL], library: Library) throws { - try FileManager.default.createDirectory(at: media, withIntermediateDirectories: true) - var files = urls - var temporary = [URL]() - defer { for url in temporary { try? FileManager.default.removeItem(at: url) } } - for zip in urls where zip.pathExtension.lowercased() == "zip" { - let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true) - temporary.append(folder) - // Validate names before extraction; reject path traversal and symlinks afterwards. - let details = try process(["-Z", "-l", zip.path]) - guard !details.split(separator: "\n").contains(where: { $0.hasPrefix("l") }) else { throw LibraryError.message("ZIP symlinks are unsupported") } - let list = try process(["-Z1", zip.path]) - let names = list.split(separator: "\n").map(String.init) - guard !names.isEmpty, names.allSatisfy({ !$0.hasPrefix("/") && !$0.split(separator: "/").contains("..") && !$0.contains("\\") }) else { throw LibraryError.message("Unsafe or empty ZIP") } - _ = try process(["-q", zip.path, "-d", folder.path]) - let extracted = FileManager.default.enumerator(at: folder, includingPropertiesForKeys: [.isSymbolicLinkKey,.isRegularFileKey])! - for case let url as URL in extracted { - let values = try url.resourceValues(forKeys: [.isSymbolicLinkKey,.isRegularFileKey]) - guard values.isSymbolicLink != true else { throw LibraryError.message("ZIP symlinks are unsupported") } - if values.isRegularFile == true { files.append(url) } - } - } - for cdg in files.filter({ $0.pathExtension.lowercased() == "cdg" }) { - let siblings = try FileManager.default.contentsOfDirectory(at:cdg.deletingLastPathComponent(),includingPropertiesForKeys:nil) - if let audio = siblings.first(where: { ["mp3","wav","m4a"].contains($0.pathExtension.lowercased()) && $0.deletingPathExtension().lastPathComponent.caseInsensitiveCompare(cdg.deletingPathExtension().lastPathComponent) == .orderedSame }) { files.append(audio) } - } - var imported = 0 - for audio in Set(files) where ["mp3","wav","m4a"].contains(audio.pathExtension.lowercased()) { - let siblings = try FileManager.default.contentsOfDirectory(at: audio.deletingLastPathComponent(), includingPropertiesForKeys: nil) - let cdg = siblings.first { $0.pathExtension.lowercased() == "cdg" && $0.deletingPathExtension().lastPathComponent.caseInsensitiveCompare(audio.deletingPathExtension().lastPathComponent) == .orderedSame } - let hash = SHA256.hash(data: try Data(contentsOf: audio)).map { String(format: "%02x", $0) }.joined() - let dest = media.appendingPathComponent(hash + "." + audio.pathExtension.lowercased()) - if !FileManager.default.fileExists(atPath: dest.path) { try FileManager.default.copyItem(at: audio, to: dest) } - var graphics: String? - if let cdg { - let target = media.appendingPathComponent(hash + ".cdg") - if !FileManager.default.fileExists(atPath: target.path) { try FileManager.default.copyItem(at: cdg, to: target) } - graphics = target.path - } - imported += 1 - let metadata = AVURLAsset(url:audio).commonMetadata - func tag(_ key: AVMetadataKey) -> String { metadata.first { $0.commonKey == key }?.stringValue ?? "" } - let taggedTitle = tag(.commonKeyTitle) - try library.add(title:taggedTitle.isEmpty ? audio.deletingPathExtension().lastPathComponent : taggedTitle,audio:dest.path,cdg:graphics,artist:tag(.commonKeyArtist),album:tag(.commonKeyAlbumName),label:tag(.commonKeyPublisher),duration:audioDuration(audio)) - } - guard imported > 0 else { throw LibraryError.message("No audio found. Keep the MP3 and matching CDG together, or import an MP3+G ZIP.") } - } - private func audioDuration(_ url: URL) -> Double { - guard let file = try? AVAudioFile(forReading:url) else { return 0 } - return Double(file.length)/file.processingFormat.sampleRate - } - private func process(_ arguments: [String]) throws -> String { - let task = Process(); task.executableURL = URL(fileURLWithPath: "/usr/bin/unzip"); task.arguments = arguments - let out = Pipe(); task.standardOutput = out - let err = FileHandle.nullDevice; task.standardError = err - try task.run() - let bytes = out.fileHandleForReading.readDataToEndOfFile(); task.waitUntilExit() - guard task.terminationStatus == 0 else { throw LibraryError.message("Cannot read ZIP archive") } - return String(decoding: bytes, as: UTF8.self) - } -} diff --git a/backups/before-kjmix-20261103-100337/KJamsClone/KJamsCloneApp.swift b/backups/before-kjmix-20261103-100337/KJamsClone/KJamsCloneApp.swift deleted file mode 100644 index ca835bb..0000000 --- a/backups/before-kjmix-20261103-100337/KJamsClone/KJamsCloneApp.swift +++ /dev/null @@ -1,1336 +0,0 @@ -import SwiftUI -import UniformTypeIdentifiers -import AVFoundation - -enum EntityKind: String, Identifiable { - case singer, venue - var id: String { rawValue } - var title: String { self == .singer ? "Singer" : "Venue" } - var table: String { self == .singer ? "singers" : "venues" } -} - -/// Only an internal, same-process song reference is exported, never media or file URLs. -struct SongDragReference: Codable, Sendable { - static let type = UTType(exportedAs:"com.kjamsclone.internal-song") - var song: Int64 - var library: String - var singer: Int64? - var venue: Int64? - var fromTonight: Bool - func provider() -> NSItemProvider { - let provider = NSItemProvider() - let data = (try? JSONEncoder().encode(self)) ?? Data() - provider.registerDataRepresentation(forTypeIdentifier:Self.type.identifier,visibility:.ownProcess) { completion in completion(data,nil);return nil } - return provider - } - static func load(_ provider: NSItemProvider) async throws -> Self { - let data: Data = try await withCheckedThrowingContinuation { continuation in - provider.loadDataRepresentation(forTypeIdentifier:Self.type.identifier) { data,error in - if let data { continuation.resume(returning:data) } - else { continuation.resume(throwing:error ?? LibraryError.message("Could not read dragged song")) } - } - } - return try JSONDecoder().decode(Self.self,from:data) - } -} -@MainActor final class AppModel: ObservableObject { - @Published var songs = [Song]() - @Published var singers = [PersonPlace]() - @Published var singerSongIDs = [Int64:[Int64]]() - @Published var favourites = [Int64:Set]() - @Published var musicStores = [MusicStore]() - @Published var readingDurations = false - var newSingerSongs = Set() - private var songIndex = [Int64:Song]() - @Published var venues = [PersonPlace]() - @Published var venueSingers = [PersonPlace]() - @Published var playlists = [PersonPlace]() - @Published var queue = [QueueEntry]() - @Published var tonightSongIDs = [Int64:[Int64]]() - @Published var history = [Performance]() - @Published private(set) var currentVenue: Int64? - @Published var selectedSinger: Int64? - @Published var autoAdvance = true - @Published var error: String? - @Published var creating: EntityKind? - let player: Player - private(set) var library: Library? - let root: URL - var currentVenueName: String { venues.first { $0.id == currentVenue }?.name ?? "No venue selected" } - init(storageURL: URL? = nil) { - root = storageURL ?? FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0].appendingPathComponent("KJamsClone") - player = Player(waveformCacheDirectory:root.appendingPathComponent("Waveforms")) - perform { - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - library = try Library(url:root.appendingPathComponent("Library.sqlite")); try refresh() - } - player.onFinished = { [weak self] in - guard let self, self.autoAdvance, !self.queue.isEmpty else { return } - self.playQueueNext() - } - } - func perform(_ work: () throws -> Void) { do { try work() } catch { self.error = error.localizedDescription } } - func refresh() throws { - guard let library else { throw LibraryError.message("Library unavailable") } - songs = try library.songs();songIndex = Dictionary(uniqueKeysWithValues:songs.map { ($0.id,$0) }); singers = try library.entities("singers"); venues = try library.entities("venues") - singerSongIDs = try library.singerSongIDs();favourites = try library.favouriteSongIDs();musicStores = try library.stores() - playlists = try library.entities("playlists"); currentVenue = try library.currentVenue() - venueSingers = try currentVenue.map { try library.members(of:$0) } ?? singers - if let selectedSinger, !venueSingers.contains(where: { $0.id == selectedSinger }) { self.selectedSinger = nil } - tonightSongIDs = try library.tonightSongIDs(venue:currentVenue) - queue = try library.queue(venue:currentVenue); history = try library.history(venue:currentVenue) - } - func chooseVenue(_ id: Int64?) { - perform { - guard let library else { throw LibraryError.message("Library unavailable") } - try library.selectVenue(id); selectedSinger = nil; try refresh() - } - } - func membership(singer: Int64, included: Bool) { - perform { - guard let library, let currentVenue else { throw LibraryError.message("Select a current venue first") } - try library.setMembership(singer:singer,venue:currentVenue,included:included); try refresh() - } - } - @discardableResult func createEntity(_ kind: EntityKind, name: String) throws -> Int64 { - guard let library else { throw LibraryError.message("Library unavailable") } - let trimmed = name.trimmingCharacters(in:.whitespacesAndNewlines) - try library.addEntity(kind.table,name:trimmed) - guard let entity = try library.entities(kind.table).first(where: { $0.name == trimmed }) else { throw LibraryError.message("Could not load new entry") } - if kind == .singer { - if let currentVenue { try library.setMembership(singer:entity.id,venue:currentVenue,included:true) } - selectedSinger = entity.id - } else { try library.selectVenue(entity.id); selectedSinger = nil } - try refresh(); return entity.id - } - func beginSinger(song: Int64? = nil) { newSingerSongs = Set(song.map { [$0] } ?? []); creating = .singer } - func songs(for singer: Int64) -> [Song] { - (singerSongIDs[singer] ?? []).compactMap { songIndex[$0] } - } - func assign(_ song: Int64, to singer: Int64, included: Bool = true) { - perform { - guard let library else { throw LibraryError.message("Library unavailable") } - if included { try library.assignSong(song,singer:singer) } else { try library.removeSingerSong(song,singer:singer) } - try refresh() - } - } - func createSinger(name: String, venue: Int64, songs: Set) throws -> Int64 { - guard let library else { throw LibraryError.message("Library unavailable") } - guard venues.contains(where: { $0.id == venue }) else { throw LibraryError.message("Choose a venue first") } - let name = name.trimmingCharacters(in:.whitespacesAndNewlines) - try library.execute("BEGIN IMMEDIATE") - let id: Int64 - do { - try library.addEntity("singers",name:name) - guard let singer = try library.entities("singers").first(where: { $0.name == name }) else { throw LibraryError.message("Could not load singer") } - id = singer.id - try library.setMembership(singer:id,venue:venue,included:true) - for song in songs { try library.assignSong(song,singer:id) } - try library.selectVenue(venue);try library.execute("COMMIT") - } catch { try? library.execute("ROLLBACK");throw error } - try refresh();selectedSinger = id;return id - } - func rename(_ table: String, id: Int64, name: String) { perform { try library?.rename(table,id:id,name:name); try refresh() } } - func delete(_ table: String, id: Int64) { perform { try library?.deleteEntity(table,id:id); try refresh() } } - func preference(_ song: Int64) -> SongPreference { - guard let library else { return .init() } - if let selectedSinger { return (try? library.preference(song:song,singer:selectedSinger)) ?? .init() } - return (try? library.defaultPreference(song:song)) ?? .init() - } - func savePreference(song: Int64, value: SongPreference) { - perform { - guard let library, let selectedSinger else { throw LibraryError.message("Select a singer to save their song preferences") } - try library.savePreference(song:song,singer:selectedSinger,value:value); try refresh() - } - } - func play(_ song: Song, singer: Int64? = nil) throws { - guard let library else { throw LibraryError.message("Library unavailable") } - let singer = singer ?? selectedSinger - if let singer, let currentVenue, try !library.members(of:currentVenue).contains(where: { $0.id == singer }) { throw LibraryError.message("This singer is not in the current venue") } - let preference = try singer.map { try library.preference(song:song.id,singer:$0) } ?? library.defaultPreference(song:song.id) - try player.load(song,preference:preference) - do { try library.updateDuration(song.id,seconds:player.duration);try library.record(song.id,singer:singer,venue:currentVenue); selectedSinger = singer; try refresh() } - catch { player.stop(); throw error } - } - func enqueue(_ song: Int64) { perform { try library?.enqueue(song:song,singer:selectedSinger,venue:currentVenue); try refresh() } } - func tonightSongs(for singer: Int64) -> [Song] { (tonightSongIDs[singer] ?? []).compactMap { songIndex[$0] } } - func addToTonight(_ song: Int64,singer: Int64? = nil) { - perform { - guard let library,let currentVenue,let singer = singer ?? selectedSinger else { throw LibraryError.message("Choose a current venue and singer, then add the song to Tonight") } - try library.addTonight(song:song,singer:singer,venue:currentVenue);try refresh() - } - } - func removeFromTonight(_ song: Int64,singer: Int64) { - perform { guard let library,let currentVenue else { return };try library.removeTonight(song:song,singer:singer,venue:currentVenue);try refresh() } - } - func playTonight(_ song: Song,singer: Int64) { - perform { - try play(song,singer:singer) - if let entry = queue.first(where:{ $0.songID == song.id && $0.singerID == singer }) { try library?.removeQueue(entry.id) } - try refresh() - } - } - func dragReference(_ song: Int64,singer: Int64? = nil,tonight: Bool = false) -> SongDragReference { - .init(song:song,library:root.standardizedFileURL.path,singer:singer,venue:currentVenue,fromTonight:tonight) - } - func placeDroppedSong(_ reference: SongDragReference,singer: Int64,venue: Int64,before: Int64?) throws { - guard let library else { throw LibraryError.message("Library unavailable") } - guard reference.library == root.standardizedFileURL.path, songIndex[reference.song] != nil else { throw LibraryError.message("Drop a song from this library") } - guard currentVenue == venue else { throw LibraryError.message("The current venue changed. Please drop again.") } - let reorder = reference.fromTonight && reference.singer == singer && reference.venue == venue && tonightSongIDs[singer]?.contains(reference.song) == true - try library.placeTonight(song:reference.song,singer:singer,venue:venue,before:before,addIfNeeded:!reorder) - try refresh() - } - func acceptSongDrop(_ providers: [NSItemProvider],singer: Int64,venue: Int64?,before: Int64?) -> Bool { - guard let venue else { return false } - let providers = providers.filter { $0.hasItemConformingToTypeIdentifier(SongDragReference.type.identifier) } - guard !providers.isEmpty else { return false } - Task { @MainActor [weak self] in - guard let self else { return } - do { for provider in providers { let reference = try await SongDragReference.load(provider);try self.placeDroppedSong(reference,singer:singer,venue:venue,before:before) } } - catch { self.error = error.localizedDescription } - } - return true - } - func moveTonight(_ song: Int64,singer: Int64,by offset: Int) { - perform { - guard let library,let currentVenue,let ids = tonightSongIDs[singer],let index = ids.firstIndex(of:song),ids.indices.contains(index+offset) else { return } - let destination = index+offset - let before = offset < 0 ? ids[destination] : destination+1 < ids.count ? ids[destination+1] : nil - try library.placeTonight(song:song,singer:singer,venue:currentVenue,before:before,addIfNeeded:false);try refresh() - } - } - func playQueueNext() { - perform { - guard let row = queue.first, let song = songs.first(where: { $0.id == row.songID }) else { return } - // Explicitly clear selection for unassigned queue entries. - selectedSinger = row.singerID - try play(song,singer:row.singerID); try library?.removeQueue(row.id); try refresh() - } - } - func moveQueue(_ id: Int64, by offset: Int) { perform { if let currentVenue { try library?.moveQueue(id,venue:currentVenue,by:offset); try refresh() } } } - func removeQueue(_ id: Int64) { perform { try library?.removeQueue(id); try refresh() } } - func createPlaylist(_ name: String) { perform { try library?.addEntity("playlists",name:name); try refresh() } } - func addToPlaylist(_ playlist: Int64, song: Int64) { perform { try library?.addToPlaylist(playlist,song:song); try refresh() } } - func setFavourite(_ song: Int64, singer: Int64, included: Bool) { perform { try library?.setFavourite(song:song,singer:singer,included:included);try refresh() } } - func updateTuning(_ song: Int64, pitch: Double? = nil, tempo: Double? = nil) { - perform { - guard let library else { throw LibraryError.message("Library unavailable") } - var value = preference(song) - if let pitch { value.pitch = pitch };if let tempo { value.tempo = tempo } - if let selectedSinger { try library.savePreference(song:song,singer:selectedSinger,value:value) } - else { try library.saveDefaultPreference(song:song,value:value) } - if player.currentSongID == song { if pitch != nil { player.pitch = value.pitch };if tempo != nil { player.tempo = value.tempo } } - try refresh() - } - } - func saveStore(_ store: MusicStore) throws { guard let library else { throw LibraryError.message("Library unavailable") };try library.saveStore(store);try refresh() } - func deleteStore(_ id: Int64) { perform { try library?.deleteStore(id);try refresh() } } - func scanDurations() { - guard !readingDurations else { return };readingDurations = true - let songs = self.songs.filter { $0.duration == 0 } - Task.detached(priority:.utility) { [weak self] in - var durations = [(Int64,Double)]() - for song in songs { - if let file = try? AVAudioFile(forReading:URL(fileURLWithPath:song.audio)) { durations.append((song.id,Double(file.length)/file.processingFormat.sampleRate)) } - } - let completedDurations = durations - await MainActor.run { [weak self] in - guard let self else { return } - self.perform { for (id,value) in completedDurations { try self.library?.updateDuration(id,seconds:value) };try self.refresh() } - self.readingDurations = false - } - } - } - func updateMetadata(_ song: Song,title: String,artist: String,album: String,label: String,rating: Int) throws { - guard let library else { throw LibraryError.message("Library unavailable") } - try library.updateMetadata(song:song.id,title:title,artist:artist,album:album,label:label,rating:rating) - if player.currentSongID == song.id { player.title = title.trimmingCharacters(in:.whitespacesAndNewlines) } - try refresh() - } - func importFiles(_ urls: [URL]) { perform { guard let library else { throw LibraryError.message("Library unavailable") }; try Importer(media:root.appendingPathComponent("Media")).run(urls,library:library); try refresh() } } -} -@main struct KJamsCloneApp: App { - @StateObject private var model = AppModel() - var body: some Scene { - Window("KJamsClone", id: "main") { - LibraryView(model: model).frame(minWidth: 1060, minHeight: 680).preferredColorScheme(.dark) - }.defaultSize(width: 1260, height: 840) - .commands { - CommandGroup(replacing: .newItem) { - Button("New Singer…") { model.beginSinger() }.keyboardShortcut("n", modifiers: [.command, .shift]) - Button("New Venue…") { model.creating = .venue }.keyboardShortcut("n", modifiers: [.command, .option]) - } - } - Window("Video", id: "lyrics") { - LyricsView(player: model.player).frame(minWidth: 480, minHeight: 320).preferredColorScheme(.dark) - }.defaultSize(width: 600, height: 400) - } -} -private enum Classic { - static let frame = Color(red: 0.15, green: 0.15, blue: 0.15) - static let navy = Color(red: 0.008, green: 0.065, blue: 0.16) - static let blue = Color(red: 0.015, green: 0.17, blue: 0.42) - static let header = Color(white: 0.115) - static let line = Color(white: 0.42) -} -struct LyricsView: View { - @ObservedObject var player: Player - var body: some View { - ZStack { - Color.black - if let image = player.image { - Image(decorative: image, scale: 1).interpolation(.none).resizable().aspectRatio(1.5, contentMode: .fit) - } - } - } -} -/// This is another view of the same published CGImage used by the Video window. -/// It owns no decoder, audio player or clock, so seeking/pause/tempo stay identical. -private struct SidebarVideoMonitor: View { - let player: Player - var body: some View { - VStack(alignment: .leading, spacing: 7) { - Label("Video Monitor", systemImage: "tv") - .font(.system(size: 11, weight: .medium)).foregroundStyle(.white.opacity(0.7)) - LyricsView(player: player) - .aspectRatio(1.5, contentMode: .fit) - .clipped() - .overlay(Rectangle().strokeBorder(.white.opacity(0.25), lineWidth: 1)) - .accessibilityLabel("Video monitor, synchronized with the Video window") - }.frame(maxWidth: .infinity) - } -} -private struct SilverSquareStyle: ButtonStyle { - func makeBody(configuration: Configuration) -> some View { - configuration.label.foregroundStyle(Color(white: 0.25)).padding(.horizontal, 6).padding(.vertical, 3) - .background(LinearGradient(colors: [Color(white: 0.95), Color(white: 0.64)], startPoint: .top, endPoint: .bottom), in: RoundedRectangle(cornerRadius: 4)) - .overlay(RoundedRectangle(cornerRadius: 4).strokeBorder(Color(white: 0.45), lineWidth: 1.5)) - .overlay(RoundedRectangle(cornerRadius: 3).strokeBorder(.white.opacity(0.7)).padding(3)) - .opacity(configuration.isPressed ? 0.7 : 1) - } -} -private struct SilverButton: View { - let symbol: String - let label: String - var size: CGFloat = 40 - var active = false - var enabled = true - let action: () -> Void - var body: some View { - Button(action: action) { - Image(systemName: symbol).font(.system(size: size * 0.41, weight: .semibold)) - .foregroundStyle(active ? Color.blue : Color(white: 0.24)) - .frame(width: size, height: size) - .background(LinearGradient(colors: [.white, Color(white: 0.85), Color(white: 0.63)], startPoint: .top, endPoint: .bottom), in: Circle()) - .overlay(Circle().strokeBorder(Color(white: 0.45), lineWidth: 1.5)) - .overlay(Circle().strokeBorder(.white.opacity(0.65), lineWidth: 1).padding(3)) - .shadow(color: .black.opacity(0.7), radius: 1, y: 1) - }.buttonStyle(.plain).disabled(!enabled).opacity(enabled ? 1 : 0.72) - .help(label).accessibilityLabel(label) - } -} -struct LibraryView: View { - @ObservedObject var model: AppModel - @State private var selected: Int64? - @State private var search = "" - @State private var name = "" - @State private var importing = false - @State private var source = "Library" - @State private var singersExpanded = true - @State private var expandedSingers = Set() - @State private var expandedSongLists = Set() - @State private var songPickerSinger: PersonPlace? - @State private var songPickerTonight = false - @State private var singerSections = [Int64:String]() - @State private var singerSelections = [Int64:Int64]() - @State private var presentedSinger: Int64? - @State private var singerSection = "All Songs" - @State private var storesExpanded = true - @State private var focusedStore: Int64? - @State private var editingSong: Song? - @State private var librarySort = "Song Name" - @State private var sortAscending = true - @Environment(\.openWindow) private var openWindow - private var visibleSongs: [Song] { - let filtered = model.songs.filter { search.isEmpty || ($0.title+" "+$0.artist+" "+$0.album).localizedCaseInsensitiveContains(search) } - return filtered.sorted { a,b in - if a.id == b.id { return false } - if librarySort == "Duration" { return a.duration == b.duration ? a.id < b.id : sortAscending ? a.duration < b.duration : a.duration > b.duration } - if librarySort == "Rating" { return a.rating == b.rating ? a.id < b.id : sortAscending ? a.rating < b.rating : a.rating > b.rating } - let first = librarySort == "Artist" ? a.artist : librarySort == "Album" ? a.album : a.title - let second = librarySort == "Artist" ? b.artist : librarySort == "Album" ? b.album : b.title - let order = first.localizedStandardCompare(second) - return order == .orderedSame ? a.id < b.id : sortAscending ? order == .orderedAscending : order == .orderedDescending - } - } - - private var selectedSong: Song? { model.songs.first { $0.id == selected } } - var body: some View { - VStack(spacing: 0) { - TransportView(player: model.player, search: $search, hasSelection: selectedSong != nil, - play: playSelected, next: playNext, display: { openWindow(id: "lyrics") }) - .padding(.horizontal, 18).padding(.top, 18).padding(.bottom, 22) - HSplitView { - sidebar.frame(minWidth: 190, idealWidth: 220, maxWidth: 240) - VStack(spacing: 12) { - if source == "Library" { songTable } - else if source == "Queue" { queuePane } - else if source == "History" { historyPane } - else if source == "Playlists" { playlistPane } - else if source == "Singer Songs" { singerSongPane } - else if source == "Music Stores" { MusicStoresPane(model:model,selected:$focusedStore) } - else { directory } - detailPanel.frame(height: 135) - }.padding(.leading, 12).frame(minWidth: 780) - }.padding(.horizontal, 18) - footer.padding(.horizontal, 18).padding(.vertical, 12) - } - .background(Classic.frame) - .sheet(item: $model.creating) { kind in - AddEntitySheet(model: model, kind: kind) { id in - if kind == .singer { expandedSingers.insert(id);expandedSongLists.insert(id);singersExpanded = true;showSinger(id,section:"All Songs") } else { model.chooseVenue(id) } - } - } - .sheet(item:$editingSong) { song in SongMetadataSheet(model:model,song:song) } - .sheet(item:$songPickerSinger) { singer in SingerSongsSheet(model:model,singer:singer,tonight:songPickerTonight) } - .onChange(of:selected) { song in - if source == "Singer Songs",let singer = model.selectedSinger,let song { singerSelections[singer] = song } - } - .onChange(of:model.selectedSinger) { singer in - if source == "Singer Songs",presentedSinger != singer { showSinger(singer,section:nil) } - } - .fileImporter(isPresented: $importing, allowedContentTypes: [.audio, .zip, UTType(filenameExtension: "cdg") ?? .data], allowsMultipleSelection: true) { result in - switch result { - case .success(let urls): model.importFiles(urls) - case .failure(let error): model.error = error.localizedDescription - } - } - .alert("KJamsClone", isPresented: Binding(get: { model.error != nil }, set: { if !$0 { model.error = nil } })) { - Button("OK") { model.error = nil } - } message: { Text(model.error ?? "") } - } - private func showSinger(_ id: Int64?,section: String? = nil) { - if source == "Singer Songs",let previous = presentedSinger { - singerSections[previous] = singerSection - if let selected { singerSelections[previous] = selected } - } - presentedSinger = id;model.selectedSinger = id - singerSection = section ?? id.flatMap { singerSections[$0] } ?? "Tonight" - if let id { singerSections[id] = singerSection;selected = singerSelections[id] } - source = "Singer Songs" - } - private func sourceCount(_ source: String) -> Int { - switch source { - case "Library": return model.songs.count - case "Singers": return model.venueSingers.count - case "Venues": return model.venues.count - case "Queue": return model.queue.count - case "History": return model.history.count - default: return model.playlists.count - } - } - private var sidebar: some View { - VStack(alignment:.leading,spacing:0) { - Text("Source").font(.system(size:15,weight:.semibold)).padding(.horizontal,10).frame(height:31) - .frame(maxWidth:.infinity,alignment:.leading).background(Classic.header) - ScrollView { - VStack(spacing:0) { - sourceRow("Library",icon:"music.note.house.fill",color:.yellow) - HStack(spacing:5) { - Button { singersExpanded.toggle() } label: { Image(systemName:singersExpanded ? "chevron.down" : "chevron.right").font(.system(size:10)).frame(width:12) }.buttonStyle(.plain).accessibilityLabel("Expand singers") - Button { source = "Singers" } label: { HStack { Image(systemName:"person.2.fill").foregroundStyle(.green);Text("Singers");Spacer();Text("\(model.venueSingers.count)").font(.caption).foregroundStyle(.secondary) } }.buttonStyle(.plain) - Button { model.beginSinger() } label: { Image(systemName:"plus.circle.fill").foregroundStyle(.green) }.buttonStyle(.plain).help("New singer and songs") - }.padding(.horizontal,10).frame(height:34).background(source == "Singers" ? Color.blue.opacity(0.65) : .clear) - if singersExpanded { - Text(model.currentVenueName).font(.system(size:10)).foregroundStyle(.secondary).lineLimit(1).padding(.leading,30).frame(maxWidth:.infinity,alignment:.leading).padding(.vertical,4) - ForEach(model.venueSingers) { singer in sidebarSinger(singer) } - if model.venueSingers.isEmpty { Text("Add a singer with +").font(.caption).foregroundStyle(.secondary).padding(8) } - } - HStack { - Button { storesExpanded.toggle() } label: { Image(systemName:storesExpanded ? "chevron.down" : "chevron.right").font(.system(size:10)) }.buttonStyle(.plain) - Button { source = "Music Stores" } label: { Label("Music Stores",systemImage:"bag.fill").foregroundStyle(.green);Spacer() }.buttonStyle(.plain) - }.padding(.horizontal,12).frame(height:34) - if storesExpanded { - ForEach(model.musicStores) { store in - Button { focusedStore = store.id;source = "Music Stores" } label: { Label(store.name,systemImage:"globe").font(.system(size:12)).lineLimit(1).padding(.leading,32).frame(maxWidth:.infinity,alignment:.leading).frame(height:26) }.buttonStyle(.plain) - } - Button("Configure Stores…") { source = "Music Stores" }.buttonStyle(.plain).font(.system(size:11)).foregroundStyle(.secondary).padding(.leading,32).frame(maxWidth:.infinity,alignment:.leading).frame(height:25) - } - sourceRow("Venues",icon:"building.2.fill",color:.cyan) - sourceRow("Queue",icon:"list.number",color:.orange) - sourceRow("History",icon:"clock.arrow.circlepath",color:.purple) - sourceRow("Playlists",icon:"music.note.list",color:.mint) - } - } - SidebarVideoMonitor(player:model.player).padding(10) - }.foregroundStyle(.white).background(Classic.navy).overlay(Rectangle().stroke(Classic.line,lineWidth:1)) - } - private func sourceRow(_ title: String, icon: String, color: Color) -> some View { - Button { source = title } label: { - HStack(spacing:10) { - Image(systemName:icon).foregroundStyle(color).frame(width:22) - Text(title).font(.system(size:16,weight:.medium));Spacer() - Text("\(sourceCount(title))").font(.system(size:11)).foregroundStyle(.white.opacity(0.6)) - }.padding(.horizontal,12).frame(height:34).contentShape(Rectangle()) - .background(source == title ? Color(red:0,green:0.36,blue:1) : .clear) - }.buttonStyle(.plain) - } - private func sidebarSinger(_ singer: PersonPlace) -> some View { - VStack(alignment:.leading,spacing:0) { - HStack(spacing:5) { - Button { - if expandedSingers.contains(singer.id) { expandedSingers.remove(singer.id) } else { expandedSingers.insert(singer.id) } - } label: { Image(systemName:expandedSingers.contains(singer.id) ? "chevron.down" : "chevron.right").font(.system(size:9)).frame(width:12) }.buttonStyle(.plain).accessibilityLabel("Expand \(singer.name)’s songs") - Button { showSinger(singer.id) } label: { - HStack(spacing:5) { Text(singer.name).lineLimit(1);Spacer();Text("\(model.singerSongIDs[singer.id]?.count ?? 0)").font(.system(size:10)).foregroundStyle(.secondary) } - }.buttonStyle(.plain) - Menu { - Button("Add to Tonight…") { showSinger(singer.id,section:"Tonight");songPickerTonight = true;songPickerSinger = singer } - Button("Manage All Songs…") { showSinger(singer.id,section:"All Songs");songPickerTonight = false;songPickerSinger = singer } - } label: { Image(systemName:"plus").font(.system(size:10,weight:.bold)) }.menuStyle(.borderlessButton).frame(width:16).help("Add songs to \(singer.name)’s Tonight or repertoire") - }.font(.system(size:13,weight:.medium)).padding(.leading,25).padding(.trailing,12).frame(height:29) - .background(model.selectedSinger == singer.id && source == "Singer Songs" ? Color.blue.opacity(0.25) : .clear) - .modifier(TonightSongDropTarget(model:model,singer:singer.id,venue:model.currentVenue,before:nil,enabled:true)) - if expandedSingers.contains(singer.id) { - singerFolder("Tonight",icon:"music.note.list",singer:singer) - singerFolder("Favourites",icon:"star.fill",singer:singer) - singerFolder("History",icon:"clock.arrow.circlepath",singer:singer) - HStack(spacing:3) { - Button { if expandedSongLists.contains(singer.id) { expandedSongLists.remove(singer.id) } else { expandedSongLists.insert(singer.id) } } label: { Image(systemName:expandedSongLists.contains(singer.id) ? "chevron.down" : "chevron.right").font(.system(size:9)) }.buttonStyle(.plain) - singerFolder("All Songs",icon:"folder",singer:singer) - }.padding(.leading,28) - if expandedSongLists.contains(singer.id) { - ForEach(model.songs(for:singer.id)) { song in - Button { showSinger(singer.id,section:"All Songs");selected = song.id;singerSelections[singer.id] = song.id } label: { - Label(song.title,systemImage:"music.note").font(.system(size:11)).lineLimit(1).frame(maxWidth:.infinity,alignment:.leading).padding(.leading,44).padding(.trailing,8).frame(height:25) - }.buttonStyle(.plain) - .onDrag { model.dragReference(song.id).provider() } - .contextMenu { - Button("Play for \(singer.name)") { model.selectedSinger = singer.id;model.perform { try model.play(song,singer:singer.id) } } - Button("Queue for \(singer.name)") { model.selectedSinger = singer.id;model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Button(model.favourites[singer.id]?.contains(song.id) == true ? "Remove Favourite" : "Add to Favourites") { model.setFavourite(song.id,singer:singer.id,included:model.favourites[singer.id]?.contains(song.id) != true) } - Button("Remove from Singer",role:.destructive) { model.assign(song.id,to:singer.id,included:false) } - } - } - if model.songs(for:singer.id).isEmpty { Text("No songs · use +").font(.system(size:10)).foregroundStyle(.secondary).padding(.leading,44).padding(.vertical,5) } - } - } - } - } - private func singerFolder(_ title: String, icon: String, singer: PersonPlace) -> some View { - Button { showSinger(singer.id,section:title) } label: { - Label { Text(title + (title == "Tonight" ? " (\(model.tonightSongIDs[singer.id]?.count ?? 0))" : "")) } icon: { if title == "Favourites" { GoldStar(filled:true,size:12) } else { Image(systemName:icon) } }.font(.system(size:11)).foregroundStyle(title == "Favourites" ? Color(red:1,green:0.75,blue:0.16) : Color.white.opacity(0.75)).padding(.leading,title == "All Songs" ? 0 : 43).frame(maxWidth:.infinity,alignment:.leading).frame(height:25) - }.buttonStyle(.plain) - .modifier(TonightSongDropTarget(model:model,singer:singer.id,venue:model.currentVenue,before:nil,enabled:title == "Tonight")) - } - private var singerSongPane: some View { - VStack(alignment:.leading,spacing:12) { - if let singer = model.singers.first(where:{ $0.id == model.selectedSinger }) { - HStack { Text("\(singer.name) · \(singerSection)").font(.headline);Spacer();Button(singerSection == "Tonight" ? "Add to Tonight…" : "Add Songs…") { songPickerTonight = singerSection == "Tonight";songPickerSinger = singer } } - Text("\(model.currentVenueName) · Singer song lists follow them across venues.").font(.caption).foregroundStyle(.secondary) - if singerSection == "History" { - ScrollView { LazyVStack(alignment:.leading,spacing:12) { ForEach(model.history.filter { $0.singerID == singer.id }) { row in HStack { Text(row.date).font(.caption.monospaced());Text(row.song);Spacer() } } } } - } else if singerSection == "Tonight" { - ScrollView { - VStack(spacing:10) { - ForEach(Array(model.tonightSongs(for:singer.id).enumerated()),id:\.element.id) { index,song in - HStack { - Image(systemName:"line.3.horizontal").foregroundStyle(.secondary).help("Drag to reorder Tonight") - Text("\(index+1)").font(.caption.monospacedDigit()).foregroundStyle(.secondary).frame(width:18) - Button { model.setFavourite(song.id,singer:singer.id,included:model.favourites[singer.id]?.contains(song.id) != true) } label: { GoldStar(filled:model.favourites[singer.id]?.contains(song.id) == true,size:15) }.buttonStyle(.plain).help("Toggle favourite") - Text(song.title).lineLimit(1);Spacer() - Text(model.queue.contains(where:{ $0.songID == song.id && $0.singerID == singer.id }) ? "Queued" : "Ready").font(.caption).foregroundStyle(.secondary) - Button("Play") { model.playTonight(song,singer:singer.id) } - Button("Queue Again") { model.selectedSinger = singer.id;model.enqueue(song.id) } - Button { model.moveTonight(song.id,singer:singer.id,by:-1) } label: { Image(systemName:"arrow.up") }.disabled(index == 0).help("Move earlier") - Button { model.moveTonight(song.id,singer:singer.id,by:1) } label: { Image(systemName:"arrow.down") }.disabled(index == model.tonightSongs(for:singer.id).count-1).help("Move later") - Button("Remove") { model.removeFromTonight(song.id,singer:singer.id) } - }.padding(8).background(.white.opacity(0.035)).contentShape(Rectangle()) - .onDrag { model.dragReference(song.id,singer:singer.id,tonight:true).provider() } - .modifier(TonightSongDropTarget(model:model,singer:singer.id,venue:model.currentVenue,before:song.id,enabled:true)) - } - Text(model.tonightSongs(for:singer.id).isEmpty ? "Drop a library song here to add it to \(singer.name)’s Tonight." : "Drop here to append · Drop on a row to place before it") - .font(.callout).foregroundStyle(.secondary).frame(maxWidth:.infinity).padding(18) - .overlay(RoundedRectangle(cornerRadius:4).strokeBorder(.white.opacity(0.16),style:StrokeStyle(lineWidth:1,dash:[5,4]))) - .modifier(TonightSongDropTarget(model:model,singer:singer.id,venue:model.currentVenue,before:nil,enabled:true)) - } - } - } else { - ScrollView { - VStack(spacing:10) { - ForEach(model.songs(for:singer.id).filter { singerSection != "Favourites" || model.favourites[singer.id]?.contains($0.id) == true }) { song in - HStack { - Button { model.setFavourite(song.id,singer:singer.id,included:model.favourites[singer.id]?.contains(song.id) != true) } label: { GoldStar(filled:model.favourites[singer.id]?.contains(song.id) == true,size:15) }.buttonStyle(.plain).help("Favourite for this singer") - Text(song.title).lineLimit(1);Spacer() - Button("Play") { model.selectedSinger = singer.id;model.perform { try model.play(song,singer:singer.id) } } - Button("Add to Tonight") { model.addToTonight(song.id,singer:singer.id) }.disabled(model.currentVenue == nil) - Button("Remove") { model.assign(song.id,to:singer.id,included:false) } - }.padding(8).background(.white.opacity(0.035)).contentShape(Rectangle()).onTapGesture { selected = song.id } - .onDrag { model.dragReference(song.id).provider() } - } - if model.songs(for:singer.id).isEmpty { Text("Use Add Songs… or the + beside this singer in the sidebar.").foregroundStyle(.secondary).padding(.top,25) } - } - } - } - } else { Text("Choose a singer from the sidebar.").foregroundStyle(.secondary);Spacer() } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - private var songTable: some View { - GeometryReader { geometry in - ScrollView(.horizontal) { - VStack(spacing: 0) { - tableHeader(width: max(geometry.size.width, 960)) - ScrollView(.vertical) { - LazyVStack(spacing: 0) { - ForEach(visibleSongs) { song in songRow(song, width: max(geometry.size.width, 960)) } - }.frame(maxWidth: .infinity, alignment: .topLeading) - } - }.frame(width: max(geometry.size.width, 960), height: geometry.size.height) - } - }.background(Classic.navy).overlay(Rectangle().stroke(Classic.line, lineWidth: 1)) - } - private func widths(_ total: CGFloat) -> [CGFloat] { [44,max(220,total-600),110,100,65,82,90,109] } - private func tableHeader(width: CGFloat) -> some View { - let sizes = widths(width) - return HStack(spacing:0) { - ForEach(Array(["ID","Song Name","Artist","Album","Duration","Pitch","Tempo","Rating"].enumerated()),id:\.offset) { index,title in - Button { - guard ["Song Name","Artist","Album","Duration","Rating"].contains(title) else { return } - if librarySort == title { sortAscending.toggle() } else { librarySort = title;sortAscending = true } - } label: { HStack(spacing:3) { Text(title);if librarySort == title { Image(systemName:sortAscending ? "chevron.up" : "chevron.down").font(.system(size:8)) } }.font(.system(size:12,weight:.medium)).lineLimit(1).padding(.leading,7).frame(width:sizes[index],height:30,alignment:.leading) } - .buttonStyle(.plain).overlay(alignment:.trailing) { Rectangle().fill(Classic.line).frame(width:1).padding(.vertical,4) } - } - }.foregroundStyle(.white).background(Classic.header).overlay(alignment:.bottom) { Rectangle().fill(Color(white:0.65)).frame(height:1) } - } - private func durationLabel(_ seconds: Double) -> String { seconds > 0 ? String(format:"%d:%02d",Int(seconds)/60,Int(seconds)%60) : "—" } - private func songRow(_ song: Song,width: CGFloat) -> some View { - let sizes = widths(width) - return HStack(spacing:0) { - Text("\(song.id)").foregroundStyle(.secondary).frame(width:sizes[0]) - Text(song.title).lineLimit(1).padding(.leading,7).frame(width:sizes[1],alignment:.leading) - Text(song.artist.isEmpty ? "—" : song.artist).foregroundStyle(.secondary).lineLimit(1).padding(.leading,7).frame(width:sizes[2],alignment:.leading) - Text(song.album.isEmpty ? "—" : song.album).foregroundStyle(.secondary).lineLimit(1).padding(.leading,7).frame(width:sizes[3],alignment:.leading) - Text(durationLabel(song.duration)).font(.system(size:11,design:.monospaced)).frame(width:sizes[4]) - HStack(spacing:2) { - Text(String(format:"%+.0f",model.preference(song.id).pitch)).font(.system(size:11,design:.monospaced)).frame(width:30) - Stepper("Pitch",value:Binding(get:{ model.preference(song.id).pitch },set:{ model.updateTuning(song.id,pitch:$0) }),in:-12...12,step:1).labelsHidden().controlSize(.mini).fixedSize() - }.frame(width:sizes[5]).help("Saved pitch; applies to the selected singer, or song default") - Picker("Tempo",selection:Binding(get:{ model.preference(song.id).tempo },set:{ model.updateTuning(song.id,tempo:$0) })) { - ForEach(10..<31) { Text("\($0*5)%").tag(Double($0)/20) } - }.labelsHidden().controlSize(.mini).frame(width:sizes[6]-8).padding(.horizontal,4).help("Saved tempo; applies live if this song is playing") - GoldRating(rating:Binding(get:{ song.rating },set:{ value in model.perform { try model.library?.rate(song.id,value);try model.refresh() } })).frame(width:sizes[7]) - }.font(.system(size:12)).foregroundStyle(.white).frame(height:30) - .background(selected == song.id ? Color.blue.opacity(0.5) : song.id % 2 == 0 ? Color.white.opacity(0.025) : .clear) - .contentShape(Rectangle()).onTapGesture(count:2) { selected = song.id;playSelected() }.onTapGesture { selected = song.id } - .onDrag { model.dragReference(song.id).provider() } - .contextMenu { - Button("Play") { selected = song.id; playSelected() } - Button("Edit Metadata…") { editingSong = song } - Menu("Add to Singer") { - ForEach(model.venueSingers) { singer in Button(singer.name) { model.assign(song.id,to:singer.id);model.selectedSinger = singer.id;expandedSingers.insert(singer.id) } } - Divider();Button("New Singer + This Song…") { model.beginSinger(song:song.id) } - } - Menu("Add to Tonight") { ForEach(model.venueSingers) { singer in Button(singer.name) { model.addToTonight(song.id,singer:singer.id) } } }.disabled(model.currentVenue == nil) - Button("Add to Current Venue Queue") { model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Menu("Add to Playlist") { ForEach(model.playlists) { playlist in Button(playlist.name) { model.addToPlaylist(playlist.id,song:song.id) } } } - } - } - @State private var managingRoster = false - @State private var rosterNewName = "" - @State private var editingEntity: PersonPlace? - @State private var renameText = "" - @State private var pendingDelete: PersonPlace? - private var directory: some View { - VStack(alignment:.leading,spacing:0) { - HStack { - Text(source == "Singers" ? "Singers · \(model.currentVenueName)" : "Venues").font(.headline) - Spacer() - if source == "Singers" { Button("Manage Venue Singers…") { managingRoster = true }.disabled(model.currentVenue == nil) } - Button(source == "Singers" ? "New Singer…" : "New Venue…") { if source == "Singers" { model.beginSinger() } else { model.creating = .venue } } - }.padding(12).background(Classic.header) - ScrollView { - VStack(alignment:.leading,spacing:0) { - if source == "Singers" && model.venueSingers.isEmpty { - Text("No singers at this venue. Add a singer or use Manage Venue Singers to include existing singers.").foregroundStyle(.secondary).padding() - } - ForEach(source == "Singers" ? model.venueSingers : model.venues) { entity in - HStack { - Button { - if source == "Singers" { model.selectedSinger = entity.id } else { model.chooseVenue(entity.id) } - } label: { - HStack { - Image(systemName:source == "Singers" ? "person.fill" : "building.2.fill") - Text(entity.name); Spacer() - if entity.id == (source == "Singers" ? model.selectedSinger : model.currentVenue) { - Text(source == "Singers" ? "Selected" : "Current venue").font(.caption).foregroundStyle(.cyan) - Image(systemName:"checkmark.circle.fill").foregroundStyle(.cyan) - } - }.contentShape(Rectangle()) - }.buttonStyle(.plain) - Button("Rename") { renameText = entity.name; editingEntity = entity } - Button("Delete",role:.destructive) { pendingDelete = entity } - }.padding(12) - } - } - } - HStack { - TextField(source == "Singers" ? "Singer name" : "Venue name",text:$name).textFieldStyle(.roundedBorder).onSubmit(addEntity) - Button(source == "Singers" ? "Add Singer" : "Add Venue",action:addEntity).disabled(name.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - }.padding(12) - }.foregroundStyle(.white).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - .sheet(isPresented:$managingRoster) { rosterSheet } - .sheet(item:$editingEntity) { entity in - VStack(alignment:.leading,spacing:16) { - Text("Rename \(source == "Singers" ? "Singer" : "Venue")").font(.headline) - TextField("Name",text:$renameText).textFieldStyle(.roundedBorder) - HStack { Button("Cancel") { editingEntity = nil }; Spacer(); Button("Save") { model.rename(source == "Singers" ? "singers" : "venues",id:entity.id,name:renameText); editingEntity = nil }.disabled(renameText.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) } - }.padding(24).frame(width:360) - } - .confirmationDialog("Delete \(pendingDelete?.name ?? "entry")? Historical plays are kept. Venue memberships and queued entries for it will be removed.",isPresented:Binding(get:{ pendingDelete != nil },set:{ if !$0 { pendingDelete = nil } })) { - Button("Delete",role:.destructive) { if let entity = pendingDelete { model.delete(source == "Singers" ? "singers" : "venues",id:entity.id) }; pendingDelete = nil } - } - } - private var rosterSheet: some View { - VStack(alignment:.leading,spacing:16) { - Text("Singers at \(model.currentVenueName)").font(.title2.bold()) - Text("A singer can belong to any number of venues. Unchecking removes them from this venue only.").foregroundStyle(.secondary) - ScrollView { - VStack(alignment:.leading,spacing:12) { - ForEach(model.singers) { singer in - Toggle(singer.name,isOn:Binding(get:{ model.venueSingers.contains { $0.id == singer.id } },set:{ model.membership(singer:singer.id,included:$0) })) - } - }.frame(maxWidth:.infinity,alignment:.leading) - }.frame(minHeight:120,maxHeight:280) - HStack { - TextField("New singer name",text:$rosterNewName).textFieldStyle(.roundedBorder) - Button("Add") { model.perform { _ = try model.createEntity(.singer,name:rosterNewName); rosterNewName = "" } }.disabled(rosterNewName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - Spacer(); Button("Done") { managingRoster = false }.keyboardShortcut(.defaultAction) - } - }.padding(24).frame(width:460) - } - private var detailPanel: some View { - VStack(alignment:.leading,spacing:9) { - HStack(spacing:10) { - Picker("Current venue",selection:Binding(get:{ model.currentVenue },set:{ model.chooseVenue($0) })) { - Text("Select venue…").tag(nil as Int64?) - ForEach(model.venues) { Text($0.name).tag(Optional($0.id)) } - } - Button { model.creating = .venue } label: { Image(systemName:"plus.circle.fill") }.buttonStyle(.plain).help("Add venue") - Picker("Singer",selection:$model.selectedSinger) { - Text("None").tag(nil as Int64?) - ForEach(model.venueSingers) { Text($0.name).tag(Optional($0.id)) } - } - Button { model.beginSinger() } label: { Image(systemName:"plus.circle.fill") }.buttonStyle(.plain).help("Add singer") - Menu("Add to Singer") { - ForEach(model.venueSingers) { singer in Button(singer.name) { if let selected { model.assign(selected,to:singer.id);model.selectedSinger = singer.id;expandedSingers.insert(singer.id) } } } - Divider();Button("New Singer + Song…") { model.beginSinger(song:selected) } - }.disabled(selected == nil) - Button("Add to Tonight") { if let selected { model.addToTonight(selected) } }.disabled(selected == nil || model.currentVenue == nil || model.selectedSinger == nil) - } - PlaybackSettings(player:model.player,model:model,selectedSong:selected) - SeekBar(player:model.player) - }.padding(12).frame(maxWidth:.infinity,maxHeight:.infinity) - .background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - @State private var playlistName = "" - @State private var selectedPlaylist: Int64? - private var queuePane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { Text("Queue · \(model.currentVenueName)").font(.headline); Spacer(); Toggle("Auto play next",isOn:$model.autoAdvance).toggleStyle(.checkbox); Button("Play Next") { model.playQueueNext() }.disabled(model.queue.isEmpty) } - ScrollView { - VStack(spacing:0) { - ForEach(Array(model.queue.enumerated()),id:\.element.id) { index,row in - HStack { - Text("\(index+1)").foregroundStyle(.secondary).frame(width:24) - Text(row.singer).frame(width:140,alignment:.leading) - Text(row.title).lineLimit(1); Spacer() - Button { model.moveQueue(row.id,by:-1) } label: { Image(systemName:"arrow.up") }.disabled(index == 0) - Button { model.moveQueue(row.id,by:1) } label: { Image(systemName:"arrow.down") }.disabled(index == model.queue.count-1) - Button("Remove") { model.removeQueue(row.id) } - }.padding(.vertical,8) - } - if model.queue.isEmpty { Text("Choose a venue and singer, select a library song, then click Queue Song.").foregroundStyle(.secondary).padding(.top,30) } - } - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - @State private var historyAllVenues = false - private var displayedHistory: [Performance] { - if historyAllVenues { return (try? model.library?.history(venue:nil,singer:model.selectedSinger)) ?? [] } - return model.history.filter { model.selectedSinger == nil || $0.singer == model.singers.first(where: { $0.id == model.selectedSinger })?.name } - } - private var historyPane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { Text("History · \(historyAllVenues || model.currentVenue == nil ? "All venues" : model.currentVenueName)").font(.headline); Spacer(); Toggle("All venues",isOn:$historyAllVenues).toggleStyle(.checkbox) } - ScrollView { - LazyVStack(alignment:.leading,spacing:12) { - ForEach(displayedHistory) { row in - HStack { Text(row.date).font(.system(.caption,design:.monospaced)); Text(row.singer).frame(width:130,alignment:.leading); Text(row.song); Spacer(); Text(row.venue).foregroundStyle(.secondary) } - } - } - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - private var playlistPane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { - Picker("Playlist",selection:$selectedPlaylist) { Text("Choose…").tag(nil as Int64?); ForEach(model.playlists) { Text($0.name).tag(Optional($0.id)) } } - TextField("New playlist name",text:$playlistName).textFieldStyle(.roundedBorder) - Button("Create") { model.createPlaylist(playlistName); selectedPlaylist = model.playlists.first { $0.name == playlistName.trimmingCharacters(in:.whitespacesAndNewlines) }?.id; playlistName = "" }.disabled(playlistName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - if let selectedPlaylist { - Button("Rename") { model.rename("playlists",id:selectedPlaylist,name:playlistName); playlistName = "" }.disabled(playlistName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - Button("Delete",role:.destructive) { model.delete("playlists",id:selectedPlaylist); self.selectedPlaylist = nil } } - } - ScrollView { - if let selectedPlaylist { - let ids = (try? model.library?.playlistSongIDs(selectedPlaylist)) ?? [] - VStack(alignment:.leading,spacing:10) { - ForEach(ids,id:\.self) { id in - if let song = model.songs.first(where: { $0.id == id }) { - HStack { - Text(song.title); Spacer() - Button("Play") { model.perform { try model.play(song) } } - Button("Queue") { model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Button("Remove") { model.perform { try model.library?.removeFromPlaylist(selectedPlaylist,song:id); try model.refresh() } } - } - } - } - } - } - Text("Add songs using the library row’s context menu.").foregroundStyle(.secondary).padding(.top,20) - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - private var footer: some View { - HStack { - Button { importing = true } label: { Image(systemName: "plus").font(.system(size: 20, weight: .bold)).frame(width: 32, height: 24) } - .help("Import audio, MP3+G or ZIP").accessibilityLabel("Import songs") - RepeatButton(player: model.player).padding(.leading, 12) - Button(model.readingDurations ? "Reading…" : "Read Durations") { model.scanDurations() }.controlSize(.small).disabled(model.readingDurations).help("Read durations for songs imported by older versions") - Button("Edit Metadata…") { editingSong = selectedSong }.controlSize(.small).disabled(selectedSong == nil) - Spacer() - Text("\(visibleSongs.count) \(visibleSongs.count == 1 ? "Song" : "Songs")").font(.system(size: 14, weight: .medium)) - Spacer() - Button { openWindow(id: "lyrics") } label: { Image(systemName: "rectangle.on.rectangle").frame(width: 32, height: 24) } - .help("Open video window").accessibilityLabel("Open video window") - }.buttonStyle(SilverSquareStyle()) - } - private func playSelected() { - guard let song = selectedSong else { return } - model.perform { try model.play(song) } - } - private func playNext() { - guard !visibleSongs.isEmpty else { return } - let index = visibleSongs.firstIndex { $0.id == selected } ?? -1 - selected = visibleSongs[(index + 1) % visibleSongs.count].id; playSelected() - } - private func addEntity() { - model.perform { - let kind: EntityKind = source == "Singers" ? .singer : .venue - let id = try model.createEntity(kind, name: name) - if kind == .singer { model.selectedSinger = id } else { model.chooseVenue(id) } - name = "" - } - } -} -private struct TonightSongDropTarget: ViewModifier { - @ObservedObject var model: AppModel - let singer: Int64 - let venue: Int64? - let before: Int64? - let enabled: Bool - @State private var targeted = false - func body(content: Content) -> some View { - content - .background(targeted && enabled ? Color.cyan.opacity(0.14) : .clear) - .overlay(alignment:.top) { if targeted && enabled { Rectangle().fill(.cyan).frame(height:2) } } - .onDrop(of:enabled && venue != nil ? [SongDragReference.type] : [],isTargeted:$targeted) { providers in - guard enabled else { return false } - return model.acceptSongDrop(providers,singer:singer,venue:venue,before:before) - } - } -} -/// Drawn with literal colours, so native menu/button tint cannot turn favourite stars white. -private struct GoldStar: View { - var filled: Bool - var size: CGFloat = 14 - var body: some View { - Canvas { context,bounds in - let centre = CGPoint(x:bounds.width/2,y:bounds.height/2),outer = min(bounds.width,bounds.height)*0.46 - var star = Path() - for point in 0..<10 { - let angle = Double(point)*Double.pi/5-Double.pi/2,radius = point % 2 == 0 ? outer : outer*0.43 - let p = CGPoint(x:centre.x+CGFloat(cos(angle))*radius,y:centre.y+CGFloat(sin(angle))*radius) - if point == 0 { star.move(to:p) } else { star.addLine(to:p) } - } - star.closeSubpath() - let gold = Color(red:1,green:0.73,blue:0.08) - if filled { context.fill(star,with:.color(gold)) } - else { context.stroke(star,with:.color(gold.opacity(0.7)),lineWidth:1) } - }.frame(width:size,height:size).accessibilityHidden(true) - } -} -private struct GoldRating: View { - @Binding var rating: Int - var body: some View { - HStack(spacing:2) { ForEach(1..<6) { value in Button { rating = rating == value ? 0 : value } label: { GoldStar(filled:value <= rating) }.buttonStyle(.plain).help("\(value) stars; click the selected rating to clear").accessibilityLabel("Set \(value) stars") } } - } -} -private struct SongMetadataSheet: View { - @ObservedObject var model: AppModel - let song: Song - @Environment(\.dismiss) private var dismiss - @State private var title = "" - @State private var artist = "" - @State private var album = "" - @State private var label = "" - @State private var rating = 0 - @State private var error: String? - var body: some View { - VStack(alignment:.leading,spacing:14) { - Text("Edit Song Metadata").font(.title2.bold()) - Grid(alignment:.leading,horizontalSpacing:12,verticalSpacing:10) { - GridRow { Text("Title");TextField("Title",text:$title) } - GridRow { Text("Artist");TextField("Artist",text:$artist) } - GridRow { Text("Album");TextField("Album",text:$album) } - GridRow { Text("Label");TextField("Label / publisher",text:$label) } - GridRow { Text("Rating");GoldRating(rating:$rating) } - }.textFieldStyle(.roundedBorder) - Text("Saved to your library. Embedded audio-file tags are not changed, and re-importing will preserve your library edits.").font(.caption).foregroundStyle(.secondary) - Text(URL(fileURLWithPath:song.audio).lastPathComponent).font(.caption.monospaced()).foregroundStyle(.secondary).lineLimit(1).truncationMode(.middle).help(song.audio) - if let error { Text(error).foregroundStyle(.red).font(.callout) } - HStack { Spacer();Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction);Button("Save") { save() }.keyboardShortcut(.defaultAction).disabled(title.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) } - }.padding(24).frame(width:500).background(Classic.frame).preferredColorScheme(.dark) - .onAppear { title = song.title;artist = song.artist;album = song.album;label = song.label;rating = song.rating } - } - private func save() { do { try model.updateMetadata(song,title:title,artist:artist,album:album,label:label,rating:rating);dismiss() } catch { self.error = error.localizedDescription } } -} -private struct MusicStoresPane: View { - @ObservedObject var model: AppModel - @Binding var selected: Int64? - @Environment(\.openURL) private var openURL - @State private var editor = false - @State private var editing: MusicStore? - @State private var search = "" - @State private var deleting: Int64? - var body: some View { - VStack(alignment:.leading,spacing:14) { - HStack { Text("Music Stores").font(.headline);Spacer();Button("Add Store…") { editing = nil;editor = true } } - Text("Define websites and optional catalogue-search URLs. Purchases and subscriptions are handled by the store in your browser.").font(.callout).foregroundStyle(.secondary) - HStack { TextField("Search store catalogue",text:$search).textFieldStyle(.roundedBorder);Text("{query} in a store’s search URL is replaced with this text.").font(.caption).foregroundStyle(.secondary) } - ScrollView { - VStack(alignment:.leading,spacing:12) { - ForEach(model.musicStores) { store in - VStack(alignment:.leading,spacing:8) { - HStack { Image(systemName:"bag.fill").foregroundStyle(.green);Text(store.name).font(.headline);Spacer() - Button("Open Store") { open(store,query:"") } - Button("Search") { open(store,query:search) }.disabled(search.isEmpty || store.searchTemplate.isEmpty) - Button("Edit") { editing = store;editor = true } - Button("Delete",role:.destructive) { deleting = store.id } - } - Text(store.url).font(.caption).foregroundStyle(.secondary).textSelection(.enabled) - }.padding(12).background(selected == store.id ? Color.blue.opacity(0.15) : Color.white.opacity(0.035)).contentShape(Rectangle()).onTapGesture { selected = store.id } - } - if model.musicStores.isEmpty { Text("No stores configured. Add a store name and website address to get started.").foregroundStyle(.secondary).padding(.top,20) } - } - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - .sheet(isPresented:$editor) { MusicStoreEditor(model:model,store:editing) } - .confirmationDialog("Delete this store definition?",isPresented:Binding(get:{ deleting != nil },set:{ if !$0 { deleting = nil } })) { - Button("Delete",role:.destructive) { if let deleting { model.deleteStore(deleting) };deleting = nil } - } - } - private func open(_ store: MusicStore,query: String) { - do { openURL(try store.destination(query:query)) } catch { model.error = error.localizedDescription } - } -} -private struct MusicStoreEditor: View { - @ObservedObject var model: AppModel - let store: MusicStore? - @Environment(\.dismiss) private var dismiss - @State private var name = "" - @State private var url = "" - @State private var search = "" - @State private var error: String? - var body: some View { - VStack(alignment:.leading,spacing:14) { - Text(store == nil ? "Add Music Store" : "Edit Music Store").font(.title2.bold()) - TextField("Store name",text:$name).textFieldStyle(.roundedBorder) - TextField("Website URL — https://example.com",text:$url).textFieldStyle(.roundedBorder) - TextField("Optional search URL — https://example.com/search?q={query}",text:$search).textFieldStyle(.roundedBorder) - Text("Use {query} where the search words belong. Only http:// and https:// websites are accepted.").font(.caption).foregroundStyle(.secondary) - if let error { Text(error).foregroundStyle(.red).font(.callout) } - HStack { Spacer();Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction);Button("Save") { save() }.keyboardShortcut(.defaultAction).disabled(name.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty || url.isEmpty) } - }.padding(24).frame(width:500).background(Classic.frame).preferredColorScheme(.dark) - .onAppear { name = store?.name ?? "";url = store?.url ?? "";search = store?.searchTemplate ?? "" } - } - private func save() { do { try model.saveStore(.init(id:store?.id ?? 0,name:name,url:url,searchTemplate:search));dismiss() } catch { self.error = error.localizedDescription } } -} -private struct SingerSongsSheet: View { - @ObservedObject var model: AppModel - let singer: PersonPlace - var tonight = false - @Environment(\.dismiss) private var dismiss - @State private var search = "" - @State private var importing = false - var body: some View { - VStack(alignment:.leading,spacing:14) { - Text(tonight ? "Tonight for \(singer.name)" : "Songs for \(singer.name)").font(.title2.bold()) - Text(tonight ? "Tick songs for this venue’s Tonight list. They stay here after playback and when switching singers." : "Tick songs to add them to this singer’s repertoire.").font(.callout).foregroundStyle(.secondary) - TextField("Search library",text:$search).textFieldStyle(.roundedBorder) - ScrollView { - LazyVStack(alignment:.leading,spacing:12) { - ForEach(model.songs.filter { search.isEmpty || $0.title.localizedCaseInsensitiveContains(search) }) { song in - HStack { - Toggle(song.title,isOn:Binding(get:{ tonight ? model.tonightSongIDs[singer.id]?.contains(song.id) == true : model.singerSongIDs[singer.id]?.contains(song.id) == true },set:{ included in - if tonight { if included { model.addToTonight(song.id,singer:singer.id) } else { model.removeFromTonight(song.id,singer:singer.id) } } - else { model.assign(song.id,to:singer.id,included:included) } - })).toggleStyle(.checkbox) - Spacer() - Button { model.setFavourite(song.id,singer:singer.id,included:model.favourites[singer.id]?.contains(song.id) != true) } label: { GoldStar(filled:model.favourites[singer.id]?.contains(song.id) == true,size:15) }.buttonStyle(.plain).help("Toggle favourite") - } - } - if model.songs.isEmpty { Text("Your library is empty. Import audio or MP3+G below.").foregroundStyle(.secondary) } - }.frame(maxWidth:.infinity,alignment:.leading) - }.frame(height:270) - HStack { Button("Import Songs…") { importing = true };Spacer();Button("Done") { dismiss() }.keyboardShortcut(.defaultAction) } - }.padding(24).frame(width:520).background(Classic.frame).preferredColorScheme(.dark) - .fileImporter(isPresented:$importing,allowedContentTypes:[.audio,.zip,UTType(filenameExtension:"cdg") ?? .data],allowsMultipleSelection:true) { result in - switch result { case .success(let urls):model.importFiles(urls);case .failure(let error):model.error = error.localizedDescription } - } - } -} -private struct AddEntitySheet: View { - @ObservedObject var model: AppModel - let kind: EntityKind - let saved: (Int64) -> Void - @Environment(\.dismiss) private var dismiss - @State private var name = "" - @State private var error: String? - @State private var venue: Int64? - @State private var songs = Set() - @State private var search = "" - @FocusState private var focused: Bool - var body: some View { - VStack(alignment:.leading,spacing:16) { - Text(kind == .singer ? "New Singer + Songs" : "New Venue").font(.title2.bold()) - TextField("\(kind.title) name",text:$name).textFieldStyle(.roundedBorder).focused($focused).onSubmit(save) - if kind == .singer { - Picker("Venue",selection:$venue) { Text("Choose a venue…").tag(nil as Int64?);ForEach(model.venues) { Text($0.name).tag(Optional($0.id)) } } - Text(venue == nil ? "Create a venue first, then add a singer to it." : "This singer will join the selected venue and become active.").font(.caption).foregroundStyle(.secondary) - Text("Add songs now (optional)").font(.headline) - TextField("Search library",text:$search).textFieldStyle(.roundedBorder) - ScrollView { - LazyVStack(alignment:.leading,spacing:10) { - ForEach(model.songs.filter { search.isEmpty || $0.title.localizedCaseInsensitiveContains(search) }) { song in - Toggle(song.title,isOn:Binding(get:{ songs.contains(song.id) },set:{ if $0 { songs.insert(song.id) } else { songs.remove(song.id) } })).toggleStyle(.checkbox) - } - if model.songs.isEmpty { Text("No library songs yet. You can add songs from the singer’s + button after importing.").font(.callout).foregroundStyle(.secondary) } - }.frame(maxWidth:.infinity,alignment:.leading) - }.frame(height:190) - } - if let error { Text(error).foregroundStyle(.red).font(.callout) } - HStack { Spacer();Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction) - Button(kind == .singer ? "Add Singer & Songs" : "Add Venue",action:save).keyboardShortcut(.defaultAction) - .disabled(name.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty || (kind == .singer && venue == nil)) - } - }.padding(24).frame(width:kind == .singer ? 500 : 360).background(Classic.frame).preferredColorScheme(.dark) - .onAppear { focused = true;venue = model.currentVenue ?? model.venues.first?.id;songs = model.newSingerSongs } - } - private func save() { - do { - let id: Int64 - if kind == .singer { guard let venue else { throw LibraryError.message("Choose a venue") };id = try model.createSinger(name:name,venue:venue,songs:songs) } - else { id = try model.createEntity(kind,name:name) } - saved(id);dismiss() - } catch { self.error = error.localizedDescription } - } -} -private struct TransportView: View { - @ObservedObject var player: Player - @Binding var search: String - let hasSelection: Bool - let play: () -> Void - let next: () -> Void - let display: () -> Void - var body: some View { - HStack(alignment: .top, spacing: 28) { - VStack(spacing: 15) { - HStack(spacing: 7) { - SilverButton(symbol: "backward.fill", label: "Back 10 seconds", size: 35, enabled: player.duration > 0) { player.seek(player.time - 10) } - SilverButton(symbol: player.playing ? "pause.fill" : "play.fill", label: player.playing ? "Pause" : "Play", size: 49, enabled: hasSelection || player.duration > 0) { - if player.duration > 0 { player.toggle() } else { play() } - } - SilverButton(symbol: "stop", label: "Stop", size: 46, enabled: player.duration > 0) { player.stop() } - SilverButton(symbol: "forward.fill", label: "Forward 10 seconds", size: 35, enabled: player.duration > 0) { player.seek(player.time + 10) } - SilverButton(symbol: "forward.end.fill", label: "Play next song", size: 26, enabled: hasSelection, action: next) - } - HStack(spacing: 9) { - Image(systemName: "speaker.fill").font(.system(size: 11)) - Slider(value: $player.volume, in: 0...1).controlSize(.small).tint(.gray).accessibilityLabel("Volume") - Image(systemName: "speaker.wave.3.fill").font(.system(size: 12)) - }.frame(width: 180) - }.frame(width: 220) - NowPlayingWaveform(player: player).padding(.top, 4) - HStack(spacing: 12) { - TextField("Search", text: $search).textFieldStyle(.plain).font(.system(size: 16)) - .padding(.horizontal, 8).frame(width: 145, height: 28).background(Color(white: 0.07), in: RoundedRectangle(cornerRadius: 5)) - .overlay(RoundedRectangle(cornerRadius: 5).stroke(.white.opacity(0.1))) - SilverButton(symbol: "eye", label: "Open video window", size: 48, action: display) - }.padding(.top, 15) - }.foregroundStyle(.white).frame(height: 130) - } -} -private struct NowPlayingWaveform: View { - @ObservedObject var player: Player - @State private var mixer = false - @State private var zoom: Double = 1 - @State private var hoverX: CGFloat? - @State private var scrubStart: Double? - @State private var resumeAfterScrub = false - @State private var scrubSong: Int64? - private var span: Double { max(0.001,player.duration/zoom) } - private var windowStart: Double { scrubStart ?? min(max(0,player.time-span/2),max(0,player.duration-span)) } - private var progress: Double { player.duration > 0 ? min(1,max(0,(player.time-windowStart)/span)) : 0 } - private func clock(_ value: Double) -> String { let n = max(0,Int(value));return String(format:"%d:%02d",n/60,n%60) } - private func preciseClock(_ value: Double) -> String { String(format:"%d:%05.2f",max(0,Int(value))/60,max(0,value).truncatingRemainder(dividingBy:60)) } - private func bandColor(_ index: Int) -> Color { - guard player.waveformBands.indices.contains(index) else { return .cyan } - let band = player.waveformBands[index] - let largest = max(0.000001,max(band.low,max(band.mid,band.high))) - let low = Double(band.low/largest),mid = Double(band.mid/largest),high = Double(band.high/largest) - return Color(red:min(1,pow(low,1.2)+mid*0.12+high*0.6),green:min(1,low*0.08+pow(mid,1.5)*0.97+high*0.1),blue:min(1,low*0.07+mid*0.22+high)) - } - var body: some View { - VStack(alignment:.leading,spacing:5) { - Text(player.duration > 0 ? player.title : "Ready to play").font(.system(size:13,weight:.semibold)).foregroundStyle(Color(white:0.94)) - .lineLimit(1).truncationMode(.middle).frame(maxWidth:.infinity,alignment:.leading).help(player.title) - GeometryReader { geometry in - Canvas { context,size in - let top: CGFloat = 10,plotHeight = size.height-top,mid = top+plotHeight/2 - var centre = Path();centre.move(to:CGPoint(x:0,y:mid));centre.addLine(to:CGPoint(x:size.width,y:mid)) - context.stroke(centre,with:.color(.white.opacity(0.13)),lineWidth:0.5) - if player.duration > 0 { - let step = [0.1,0.25,0.5,1.0,2,5,10,15,30,60,120,300,600,1800,3600].first { $0 >= span/5 } ?? 3600 - let first = floor(windowStart/(step/4))*(step/4) - for t in stride(from:first,through:min(player.duration,windowStart+span),by:step/4) { - let x = size.width*(t-windowStart)/span - if x < 0 { continue } - let major = abs(t/step-(t/step).rounded()) < 0.001 - var tick = Path();tick.move(to:CGPoint(x:x,y:top));tick.addLine(to:CGPoint(x:x,y:size.height)) - context.stroke(tick,with:.color(major ? .yellow.opacity(0.65) : .white.opacity(0.16)),lineWidth:major ? 0.8 : 0.5) - if major && x < size.width-25 { - context.draw(Text(span < 10 ? preciseClock(t) : clock(t)).font(.system(size:8,design:.monospaced)).foregroundColor(.gray),at:CGPoint(x:x+3,y:3),anchor:.leading) - } - } - } - if !player.waveform.isEmpty { - let count = max(1,Int(size.width/2)),step = size.width/CGFloat(count) - for bar in 0.. 0,geometry.size.width > 0 else { return } - if scrubStart == nil { - scrubStart = windowStart;scrubSong = player.currentSongID;resumeAfterScrub = player.playing - if player.playing { player.toggle() } - } - guard scrubSong == player.currentSongID else { return } - hoverX = value.location.x - let target = windowStart+Double(min(1,max(0,value.location.x/geometry.size.width)))*span - if abs(target-player.time) > 0.02 { player.seek(target) } - }.onEnded { value in - if scrubStart == nil { - if player.duration > 0 { player.seek(windowStart+Double(min(1,max(0,value.location.x/max(1,geometry.size.width))))*span) } - return - } - let target = windowStart+Double(min(1,max(0,value.location.x/max(1,geometry.size.width))))*span - if scrubSong == player.currentSongID { - player.seek(target) - if resumeAfterScrub && !player.playing && target < player.duration-0.01 { player.toggle() } - } - scrubStart = nil;resumeAfterScrub = false;scrubSong = nil - }).help("Hover for exact time. Drag to scrub; playback resumes on release. Zoom for fine positioning.") - .accessibilityLabel("Audio waveform").accessibilityValue("\(clock(player.time)) of \(clock(player.duration))") - .accessibilityAdjustableAction { direction in if direction == .increment { player.seek(player.time+5) } else if direction == .decrement { player.seek(player.time-5) } } - }.frame(height:60) - HStack(spacing:5) { - Circle().fill(player.playing ? Color.green : Color.orange).frame(width:4,height:4) - Text(player.duration == 0 ? "NO TRACK LOADED" : player.playing ? "PLAYING" : "PAUSED").tracking(1) - if player.waveformUnavailable { Text("· Waveform unavailable").foregroundStyle(.secondary) } - Spacer(minLength:0) - Button { zoom = max(1,zoom/2) } label: { Image(systemName:"minus.magnifyingglass") }.buttonStyle(.plain).disabled(zoom <= 1).help("Zoom out") - Button { zoom = min(32,zoom*2) } label: { Image(systemName:"plus.magnifyingglass") }.buttonStyle(.plain).disabled(zoom >= 32).help("Zoom in for precise scrubbing") - Menu("\(Int(zoom))×") { ForEach([1.0,2,4,8,16,32],id:\.self) { value in Button("\(Int(value))× zoom") { zoom = value } } }.menuStyle(.borderlessButton).frame(width:34).help("Waveform zoom around the playhead") - Menu { Button("Re-analyse Waveform") { player.reanalyseWaveform() }.disabled(player.duration == 0) - Text(player.waveformLoading ? "Analysing…" : player.waveformFromCache ? "Loaded saved waveform" : player.waveformSaved ? "Analysis saved" : "No saved analysis") - } label: { Image(systemName:"waveform") }.menuStyle(.borderlessButton).frame(width:20).help("Waveform cache and re-analysis") - Button("EQ / TONE") { mixer.toggle() }.buttonStyle(.plain).foregroundStyle(.white.opacity(0.85)) - .padding(.horizontal,6).padding(.vertical,2).background(.white.opacity(0.08),in:RoundedRectangle(cornerRadius:3)) - .popover(isPresented:$mixer) { ToneMixerView(player:player) } - Text("\(clock(player.time)) / \(clock(player.duration))").monospacedDigit().padding(.leading,5) - }.font(.system(size:9,weight:.medium)).foregroundStyle(Color(white:0.6)) - }.padding(.horizontal,12).padding(.vertical,9).frame(maxWidth:.infinity).frame(height:120) - .background(Color(red:0.025,green:0.028,blue:0.035)).overlay(Rectangle().strokeBorder(Color(white:0.24),lineWidth:1)) - } -} -private struct ToneKnob: View { - let title: String - @Binding var value: Double - let range: ClosedRange - var filter = false - @State private var initial: Double? - private var fraction: Double { min(1,max(0,(value-range.lowerBound)/(range.upperBound-range.lowerBound))) } - private var display: String { - if filter { return abs(value) < 0.01 ? "OFF" : value < 0 ? "LOW PASS" : "HIGH PASS" } - return String(format:"%+.1f dB",value) - } - var body: some View { - VStack(spacing:4) { - ZStack { - Circle().trim(from:0,to:0.75).stroke(Color(white:0.21),style:StrokeStyle(lineWidth:4,lineCap:.round)).rotationEffect(.degrees(135)) - Circle().trim(from:0,to:0.75*fraction).stroke(Color(white:0.48),style:StrokeStyle(lineWidth:3,lineCap:.round)).rotationEffect(.degrees(135)) - Circle().fill(LinearGradient(colors:[Color(white:0.19),Color(white:0.09)],startPoint:.top,endPoint:.bottom)).padding(6).overlay(Circle().stroke(.black.opacity(0.65),lineWidth:1.5).padding(6)) - Capsule().fill(.white).frame(width:2,height:12).offset(y:-13).rotationEffect(.degrees(-135+270*fraction)) - }.frame(width:50,height:50).contentShape(Circle()) - .gesture(DragGesture(minimumDistance:0).onChanged { gesture in - if initial == nil { initial = value } - value = min(range.upperBound,max(range.lowerBound,(initial ?? value)-Double(gesture.translation.height)/130*(range.upperBound-range.lowerBound))) - }.onEnded { _ in initial = nil }) - .simultaneousGesture(TapGesture(count:2).onEnded { value = 0 }) - .accessibilityElement().accessibilityLabel(title).accessibilityValue(display) - .accessibilityAdjustableAction { direction in - let change = (range.upperBound-range.lowerBound)/24 - value = min(range.upperBound,max(range.lowerBound,value+(direction == .increment ? change : -change))) - }.help("Drag up/down to adjust. Double-click to reset.") - Text(title).font(.system(size:10,weight:.bold)).foregroundStyle(Color(white:0.6)) - Text(display).font(.system(size:8,design:.monospaced)).foregroundStyle(Color(white:0.45)) - } - } -} -private struct StereoMeter: View { - @ObservedObject var player: Player - private func normal(_ level: Float) -> Double { max(0,min(1,(20*log10(Double(max(level,0.000001)))+60)/60)) } - var body: some View { - HStack(spacing:3) { - ForEach(0..<2) { channel in - VStack(spacing:2) { - ForEach((0..<24).reversed(),id:\.self) { segment in - let on = Double(segment)/24 < normal(channel == 0 ? player.leftLevel : player.rightLevel) - Rectangle().fill(on ? (segment > 21 ? Color.red : segment > 17 ? Color.yellow : Color.green) : Color.black.opacity(0.5)) - } - } - } - }.frame(width:23,height:125).accessibilityLabel("Stereo output levels") - } -} -private struct MixerFader: View { - @Binding var value: Double - var body: some View { - GeometryReader { geometry in - let travel = geometry.size.height-22 - ZStack(alignment:.top) { - VStack { ForEach(0..<7) { _ in Rectangle().fill(.white.opacity(0.09)).frame(height:1);Spacer(minLength:0) } }.padding(.vertical,11) - Capsule().fill(.black.opacity(0.8)).frame(width:5).padding(.vertical,8) - RoundedRectangle(cornerRadius:5).fill(LinearGradient(colors:[Color(white:0.45),Color(white:0.23)],startPoint:.top,endPoint:.bottom)) - .frame(width:45,height:20).overlay(Rectangle().fill(.white.opacity(0.15)).frame(width:18,height:1)) - .offset(y:(1-value)*travel) - }.frame(maxWidth:.infinity).contentShape(Rectangle()) - .gesture(DragGesture(minimumDistance:0).onChanged { value = min(1,max(0,1-Double(($0.location.y-11)/travel))) }) - }.frame(width:56,height:135).accessibilityLabel("Master volume").accessibilityValue("\(Int(value*100)) percent") - .accessibilityAdjustableAction { direction in value = min(1,max(0,value+(direction == .increment ? 0.05 : -0.05))) } - } -} -private struct ToneMixerView: View { - @ObservedObject var player: Player - var body: some View { - VStack(spacing:14) { - HStack { Text("TONE / MIXER").font(.system(size:12,weight:.bold));Spacer();Toggle("EQ",isOn:$player.toneEnabled).toggleStyle(.switch).controlSize(.mini) } - HStack(alignment:.top,spacing:28) { - VStack(spacing:8) { - ToneKnob(title:"HIGH",value:$player.highGain,range:-12...12) - ToneKnob(title:"MID",value:$player.midGain,range:-12...12) - ToneKnob(title:"LOW",value:$player.lowGain,range:-12...12) - } - VStack(spacing:15) { - ToneKnob(title:"FILTER",value:$player.filter,range:-1...1,filter:true) - HStack(spacing:20) { StereoMeter(player:player);MixerFader(value:$player.volume) } - Text(player.volume <= 0 ? "−∞ dB" : String(format:"%+.1f dB",20*log10(player.volume))).font(.system(size:10,design:.monospaced)).foregroundStyle(.secondary) - } - }.padding(.horizontal,15) - HStack { Text("Drag knobs · Double-click to reset").font(.system(size:9)).foregroundStyle(.secondary);Spacer();Button("Reset EQ") { player.resetTone() }.controlSize(.small) } - }.padding(18).frame(width:270).background(Color(white:0.105)).preferredColorScheme(.dark) - } -} -private struct PlaybackSettings: View { - @ObservedObject var player: Player - @ObservedObject var model: AppModel - let selectedSong: Int64? - @State private var personalRating = 0 - var body: some View { - HStack(spacing:10) { - Text("Key") - Picker("Key",selection:$player.pitch) { ForEach(-12..<13) { Text(String(format:"%+d",$0)).tag(Double($0)) } }.labelsHidden().frame(width:70) - Text("Tempo") - Slider(value:$player.tempo,in:0.5...1.5,step:0.05).frame(width:85) - Text(String(format:"%.0f%%",player.tempo*100)).monospacedDigit().frame(width:40) - Text("Rating") - GoldRating(rating:$personalRating).frame(width:88).help("Singer-specific song rating") - Button("Save for Singer") { - if let song = player.currentSongID ?? selectedSong { model.savePreference(song:song,value:.init(pitch:player.pitch,tempo:player.tempo,rating:personalRating)) } - }.disabled(model.selectedSinger == nil || (player.currentSongID == nil && selectedSong == nil)) - Menu { - Button("Reset key / tempo") { player.pitch = 0; player.tempo = 1 } - ForEach([-1.0,-0.5,0,0.5,1.0],id:\.self) { offset in Button(String(format:"Graphics offset %+.1fs",offset)) { player.graphicsOffset = offset } } - } label: { Image(systemName:"slider.horizontal.3") }.menuStyle(.borderlessButton).frame(width:22).help("Playback settings") - }.font(.system(size:11)) - .onChange(of:model.selectedSinger) { _ in loadRating() } - .onChange(of:player.currentSongID) { _ in loadRating() } - .onChange(of:selectedSong) { _ in loadRating() } - } - private func loadRating() { if let song = player.currentSongID ?? selectedSong { personalRating = model.preference(song).rating } else { personalRating = 0 } } -} -private struct SeekBar: View { - @ObservedObject var player: Player - private func clock(_ seconds: Double) -> String { let n = Int(seconds); return String(format: "%d:%02d", n / 60, n % 60) } - var body: some View { - HStack(spacing: 10) { - Text(clock(player.time)) - Slider(value: Binding(get: { player.time }, set: { player.seek($0) }), in: 0...max(1, player.duration)) - .controlSize(.mini).tint(.gray).disabled(player.duration == 0).accessibilityLabel("Playback position") - Text(clock(player.duration)) - }.font(.system(size: 10, design: .monospaced)).foregroundStyle(.white.opacity(0.65)) - } -} -private struct RepeatButton: View { - @ObservedObject var player: Player - var body: some View { - Button { player.repeating.toggle() } label: { - Image(systemName: "repeat").font(.system(size: 18, weight: .semibold)) - .foregroundStyle(player.repeating ? Color.blue : Color(white: 0.25)).frame(width: 32, height: 24) - }.help(player.repeating ? "Repeat song: on" : "Repeat song: off").accessibilityLabel("Repeat song").accessibilityValue(player.repeating ? "On" : "Off") - } -} diff --git a/backups/before-kjmix-20261103-100337/KJamsClone/Library.swift b/backups/before-kjmix-20261103-100337/KJamsClone/Library.swift deleted file mode 100644 index ce3d2e4..0000000 --- a/backups/before-kjmix-20261103-100337/KJamsClone/Library.swift +++ /dev/null @@ -1,348 +0,0 @@ -import Foundation -import SQLite3 - -struct Song: Identifiable, Hashable { - var id: Int64 - var title: String - var audio: String - var cdg: String? - var rating: Int - var plays: Int - var artist: String = "" - var album: String = "" - var label: String = "" - var duration: Double = 0 -} -struct MusicStore: Identifiable, Hashable { - var id: Int64 - var name: String - var url: String - var searchTemplate: String - func destination(query: String = "") throws -> URL { - let query = query.trimmingCharacters(in:.whitespacesAndNewlines) - let encoded = query.addingPercentEncoding(withAllowedCharacters:CharacterSet(charactersIn:"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~")) ?? "" - let value = query.isEmpty || searchTemplate.isEmpty ? url : searchTemplate.replacingOccurrences(of:"{query}",with:encoded) - guard let result = URL(string:value), ["http","https"].contains(result.scheme?.lowercased() ?? ""), result.host?.isEmpty == false, result.user == nil, result.password == nil else { throw LibraryError.message("Use a valid http:// or https:// store URL without credentials") } - return result - } -} -struct PersonPlace: Identifiable, Hashable { var id: Int64; var name: String } -struct SongPreference: Equatable { - var pitch: Double = 0 - var tempo: Double = 1 - var rating: Int = 0 -} -struct Performance: Identifiable { - var id: Int64 - var song: String - var singer: String - var venue: String - var date: String - var singerID: Int64? - var songID: Int64? -} -struct QueueEntry: Identifiable { - var id: Int64 - var songID: Int64 - var singerID: Int64? - var title: String - var singer: String -} -enum LibraryError: LocalizedError { - case message(String) - var errorDescription: String? { if case .message(let s) = self { return s }; return nil } -} -final class Library { - private var db: OpaquePointer? - init(url: URL) throws { - guard sqlite3_open(url.path, &db) == SQLITE_OK else { throw LibraryError.message("Cannot open library") } - try execute("PRAGMA foreign_keys=ON") - try execute("CREATE TABLE IF NOT EXISTS songs(id INTEGER PRIMARY KEY,title TEXT NOT NULL,audio TEXT UNIQUE NOT NULL,cdg TEXT,rating INTEGER NOT NULL DEFAULT 0 CHECK(rating BETWEEN 0 AND 5),plays INTEGER NOT NULL DEFAULT 0)") - try execute("CREATE TABLE IF NOT EXISTS singers(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS venues(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS history(id INTEGER PRIMARY KEY,song INTEGER REFERENCES songs(id),singer INTEGER REFERENCES singers(id),venue INTEGER REFERENCES venues(id),played TEXT DEFAULT CURRENT_TIMESTAMP)") - // Additive migration: preserve older libraries and infer existing memberships from history. - for column in ["artist", "album", "label"] { - if try !columns("songs").contains(column) { try execute("ALTER TABLE songs ADD COLUMN \(column) TEXT NOT NULL DEFAULT ''") } - } - try execute("CREATE TABLE IF NOT EXISTS venue_singers(venue INTEGER NOT NULL REFERENCES venues(id) ON DELETE CASCADE,singer INTEGER NOT NULL REFERENCES singers(id) ON DELETE CASCADE,PRIMARY KEY(venue,singer))") - if try schemaVersion() < 3 { try execute("INSERT OR IGNORE INTO venue_singers SELECT DISTINCT venue,singer FROM history WHERE venue IS NOT NULL AND singer IS NOT NULL") } - try execute("CREATE TABLE IF NOT EXISTS settings(key TEXT PRIMARY KEY,value TEXT)") - try execute("CREATE TABLE IF NOT EXISTS preferences(song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,singer INTEGER NOT NULL REFERENCES singers(id) ON DELETE CASCADE,pitch REAL NOT NULL DEFAULT 0 CHECK(pitch BETWEEN -12 AND 12),tempo REAL NOT NULL DEFAULT 1 CHECK(tempo BETWEEN 0.5 AND 1.5),rating INTEGER NOT NULL DEFAULT 0 CHECK(rating BETWEEN 0 AND 5),PRIMARY KEY(song,singer))") - try execute("CREATE TABLE IF NOT EXISTS queue(id INTEGER PRIMARY KEY,venue INTEGER REFERENCES venues(id) ON DELETE CASCADE,song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,singer INTEGER REFERENCES singers(id) ON DELETE CASCADE,position INTEGER NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS playlists(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS playlist_songs(playlist INTEGER NOT NULL REFERENCES playlists(id) ON DELETE CASCADE,song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,position INTEGER NOT NULL,PRIMARY KEY(playlist,song))") - try execute("CREATE TABLE IF NOT EXISTS singer_songs(singer INTEGER NOT NULL REFERENCES singers(id) ON DELETE CASCADE,song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,position INTEGER NOT NULL,PRIMARY KEY(singer,song))") - if try schemaVersion() < 4 { - try execute("INSERT OR IGNORE INTO singer_songs(singer,song,position) SELECT singer,song,MIN(id) FROM history WHERE singer IS NOT NULL AND song IS NOT NULL GROUP BY singer,song") - try execute("INSERT OR IGNORE INTO singer_songs(singer,song,position) SELECT singer,song,0 FROM preferences") - } - if try !columns("songs").contains("duration") { try execute("ALTER TABLE songs ADD COLUMN duration REAL NOT NULL DEFAULT 0") } - if try !columns("singer_songs").contains("favourite") { try execute("ALTER TABLE singer_songs ADD COLUMN favourite INTEGER NOT NULL DEFAULT 0 CHECK(favourite IN (0,1))") } - if try schemaVersion() < 5 { try execute("UPDATE singer_songs SET favourite=1 WHERE EXISTS(SELECT 1 FROM preferences WHERE preferences.singer=singer_songs.singer AND preferences.song=singer_songs.song AND preferences.rating>=4)") } - try execute("CREATE TABLE IF NOT EXISTS song_settings(song INTEGER PRIMARY KEY REFERENCES songs(id) ON DELETE CASCADE,pitch REAL NOT NULL DEFAULT 0 CHECK(pitch BETWEEN -12 AND 12),tempo REAL NOT NULL DEFAULT 1 CHECK(tempo BETWEEN 0.5 AND 1.5))") - try execute("CREATE TABLE IF NOT EXISTS music_stores(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL,url TEXT NOT NULL,search_template TEXT NOT NULL DEFAULT '')") - if try !columns("songs").contains("metadata_edited") { try execute("ALTER TABLE songs ADD COLUMN metadata_edited INTEGER NOT NULL DEFAULT 0") } - try execute("CREATE TABLE IF NOT EXISTS singer_tonight(venue INTEGER NOT NULL,singer INTEGER NOT NULL,song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,position INTEGER NOT NULL,PRIMARY KEY(venue,singer,song),FOREIGN KEY(venue,singer) REFERENCES venue_singers(venue,singer) ON DELETE CASCADE)") - if try schemaVersion() < 7 { - try execute("INSERT OR IGNORE INTO singer_tonight(venue,singer,song,position) SELECT queue.venue,queue.singer,queue.song,MIN(queue.position) FROM queue JOIN venue_singers ON venue_singers.venue=queue.venue AND venue_singers.singer=queue.singer WHERE queue.singer IS NOT NULL GROUP BY queue.venue,queue.singer,queue.song") - } - try execute("PRAGMA user_version=7") - } - deinit { sqlite3_close(db) } - private func statement(_ sql: String, _ values: [String?]) throws -> OpaquePointer { - var s: OpaquePointer? - guard sqlite3_prepare_v2(db, sql, -1, &s, nil) == SQLITE_OK, let s else { throw error() } - for (i,v) in values.enumerated() { - let code = v.map { sqlite3_bind_text(s, Int32(i + 1), $0, -1, unsafeBitCast(-1, to: sqlite3_destructor_type.self)) } ?? sqlite3_bind_null(s, Int32(i + 1)) - if code != SQLITE_OK { sqlite3_finalize(s); throw error() } - } - return s - } - private func error() -> LibraryError { .message(String(cString: sqlite3_errmsg(db))) } - func execute(_ sql: String, _ values: [String?] = []) throws { - let s = try statement(sql, values); defer { sqlite3_finalize(s) } - guard sqlite3_step(s) == SQLITE_DONE else { throw error() } - } - func songs() throws -> [Song] { - let s = try statement("SELECT id,title,audio,cdg,rating,plays,artist,album,label,duration FROM songs ORDER BY title COLLATE NOCASE", []); defer { sqlite3_finalize(s) } - var result = [Song]() - while true { - let code = sqlite3_step(s); if code == SQLITE_DONE { break }; guard code == SQLITE_ROW else { throw error() } - result.append(Song(id: sqlite3_column_int64(s,0), title: String(cString: sqlite3_column_text(s,1)), audio: String(cString: sqlite3_column_text(s,2)), cdg: sqlite3_column_text(s,3).map { String(cString:$0) }, rating: Int(sqlite3_column_int(s,4)), plays: Int(sqlite3_column_int(s,5)), artist: text(s,6), album: text(s,7), label: text(s,8),duration:sqlite3_column_double(s,9))) - } - return result - } - func add(title: String, audio: String, cdg: String?, artist: String = "", album: String = "", label: String = "", duration: Double = 0) throws { - try execute("INSERT INTO songs(title,audio,cdg,artist,album,label,duration) VALUES(?,?,?,?,?,?,?) ON CONFLICT(audio) DO UPDATE SET cdg=COALESCE(excluded.cdg,songs.cdg),artist=CASE WHEN songs.metadata_edited=0 AND excluded.artist!='' THEN excluded.artist ELSE songs.artist END,album=CASE WHEN songs.metadata_edited=0 AND excluded.album!='' THEN excluded.album ELSE songs.album END,label=CASE WHEN songs.metadata_edited=0 AND excluded.label!='' THEN excluded.label ELSE songs.label END,duration=CASE WHEN excluded.duration>0 THEN excluded.duration ELSE songs.duration END", [title,audio,cdg,artist,album,label,String(duration)]) - } - func rate(_ id: Int64, _ rating: Int) throws { try execute("UPDATE songs SET rating=? WHERE id=?", [String(rating),String(id)]) } - func entities(_ table: String) throws -> [PersonPlace] { - precondition(["singers","venues","playlists"].contains(table)) - let s = try statement("SELECT id,name FROM \(table) ORDER BY name", []); defer { sqlite3_finalize(s) } - var rows = [PersonPlace]() - while sqlite3_step(s) == SQLITE_ROW { rows.append(.init(id: sqlite3_column_int64(s,0), name: String(cString: sqlite3_column_text(s,1)))) } - return rows - } - func addEntity(_ table: String, name: String) throws { - precondition(["singers","venues","playlists"].contains(table)) - let name = name.trimmingCharacters(in: .whitespacesAndNewlines) - guard !name.isEmpty else { throw LibraryError.message("Enter a name") } - try execute("INSERT OR IGNORE INTO \(table)(name) VALUES(?)", [name]) - } - func record(_ song: Int64, singer: Int64?, venue: Int64?) throws { - try execute("BEGIN IMMEDIATE") - do { - if let singer { try assignSong(song,singer:singer) } - try execute("INSERT INTO history(song,singer,venue) VALUES(?,?,?)", [String(song),singer.map(String.init),venue.map(String.init)]) - try execute("UPDATE songs SET plays=plays+1 WHERE id=?", [String(song)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK"); throw error } - } - - private func text(_ s: OpaquePointer, _ index: Int32) -> String { sqlite3_column_text(s,index).map { String(cString:$0) } ?? "" } - private func schemaVersion() throws -> Int { - let s = try statement("PRAGMA user_version",[]); defer { sqlite3_finalize(s) } - return sqlite3_step(s) == SQLITE_ROW ? Int(sqlite3_column_int(s,0)) : 0 - } - private func columns(_ table: String) throws -> Set { - let s = try statement("PRAGMA table_info(\(table))", []); defer { sqlite3_finalize(s) } - var result = Set(); while sqlite3_step(s) == SQLITE_ROW { result.insert(text(s,1)) }; return result - } - func members(of venue: Int64) throws -> [PersonPlace] { - let s = try statement("SELECT singers.id,singers.name FROM singers JOIN venue_singers ON singers.id=venue_singers.singer WHERE venue=? ORDER BY name", [String(venue)]); defer { sqlite3_finalize(s) } - var result = [PersonPlace](); while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),name:text(s,1))) }; return result - } - func setMembership(singer: Int64, venue: Int64, included: Bool) throws { - try execute(included ? "INSERT OR IGNORE INTO venue_singers(venue,singer) VALUES(?,?)" : "DELETE FROM venue_singers WHERE venue=? AND singer=?", [String(venue),String(singer)]) - if !included { try execute("DELETE FROM queue WHERE venue=? AND singer=?",[String(venue),String(singer)]) } - } - func currentVenue() throws -> Int64? { - let s = try statement("SELECT venues.id FROM venues JOIN settings ON CAST(settings.value AS INTEGER)=venues.id WHERE settings.key='currentVenue'", []); defer { sqlite3_finalize(s) } - return sqlite3_step(s) == SQLITE_ROW ? sqlite3_column_int64(s,0) : nil - } - func selectVenue(_ id: Int64?) throws { - if let id { - guard try entities("venues").contains(where: { $0.id == id }) else { throw LibraryError.message("Venue no longer exists") } - } - try execute("INSERT INTO settings(key,value) VALUES('currentVenue',?) ON CONFLICT(key) DO UPDATE SET value=excluded.value",[id.map(String.init)]) - } - func rename(_ table: String, id: Int64, name: String) throws { - precondition(["singers","venues","playlists"].contains(table)) - let name = name.trimmingCharacters(in:.whitespacesAndNewlines) - guard !name.isEmpty else { throw LibraryError.message("Enter a name") } - try execute("UPDATE \(table) SET name=? WHERE id=?",[name,String(id)]) - } - func deleteEntity(_ table: String, id: Int64) throws { - precondition(["singers","venues","playlists"].contains(table)) - try execute("BEGIN IMMEDIATE") - do { - if table == "singers" { try execute("UPDATE history SET singer=NULL WHERE singer=?",[String(id)]) } - if table == "venues" { - try execute("UPDATE history SET venue=NULL WHERE venue=?",[String(id)]) - try execute("DELETE FROM settings WHERE key='currentVenue' AND value=?",[String(id)]) - } - try execute("DELETE FROM \(table) WHERE id=?",[String(id)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK"); throw error } - } - func preference(song: Int64, singer: Int64) throws -> SongPreference { - let s = try statement("SELECT pitch,tempo,rating FROM preferences WHERE song=? AND singer=?",[String(song),String(singer)]); defer { sqlite3_finalize(s) } - guard sqlite3_step(s) == SQLITE_ROW else { return try defaultPreference(song:song) } - return .init(pitch:sqlite3_column_double(s,0),tempo:sqlite3_column_double(s,1),rating:Int(sqlite3_column_int(s,2))) - } - func savePreference(song: Int64, singer: Int64, value: SongPreference) throws { - try execute("INSERT INTO preferences(song,singer,pitch,tempo,rating) VALUES(?,?,?,?,?) ON CONFLICT(song,singer) DO UPDATE SET pitch=excluded.pitch,tempo=excluded.tempo,rating=excluded.rating",[String(song),String(singer),String(value.pitch),String(value.tempo),String(value.rating)]) - } - func history(venue: Int64?, singer: Int64? = nil) throws -> [Performance] { - let s = try statement("SELECT history.id,COALESCE(songs.title,'Deleted song'),COALESCE(singers.name,'—'),COALESCE(venues.name,'—'),played,history.singer,history.song FROM history LEFT JOIN songs ON songs.id=history.song LEFT JOIN singers ON singers.id=history.singer LEFT JOIN venues ON venues.id=history.venue WHERE (? IS NULL OR history.venue=?) AND (? IS NULL OR history.singer=?) ORDER BY history.id DESC",[venue.map(String.init),venue.map(String.init),singer.map(String.init),singer.map(String.init)]); defer { sqlite3_finalize(s) } - var result = [Performance](); while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),song:text(s,1),singer:text(s,2),venue:text(s,3),date:text(s,4),singerID:sqlite3_column_type(s,5) == SQLITE_NULL ? nil : sqlite3_column_int64(s,5),songID:sqlite3_column_type(s,6) == SQLITE_NULL ? nil : sqlite3_column_int64(s,6))) }; return result - } - func enqueue(song: Int64, singer: Int64?, venue: Int64?) throws { - guard let venue else { throw LibraryError.message("Select a current venue before adding to its queue") } - if let singer, try !members(of:venue).contains(where: { $0.id == singer }) { throw LibraryError.message("Add this singer to the current venue first") } - try execute("BEGIN IMMEDIATE") - do { - if let singer { - try assignSong(song,singer:singer) - try execute("INSERT OR IGNORE INTO singer_tonight(venue,singer,song,position) VALUES(?,?,?,(SELECT COALESCE(MAX(position),0)+1 FROM singer_tonight WHERE venue=? AND singer=?))",[String(venue),String(singer),String(song),String(venue),String(singer)]) - } - try execute("INSERT INTO queue(venue,song,singer,position) VALUES(?,?,?,(SELECT COALESCE(MAX(position),0)+1 FROM queue WHERE venue=?))",[String(venue),String(song),singer.map(String.init),String(venue)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK");throw error } - } - func queue(venue: Int64?) throws -> [QueueEntry] { - guard let venue else { return [] } - let s = try statement("SELECT queue.id,queue.song,queue.singer,songs.title,COALESCE(singers.name,'No singer') FROM queue JOIN songs ON songs.id=queue.song LEFT JOIN singers ON singers.id=queue.singer WHERE queue.venue=? ORDER BY queue.position,queue.id",[String(venue)]); defer { sqlite3_finalize(s) } - var result = [QueueEntry](); while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),songID:sqlite3_column_int64(s,1),singerID:sqlite3_column_type(s,2) == SQLITE_NULL ? nil : sqlite3_column_int64(s,2),title:text(s,3),singer:text(s,4))) }; return result - } - func removeQueue(_ id: Int64) throws { try execute("DELETE FROM queue WHERE id=?",[String(id)]) } - func moveQueue(_ id: Int64, venue: Int64, by offset: Int) throws { - var rows = try queue(venue:venue) - guard let index = rows.firstIndex(where: { $0.id == id }), rows.indices.contains(index+offset) else { return } - rows.swapAt(index,index+offset) - try execute("BEGIN IMMEDIATE") - do { for (i,row) in rows.enumerated() { try execute("UPDATE queue SET position=? WHERE id=?",[String(i),String(row.id)]) }; try execute("COMMIT") } - catch { try? execute("ROLLBACK"); throw error } - } - func addToPlaylist(_ playlist: Int64, song: Int64) throws { - try execute("INSERT OR IGNORE INTO playlist_songs(playlist,song,position) VALUES(?,?,(SELECT COALESCE(MAX(position),0)+1 FROM playlist_songs WHERE playlist=?))",[String(playlist),String(song),String(playlist)]) - } - func playlistSongIDs(_ playlist: Int64) throws -> [Int64] { - let s = try statement("SELECT song FROM playlist_songs WHERE playlist=? ORDER BY position",[String(playlist)]); defer { sqlite3_finalize(s) } - var ids = [Int64](); while sqlite3_step(s) == SQLITE_ROW { ids.append(sqlite3_column_int64(s,0)) }; return ids - } - func removeFromPlaylist(_ playlist: Int64, song: Int64) throws { try execute("DELETE FROM playlist_songs WHERE playlist=? AND song=?",[String(playlist),String(song)]) } - func assignSong(_ song: Int64, singer: Int64) throws { - try execute("INSERT OR IGNORE INTO singer_songs(singer,song,position) VALUES(?,?,(SELECT COALESCE(MAX(position),0)+1 FROM singer_songs WHERE singer=?))",[String(singer),String(song),String(singer)]) - } - func removeSingerSong(_ song: Int64, singer: Int64) throws { - try execute("DELETE FROM singer_songs WHERE singer=? AND song=?",[String(singer),String(song)]) - } - func singerSongIDs() throws -> [Int64:[Int64]] { - let s = try statement("SELECT singer,song FROM singer_songs ORDER BY singer,position,song",[]); defer { sqlite3_finalize(s) } - var result = [Int64:[Int64]]() - while sqlite3_step(s) == SQLITE_ROW { result[sqlite3_column_int64(s,0),default:[]].append(sqlite3_column_int64(s,1)) } - return result - } - func defaultPreference(song: Int64) throws -> SongPreference { - let s = try statement("SELECT pitch,tempo FROM song_settings WHERE song=?",[String(song)]);defer { sqlite3_finalize(s) } - guard sqlite3_step(s) == SQLITE_ROW else { return .init() } - return .init(pitch:sqlite3_column_double(s,0),tempo:sqlite3_column_double(s,1),rating:0) - } - func saveDefaultPreference(song: Int64, value: SongPreference) throws { - try execute("INSERT INTO song_settings(song,pitch,tempo) VALUES(?,?,?) ON CONFLICT(song) DO UPDATE SET pitch=excluded.pitch,tempo=excluded.tempo",[String(song),String(value.pitch),String(value.tempo)]) - } - func updateDuration(_ song: Int64, seconds: Double) throws { - guard seconds.isFinite && seconds >= 0 else { return } - try execute("UPDATE songs SET duration=? WHERE id=?",[String(seconds),String(song)]) - } - func setFavourite(song: Int64, singer: Int64, included: Bool) throws { - if included { try assignSong(song,singer:singer) } - try execute("UPDATE singer_songs SET favourite=? WHERE singer=? AND song=?",[included ? "1" : "0",String(singer),String(song)]) - } - func favouriteSongIDs() throws -> [Int64:Set] { - let s = try statement("SELECT singer,song FROM singer_songs WHERE favourite=1",[]);defer { sqlite3_finalize(s) } - var result = [Int64:Set]() - while sqlite3_step(s) == SQLITE_ROW { result[sqlite3_column_int64(s,0),default:[]].insert(sqlite3_column_int64(s,1)) };return result - } - func stores() throws -> [MusicStore] { - let s = try statement("SELECT id,name,url,search_template FROM music_stores ORDER BY name",[]);defer { sqlite3_finalize(s) } - var result = [MusicStore]() - while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),name:text(s,1),url:text(s,2),searchTemplate:text(s,3))) };return result - } - func saveStore(_ store: MusicStore) throws { - let name = store.name.trimmingCharacters(in:.whitespacesAndNewlines),url = store.url.trimmingCharacters(in:.whitespacesAndNewlines),search = store.searchTemplate.trimmingCharacters(in:.whitespacesAndNewlines) - guard !name.isEmpty else { throw LibraryError.message("Enter a store name") } - let cleaned = MusicStore(id:store.id,name:name,url:url,searchTemplate:search) - _ = try cleaned.destination() - if !search.isEmpty { - guard search.contains("{query}") else { throw LibraryError.message("Search URL must contain {query}") } - _ = try cleaned.destination(query:"test") - } - if store.id == 0 { try execute("INSERT INTO music_stores(name,url,search_template) VALUES(?,?,?)",[name,url,search]) } - else { try execute("UPDATE music_stores SET name=?,url=?,search_template=? WHERE id=?",[name,url,search,String(store.id)]) } - } - func deleteStore(_ id: Int64) throws { try execute("DELETE FROM music_stores WHERE id=?",[String(id)]) } - func updateMetadata(song: Int64,title: String,artist: String,album: String,label: String,rating: Int) throws { - let title = title.trimmingCharacters(in:.whitespacesAndNewlines) - guard !title.isEmpty else { throw LibraryError.message("Song title cannot be empty") } - try execute("UPDATE songs SET title=?,artist=?,album=?,label=?,rating=?,metadata_edited=1 WHERE id=?",[title,artist.trimmingCharacters(in:.whitespacesAndNewlines),album.trimmingCharacters(in:.whitespacesAndNewlines),label.trimmingCharacters(in:.whitespacesAndNewlines),String(rating),String(song)]) - guard sqlite3_changes(db) == 1 else { throw LibraryError.message("Song no longer exists") } - } - func tonightSongIDs(venue: Int64?) throws -> [Int64:[Int64]] { - guard let venue else { return [:] } - let s = try statement("SELECT singer,song FROM singer_tonight WHERE venue=? ORDER BY position,song",[String(venue)]);defer { sqlite3_finalize(s) } - var result = [Int64:[Int64]]() - while sqlite3_step(s) == SQLITE_ROW { result[sqlite3_column_int64(s,0),default:[]].append(sqlite3_column_int64(s,1)) };return result - } - func addTonight(song: Int64,singer: Int64,venue: Int64) throws { - guard try members(of:venue).contains(where:{ $0.id == singer }) else { throw LibraryError.message("This singer is not a member of the current venue") } - try execute("BEGIN IMMEDIATE") - do { - try assignSong(song,singer:singer) - try execute("INSERT OR IGNORE INTO singer_tonight(venue,singer,song,position) VALUES(?,?,?,(SELECT COALESCE(MAX(position),0)+1 FROM singer_tonight WHERE venue=? AND singer=?))",[String(venue),String(singer),String(song),String(venue),String(singer)]) - try execute("INSERT INTO queue(venue,song,singer,position) SELECT ?,?,?,(SELECT COALESCE(MAX(position),0)+1 FROM queue WHERE venue=?) WHERE NOT EXISTS(SELECT 1 FROM queue WHERE venue=? AND singer=? AND song=?)",[String(venue),String(song),String(singer),String(venue),String(venue),String(singer),String(song)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK");throw error } - } - func removeTonight(song: Int64,singer: Int64,venue: Int64) throws { - try execute("BEGIN IMMEDIATE") - do { - try execute("DELETE FROM singer_tonight WHERE venue=? AND singer=? AND song=?",[String(venue),String(singer),String(song)]) - try execute("DELETE FROM queue WHERE venue=? AND singer=? AND song=?",[String(venue),String(singer),String(song)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK");throw error } - } - /// Atomically adds/copies or reorders a request, retaining other singers' queue slots. - func placeTonight(song: Int64,singer: Int64,venue: Int64,before: Int64?,addIfNeeded: Bool) throws { - guard try members(of:venue).contains(where:{ $0.id == singer }) else { throw LibraryError.message("This singer is not in the target venue") } - try execute("BEGIN IMMEDIATE") - do { - var ids = try tonightSongIDs(venue:venue)[singer] ?? [] - if let before, !ids.contains(before) { throw LibraryError.message("The drop target changed. Please drop again.") } - if !ids.contains(song) && !addIfNeeded { throw LibraryError.message("This Tonight request no longer exists") } - if addIfNeeded { - try assignSong(song,singer:singer) - try execute("INSERT OR IGNORE INTO singer_tonight(venue,singer,song,position) VALUES(?,?,?,0)",[String(venue),String(singer),String(song)]) - try execute("INSERT INTO queue(venue,song,singer,position) SELECT ?,?,?,(SELECT COALESCE(MAX(position),0)+1 FROM queue WHERE venue=?) WHERE NOT EXISTS(SELECT 1 FROM queue WHERE venue=? AND singer=? AND song=?)",[String(venue),String(song),String(singer),String(venue),String(venue),String(singer),String(song)]) - } - if before != song { - ids.removeAll { $0 == song } - if let before,let index = ids.firstIndex(of:before) { ids.insert(song,at:index) } else { ids.append(song) } - } - for (index,id) in ids.enumerated() { try execute("UPDATE singer_tonight SET position=? WHERE venue=? AND singer=? AND song=?",[String(index),String(venue),String(singer),String(id)]) } - let all = try queue(venue:venue) - let slots = all.indices.filter { all[$0].singerID == singer } - let rank = Dictionary(uniqueKeysWithValues:ids.enumerated().map { ($0.element,$0.offset) }) - let requests = slots.enumerated().map { (original:$0.offset,row:all[$0.element]) }.sorted { - let a = rank[$0.row.songID] ?? Int.max,b = rank[$1.row.songID] ?? Int.max - return a == b ? $0.original < $1.original : a < b - } - var ordered = all - for (slot,request) in zip(slots,requests) { ordered[slot] = request.row } - for (index,row) in ordered.enumerated() { try execute("UPDATE queue SET position=? WHERE id=?",[String(index),String(row.id)]) } - try execute("COMMIT") - } catch { try? execute("ROLLBACK");throw error } - } -} diff --git a/backups/before-kjmix-20261103-100337/KJamsClone/Player.swift b/backups/before-kjmix-20261103-100337/KJamsClone/Player.swift deleted file mode 100644 index b289215..0000000 --- a/backups/before-kjmix-20261103-100337/KJamsClone/Player.swift +++ /dev/null @@ -1,277 +0,0 @@ -import SwiftUI -import AVFoundation -import CryptoKit - -/// CDG follows consumed source frames, so tempo adjustment preserves graphics timing. -@MainActor final class Player: ObservableObject { - @Published var image: CGImage? - @Published private(set) var waveform = [Float]() - @Published private(set) var waveformBands = [WaveformBands]() - @Published var lowGain: Double = 0 { didSet { updateTone() } } - @Published var midGain: Double = 0 { didSet { updateTone() } } - @Published var highGain: Double = 0 { didSet { updateTone() } } - @Published var filter: Double = 0 { didSet { updateTone() } } - @Published var toneEnabled = true { didSet { updateTone() } } - @Published private(set) var leftLevel: Float = 0 - @Published private(set) var rightLevel: Float = 0 - private let tone = AVAudioUnitEQ(numberOfBands:4) - private let meter = AudioLevelMeter() - private var metering = false - @Published private(set) var waveformLoading = false - @Published private(set) var waveformUnavailable = false - @Published private(set) var waveformFromCache = false - @Published private(set) var waveformSaved = false - private let waveformCacheDirectory: URL - private var audioURL: URL? - private var waveformTask: Task? - private var waveformGeneration = UUID() - @Published var playing = false - @Published var time: Double = 0 - @Published var duration: Double = 0 - @Published var title = "Select a song" - @Published var volume: Double = 0.8 { didSet { engine.mainMixerNode.outputVolume = Float(volume) } } - @Published var repeating = false - @Published var pitch: Double = 0 { didSet { effect.pitch = Float(pitch * 100) } } - @Published var tempo: Double = 1 { didSet { effect.rate = Float(tempo) } } - @Published var graphicsOffset: Double = 0 - private(set) var currentSongID: Int64? - var onFinished: (() -> Void)? - private let engine = AVAudioEngine() - private let node = AVAudioPlayerNode() - private let effect = AVAudioUnitTimePitch() - private var file: AVAudioFile? - private var anchor: Double = 0 - private var generation = UUID() - private var cdg = Data() - private var decoder = CDGDecoder() - private var timer: Timer? - init(waveformCacheDirectory: URL? = nil) { - self.waveformCacheDirectory = waveformCacheDirectory ?? FileManager.default.urls(for:.applicationSupportDirectory,in:.userDomainMask)[0].appendingPathComponent("KJamsClone/Waveforms") - engine.attach(node);engine.attach(effect);engine.attach(tone);updateTone() - } - func reanalyseWaveform() { if let audioURL { analyseWaveform(audioURL,force:true) } } - func resetTone() { lowGain = 0; midGain = 0; highGain = 0; filter = 0; toneEnabled = true } - private func updateTone() { - AudioTone.configure(tone,sampleRate:file?.processingFormat.sampleRate ?? 44100,low:lowGain,mid:midGain,high:highGain,filter:filter,enabled:toneEnabled) - } - func load(_ song: Song, preference: SongPreference = .init()) throws { - stop() - do { - let loaded = try AVAudioFile(forReading:URL(fileURLWithPath:song.audio)) - let graphics = try song.cdg.map { try Data(contentsOf:URL(fileURLWithPath:$0)) } ?? Data() - guard loaded.length > 0 else { throw LibraryError.message("Audio file is empty") } - engine.connect(node,to:effect,format:loaded.processingFormat) - engine.connect(effect,to:tone,format:loaded.processingFormat) - engine.connect(tone,to:engine.mainMixerNode,format:loaded.processingFormat) - file = loaded; cdg = graphics; decoder = CDGDecoder() - duration = Double(loaded.length)/loaded.processingFormat.sampleRate - title = song.title; currentSongID = song.id - pitch = preference.pitch; tempo = preference.tempo - updateTone() - let meter = self.meter - engine.mainMixerNode.installTap(onBus:0,bufferSize:1024,format:nil) { buffer, _ in meter.consume(buffer) } - metering = true - engine.mainMixerNode.outputVolume = Float(volume) - engine.prepare(); try engine.start() - schedule(at:0,play:true); startTimer(); tick() - audioURL = URL(fileURLWithPath:song.audio) - analyseWaveform(audioURL!) - } catch { stop(); throw error } - } - private func analyseWaveform(_ url: URL, force: Bool = false) { - waveformTask?.cancel() - let token = UUID();waveformGeneration = token;waveformLoading = true;waveformUnavailable = false - let directory = waveformCacheDirectory - waveformTask = Task.detached(priority:.utility) { [weak self] in - let result: Result - var cached = false,saved = false - do { - if !force,let analysis = try? WaveformCache.load(audio:url,directory:directory) { - result = .success(analysis);cached = true;saved = true - } else { - let analysis = try AudioWaveform.analyse(url:url,cancelled:{ Task.isCancelled }) - if !Task.isCancelled { saved = (try? WaveformCache.save(analysis,audio:url,directory:directory)) != nil } - result = .success(analysis) - } - } catch { result = .failure(error) } - guard !Task.isCancelled else { return } - let loadedFromCache = cached,analysisSaved = saved - await MainActor.run { [weak self] in - guard let self,self.waveformGeneration == token else { return } - self.waveformLoading = false;self.waveformFromCache = loadedFromCache;self.waveformSaved = analysisSaved - switch result { - case .success(let analysis):self.waveform = analysis.levels;self.waveformBands = analysis.bands - case .failure:self.waveformUnavailable = true - } - } - } - } - private func schedule(at seconds: Double, play: Bool) { - guard let file else { return } - generation = UUID(); let token = generation - node.stop() - let rate = file.processingFormat.sampleRate - let start = min(file.length,max(0,AVAudioFramePosition(seconds*rate))) - anchor = Double(start)/rate; time = anchor - guard start < file.length else { playing = false; render(); return } - node.scheduleSegment(file,startingFrame:start,frameCount:AVAudioFrameCount(min(file.length-start,Int64(UInt32.max))),at:nil,completionCallbackType:.dataPlayedBack) { [weak self] _ in - Task { @MainActor in - guard let self, self.generation == token else { return } - if self.repeating { self.schedule(at:0,play:true) } - else { - self.playing = false; self.time = self.duration; self.render() - self.timer?.invalidate(); self.timer = nil; self.onFinished?() - } - } - } - if play { node.play() }; playing = play; render() - } - private func startTimer() { - timer?.invalidate() - timer = Timer.scheduledTimer(withTimeInterval:1.0/30,repeats:true) { [weak self] _ in Task { @MainActor in self?.tick() } } - } - func toggle() { - guard file != nil else { return } - if playing { tick(); node.pause(); playing = false } - else if time >= duration { schedule(at:0,play:true); startTimer() } - else { node.play(); playing = true; startTimer() } - } - func stop() { - waveformTask?.cancel(); waveformTask = nil; waveformGeneration = UUID() - waveform = [];waveformBands = [];waveformLoading = false;waveformUnavailable = false;waveformFromCache = false;waveformSaved = false;audioURL = nil - generation = UUID(); timer?.invalidate(); timer = nil; node.stop(); engine.stop() - if metering { engine.mainMixerNode.removeTap(onBus:0); metering = false } - meter.reset(); leftLevel = 0; rightLevel = 0 - engine.disconnectNodeOutput(node); engine.disconnectNodeOutput(effect); engine.disconnectNodeOutput(tone) - file = nil; playing = false; time = 0; anchor = 0; duration = 0; image = nil; currentSongID = nil; title = "Select a song" - } - func seek(_ value: Double) { - guard file != nil, value.isFinite else { return } - schedule(at:min(max(value,0),duration),play:playing); startTimer() - } - private func render() { decoder.render(cdg,at:max(0,time+graphicsOffset)); image = cdg.isEmpty ? nil : decoder.image() } - private func tick() { - let levels = meter.snapshot() - leftLevel = playing ? levels.0 : 0; rightLevel = playing ? levels.1 : 0 - if playing, let file, let renderTime = node.lastRenderTime, let playerTime = node.playerTime(forNodeTime:renderTime) { - time = min(duration,max(0,anchor+Double(playerTime.sampleTime)/file.processingFormat.sampleRate)) - } - render() - } -} - -/// Streams fixed-size PCM chunks into a bounded RMS envelope, independent of playback. -/// A separate AVAudioFile keeps analysis away from the player's scheduling/read position. -enum AudioWaveform { - struct Analysis: Codable, Sendable { var levels: [Float]; var bands: [WaveformBands] } - static func read(url: URL, bins: Int = 4096, cancelled: () -> Bool = { false }) throws -> [Float] { - try analyse(url:url,bins:bins,cancelled:cancelled).levels - } - static func analyse(url: URL, bins: Int = 4096, cancelled: () -> Bool = { false }) throws -> Analysis { - guard bins > 0 else { return .init(levels:[],bands:[]) } - let file = try AVAudioFile(forReading: url, commonFormat: .pcmFormatFloat32, interleaved: false) - guard file.length > 0, let buffer = AVAudioPCMBuffer(pcmFormat: file.processingFormat, frameCapacity: 16384) else { return .init(levels:[],bands:[]) } - var energy = [Double](repeating: 0, count: bins) - var counts = [Int](repeating: 0, count: bins) - var position: Int64 = 0 - let channels = Int(file.processingFormat.channelCount) - let rate = file.processingFormat.sampleRate - let lowAlpha = exp(-2*Double.pi*250/rate), highAlpha = exp(-2*Double.pi*2500/rate) - var lowState = [Double](repeating:0,count:channels), highState = lowState - var lows = [Double](repeating:0,count:bins), mids = lows, highs = lows - while position < file.length { - if cancelled() { throw CancellationError() } - try file.read(into: buffer, frameCount: AVAudioFrameCount(min(16384, file.length-position))) - let frames = Int(buffer.frameLength) - guard frames > 0, let data = buffer.floatChannelData else { break } - for frame in 0.. 0 ? sqrt($0/Double($1)) : 0 } - let peak = rms.max() ?? 0 - let levels = peak > 0 ? rms.map { Float(pow(min(1,$0/peak),0.7)) } : [Float](repeating:0,count:bins) - let bands = (0.. (Float,Float) { lock.lock();defer { lock.unlock() };return levels } - func reset() { lock.lock();levels = (0,0);lock.unlock() } -} - -/// Persistent analysis cache: file path, size, modification time and analyser version form its key. -/// Invalid or obsolete entries are treated as misses, never as playback errors. -enum WaveformCache { - static func location(audio: URL,directory: URL) throws -> URL { - let values = try FileManager.default.attributesOfItem(atPath:audio.path) - let stamp = (values[.modificationDate] as? Date)?.timeIntervalSince1970 ?? 0 - let size = (values[.size] as? NSNumber)?.int64Value ?? 0 - let signature = "rgb-rms-v2-4096|\(audio.standardizedFileURL.path)|\(size)|\(stamp)" - let key = SHA256.hash(data:Data(signature.utf8)).map { String(format:"%02x",$0) }.joined() - return directory.appendingPathComponent(key+".waveform") - } - static func load(audio: URL,directory: URL) throws -> AudioWaveform.Analysis { - let url = try location(audio:audio,directory:directory) - let data = try Data(contentsOf:url) - guard data.count < 4_000_000 else { throw LibraryError.message("Invalid waveform cache") } - let analysis = try PropertyListDecoder().decode(AudioWaveform.Analysis.self,from:data) - guard analysis.levels.count == 4096,analysis.bands.count == 4096, - analysis.levels.allSatisfy({ $0.isFinite && $0 >= 0 && $0 <= 1 }), - analysis.bands.allSatisfy({ $0.low.isFinite && $0.mid.isFinite && $0.high.isFinite && $0.low >= 0 && $0.mid >= 0 && $0.high >= 0 }) else { throw LibraryError.message("Invalid waveform cache") } - return analysis - } - static func save(_ analysis: AudioWaveform.Analysis,audio: URL,directory: URL) throws { - try FileManager.default.createDirectory(at:directory,withIntermediateDirectories:true) - let encoder = PropertyListEncoder();encoder.outputFormat = .binary - try encoder.encode(analysis).write(to:location(audio:audio,directory:directory),options:.atomic) - } -} diff --git a/backups/before-kjmix-20261103-100337/scripts/build.sh b/backups/before-kjmix-20261103-100337/scripts/build.sh deleted file mode 100755 index 434cd7e..0000000 --- a/backups/before-kjmix-20261103-100337/scripts/build.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -set -euo pipefail -cd "$(dirname "$0")/.." -xcodebuild -project KJamsClone.xcodeproj -scheme KJamsClone -configuration Debug -destination 'platform=macOS' -derivedDataPath "${DERIVED_DATA:-$PWD/build}" CODE_SIGNING_ALLOWED=NO build "$@" diff --git a/backups/before-kjmix-20261103-100337/scripts/generate-test-media.py b/backups/before-kjmix-20261103-100337/scripts/generate-test-media.py deleted file mode 100644 index f6b74ee..0000000 --- a/backups/before-kjmix-20261103-100337/scripts/generate-test-media.py +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env python3 -"""Original synthetic MP3+G test media. Regeneration requires ffmpeg; playback does not.""" -from pathlib import Path -import wave,struct,math,subprocess,zipfile,shutil -root=Path(__file__).resolve().parents[1]/'Fixtures';root.mkdir(exist_ok=True) -font={ -'A':['01110','10001','10001','11111','10001','10001','10001'], -'C':['01111','10000','10000','10000','10000','10000','01111'], -'D':['11110','10001','10001','10001','10001','10001','11110'], -'E':['11111','10000','10000','11110','10000','10000','11111'], -'F':['11111','10000','10000','11110','10000','10000','10000'], -'G':['01111','10000','10000','10111','10001','10001','01111'], -'H':['10001','10001','10001','11111','10001','10001','10001'], -'I':['11111','00100','00100','00100','00100','00100','11111'], -'J':['00111','00010','00010','00010','10010','10010','01100'], -'K':['10001','10010','10100','11000','10100','10010','10001'], -'L':['10000','10000','10000','10000','10000','10000','11111'], -'M':['10001','11011','10101','10101','10001','10001','10001'], -'N':['10001','11001','10101','10011','10001','10001','10001'], -'O':['01110','10001','10001','10001','10001','10001','01110'], -'P':['11110','10001','10001','11110','10000','10000','10000'], -'R':['11110','10001','10001','11110','10100','10010','10001'], -'S':['01111','10000','10000','01110','00001','00001','11110'], -'T':['11111','00100','00100','00100','00100','00100','00100'], -'U':['10001','10001','10001','10001','10001','10001','01110'], -'V':['10001','10001','10001','10001','10001','01010','00100'], -'W':['10001','10001','10001','10101','10101','11011','10001'], -'Y':['10001','10001','01010','00100','00100','00100','00100'], -'3':['11110','00001','00001','01110','00001','00001','11110'], -' ':['00000']*7, -} -def packet(inst,data):return bytes([9,inst,0,0]+(data+[0]*16)[:16]+[0]*4) -packets=[bytes(24) for _ in range(6000)] -def put(index,seq): - for p in seq: - assert packets[index]==bytes(24),'overlapping instructions' - packets[index]=p;index+=1 - return index -colors=[0x013,0xfff,0xfd0,0x0cf]+[0]*12 -def palette(offset): - data=[] - for c in colors[offset:offset+8]:data.extend([(c>>6)&63,c&63]) - return packet(30 if offset==0 else 31,data) -put(0,[palette(0),palette(8),packet(1,[0,0]),packet(2,[0])]) -def frame(lines): - pixels=[[0]*300 for _ in range(216)] - for line,(text,y) in enumerate(lines): - x=(300-len(text)*12)//2 - for char in text: - for gy,row in enumerate(font[char]): - for gx,bit in enumerate(row): - if bit=='1': - for dy in range(2): - for dx in range(2):pixels[y+gy*2+dy][x+gx*2+dx]=1 - x+=12 - return pixels -def tiles(pixels,xor=False): - result=[] - for row in range(1,17): - for col in range(1,49): - bits=[] - for y in range(12): - v=0 - for x in range(6):v=(v<<1)|pixels[row*12+y][col*6+x] - bits.append(v) - if any(bits):result.append(packet(38 if xor else 6,[0,3 if xor else 1,row,col]+bits)) - return result -scenes=[[("KJAMS CLONE",66),("MP3 PLUS G TEST",114)],[("ONE TWO THREE FOUR",66),("SING ALONG",114)],[("WITH THE TEST TONE",66),("PLAY PAUSE SEEK",114)],[("MP3 PLUS G TEST",66),("TEST COMPLETE",114)]] -for index,lines in enumerate(scenes): - start=index*1500+(5 if index==0 else 0) - pixels=frame(lines) - put(start,([packet(1,[0,0])] if index else [])+tiles(pixels)) - # Highlight each word after the initial white text has been drawn. - for line,(text,y) in enumerate(lines): - left=(300-len(text)*12)//2 - words=text.split();cursor=0 - for wi,word in enumerate(words): - mask=[[0]*300 for _ in range(216)] - for py in range(y,y+14): - for px in range(left+cursor*12,left+(cursor+len(word))*12):mask[py][px]=pixels[py][px] - put(index*1500+240+line*600+wi*100,tiles(mask,True)) - cursor+=len(word)+1 -(root/'TestTrack.cdg').write_bytes(b''.join(packets)) -rate=44100;duration=20;notes=[261.63,329.63,392.0,523.25,392.0,329.63,293.66,261.63] -with wave.open(str(root/'TestTrack.wav'),'w') as out: - out.setparams((1,2,rate,0,'NONE','not compressed')) - for beat in range(duration*2): - freq=notes[beat%len(notes)] - data=bytearray() - for i in range(rate//2): - t=i/rate;fade=min(1,t/0.015,(0.5-t)/0.04) - data.extend(struct.pack(' Void) { do { try work() } catch { self.error = error.localizedDescription } } - func refresh() throws { - guard let library else { throw LibraryError.message("Library unavailable") } - songs = try library.songs(); singers = try library.entities("singers"); venues = try library.entities("venues") - playlists = try library.entities("playlists"); currentVenue = try library.currentVenue() - venueSingers = try currentVenue.map { try library.members(of:$0) } ?? singers - if let selectedSinger, !venueSingers.contains(where: { $0.id == selectedSinger }) { self.selectedSinger = nil } - queue = try library.queue(venue:currentVenue); history = try library.history(venue:currentVenue) - } - func chooseVenue(_ id: Int64?) { - perform { - guard let library else { throw LibraryError.message("Library unavailable") } - try library.selectVenue(id); selectedSinger = nil; try refresh() - } - } - func membership(singer: Int64, included: Bool) { - perform { - guard let library, let currentVenue else { throw LibraryError.message("Select a current venue first") } - try library.setMembership(singer:singer,venue:currentVenue,included:included); try refresh() - } - } - @discardableResult func createEntity(_ kind: EntityKind, name: String) throws -> Int64 { - guard let library else { throw LibraryError.message("Library unavailable") } - let trimmed = name.trimmingCharacters(in:.whitespacesAndNewlines) - try library.addEntity(kind.table,name:trimmed) - guard let entity = try library.entities(kind.table).first(where: { $0.name == trimmed }) else { throw LibraryError.message("Could not load new entry") } - if kind == .singer { - if let currentVenue { try library.setMembership(singer:entity.id,venue:currentVenue,included:true) } - selectedSinger = entity.id - } else { try library.selectVenue(entity.id); selectedSinger = nil } - try refresh(); return entity.id - } - func rename(_ table: String, id: Int64, name: String) { perform { try library?.rename(table,id:id,name:name); try refresh() } } - func delete(_ table: String, id: Int64) { perform { try library?.deleteEntity(table,id:id); try refresh() } } - func preference(_ song: Int64) -> SongPreference { - guard let library, let selectedSinger else { return .init() } - return (try? library.preference(song:song,singer:selectedSinger)) ?? .init() - } - func savePreference(song: Int64, value: SongPreference) { - perform { - guard let library, let selectedSinger else { throw LibraryError.message("Select a singer to save their song preferences") } - try library.savePreference(song:song,singer:selectedSinger,value:value); try refresh() - } - } - func play(_ song: Song, singer: Int64? = nil) throws { - guard let library else { throw LibraryError.message("Library unavailable") } - let singer = singer ?? selectedSinger - if let singer, let currentVenue, try !library.members(of:currentVenue).contains(where: { $0.id == singer }) { throw LibraryError.message("This singer is not in the current venue") } - let preference = try singer.map { try library.preference(song:song.id,singer:$0) } ?? SongPreference() - try player.load(song,preference:preference) - do { try library.record(song.id,singer:singer,venue:currentVenue); selectedSinger = singer; try refresh() } - catch { player.stop(); throw error } - } - func enqueue(_ song: Int64) { perform { try library?.enqueue(song:song,singer:selectedSinger,venue:currentVenue); try refresh() } } - func playQueueNext() { - perform { - guard let row = queue.first, let song = songs.first(where: { $0.id == row.songID }) else { return } - // Explicitly clear selection for unassigned queue entries. - selectedSinger = row.singerID - try play(song,singer:row.singerID); try library?.removeQueue(row.id); try refresh() - } - } - func moveQueue(_ id: Int64, by offset: Int) { perform { if let currentVenue { try library?.moveQueue(id,venue:currentVenue,by:offset); try refresh() } } } - func removeQueue(_ id: Int64) { perform { try library?.removeQueue(id); try refresh() } } - func createPlaylist(_ name: String) { perform { try library?.addEntity("playlists",name:name); try refresh() } } - func addToPlaylist(_ playlist: Int64, song: Int64) { perform { try library?.addToPlaylist(playlist,song:song); try refresh() } } - func importFiles(_ urls: [URL]) { perform { guard let library else { throw LibraryError.message("Library unavailable") }; try Importer(media:root.appendingPathComponent("Media")).run(urls,library:library); try refresh() } } -} -@main struct KJamsCloneApp: App { - @StateObject private var model = AppModel() - var body: some Scene { - Window("KJamsClone", id: "main") { - LibraryView(model: model).frame(minWidth: 1060, minHeight: 680).preferredColorScheme(.dark) - }.defaultSize(width: 1260, height: 840) - .commands { - CommandGroup(replacing: .newItem) { - Button("New Singer…") { model.creating = .singer }.keyboardShortcut("n", modifiers: [.command, .shift]) - Button("New Venue…") { model.creating = .venue }.keyboardShortcut("n", modifiers: [.command, .option]) - } - } - Window("Video", id: "lyrics") { - LyricsView(player: model.player).frame(minWidth: 480, minHeight: 320).preferredColorScheme(.dark) - }.defaultSize(width: 600, height: 400) - } -} -private enum Classic { - static let frame = Color(red: 0.15, green: 0.15, blue: 0.15) - static let navy = Color(red: 0.008, green: 0.065, blue: 0.16) - static let blue = Color(red: 0.015, green: 0.17, blue: 0.42) - static let header = Color(white: 0.115) - static let line = Color(white: 0.42) -} -struct LyricsView: View { - @ObservedObject var player: Player - var body: some View { - ZStack { - Color.black - if let image = player.image { - Image(decorative: image, scale: 1).interpolation(.none).resizable().aspectRatio(1.5, contentMode: .fit) - } - } - } -} -/// This is another view of the same published CGImage used by the Video window. -/// It owns no decoder, audio player or clock, so seeking/pause/tempo stay identical. -private struct SidebarVideoMonitor: View { - let player: Player - var body: some View { - VStack(alignment: .leading, spacing: 7) { - Label("Video Monitor", systemImage: "tv") - .font(.system(size: 11, weight: .medium)).foregroundStyle(.white.opacity(0.7)) - LyricsView(player: player) - .aspectRatio(1.5, contentMode: .fit) - .clipped() - .overlay(Rectangle().strokeBorder(.white.opacity(0.25), lineWidth: 1)) - .accessibilityLabel("Video monitor, synchronized with the Video window") - }.frame(maxWidth: .infinity) - } -} -private struct SilverSquareStyle: ButtonStyle { - func makeBody(configuration: Configuration) -> some View { - configuration.label.foregroundStyle(Color(white: 0.25)).padding(.horizontal, 6).padding(.vertical, 3) - .background(LinearGradient(colors: [Color(white: 0.95), Color(white: 0.64)], startPoint: .top, endPoint: .bottom), in: RoundedRectangle(cornerRadius: 4)) - .overlay(RoundedRectangle(cornerRadius: 4).strokeBorder(Color(white: 0.45), lineWidth: 1.5)) - .overlay(RoundedRectangle(cornerRadius: 3).strokeBorder(.white.opacity(0.7)).padding(3)) - .opacity(configuration.isPressed ? 0.7 : 1) - } -} -private struct SilverButton: View { - let symbol: String - let label: String - var size: CGFloat = 40 - var active = false - var enabled = true - let action: () -> Void - var body: some View { - Button(action: action) { - Image(systemName: symbol).font(.system(size: size * 0.41, weight: .semibold)) - .foregroundStyle(active ? Color.blue : Color(white: 0.24)) - .frame(width: size, height: size) - .background(LinearGradient(colors: [.white, Color(white: 0.85), Color(white: 0.63)], startPoint: .top, endPoint: .bottom), in: Circle()) - .overlay(Circle().strokeBorder(Color(white: 0.45), lineWidth: 1.5)) - .overlay(Circle().strokeBorder(.white.opacity(0.65), lineWidth: 1).padding(3)) - .shadow(color: .black.opacity(0.7), radius: 1, y: 1) - }.buttonStyle(.plain).disabled(!enabled).opacity(enabled ? 1 : 0.72) - .help(label).accessibilityLabel(label) - } -} -struct LibraryView: View { - @ObservedObject var model: AppModel - @State private var selected: Int64? - @State private var search = "" - @State private var name = "" - @State private var importing = false - @State private var source = "Library" - @Environment(\.openWindow) private var openWindow - private var visibleSongs: [Song] { model.songs.filter { search.isEmpty || ($0.title+" "+$0.artist+" "+$0.album).localizedCaseInsensitiveContains(search) } } - private var selectedSong: Song? { model.songs.first { $0.id == selected } } - var body: some View { - VStack(spacing: 0) { - TransportView(player: model.player, search: $search, hasSelection: selectedSong != nil, - play: playSelected, next: playNext, display: { openWindow(id: "lyrics") }) - .padding(.horizontal, 18).padding(.top, 18).padding(.bottom, 22) - HSplitView { - sidebar.frame(minWidth: 190, idealWidth: 220, maxWidth: 240) - VStack(spacing: 12) { - if source == "Library" { songTable } - else if source == "Queue" { queuePane } - else if source == "History" { historyPane } - else if source == "Playlists" { playlistPane } - else { directory } - detailPanel.frame(height: 135) - }.padding(.leading, 12).frame(minWidth: 780) - }.padding(.horizontal, 18) - footer.padding(.horizontal, 18).padding(.vertical, 12) - } - .background(Classic.frame) - .sheet(item: $model.creating) { kind in - AddEntitySheet(model: model, kind: kind) { id in - if kind == .singer { model.selectedSinger = id } else { model.chooseVenue(id) } - } - } - .fileImporter(isPresented: $importing, allowedContentTypes: [.audio, .zip, UTType(filenameExtension: "cdg") ?? .data], allowsMultipleSelection: true) { result in - switch result { - case .success(let urls): model.importFiles(urls) - case .failure(let error): model.error = error.localizedDescription - } - } - .alert("KJamsClone", isPresented: Binding(get: { model.error != nil }, set: { if !$0 { model.error = nil } })) { - Button("OK") { model.error = nil } - } message: { Text(model.error ?? "") } - } - private func sourceCount(_ source: String) -> Int { - switch source { - case "Library": return model.songs.count - case "Singers": return model.venueSingers.count - case "Venues": return model.venues.count - case "Queue": return model.queue.count - case "History": return model.history.count - default: return model.playlists.count - } - } - private var sidebar: some View { - VStack(alignment: .leading, spacing: 0) { - Text("Source").font(.system(size: 15, weight: .semibold)).padding(.horizontal, 10).frame(height: 31) - .frame(maxWidth: .infinity, alignment: .leading).background(Classic.header) - ForEach([("Library", "music.note.house.fill", Color.yellow), ("Singers", "person.2.fill", Color.green), ("Venues", "building.2.fill", Color.cyan), ("Queue", "list.number", Color.orange), ("History", "clock.arrow.circlepath", Color.purple), ("Playlists", "music.note.list", Color.mint)], id: \.0) { item in - Button { source = item.0 } label: { - HStack(spacing: 10) { - Image(systemName: item.1).foregroundStyle(item.2).frame(width: 22) - Text(item.0).font(.system(size: 16, weight: .medium)) - Spacer() - Text("\(sourceCount(item.0))") - .font(.system(size: 11)).foregroundStyle(.white.opacity(0.6)) - }.padding(.horizontal, 12).frame(height: 34).contentShape(Rectangle()) - .background(source == item.0 ? Color(red: 0, green: 0.36, blue: 1) : .clear) - }.buttonStyle(.plain) - } - Spacer(minLength: 12) - SidebarVideoMonitor(player: model.player).padding(10) - }.foregroundStyle(.white).background(Classic.navy).overlay(Rectangle().stroke(Classic.line, lineWidth: 1)) - } - private var songTable: some View { - GeometryReader { geometry in - ScrollView(.horizontal) { - VStack(spacing: 0) { - tableHeader(width: max(geometry.size.width, 790)) - ScrollView(.vertical) { - LazyVStack(spacing: 0) { - ForEach(visibleSongs) { song in songRow(song, width: max(geometry.size.width, 790)) } - }.frame(maxWidth: .infinity, alignment: .topLeading) - } - }.frame(width: max(geometry.size.width, 790), height: geometry.size.height) - } - }.background(Classic.navy).overlay(Rectangle().stroke(Classic.line, lineWidth: 1)) - } - private func widths(_ total: CGFloat) -> [CGFloat] { - [42, max(200, total - 598), 100, 100, 76, 86, 72, 122] - } - private func tableHeader(width: CGFloat) -> some View { - let sizes = widths(width) - return HStack(spacing: 0) { - ForEach(Array(["PLI", "Song Name", "Artist", "Album", "Label", "Key Adjust", "Tempo", "Rating"].enumerated()), id: \.offset) { index, title in - Text(title).font(.system(size: 13, weight: .medium)).lineLimit(1) - .padding(.leading, 7).frame(width: sizes[index], height: 30, alignment: .leading) - .overlay(alignment: .trailing) { Rectangle().fill(Classic.line).frame(width: 1).padding(.vertical, 4) } - } - }.foregroundStyle(.white).background(Classic.header) - .overlay(alignment: .bottom) { Rectangle().fill(Color(white: 0.65)).frame(height: 1) } - } - private func cellText(_ song: Song, column: Int) -> String { - switch column { - case 2: return song.artist.isEmpty ? "—" : song.artist - case 3: return song.album.isEmpty ? "—" : song.album - case 4: return song.label.isEmpty ? (song.cdg == nil ? "Audio" : URL(fileURLWithPath:song.audio).pathExtension.uppercased()+"+G") : song.label - case 5: return String(format:"%+.0f",model.preference(song.id).pitch) - default: return String(format:"%.0f%%",model.preference(song.id).tempo*100) - } - } - private func songRow(_ song: Song, width: CGFloat) -> some View { - let sizes = widths(width) - return HStack(spacing: 0) { - Image(systemName: song.cdg == nil ? "music.note" : "music.note.tv") - .foregroundStyle(.white.opacity(0.75)).frame(width: sizes[0]) - Text(song.title).lineLimit(1).padding(.leading, 7).frame(width: sizes[1], alignment: .leading) - ForEach(2..<7) { index in - Text(cellText(song, column: index)) - .foregroundStyle(.white.opacity(0.5)).padding(.leading, 7).frame(width: sizes[index], alignment: .leading) - } - Menu { - ForEach(0..<6) { value in - Button(value == 0 ? "Unrated" : String(repeating: "★", count: value)) { - model.perform { try model.library?.rate(song.id, value); try model.refresh() } - } - } - } label: { - Text(song.rating == 0 ? "☆☆☆☆☆" : String(repeating: "★", count: song.rating) + String(repeating: "☆", count: 5 - song.rating)) - .font(.system(size: 13)).foregroundStyle(song.rating == 0 ? Color.gray : Color.yellow) - }.menuStyle(.borderlessButton).frame(width: sizes[7] - 14).padding(.horizontal, 7).help("Set song rating") - }.font(.system(size: 13)).foregroundStyle(.white).frame(height: 30) - .background(selected == song.id ? Color(red: 0, green: 0.28, blue: 0.72) : .clear) - .contentShape(Rectangle()).onTapGesture(count: 2) { selected = song.id; playSelected() } - .onTapGesture { selected = song.id } - .contextMenu { - Button("Play") { selected = song.id; playSelected() } - Button("Add to Current Venue Queue") { model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Menu("Add to Playlist") { ForEach(model.playlists) { playlist in Button(playlist.name) { model.addToPlaylist(playlist.id,song:song.id) } } } - } - } - @State private var managingRoster = false - @State private var rosterNewName = "" - @State private var editingEntity: PersonPlace? - @State private var renameText = "" - @State private var pendingDelete: PersonPlace? - private var directory: some View { - VStack(alignment:.leading,spacing:0) { - HStack { - Text(source == "Singers" ? "Singers · \(model.currentVenueName)" : "Venues").font(.headline) - Spacer() - if source == "Singers" { Button("Manage Venue Singers…") { managingRoster = true }.disabled(model.currentVenue == nil) } - Button(source == "Singers" ? "New Singer…" : "New Venue…") { model.creating = source == "Singers" ? .singer : .venue } - }.padding(12).background(Classic.header) - ScrollView { - VStack(alignment:.leading,spacing:0) { - if source == "Singers" && model.venueSingers.isEmpty { - Text("No singers at this venue. Add a singer or use Manage Venue Singers to include existing singers.").foregroundStyle(.secondary).padding() - } - ForEach(source == "Singers" ? model.venueSingers : model.venues) { entity in - HStack { - Button { - if source == "Singers" { model.selectedSinger = entity.id } else { model.chooseVenue(entity.id) } - } label: { - HStack { - Image(systemName:source == "Singers" ? "person.fill" : "building.2.fill") - Text(entity.name); Spacer() - if entity.id == (source == "Singers" ? model.selectedSinger : model.currentVenue) { - Text(source == "Singers" ? "Selected" : "Current venue").font(.caption).foregroundStyle(.cyan) - Image(systemName:"checkmark.circle.fill").foregroundStyle(.cyan) - } - }.contentShape(Rectangle()) - }.buttonStyle(.plain) - Button("Rename") { renameText = entity.name; editingEntity = entity } - Button("Delete",role:.destructive) { pendingDelete = entity } - }.padding(12) - } - } - } - HStack { - TextField(source == "Singers" ? "Singer name" : "Venue name",text:$name).textFieldStyle(.roundedBorder).onSubmit(addEntity) - Button(source == "Singers" ? "Add Singer" : "Add Venue",action:addEntity).disabled(name.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - }.padding(12) - }.foregroundStyle(.white).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - .sheet(isPresented:$managingRoster) { rosterSheet } - .sheet(item:$editingEntity) { entity in - VStack(alignment:.leading,spacing:16) { - Text("Rename \(source == "Singers" ? "Singer" : "Venue")").font(.headline) - TextField("Name",text:$renameText).textFieldStyle(.roundedBorder) - HStack { Button("Cancel") { editingEntity = nil }; Spacer(); Button("Save") { model.rename(source == "Singers" ? "singers" : "venues",id:entity.id,name:renameText); editingEntity = nil }.disabled(renameText.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) } - }.padding(24).frame(width:360) - } - .confirmationDialog("Delete \(pendingDelete?.name ?? "entry")? Historical plays are kept. Venue memberships and queued entries for it will be removed.",isPresented:Binding(get:{ pendingDelete != nil },set:{ if !$0 { pendingDelete = nil } })) { - Button("Delete",role:.destructive) { if let entity = pendingDelete { model.delete(source == "Singers" ? "singers" : "venues",id:entity.id) }; pendingDelete = nil } - } - } - private var rosterSheet: some View { - VStack(alignment:.leading,spacing:16) { - Text("Singers at \(model.currentVenueName)").font(.title2.bold()) - Text("A singer can belong to any number of venues. Unchecking removes them from this venue only.").foregroundStyle(.secondary) - ScrollView { - VStack(alignment:.leading,spacing:12) { - ForEach(model.singers) { singer in - Toggle(singer.name,isOn:Binding(get:{ model.venueSingers.contains { $0.id == singer.id } },set:{ model.membership(singer:singer.id,included:$0) })) - } - }.frame(maxWidth:.infinity,alignment:.leading) - }.frame(minHeight:120,maxHeight:280) - HStack { - TextField("New singer name",text:$rosterNewName).textFieldStyle(.roundedBorder) - Button("Add") { model.perform { _ = try model.createEntity(.singer,name:rosterNewName); rosterNewName = "" } }.disabled(rosterNewName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - Spacer(); Button("Done") { managingRoster = false }.keyboardShortcut(.defaultAction) - } - }.padding(24).frame(width:460) - } - private var detailPanel: some View { - VStack(alignment:.leading,spacing:9) { - HStack(spacing:10) { - Picker("Current venue",selection:Binding(get:{ model.currentVenue },set:{ model.chooseVenue($0) })) { - Text("Select venue…").tag(nil as Int64?) - ForEach(model.venues) { Text($0.name).tag(Optional($0.id)) } - } - Button { model.creating = .venue } label: { Image(systemName:"plus.circle.fill") }.buttonStyle(.plain).help("Add venue") - Picker("Singer",selection:$model.selectedSinger) { - Text("None").tag(nil as Int64?) - ForEach(model.venueSingers) { Text($0.name).tag(Optional($0.id)) } - } - Button { model.creating = .singer } label: { Image(systemName:"plus.circle.fill") }.buttonStyle(.plain).help("Add singer") - Button("Queue Song") { if let selected { model.enqueue(selected) } }.disabled(selected == nil || model.currentVenue == nil) - } - PlaybackSettings(player:model.player,model:model,selectedSong:selected) - SeekBar(player:model.player) - }.padding(12).frame(maxWidth:.infinity,maxHeight:.infinity) - .background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - @State private var playlistName = "" - @State private var selectedPlaylist: Int64? - private var queuePane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { Text("Queue · \(model.currentVenueName)").font(.headline); Spacer(); Toggle("Auto play next",isOn:$model.autoAdvance).toggleStyle(.checkbox); Button("Play Next") { model.playQueueNext() }.disabled(model.queue.isEmpty) } - ScrollView { - VStack(spacing:0) { - ForEach(Array(model.queue.enumerated()),id:\.element.id) { index,row in - HStack { - Text("\(index+1)").foregroundStyle(.secondary).frame(width:24) - Text(row.singer).frame(width:140,alignment:.leading) - Text(row.title).lineLimit(1); Spacer() - Button { model.moveQueue(row.id,by:-1) } label: { Image(systemName:"arrow.up") }.disabled(index == 0) - Button { model.moveQueue(row.id,by:1) } label: { Image(systemName:"arrow.down") }.disabled(index == model.queue.count-1) - Button("Remove") { model.removeQueue(row.id) } - }.padding(.vertical,8) - } - if model.queue.isEmpty { Text("Choose a venue and singer, select a library song, then click Queue Song.").foregroundStyle(.secondary).padding(.top,30) } - } - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - @State private var historyAllVenues = false - private var displayedHistory: [Performance] { - if historyAllVenues { return (try? model.library?.history(venue:nil,singer:model.selectedSinger)) ?? [] } - return model.history.filter { model.selectedSinger == nil || $0.singer == model.singers.first(where: { $0.id == model.selectedSinger })?.name } - } - private var historyPane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { Text("History · \(historyAllVenues || model.currentVenue == nil ? "All venues" : model.currentVenueName)").font(.headline); Spacer(); Toggle("All venues",isOn:$historyAllVenues).toggleStyle(.checkbox) } - ScrollView { - LazyVStack(alignment:.leading,spacing:12) { - ForEach(displayedHistory) { row in - HStack { Text(row.date).font(.system(.caption,design:.monospaced)); Text(row.singer).frame(width:130,alignment:.leading); Text(row.song); Spacer(); Text(row.venue).foregroundStyle(.secondary) } - } - } - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - private var playlistPane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { - Picker("Playlist",selection:$selectedPlaylist) { Text("Choose…").tag(nil as Int64?); ForEach(model.playlists) { Text($0.name).tag(Optional($0.id)) } } - TextField("New playlist name",text:$playlistName).textFieldStyle(.roundedBorder) - Button("Create") { model.createPlaylist(playlistName); selectedPlaylist = model.playlists.first { $0.name == playlistName.trimmingCharacters(in:.whitespacesAndNewlines) }?.id; playlistName = "" }.disabled(playlistName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - if let selectedPlaylist { - Button("Rename") { model.rename("playlists",id:selectedPlaylist,name:playlistName); playlistName = "" }.disabled(playlistName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - Button("Delete",role:.destructive) { model.delete("playlists",id:selectedPlaylist); self.selectedPlaylist = nil } } - } - ScrollView { - if let selectedPlaylist { - let ids = (try? model.library?.playlistSongIDs(selectedPlaylist)) ?? [] - VStack(alignment:.leading,spacing:10) { - ForEach(ids,id:\.self) { id in - if let song = model.songs.first(where: { $0.id == id }) { - HStack { - Text(song.title); Spacer() - Button("Play") { model.perform { try model.play(song) } } - Button("Queue") { model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Button("Remove") { model.perform { try model.library?.removeFromPlaylist(selectedPlaylist,song:id); try model.refresh() } } - } - } - } - } - } - Text("Add songs using the library row’s context menu.").foregroundStyle(.secondary).padding(.top,20) - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - private var footer: some View { - HStack { - Button { importing = true } label: { Image(systemName: "plus").font(.system(size: 20, weight: .bold)).frame(width: 32, height: 24) } - .help("Import audio, MP3+G or ZIP").accessibilityLabel("Import songs") - RepeatButton(player: model.player).padding(.leading, 12) - Spacer() - Text("\(visibleSongs.count) \(visibleSongs.count == 1 ? "Song" : "Songs")").font(.system(size: 14, weight: .medium)) - Spacer() - Button { openWindow(id: "lyrics") } label: { Image(systemName: "rectangle.on.rectangle").frame(width: 32, height: 24) } - .help("Open video window").accessibilityLabel("Open video window") - }.buttonStyle(SilverSquareStyle()) - } - private func playSelected() { - guard let song = selectedSong else { return } - model.perform { try model.play(song) } - } - private func playNext() { - guard !visibleSongs.isEmpty else { return } - let index = visibleSongs.firstIndex { $0.id == selected } ?? -1 - selected = visibleSongs[(index + 1) % visibleSongs.count].id; playSelected() - } - private func addEntity() { - model.perform { - let kind: EntityKind = source == "Singers" ? .singer : .venue - let id = try model.createEntity(kind, name: name) - if kind == .singer { model.selectedSinger = id } else { model.chooseVenue(id) } - name = "" - } - } -} -private struct AddEntitySheet: View { - @ObservedObject var model: AppModel - let kind: EntityKind - let saved: (Int64) -> Void - @Environment(\.dismiss) private var dismiss - @State private var name = "" - @State private var error: String? - @FocusState private var focused: Bool - var body: some View { - VStack(alignment: .leading, spacing: 16) { - Text("New \(kind.title)").font(.title2.bold()) - TextField("\(kind.title) name", text: $name).textFieldStyle(.roundedBorder) - .focused($focused).onSubmit(save) - if let error { Text(error).foregroundStyle(.red).font(.callout) } - HStack { - Spacer() - Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction) - Button("Add \(kind.title)", action: save).keyboardShortcut(.defaultAction) - .disabled(name.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty) - } - }.padding(24).frame(width: 360).onAppear { focused = true } - } - private func save() { - do { let id = try model.createEntity(kind, name: name); saved(id); dismiss() } - catch { self.error = error.localizedDescription } - } -} -private struct TransportView: View { - @ObservedObject var player: Player - @Binding var search: String - let hasSelection: Bool - let play: () -> Void - let next: () -> Void - let display: () -> Void - var body: some View { - HStack(alignment: .top, spacing: 28) { - VStack(spacing: 15) { - HStack(spacing: 7) { - SilverButton(symbol: "backward.fill", label: "Back 10 seconds", size: 35, enabled: player.duration > 0) { player.seek(player.time - 10) } - SilverButton(symbol: player.playing ? "pause.fill" : "play.fill", label: player.playing ? "Pause" : "Play", size: 49, enabled: hasSelection || player.duration > 0) { - if player.duration > 0 { player.toggle() } else { play() } - } - SilverButton(symbol: "stop", label: "Stop", size: 46, enabled: player.duration > 0) { player.stop() } - SilverButton(symbol: "forward.fill", label: "Forward 10 seconds", size: 35, enabled: player.duration > 0) { player.seek(player.time + 10) } - SilverButton(symbol: "forward.end.fill", label: "Play next song", size: 26, enabled: hasSelection, action: next) - } - HStack(spacing: 9) { - Image(systemName: "speaker.fill").font(.system(size: 11)) - Slider(value: $player.volume, in: 0...1).controlSize(.small).tint(.gray).accessibilityLabel("Volume") - Image(systemName: "speaker.wave.3.fill").font(.system(size: 12)) - }.frame(width: 180) - }.frame(width: 220) - NowPlayingWaveform(player: player).padding(.top, 4) - HStack(spacing: 12) { - TextField("Search", text: $search).textFieldStyle(.plain).font(.system(size: 16)) - .padding(.horizontal, 8).frame(width: 145, height: 28).background(Color(white: 0.07), in: RoundedRectangle(cornerRadius: 5)) - .overlay(RoundedRectangle(cornerRadius: 5).stroke(.white.opacity(0.1))) - SilverButton(symbol: "eye", label: "Open video window", size: 48, action: display) - }.padding(.top, 15) - }.foregroundStyle(.white).frame(height: 96) - } -} -private struct NowPlayingWaveform: View { - @ObservedObject var player: Player - private let teal = Color(red: 0.18, green: 0.83, blue: 0.75) - private let cyan = Color(red: 0.22, green: 0.74, blue: 0.97) - private var progress: Double { player.duration > 0 ? min(1, max(0, player.time / player.duration)) : 0 } - private func clock(_ value: Double) -> String { let n = max(0, Int(value)); return String(format: "%d:%02d", n/60, n%60) } - var body: some View { - VStack(alignment: .leading, spacing: 5) { - Text(player.duration > 0 ? player.title : "Ready to play") - .font(.system(size: 13, weight: .semibold)).foregroundStyle(Color(white: 0.94)) - .lineLimit(1).truncationMode(.middle).frame(maxWidth: .infinity, alignment: .leading).help(player.title) - GeometryReader { geometry in - Canvas { context, size in - let mid = size.height/2 - var grid = Path() - for fraction in [0.25, 0.5, 0.75] { - let y = size.height*fraction; grid.move(to:CGPoint(x:0,y:y)); grid.addLine(to:CGPoint(x:size.width,y:y)) - } - context.stroke(grid,with:.color(.white.opacity(0.045)),lineWidth:1) - if !player.waveform.isEmpty { - let count = max(1, Int(size.width/3)) - let step = size.width/CGFloat(count) - for bar in 0.. 0, geometry.size.width > 0 else { return } - player.seek(min(1,max(0,value.location.x/geometry.size.width))*player.duration) - }) - .help("Click the waveform to seek") - .accessibilityLabel("Audio waveform") - .accessibilityValue("\(clock(player.time)) of \(clock(player.duration))") - .accessibilityAdjustableAction { direction in - if direction == .increment { player.seek(player.time+5) } else if direction == .decrement { player.seek(player.time-5) } - } - }.frame(height:28) - HStack(spacing:5) { - Circle().fill(player.playing ? teal : Color(red:0.9,green:0.68,blue:0.3)).frame(width:4,height:4) - Text(player.duration == 0 ? "NO TRACK LOADED" : player.playing ? "PLAYING" : "PAUSED") - .tracking(1) - if player.waveformUnavailable { Text("· Waveform unavailable").foregroundStyle(.secondary) } - Spacer(minLength:0) - Text("\(clock(player.time)) / \(clock(player.duration))").monospacedDigit() - }.font(.system(size:9,weight:.medium)).foregroundStyle(Color(red:0.57,green:0.67,blue:0.79)) - }.padding(.horizontal,12).padding(.vertical,9) - .frame(maxWidth:.infinity).frame(height:86) - .background(LinearGradient(colors:[Color(red:0.035,green:0.065,blue:0.105),Color(red:0.05,green:0.09,blue:0.15)],startPoint:.top,endPoint:.bottom)) - .overlay(Rectangle().strokeBorder(Color(red:0.21,green:0.29,blue:0.38),lineWidth:1)) - } -} -private struct PlaybackSettings: View { - @ObservedObject var player: Player - @ObservedObject var model: AppModel - let selectedSong: Int64? - @State private var personalRating = 0 - var body: some View { - HStack(spacing:10) { - Text("Key") - Picker("Key",selection:$player.pitch) { ForEach(-12..<13) { Text(String(format:"%+d",$0)).tag(Double($0)) } }.labelsHidden().frame(width:70) - Text("Tempo") - Slider(value:$player.tempo,in:0.5...1.5,step:0.05).frame(width:85) - Text(String(format:"%.0f%%",player.tempo*100)).monospacedDigit().frame(width:40) - Text("Rating") - Picker("Singer rating",selection:$personalRating) { ForEach(0..<6) { Text($0 == 0 ? "Unrated" : String(repeating:"★",count:$0)).tag($0) } }.labelsHidden().frame(width:88).help("Singer-specific song rating") - Button("Save for Singer") { - if let song = player.currentSongID ?? selectedSong { model.savePreference(song:song,value:.init(pitch:player.pitch,tempo:player.tempo,rating:personalRating)) } - }.disabled(model.selectedSinger == nil || (player.currentSongID == nil && selectedSong == nil)) - Menu { - Button("Reset key / tempo") { player.pitch = 0; player.tempo = 1 } - ForEach([-1.0,-0.5,0,0.5,1.0],id:\.self) { offset in Button(String(format:"Graphics offset %+.1fs",offset)) { player.graphicsOffset = offset } } - } label: { Image(systemName:"slider.horizontal.3") }.menuStyle(.borderlessButton).frame(width:22).help("Playback settings") - }.font(.system(size:11)) - .onChange(of:model.selectedSinger) { _ in loadRating() } - .onChange(of:player.currentSongID) { _ in loadRating() } - .onChange(of:selectedSong) { _ in loadRating() } - } - private func loadRating() { if let song = player.currentSongID ?? selectedSong { personalRating = model.preference(song).rating } else { personalRating = 0 } } -} -private struct SeekBar: View { - @ObservedObject var player: Player - private func clock(_ seconds: Double) -> String { let n = Int(seconds); return String(format: "%d:%02d", n / 60, n % 60) } - var body: some View { - HStack(spacing: 10) { - Text(clock(player.time)) - Slider(value: Binding(get: { player.time }, set: { player.seek($0) }), in: 0...max(1, player.duration)) - .controlSize(.mini).tint(.gray).disabled(player.duration == 0).accessibilityLabel("Playback position") - Text(clock(player.duration)) - }.font(.system(size: 10, design: .monospaced)).foregroundStyle(.white.opacity(0.65)) - } -} -private struct RepeatButton: View { - @ObservedObject var player: Player - var body: some View { - Button { player.repeating.toggle() } label: { - Image(systemName: "repeat").font(.system(size: 18, weight: .semibold)) - .foregroundStyle(player.repeating ? Color.blue : Color(white: 0.25)).frame(width: 32, height: 24) - }.help(player.repeating ? "Repeat song: on" : "Repeat song: off").accessibilityLabel("Repeat song").accessibilityValue(player.repeating ? "On" : "Off") - } -} diff --git a/backups/before-mixer-repertoire-20261103-084301/KJamsClone/Library.swift b/backups/before-mixer-repertoire-20261103-084301/KJamsClone/Library.swift deleted file mode 100644 index b98286f..0000000 --- a/backups/before-mixer-repertoire-20261103-084301/KJamsClone/Library.swift +++ /dev/null @@ -1,196 +0,0 @@ -import Foundation -import SQLite3 - -struct Song: Identifiable, Hashable { - var id: Int64 - var title: String - var audio: String - var cdg: String? - var rating: Int - var plays: Int - var artist: String = "" - var album: String = "" - var label: String = "" -} -struct PersonPlace: Identifiable, Hashable { var id: Int64; var name: String } -struct SongPreference: Equatable { - var pitch: Double = 0 - var tempo: Double = 1 - var rating: Int = 0 -} -struct Performance: Identifiable { - var id: Int64 - var song: String - var singer: String - var venue: String - var date: String -} -struct QueueEntry: Identifiable { - var id: Int64 - var songID: Int64 - var singerID: Int64? - var title: String - var singer: String -} -enum LibraryError: LocalizedError { - case message(String) - var errorDescription: String? { if case .message(let s) = self { return s }; return nil } -} -final class Library { - private var db: OpaquePointer? - init(url: URL) throws { - guard sqlite3_open(url.path, &db) == SQLITE_OK else { throw LibraryError.message("Cannot open library") } - try execute("PRAGMA foreign_keys=ON") - try execute("CREATE TABLE IF NOT EXISTS songs(id INTEGER PRIMARY KEY,title TEXT NOT NULL,audio TEXT UNIQUE NOT NULL,cdg TEXT,rating INTEGER NOT NULL DEFAULT 0 CHECK(rating BETWEEN 0 AND 5),plays INTEGER NOT NULL DEFAULT 0)") - try execute("CREATE TABLE IF NOT EXISTS singers(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS venues(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS history(id INTEGER PRIMARY KEY,song INTEGER REFERENCES songs(id),singer INTEGER REFERENCES singers(id),venue INTEGER REFERENCES venues(id),played TEXT DEFAULT CURRENT_TIMESTAMP)") - // Additive migration: preserve older libraries and infer existing memberships from history. - for column in ["artist", "album", "label"] { - if try !columns("songs").contains(column) { try execute("ALTER TABLE songs ADD COLUMN \(column) TEXT NOT NULL DEFAULT ''") } - } - try execute("CREATE TABLE IF NOT EXISTS venue_singers(venue INTEGER NOT NULL REFERENCES venues(id) ON DELETE CASCADE,singer INTEGER NOT NULL REFERENCES singers(id) ON DELETE CASCADE,PRIMARY KEY(venue,singer))") - if try schemaVersion() < 3 { try execute("INSERT OR IGNORE INTO venue_singers SELECT DISTINCT venue,singer FROM history WHERE venue IS NOT NULL AND singer IS NOT NULL") } - try execute("CREATE TABLE IF NOT EXISTS settings(key TEXT PRIMARY KEY,value TEXT)") - try execute("CREATE TABLE IF NOT EXISTS preferences(song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,singer INTEGER NOT NULL REFERENCES singers(id) ON DELETE CASCADE,pitch REAL NOT NULL DEFAULT 0 CHECK(pitch BETWEEN -12 AND 12),tempo REAL NOT NULL DEFAULT 1 CHECK(tempo BETWEEN 0.5 AND 1.5),rating INTEGER NOT NULL DEFAULT 0 CHECK(rating BETWEEN 0 AND 5),PRIMARY KEY(song,singer))") - try execute("CREATE TABLE IF NOT EXISTS queue(id INTEGER PRIMARY KEY,venue INTEGER REFERENCES venues(id) ON DELETE CASCADE,song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,singer INTEGER REFERENCES singers(id) ON DELETE CASCADE,position INTEGER NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS playlists(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS playlist_songs(playlist INTEGER NOT NULL REFERENCES playlists(id) ON DELETE CASCADE,song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,position INTEGER NOT NULL,PRIMARY KEY(playlist,song))") - try execute("PRAGMA user_version=3") - } - deinit { sqlite3_close(db) } - private func statement(_ sql: String, _ values: [String?]) throws -> OpaquePointer { - var s: OpaquePointer? - guard sqlite3_prepare_v2(db, sql, -1, &s, nil) == SQLITE_OK, let s else { throw error() } - for (i,v) in values.enumerated() { - let code = v.map { sqlite3_bind_text(s, Int32(i + 1), $0, -1, unsafeBitCast(-1, to: sqlite3_destructor_type.self)) } ?? sqlite3_bind_null(s, Int32(i + 1)) - if code != SQLITE_OK { sqlite3_finalize(s); throw error() } - } - return s - } - private func error() -> LibraryError { .message(String(cString: sqlite3_errmsg(db))) } - func execute(_ sql: String, _ values: [String?] = []) throws { - let s = try statement(sql, values); defer { sqlite3_finalize(s) } - guard sqlite3_step(s) == SQLITE_DONE else { throw error() } - } - func songs() throws -> [Song] { - let s = try statement("SELECT id,title,audio,cdg,rating,plays,artist,album,label FROM songs ORDER BY title COLLATE NOCASE", []); defer { sqlite3_finalize(s) } - var result = [Song]() - while true { - let code = sqlite3_step(s); if code == SQLITE_DONE { break }; guard code == SQLITE_ROW else { throw error() } - result.append(Song(id: sqlite3_column_int64(s,0), title: String(cString: sqlite3_column_text(s,1)), audio: String(cString: sqlite3_column_text(s,2)), cdg: sqlite3_column_text(s,3).map { String(cString:$0) }, rating: Int(sqlite3_column_int(s,4)), plays: Int(sqlite3_column_int(s,5)), artist: text(s,6), album: text(s,7), label: text(s,8))) - } - return result - } - func add(title: String, audio: String, cdg: String?, artist: String = "", album: String = "", label: String = "") throws { - try execute("INSERT INTO songs(title,audio,cdg,artist,album,label) VALUES(?,?,?,?,?,?) ON CONFLICT(audio) DO UPDATE SET cdg=COALESCE(excluded.cdg,songs.cdg),artist=CASE WHEN excluded.artist!='' THEN excluded.artist ELSE songs.artist END,album=CASE WHEN excluded.album!='' THEN excluded.album ELSE songs.album END,label=CASE WHEN excluded.label!='' THEN excluded.label ELSE songs.label END", [title,audio,cdg,artist,album,label]) - } - func rate(_ id: Int64, _ rating: Int) throws { try execute("UPDATE songs SET rating=? WHERE id=?", [String(rating),String(id)]) } - func entities(_ table: String) throws -> [PersonPlace] { - precondition(["singers","venues","playlists"].contains(table)) - let s = try statement("SELECT id,name FROM \(table) ORDER BY name", []); defer { sqlite3_finalize(s) } - var rows = [PersonPlace]() - while sqlite3_step(s) == SQLITE_ROW { rows.append(.init(id: sqlite3_column_int64(s,0), name: String(cString: sqlite3_column_text(s,1)))) } - return rows - } - func addEntity(_ table: String, name: String) throws { - precondition(["singers","venues","playlists"].contains(table)) - let name = name.trimmingCharacters(in: .whitespacesAndNewlines) - guard !name.isEmpty else { throw LibraryError.message("Enter a name") } - try execute("INSERT OR IGNORE INTO \(table)(name) VALUES(?)", [name]) - } - func record(_ song: Int64, singer: Int64?, venue: Int64?) throws { - try execute("BEGIN IMMEDIATE") - do { - try execute("INSERT INTO history(song,singer,venue) VALUES(?,?,?)", [String(song),singer.map(String.init),venue.map(String.init)]) - try execute("UPDATE songs SET plays=plays+1 WHERE id=?", [String(song)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK"); throw error } - } - - private func text(_ s: OpaquePointer, _ index: Int32) -> String { sqlite3_column_text(s,index).map { String(cString:$0) } ?? "" } - private func schemaVersion() throws -> Int { - let s = try statement("PRAGMA user_version",[]); defer { sqlite3_finalize(s) } - return sqlite3_step(s) == SQLITE_ROW ? Int(sqlite3_column_int(s,0)) : 0 - } - private func columns(_ table: String) throws -> Set { - let s = try statement("PRAGMA table_info(\(table))", []); defer { sqlite3_finalize(s) } - var result = Set(); while sqlite3_step(s) == SQLITE_ROW { result.insert(text(s,1)) }; return result - } - func members(of venue: Int64) throws -> [PersonPlace] { - let s = try statement("SELECT singers.id,singers.name FROM singers JOIN venue_singers ON singers.id=venue_singers.singer WHERE venue=? ORDER BY name", [String(venue)]); defer { sqlite3_finalize(s) } - var result = [PersonPlace](); while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),name:text(s,1))) }; return result - } - func setMembership(singer: Int64, venue: Int64, included: Bool) throws { - try execute(included ? "INSERT OR IGNORE INTO venue_singers(venue,singer) VALUES(?,?)" : "DELETE FROM venue_singers WHERE venue=? AND singer=?", [String(venue),String(singer)]) - if !included { try execute("DELETE FROM queue WHERE venue=? AND singer=?",[String(venue),String(singer)]) } - } - func currentVenue() throws -> Int64? { - let s = try statement("SELECT venues.id FROM venues JOIN settings ON CAST(settings.value AS INTEGER)=venues.id WHERE settings.key='currentVenue'", []); defer { sqlite3_finalize(s) } - return sqlite3_step(s) == SQLITE_ROW ? sqlite3_column_int64(s,0) : nil - } - func selectVenue(_ id: Int64?) throws { - if let id { - guard try entities("venues").contains(where: { $0.id == id }) else { throw LibraryError.message("Venue no longer exists") } - } - try execute("INSERT INTO settings(key,value) VALUES('currentVenue',?) ON CONFLICT(key) DO UPDATE SET value=excluded.value",[id.map(String.init)]) - } - func rename(_ table: String, id: Int64, name: String) throws { - precondition(["singers","venues","playlists"].contains(table)) - let name = name.trimmingCharacters(in:.whitespacesAndNewlines) - guard !name.isEmpty else { throw LibraryError.message("Enter a name") } - try execute("UPDATE \(table) SET name=? WHERE id=?",[name,String(id)]) - } - func deleteEntity(_ table: String, id: Int64) throws { - precondition(["singers","venues","playlists"].contains(table)) - try execute("BEGIN IMMEDIATE") - do { - if table == "singers" { try execute("UPDATE history SET singer=NULL WHERE singer=?",[String(id)]) } - if table == "venues" { - try execute("UPDATE history SET venue=NULL WHERE venue=?",[String(id)]) - try execute("DELETE FROM settings WHERE key='currentVenue' AND value=?",[String(id)]) - } - try execute("DELETE FROM \(table) WHERE id=?",[String(id)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK"); throw error } - } - func preference(song: Int64, singer: Int64) throws -> SongPreference { - let s = try statement("SELECT pitch,tempo,rating FROM preferences WHERE song=? AND singer=?",[String(song),String(singer)]); defer { sqlite3_finalize(s) } - guard sqlite3_step(s) == SQLITE_ROW else { return .init() } - return .init(pitch:sqlite3_column_double(s,0),tempo:sqlite3_column_double(s,1),rating:Int(sqlite3_column_int(s,2))) - } - func savePreference(song: Int64, singer: Int64, value: SongPreference) throws { - try execute("INSERT INTO preferences(song,singer,pitch,tempo,rating) VALUES(?,?,?,?,?) ON CONFLICT(song,singer) DO UPDATE SET pitch=excluded.pitch,tempo=excluded.tempo,rating=excluded.rating",[String(song),String(singer),String(value.pitch),String(value.tempo),String(value.rating)]) - } - func history(venue: Int64?, singer: Int64? = nil) throws -> [Performance] { - let s = try statement("SELECT history.id,COALESCE(songs.title,'Deleted song'),COALESCE(singers.name,'—'),COALESCE(venues.name,'—'),played FROM history LEFT JOIN songs ON songs.id=history.song LEFT JOIN singers ON singers.id=history.singer LEFT JOIN venues ON venues.id=history.venue WHERE (? IS NULL OR history.venue=?) AND (? IS NULL OR history.singer=?) ORDER BY history.id DESC",[venue.map(String.init),venue.map(String.init),singer.map(String.init),singer.map(String.init)]); defer { sqlite3_finalize(s) } - var result = [Performance](); while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),song:text(s,1),singer:text(s,2),venue:text(s,3),date:text(s,4))) }; return result - } - func enqueue(song: Int64, singer: Int64?, venue: Int64?) throws { - guard let venue else { throw LibraryError.message("Select a current venue before adding to its queue") } - if let singer, try !members(of:venue).contains(where: { $0.id == singer }) { throw LibraryError.message("Add this singer to the current venue first") } - try execute("INSERT INTO queue(venue,song,singer,position) VALUES(?,?,?,(SELECT COALESCE(MAX(position),0)+1 FROM queue WHERE venue=?))",[String(venue),String(song),singer.map(String.init),String(venue)]) - } - func queue(venue: Int64?) throws -> [QueueEntry] { - guard let venue else { return [] } - let s = try statement("SELECT queue.id,queue.song,queue.singer,songs.title,COALESCE(singers.name,'No singer') FROM queue JOIN songs ON songs.id=queue.song LEFT JOIN singers ON singers.id=queue.singer WHERE queue.venue=? ORDER BY queue.position,queue.id",[String(venue)]); defer { sqlite3_finalize(s) } - var result = [QueueEntry](); while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),songID:sqlite3_column_int64(s,1),singerID:sqlite3_column_type(s,2) == SQLITE_NULL ? nil : sqlite3_column_int64(s,2),title:text(s,3),singer:text(s,4))) }; return result - } - func removeQueue(_ id: Int64) throws { try execute("DELETE FROM queue WHERE id=?",[String(id)]) } - func moveQueue(_ id: Int64, venue: Int64, by offset: Int) throws { - var rows = try queue(venue:venue) - guard let index = rows.firstIndex(where: { $0.id == id }), rows.indices.contains(index+offset) else { return } - rows.swapAt(index,index+offset) - try execute("BEGIN IMMEDIATE") - do { for (i,row) in rows.enumerated() { try execute("UPDATE queue SET position=? WHERE id=?",[String(i),String(row.id)]) }; try execute("COMMIT") } - catch { try? execute("ROLLBACK"); throw error } - } - func addToPlaylist(_ playlist: Int64, song: Int64) throws { - try execute("INSERT OR IGNORE INTO playlist_songs(playlist,song,position) VALUES(?,?,(SELECT COALESCE(MAX(position),0)+1 FROM playlist_songs WHERE playlist=?))",[String(playlist),String(song),String(playlist)]) - } - func playlistSongIDs(_ playlist: Int64) throws -> [Int64] { - let s = try statement("SELECT song FROM playlist_songs WHERE playlist=? ORDER BY position",[String(playlist)]); defer { sqlite3_finalize(s) } - var ids = [Int64](); while sqlite3_step(s) == SQLITE_ROW { ids.append(sqlite3_column_int64(s,0)) }; return ids - } - func removeFromPlaylist(_ playlist: Int64, song: Int64) throws { try execute("DELETE FROM playlist_songs WHERE playlist=? AND song=?",[String(playlist),String(song)]) } -} diff --git a/backups/before-mixer-repertoire-20261103-084301/KJamsClone/Player.swift b/backups/before-mixer-repertoire-20261103-084301/KJamsClone/Player.swift deleted file mode 100644 index 5c2440b..0000000 --- a/backups/before-mixer-repertoire-20261103-084301/KJamsClone/Player.swift +++ /dev/null @@ -1,150 +0,0 @@ -import SwiftUI -import AVFoundation - -/// CDG follows consumed source frames, so tempo adjustment preserves graphics timing. -@MainActor final class Player: ObservableObject { - @Published var image: CGImage? - @Published private(set) var waveform = [Float]() - @Published private(set) var waveformLoading = false - @Published private(set) var waveformUnavailable = false - private var waveformTask: Task? - private var waveformGeneration = UUID() - @Published var playing = false - @Published var time: Double = 0 - @Published var duration: Double = 0 - @Published var title = "Select a song" - @Published var volume: Double = 0.8 { didSet { engine.mainMixerNode.outputVolume = Float(volume) } } - @Published var repeating = false - @Published var pitch: Double = 0 { didSet { effect.pitch = Float(pitch * 100) } } - @Published var tempo: Double = 1 { didSet { effect.rate = Float(tempo) } } - @Published var graphicsOffset: Double = 0 - private(set) var currentSongID: Int64? - var onFinished: (() -> Void)? - private let engine = AVAudioEngine() - private let node = AVAudioPlayerNode() - private let effect = AVAudioUnitTimePitch() - private var file: AVAudioFile? - private var anchor: Double = 0 - private var generation = UUID() - private var cdg = Data() - private var decoder = CDGDecoder() - private var timer: Timer? - init() { engine.attach(node); engine.attach(effect) } - func load(_ song: Song, preference: SongPreference = .init()) throws { - stop() - do { - let loaded = try AVAudioFile(forReading:URL(fileURLWithPath:song.audio)) - let graphics = try song.cdg.map { try Data(contentsOf:URL(fileURLWithPath:$0)) } ?? Data() - guard loaded.length > 0 else { throw LibraryError.message("Audio file is empty") } - engine.connect(node,to:effect,format:loaded.processingFormat) - engine.connect(effect,to:engine.mainMixerNode,format:loaded.processingFormat) - file = loaded; cdg = graphics; decoder = CDGDecoder() - duration = Double(loaded.length)/loaded.processingFormat.sampleRate - title = song.title; currentSongID = song.id - pitch = preference.pitch; tempo = preference.tempo - engine.mainMixerNode.outputVolume = Float(volume) - engine.prepare(); try engine.start() - schedule(at:0,play:true); startTimer(); tick() - analyseWaveform(URL(fileURLWithPath:song.audio)) - } catch { stop(); throw error } - } - private func analyseWaveform(_ url: URL) { - let token = UUID(); waveformGeneration = token; waveformLoading = true - waveformTask = Task.detached(priority: .utility) { [weak self] in - let result: Result<[Float], Error> - do { result = .success(try AudioWaveform.read(url: url, cancelled: { Task.isCancelled })) } - catch { result = .failure(error) } - guard !Task.isCancelled else { return } - await MainActor.run { [weak self] in - guard let self, self.waveformGeneration == token else { return } - self.waveformLoading = false - switch result { - case .success(let samples): self.waveform = samples - case .failure: self.waveformUnavailable = true - } - } - } - } - private func schedule(at seconds: Double, play: Bool) { - guard let file else { return } - generation = UUID(); let token = generation - node.stop() - let rate = file.processingFormat.sampleRate - let start = min(file.length,max(0,AVAudioFramePosition(seconds*rate))) - anchor = Double(start)/rate; time = anchor - guard start < file.length else { playing = false; render(); return } - node.scheduleSegment(file,startingFrame:start,frameCount:AVAudioFrameCount(min(file.length-start,Int64(UInt32.max))),at:nil,completionCallbackType:.dataPlayedBack) { [weak self] _ in - Task { @MainActor in - guard let self, self.generation == token else { return } - if self.repeating { self.schedule(at:0,play:true) } - else { - self.playing = false; self.time = self.duration; self.render() - self.timer?.invalidate(); self.timer = nil; self.onFinished?() - } - } - } - if play { node.play() }; playing = play; render() - } - private func startTimer() { - timer?.invalidate() - timer = Timer.scheduledTimer(withTimeInterval:1.0/30,repeats:true) { [weak self] _ in Task { @MainActor in self?.tick() } } - } - func toggle() { - guard file != nil else { return } - if playing { tick(); node.pause(); playing = false } - else if time >= duration { schedule(at:0,play:true); startTimer() } - else { node.play(); playing = true; startTimer() } - } - func stop() { - waveformTask?.cancel(); waveformTask = nil; waveformGeneration = UUID() - waveform = []; waveformLoading = false; waveformUnavailable = false - generation = UUID(); timer?.invalidate(); timer = nil; node.stop(); engine.stop() - engine.disconnectNodeOutput(node); engine.disconnectNodeOutput(effect) - file = nil; playing = false; time = 0; anchor = 0; duration = 0; image = nil; currentSongID = nil; title = "Select a song" - } - func seek(_ value: Double) { - guard file != nil, value.isFinite else { return } - schedule(at:min(max(value,0),duration),play:playing); startTimer() - } - private func render() { decoder.render(cdg,at:max(0,time+graphicsOffset)); image = cdg.isEmpty ? nil : decoder.image() } - private func tick() { - if playing, let file, let renderTime = node.lastRenderTime, let playerTime = node.playerTime(forNodeTime:renderTime) { - time = min(duration,max(0,anchor+Double(playerTime.sampleTime)/file.processingFormat.sampleRate)) - } - render() - } -} - -/// Streams fixed-size PCM chunks into a bounded RMS envelope, independent of playback. -/// A separate AVAudioFile keeps analysis away from the player's scheduling/read position. -enum AudioWaveform { - static func read(url: URL, bins: Int = 1024, cancelled: () -> Bool = { false }) throws -> [Float] { - guard bins > 0 else { return [] } - let file = try AVAudioFile(forReading: url, commonFormat: .pcmFormatFloat32, interleaved: false) - guard file.length > 0, let buffer = AVAudioPCMBuffer(pcmFormat: file.processingFormat, frameCapacity: 16384) else { return [] } - var energy = [Double](repeating: 0, count: bins) - var counts = [Int](repeating: 0, count: bins) - var position: Int64 = 0 - let channels = Int(file.processingFormat.channelCount) - while position < file.length { - if cancelled() { throw CancellationError() } - try file.read(into: buffer, frameCount: AVAudioFrameCount(min(16384, file.length-position))) - let frames = Int(buffer.frameLength) - guard frames > 0, let data = buffer.floatChannelData else { break } - for frame in 0.. 0 ? sqrt($0/Double($1)) : 0 } - let peak = rms.max() ?? 0 - guard peak > 0 else { return [Float](repeating:0,count:bins) } - return rms.map { Float(pow(min(1,$0/peak),0.7)) } - } -} diff --git a/backups/before-mixer-repertoire-20261103-084301/KJamsCloneTests/KJamsCloneTests.swift b/backups/before-mixer-repertoire-20261103-084301/KJamsCloneTests/KJamsCloneTests.swift deleted file mode 100644 index 61af9e3..0000000 --- a/backups/before-mixer-repertoire-20261103-084301/KJamsCloneTests/KJamsCloneTests.swift +++ /dev/null @@ -1,266 +0,0 @@ -import XCTest -import AVFoundation -@testable import KJamsClone - -final class KJamsCloneTests: XCTestCase { - func packet(_ instruction: UInt8, _ data: [UInt8]) -> [UInt8] { [9,instruction,0,0] + Array((data + Array(repeating: 0,count:16)).prefix(16)) + [0,0,0,0] } - func testPresetTileXORAndInvalidCoordinates() { - var d = CDGDecoder() - d.apply(packet(1,[3,0])); XCTAssertEqual(d.pixels[0],3) - d.apply(packet(6,[0,5,1,1] + Array(repeating:63,count:12))) - XCTAssertEqual(d.pixels[12*300+6],5) - d.apply(packet(38,[0,5,1,1] + Array(repeating:63,count:12))) - XCTAssertEqual(d.pixels[12*300+6],0) - let old = d.pixels; d.apply(packet(6,[1,2,31,63])); XCTAssertEqual(d.pixels,old) - } - func testSeekAndTruncatedPacket() { - var d = CDGDecoder() - let data = Data(packet(1,[2,0]) + packet(1,[7,0]) + [9]) - d.render(data,at:1); XCTAssertEqual(d.pixels[0],7); XCTAssertEqual(d.packetIndex,2) - d.render(data,at:1.0/300); XCTAssertEqual(d.pixels[0],2) - d.render(data,at:0); XCTAssertEqual(d.pixels[0],0) - } - func testPaletteBorderScrollAndImage() { - var d = CDGDecoder() - d.apply(packet(30,[63,63])); XCTAssertEqual(d.palette[0],0xFFFFFFFF) - d.apply(packet(2,[4])); XCTAssertEqual(d.pixels[0],4); XCTAssertEqual(d.pixels[12*300+6],0) - d.apply(packet(20,[3,16,0])); XCTAssertEqual(d.pixels[100*300],3) - d.apply(packet(24,[0,32,0])); XCTAssertEqual(d.pixels[100*300+294],3) - XCTAssertEqual(d.image()?.width,288) - } - func testSQLitePersistenceDedupRatingsAndHistory() throws { - let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at: folder,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:folder) } - let url = folder.appendingPathComponent("test.sqlite") - do { - let db = try Library(url:url) - try db.add(title:"Singer's Song",audio:"/test.mp3",cdg:nil) - try db.add(title:"Duplicate",audio:"/test.mp3",cdg:"/test.cdg") - let song = try XCTUnwrap(db.songs().first) - try db.rate(song.id,5); XCTAssertThrowsError(try db.rate(song.id,6)) - try db.addEntity("singers",name:"O'Neil"); try db.addEntity("venues",name:"Hall") - try db.record(song.id,singer:db.entities("singers").first?.id,venue:db.entities("venues").first?.id) - } - let reopened = try Library(url:url); let songs = try reopened.songs() - XCTAssertEqual(songs.count,1); XCTAssertEqual(songs[0].rating,5); XCTAssertEqual(songs[0].plays,1); XCTAssertEqual(songs[0].cdg,"/test.cdg") - XCTAssertEqual(try reopened.entities("singers").first?.name,"O'Neil") - } - func testPairedImportAndContentDedup() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let audio = root.appendingPathComponent("Test.mp3"), cdg = root.appendingPathComponent("Test.CDG") - try Data([1,2,3]).write(to:audio); try Data(packet(1,[2,0])).write(to:cdg) - let db = try Library(url:root.appendingPathComponent("test.sqlite")) - let importer = Importer(media:root.appendingPathComponent("Media")) - try importer.run([audio],library:db); try importer.run([audio],library:db) - XCTAssertEqual(try db.songs().count,1) - XCTAssertNotNil(try db.songs().first?.cdg) - } - - func testZippedMP3GImportAndUnsafeArchiveRejection() throws { - let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:folder,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:folder) } - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let db = try Library(url:folder.appendingPathComponent("db.sqlite")) - let importer = Importer(media:folder.appendingPathComponent("Media")) - try importer.run([fixtures.appendingPathComponent("Demo.zip")],library:db) - let song = try XCTUnwrap(db.songs().first) - XCTAssertEqual(song.title,"Demo"); XCTAssertNotNil(song.cdg) - XCTAssertTrue(FileManager.default.fileExists(atPath:song.audio)) - XCTAssertThrowsError(try importer.run([fixtures.appendingPathComponent("Unsafe.zip")],library:db)) - } - @MainActor func testMP3PlaybackPauseAndSeek() throws { - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let player = Player() - defer { player.stop() } - try player.load(Song(id:1,title:"Demo",audio:fixtures.appendingPathComponent("Demo.mp3").path,cdg:fixtures.appendingPathComponent("Demo.cdg").path,rating:0,plays:0)) - XCTAssertGreaterThan(player.duration,3.9); XCTAssertTrue(player.playing) - player.toggle(); XCTAssertFalse(player.playing) - player.seek(2); XCTAssertEqual(player.time,2,accuracy:0.05); XCTAssertNotNil(player.image) - player.seek(0.1); XCTAssertEqual(player.time,0.1,accuracy:0.05) - } - @MainActor func testCreateSingerAndVenueThroughAppModel() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - defer { try? FileManager.default.removeItem(at: root) } - let model = AppModel(storageURL: root) - XCTAssertNil(model.error) - let singer = try model.createEntity(.singer, name: " Alex ") - let venue = try model.createEntity(.venue, name: "Town Hall") - XCTAssertEqual(model.singers.first?.name, "Alex") - XCTAssertEqual(model.venues.first?.name, "Town Hall") - XCTAssertEqual(try model.createEntity(.singer, name: "Alex"), singer) - XCTAssertEqual(model.singers.count, 1) - XCTAssertThrowsError(try model.createEntity(.venue, name: " ")) - let reopened = AppModel(storageURL: root) - XCTAssertEqual(reopened.singers.first?.id, singer) - XCTAssertEqual(reopened.venues.first?.id, venue) - } - - @MainActor func testVenuesShareSingersAndRememberSelection() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - defer { try? FileManager.default.removeItem(at:root) } - let model = AppModel(storageURL:root) - let hall = try model.createEntity(.venue,name:"Hall") - let alex = try model.createEntity(.singer,name:"Alex") - let club = try model.createEntity(.venue,name:"Club") - XCTAssertTrue(model.venueSingers.isEmpty) - model.membership(singer:alex,included:true) - XCTAssertEqual(model.venueSingers.map(\.id),[alex]) - model.chooseVenue(hall); XCTAssertEqual(model.venueSingers.map(\.id),[alex]) - model.chooseVenue(club); model.membership(singer:alex,included:false) - XCTAssertTrue(model.venueSingers.isEmpty) - let reopened = AppModel(storageURL:root) - XCTAssertEqual(reopened.currentVenue,club); XCTAssertTrue(reopened.venueSingers.isEmpty) - reopened.chooseVenue(hall); XCTAssertEqual(reopened.venueSingers.map(\.id),[alex]) - XCTAssertEqual(reopened.singers.count,1) - } - func testMigrationAndMembershipRemovalDoesNotReappear() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let url = root.appendingPathComponent("db.sqlite") - var singer: Int64 = 0, venue: Int64 = 0 - do { - let db = try Library(url:url) - try db.add(title:"Song",audio:"/a.mp3",cdg:nil) - try db.addEntity("singers",name:"Alex"); try db.addEntity("venues",name:"Hall") - singer = try XCTUnwrap(db.entities("singers").first?.id); venue = try XCTUnwrap(db.entities("venues").first?.id) - try db.record(XCTUnwrap(db.songs().first?.id),singer:singer,venue:venue) - try db.execute("PRAGMA user_version=1") - } - do { - let migrated = try Library(url:url) - XCTAssertEqual(try migrated.members(of:venue).map(\.id),[singer]) - try migrated.setMembership(singer:singer,venue:venue,included:false) - } - let reopened = try Library(url:url) - XCTAssertTrue(try reopened.members(of:venue).isEmpty) - XCTAssertEqual(try reopened.history(venue:venue).count,1) - } - func testQueuePlaylistsPreferencesAndDeletion() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let db = try Library(url:root.appendingPathComponent("db.sqlite")) - try db.add(title:"First",audio:"/1.mp3",cdg:nil) - try db.add(title:"Second",audio:"/2.mp3",cdg:nil) - let songs = try db.songs() - try db.addEntity("singers",name:"Alex"); try db.addEntity("venues",name:"Hall"); try db.addEntity("venues",name:"Club") - let singer = try XCTUnwrap(db.entities("singers").first?.id) - let hall = try XCTUnwrap(db.entities("venues").first(where: { $0.name == "Hall" })?.id) - let club = try XCTUnwrap(db.entities("venues").first(where: { $0.name == "Club" })?.id) - XCTAssertThrowsError(try db.enqueue(song:songs[0].id,singer:singer,venue:hall)) - try db.setMembership(singer:singer,venue:hall,included:true) - try db.enqueue(song:songs[0].id,singer:singer,venue:hall); try db.enqueue(song:songs[1].id,singer:singer,venue:hall) - XCTAssertTrue(try db.queue(venue:club).isEmpty) - let second = try XCTUnwrap(db.queue(venue:hall).last) - try db.moveQueue(second.id,venue:hall,by:-1) - XCTAssertEqual(try db.queue(venue:hall).first?.songID,songs[1].id) - let preference = SongPreference(pitch:3,tempo:0.85,rating:4) - try db.savePreference(song:songs[0].id,singer:singer,value:preference) - XCTAssertEqual(try db.preference(song:songs[0].id,singer:singer),preference) - XCTAssertThrowsError(try db.savePreference(song:songs[0].id,singer:singer,value:.init(pitch:99))) - try db.addEntity("playlists",name:"Party") - let playlist = try XCTUnwrap(db.entities("playlists").first?.id) - try db.addToPlaylist(playlist,song:songs[0].id); try db.addToPlaylist(playlist,song:songs[0].id) - XCTAssertEqual(try db.playlistSongIDs(playlist),[songs[0].id]) - try db.record(songs[0].id,singer:singer,venue:hall) - try db.rename("singers",id:singer,name:"Alex Jones") - XCTAssertEqual(try db.history(venue:hall).first?.singer,"Alex Jones") - try db.deleteEntity("singers",id:singer) - XCTAssertTrue(try db.queue(venue:hall).isEmpty) - XCTAssertEqual(try db.history(venue:hall).count,1) - try db.selectVenue(hall); try db.deleteEntity("venues",id:hall) - XCTAssertNil(try db.currentVenue()); XCTAssertEqual(try db.history(venue:nil).count,1) - } - @MainActor func testTempoSourceClockPauseAndResume() async throws { - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let player = Player(); defer { player.stop() } - let song = Song(id:1,title:"Demo",audio:fixtures.appendingPathComponent("Demo.mp3").path,cdg:fixtures.appendingPathComponent("Demo.cdg").path,rating:0,plays:0) - try player.load(song,preference:.init(pitch:2,tempo:1.5,rating:3)) - XCTAssertEqual(player.pitch,2); XCTAssertEqual(player.tempo,1.5) - try await Task.sleep(nanoseconds:500_000_000) - XCTAssertGreaterThan(player.time,0.45); XCTAssertLessThan(player.time,1.3) - player.toggle(); let paused = player.time - try await Task.sleep(nanoseconds:100_000_000) - XCTAssertEqual(player.time,paused,accuracy:0.025) - player.seek(1.5); player.toggle() - try await Task.sleep(nanoseconds:200_000_000) - XCTAssertGreaterThan(player.time,1.6); XCTAssertNotNil(player.image) - } - func testNewTestMediaMetadataAndCDGPairImport() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let db = try Library(url:root.appendingPathComponent("db.sqlite")) - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let importer = Importer(media:root.appendingPathComponent("Media")) - try importer.run([fixtures.appendingPathComponent("TestTrack.cdg")],library:db) - let song = try XCTUnwrap(db.songs().first) - XCTAssertEqual(song.title,"MP3 Plus G Test") - XCTAssertEqual(song.artist,"KJamsClone Test Generator") - XCTAssertNotNil(song.cdg) - let bytes = try Data(contentsOf:fixtures.appendingPathComponent("TestTrack.cdg")) - XCTAssertEqual(bytes.count,20*300*24) - var decoder = CDGDecoder(); decoder.render(bytes,at:2) - XCTAssertTrue(decoder.pixels.contains(1)); XCTAssertTrue(decoder.pixels.contains(2)) - } - @MainActor func testAutomaticVenueQueueAdvancesAndRecordsSinger() async throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - defer { try? FileManager.default.removeItem(at:root) } - let model = AppModel(storageURL:root); defer { model.player.stop() } - _ = try model.createEntity(.venue,name:"Test Hall") - _ = try model.createEntity(.singer,name:"Alex") - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - model.importFiles([fixtures.appendingPathComponent("Demo.zip")]) - let song = try XCTUnwrap(model.songs.first) - model.enqueue(song.id); model.enqueue(song.id); model.playQueueNext() - XCTAssertEqual(model.queue.count,1); XCTAssertEqual(model.history.count,1) - model.player.seek(model.player.duration-0.1) - for _ in 0..<25 { - if model.queue.isEmpty { break } - try await Task.sleep(nanoseconds:100_000_000) - } - XCTAssertNil(model.error); XCTAssertTrue(model.queue.isEmpty) - XCTAssertEqual(model.history.count,2); XCTAssertEqual(model.history.first?.singer,"Alex") - } - func testWaveformRepresentsSilenceAndSignalInTimeOrder() throws { - let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:folder,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:folder) } - let url = folder.appendingPathComponent("signal.wav") - let format = try XCTUnwrap(AVAudioFormat(standardFormatWithSampleRate:8000,channels:1)) - do { - let file = try AVAudioFile(forWriting:url,settings:format.settings) - let buffer = try XCTUnwrap(AVAudioPCMBuffer(pcmFormat:format,frameCapacity:4096)); buffer.frameLength = 4096 - let samples = try XCTUnwrap(buffer.floatChannelData?[0]) - for i in 0..<4096 { samples[i] = i < 2048 ? 0 : Float(sin(Double(i)*0.2)*0.5) } - try file.write(from:buffer) - } - let envelope = try AudioWaveform.read(url:url,bins:32) - XCTAssertEqual(envelope.count,32) - XCTAssertTrue(envelope.prefix(16).allSatisfy { $0 == 0 }) - XCTAssertTrue(envelope.suffix(16).allSatisfy { $0 > 0.8 && $0 <= 1 }) - XCTAssertThrowsError(try AudioWaveform.read(url:url,cancelled:{true})) - } - @MainActor func testWaveformAnalysisAndStopClearsTrackData() async throws { - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let player = Player(); defer { player.stop() } - try player.load(Song(id:1,title:"Demo",audio:fixtures.appendingPathComponent("Demo.mp3").path,cdg:nil,rating:0,plays:0)) - player.toggle() - for _ in 0..<50 { - if !player.waveformLoading { break } - try await Task.sleep(nanoseconds:20_000_000) - } - XCTAssertEqual(player.waveform.count,1024) - XCTAssertFalse(player.waveformUnavailable) - player.stop() - XCTAssertTrue(player.waveform.isEmpty) - XCTAssertFalse(player.waveformLoading) - try await Task.sleep(nanoseconds:50_000_000) - XCTAssertTrue(player.waveform.isEmpty) - } -} diff --git a/backups/before-sidebar-monitor-20261103-081330/KJamsClone/KJamsCloneApp.swift b/backups/before-sidebar-monitor-20261103-081330/KJamsClone/KJamsCloneApp.swift deleted file mode 100644 index 89c3daa..0000000 --- a/backups/before-sidebar-monitor-20261103-081330/KJamsClone/KJamsCloneApp.swift +++ /dev/null @@ -1,619 +0,0 @@ -import SwiftUI -import UniformTypeIdentifiers - -enum EntityKind: String, Identifiable { - case singer, venue - var id: String { rawValue } - var title: String { self == .singer ? "Singer" : "Venue" } - var table: String { self == .singer ? "singers" : "venues" } -} - -@MainActor final class AppModel: ObservableObject { - @Published var songs = [Song]() - @Published var singers = [PersonPlace]() - @Published var venues = [PersonPlace]() - @Published var venueSingers = [PersonPlace]() - @Published var playlists = [PersonPlace]() - @Published var queue = [QueueEntry]() - @Published var history = [Performance]() - @Published private(set) var currentVenue: Int64? - @Published var selectedSinger: Int64? - @Published var autoAdvance = true - @Published var error: String? - @Published var creating: EntityKind? - let player = Player() - private(set) var library: Library? - let root: URL - var currentVenueName: String { venues.first { $0.id == currentVenue }?.name ?? "No venue selected" } - init(storageURL: URL? = nil) { - root = storageURL ?? FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0].appendingPathComponent("KJamsClone") - perform { - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - library = try Library(url:root.appendingPathComponent("Library.sqlite")); try refresh() - } - player.onFinished = { [weak self] in - guard let self, self.autoAdvance, !self.queue.isEmpty else { return } - self.playQueueNext() - } - } - func perform(_ work: () throws -> Void) { do { try work() } catch { self.error = error.localizedDescription } } - func refresh() throws { - guard let library else { throw LibraryError.message("Library unavailable") } - songs = try library.songs(); singers = try library.entities("singers"); venues = try library.entities("venues") - playlists = try library.entities("playlists"); currentVenue = try library.currentVenue() - venueSingers = try currentVenue.map { try library.members(of:$0) } ?? singers - if let selectedSinger, !venueSingers.contains(where: { $0.id == selectedSinger }) { self.selectedSinger = nil } - queue = try library.queue(venue:currentVenue); history = try library.history(venue:currentVenue) - } - func chooseVenue(_ id: Int64?) { - perform { - guard let library else { throw LibraryError.message("Library unavailable") } - try library.selectVenue(id); selectedSinger = nil; try refresh() - } - } - func membership(singer: Int64, included: Bool) { - perform { - guard let library, let currentVenue else { throw LibraryError.message("Select a current venue first") } - try library.setMembership(singer:singer,venue:currentVenue,included:included); try refresh() - } - } - @discardableResult func createEntity(_ kind: EntityKind, name: String) throws -> Int64 { - guard let library else { throw LibraryError.message("Library unavailable") } - let trimmed = name.trimmingCharacters(in:.whitespacesAndNewlines) - try library.addEntity(kind.table,name:trimmed) - guard let entity = try library.entities(kind.table).first(where: { $0.name == trimmed }) else { throw LibraryError.message("Could not load new entry") } - if kind == .singer { - if let currentVenue { try library.setMembership(singer:entity.id,venue:currentVenue,included:true) } - selectedSinger = entity.id - } else { try library.selectVenue(entity.id); selectedSinger = nil } - try refresh(); return entity.id - } - func rename(_ table: String, id: Int64, name: String) { perform { try library?.rename(table,id:id,name:name); try refresh() } } - func delete(_ table: String, id: Int64) { perform { try library?.deleteEntity(table,id:id); try refresh() } } - func preference(_ song: Int64) -> SongPreference { - guard let library, let selectedSinger else { return .init() } - return (try? library.preference(song:song,singer:selectedSinger)) ?? .init() - } - func savePreference(song: Int64, value: SongPreference) { - perform { - guard let library, let selectedSinger else { throw LibraryError.message("Select a singer to save their song preferences") } - try library.savePreference(song:song,singer:selectedSinger,value:value); try refresh() - } - } - func play(_ song: Song, singer: Int64? = nil) throws { - guard let library else { throw LibraryError.message("Library unavailable") } - let singer = singer ?? selectedSinger - if let singer, let currentVenue, try !library.members(of:currentVenue).contains(where: { $0.id == singer }) { throw LibraryError.message("This singer is not in the current venue") } - let preference = try singer.map { try library.preference(song:song.id,singer:$0) } ?? SongPreference() - try player.load(song,preference:preference) - do { try library.record(song.id,singer:singer,venue:currentVenue); selectedSinger = singer; try refresh() } - catch { player.stop(); throw error } - } - func enqueue(_ song: Int64) { perform { try library?.enqueue(song:song,singer:selectedSinger,venue:currentVenue); try refresh() } } - func playQueueNext() { - perform { - guard let row = queue.first, let song = songs.first(where: { $0.id == row.songID }) else { return } - // Explicitly clear selection for unassigned queue entries. - selectedSinger = row.singerID - try play(song,singer:row.singerID); try library?.removeQueue(row.id); try refresh() - } - } - func moveQueue(_ id: Int64, by offset: Int) { perform { if let currentVenue { try library?.moveQueue(id,venue:currentVenue,by:offset); try refresh() } } } - func removeQueue(_ id: Int64) { perform { try library?.removeQueue(id); try refresh() } } - func createPlaylist(_ name: String) { perform { try library?.addEntity("playlists",name:name); try refresh() } } - func addToPlaylist(_ playlist: Int64, song: Int64) { perform { try library?.addToPlaylist(playlist,song:song); try refresh() } } - func importFiles(_ urls: [URL]) { perform { guard let library else { throw LibraryError.message("Library unavailable") }; try Importer(media:root.appendingPathComponent("Media")).run(urls,library:library); try refresh() } } -} -@main struct KJamsCloneApp: App { - @StateObject private var model = AppModel() - var body: some Scene { - Window("KJamsClone", id: "main") { - LibraryView(model: model).frame(minWidth: 1060, minHeight: 680).preferredColorScheme(.dark) - }.defaultSize(width: 1260, height: 840) - .commands { - CommandGroup(replacing: .newItem) { - Button("New Singer…") { model.creating = .singer }.keyboardShortcut("n", modifiers: [.command, .shift]) - Button("New Venue…") { model.creating = .venue }.keyboardShortcut("n", modifiers: [.command, .option]) - } - } - Window("Video", id: "lyrics") { - LyricsView(player: model.player).frame(minWidth: 480, minHeight: 320).preferredColorScheme(.dark) - }.defaultSize(width: 600, height: 400) - } -} -private enum Classic { - static let frame = Color(red: 0.15, green: 0.15, blue: 0.15) - static let navy = Color(red: 0.008, green: 0.065, blue: 0.16) - static let blue = Color(red: 0.015, green: 0.17, blue: 0.42) - static let header = Color(white: 0.115) - static let line = Color(white: 0.42) -} -struct LyricsView: View { - @ObservedObject var player: Player - var body: some View { - ZStack { - Color.black - if let image = player.image { - Image(decorative: image, scale: 1).interpolation(.none).resizable().aspectRatio(1.5, contentMode: .fit) - } - } - } -} -private struct SilverSquareStyle: ButtonStyle { - func makeBody(configuration: Configuration) -> some View { - configuration.label.foregroundStyle(Color(white: 0.25)).padding(.horizontal, 6).padding(.vertical, 3) - .background(LinearGradient(colors: [Color(white: 0.95), Color(white: 0.64)], startPoint: .top, endPoint: .bottom), in: RoundedRectangle(cornerRadius: 4)) - .overlay(RoundedRectangle(cornerRadius: 4).strokeBorder(Color(white: 0.45), lineWidth: 1.5)) - .overlay(RoundedRectangle(cornerRadius: 3).strokeBorder(.white.opacity(0.7)).padding(3)) - .opacity(configuration.isPressed ? 0.7 : 1) - } -} -private struct SilverButton: View { - let symbol: String - let label: String - var size: CGFloat = 40 - var active = false - var enabled = true - let action: () -> Void - var body: some View { - Button(action: action) { - Image(systemName: symbol).font(.system(size: size * 0.41, weight: .semibold)) - .foregroundStyle(active ? Color.blue : Color(white: 0.24)) - .frame(width: size, height: size) - .background(LinearGradient(colors: [.white, Color(white: 0.85), Color(white: 0.63)], startPoint: .top, endPoint: .bottom), in: Circle()) - .overlay(Circle().strokeBorder(Color(white: 0.45), lineWidth: 1.5)) - .overlay(Circle().strokeBorder(.white.opacity(0.65), lineWidth: 1).padding(3)) - .shadow(color: .black.opacity(0.7), radius: 1, y: 1) - }.buttonStyle(.plain).disabled(!enabled).opacity(enabled ? 1 : 0.72) - .help(label).accessibilityLabel(label) - } -} -struct LibraryView: View { - @ObservedObject var model: AppModel - @State private var selected: Int64? - @State private var search = "" - @State private var name = "" - @State private var importing = false - @State private var source = "Library" - @Environment(\.openWindow) private var openWindow - private var visibleSongs: [Song] { model.songs.filter { search.isEmpty || ($0.title+" "+$0.artist+" "+$0.album).localizedCaseInsensitiveContains(search) } } - private var selectedSong: Song? { model.songs.first { $0.id == selected } } - var body: some View { - VStack(spacing: 0) { - TransportView(player: model.player, search: $search, hasSelection: selectedSong != nil, - play: playSelected, next: playNext, display: { openWindow(id: "lyrics") }) - .padding(.horizontal, 18).padding(.top, 18).padding(.bottom, 22) - HSplitView { - sidebar.frame(minWidth: 190, idealWidth: 220, maxWidth: 240) - VStack(spacing: 12) { - if source == "Library" { songTable } - else if source == "Queue" { queuePane } - else if source == "History" { historyPane } - else if source == "Playlists" { playlistPane } - else { directory } - detailPanel.frame(height: 135) - }.padding(.leading, 12).frame(minWidth: 780) - }.padding(.horizontal, 18) - footer.padding(.horizontal, 18).padding(.vertical, 12) - } - .background(Classic.frame) - .sheet(item: $model.creating) { kind in - AddEntitySheet(model: model, kind: kind) { id in - if kind == .singer { model.selectedSinger = id } else { model.chooseVenue(id) } - } - } - .fileImporter(isPresented: $importing, allowedContentTypes: [.audio, .zip, UTType(filenameExtension: "cdg") ?? .data], allowsMultipleSelection: true) { result in - switch result { - case .success(let urls): model.importFiles(urls) - case .failure(let error): model.error = error.localizedDescription - } - } - .alert("KJamsClone", isPresented: Binding(get: { model.error != nil }, set: { if !$0 { model.error = nil } })) { - Button("OK") { model.error = nil } - } message: { Text(model.error ?? "") } - } - private func sourceCount(_ source: String) -> Int { - switch source { - case "Library": return model.songs.count - case "Singers": return model.venueSingers.count - case "Venues": return model.venues.count - case "Queue": return model.queue.count - case "History": return model.history.count - default: return model.playlists.count - } - } - private var sidebar: some View { - VStack(alignment: .leading, spacing: 0) { - Text("Source").font(.system(size: 15, weight: .semibold)).padding(.horizontal, 10).frame(height: 31) - .frame(maxWidth: .infinity, alignment: .leading).background(Classic.header) - ForEach([("Library", "music.note.house.fill", Color.yellow), ("Singers", "person.2.fill", Color.green), ("Venues", "building.2.fill", Color.cyan), ("Queue", "list.number", Color.orange), ("History", "clock.arrow.circlepath", Color.purple), ("Playlists", "music.note.list", Color.mint)], id: \.0) { item in - Button { source = item.0 } label: { - HStack(spacing: 10) { - Image(systemName: item.1).foregroundStyle(item.2).frame(width: 22) - Text(item.0).font(.system(size: 16, weight: .medium)) - Spacer() - Text("\(sourceCount(item.0))") - .font(.system(size: 11)).foregroundStyle(.white.opacity(0.6)) - }.padding(.horizontal, 12).frame(height: 34).contentShape(Rectangle()) - .background(source == item.0 ? Color(red: 0, green: 0.36, blue: 1) : .clear) - }.buttonStyle(.plain) - } - Spacer() - }.foregroundStyle(.white).background(Classic.navy).overlay(Rectangle().stroke(Classic.line, lineWidth: 1)) - } - private var songTable: some View { - GeometryReader { geometry in - ScrollView(.horizontal) { - VStack(spacing: 0) { - tableHeader(width: max(geometry.size.width, 790)) - ScrollView(.vertical) { - LazyVStack(spacing: 0) { - ForEach(visibleSongs) { song in songRow(song, width: max(geometry.size.width, 790)) } - }.frame(maxWidth: .infinity, alignment: .topLeading) - } - }.frame(width: max(geometry.size.width, 790), height: geometry.size.height) - } - }.background(Classic.navy).overlay(Rectangle().stroke(Classic.line, lineWidth: 1)) - } - private func widths(_ total: CGFloat) -> [CGFloat] { - [42, max(200, total - 598), 100, 100, 76, 86, 72, 122] - } - private func tableHeader(width: CGFloat) -> some View { - let sizes = widths(width) - return HStack(spacing: 0) { - ForEach(Array(["PLI", "Song Name", "Artist", "Album", "Label", "Key Adjust", "Tempo", "Rating"].enumerated()), id: \.offset) { index, title in - Text(title).font(.system(size: 13, weight: .medium)).lineLimit(1) - .padding(.leading, 7).frame(width: sizes[index], height: 30, alignment: .leading) - .overlay(alignment: .trailing) { Rectangle().fill(Classic.line).frame(width: 1).padding(.vertical, 4) } - } - }.foregroundStyle(.white).background(Classic.header) - .overlay(alignment: .bottom) { Rectangle().fill(Color(white: 0.65)).frame(height: 1) } - } - private func cellText(_ song: Song, column: Int) -> String { - switch column { - case 2: return song.artist.isEmpty ? "—" : song.artist - case 3: return song.album.isEmpty ? "—" : song.album - case 4: return song.label.isEmpty ? (song.cdg == nil ? "Audio" : URL(fileURLWithPath:song.audio).pathExtension.uppercased()+"+G") : song.label - case 5: return String(format:"%+.0f",model.preference(song.id).pitch) - default: return String(format:"%.0f%%",model.preference(song.id).tempo*100) - } - } - private func songRow(_ song: Song, width: CGFloat) -> some View { - let sizes = widths(width) - return HStack(spacing: 0) { - Image(systemName: song.cdg == nil ? "music.note" : "music.note.tv") - .foregroundStyle(.white.opacity(0.75)).frame(width: sizes[0]) - Text(song.title).lineLimit(1).padding(.leading, 7).frame(width: sizes[1], alignment: .leading) - ForEach(2..<7) { index in - Text(cellText(song, column: index)) - .foregroundStyle(.white.opacity(0.5)).padding(.leading, 7).frame(width: sizes[index], alignment: .leading) - } - Menu { - ForEach(0..<6) { value in - Button(value == 0 ? "Unrated" : String(repeating: "★", count: value)) { - model.perform { try model.library?.rate(song.id, value); try model.refresh() } - } - } - } label: { - Text(song.rating == 0 ? "☆☆☆☆☆" : String(repeating: "★", count: song.rating) + String(repeating: "☆", count: 5 - song.rating)) - .font(.system(size: 13)).foregroundStyle(song.rating == 0 ? Color.gray : Color.yellow) - }.menuStyle(.borderlessButton).frame(width: sizes[7] - 14).padding(.horizontal, 7).help("Set song rating") - }.font(.system(size: 13)).foregroundStyle(.white).frame(height: 30) - .background(selected == song.id ? Color(red: 0, green: 0.28, blue: 0.72) : .clear) - .contentShape(Rectangle()).onTapGesture(count: 2) { selected = song.id; playSelected() } - .onTapGesture { selected = song.id } - .contextMenu { - Button("Play") { selected = song.id; playSelected() } - Button("Add to Current Venue Queue") { model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Menu("Add to Playlist") { ForEach(model.playlists) { playlist in Button(playlist.name) { model.addToPlaylist(playlist.id,song:song.id) } } } - } - } - @State private var managingRoster = false - @State private var rosterNewName = "" - @State private var editingEntity: PersonPlace? - @State private var renameText = "" - @State private var pendingDelete: PersonPlace? - private var directory: some View { - VStack(alignment:.leading,spacing:0) { - HStack { - Text(source == "Singers" ? "Singers · \(model.currentVenueName)" : "Venues").font(.headline) - Spacer() - if source == "Singers" { Button("Manage Venue Singers…") { managingRoster = true }.disabled(model.currentVenue == nil) } - Button(source == "Singers" ? "New Singer…" : "New Venue…") { model.creating = source == "Singers" ? .singer : .venue } - }.padding(12).background(Classic.header) - ScrollView { - VStack(alignment:.leading,spacing:0) { - if source == "Singers" && model.venueSingers.isEmpty { - Text("No singers at this venue. Add a singer or use Manage Venue Singers to include existing singers.").foregroundStyle(.secondary).padding() - } - ForEach(source == "Singers" ? model.venueSingers : model.venues) { entity in - HStack { - Button { - if source == "Singers" { model.selectedSinger = entity.id } else { model.chooseVenue(entity.id) } - } label: { - HStack { - Image(systemName:source == "Singers" ? "person.fill" : "building.2.fill") - Text(entity.name); Spacer() - if entity.id == (source == "Singers" ? model.selectedSinger : model.currentVenue) { - Text(source == "Singers" ? "Selected" : "Current venue").font(.caption).foregroundStyle(.cyan) - Image(systemName:"checkmark.circle.fill").foregroundStyle(.cyan) - } - }.contentShape(Rectangle()) - }.buttonStyle(.plain) - Button("Rename") { renameText = entity.name; editingEntity = entity } - Button("Delete",role:.destructive) { pendingDelete = entity } - }.padding(12) - } - } - } - HStack { - TextField(source == "Singers" ? "Singer name" : "Venue name",text:$name).textFieldStyle(.roundedBorder).onSubmit(addEntity) - Button(source == "Singers" ? "Add Singer" : "Add Venue",action:addEntity).disabled(name.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - }.padding(12) - }.foregroundStyle(.white).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - .sheet(isPresented:$managingRoster) { rosterSheet } - .sheet(item:$editingEntity) { entity in - VStack(alignment:.leading,spacing:16) { - Text("Rename \(source == "Singers" ? "Singer" : "Venue")").font(.headline) - TextField("Name",text:$renameText).textFieldStyle(.roundedBorder) - HStack { Button("Cancel") { editingEntity = nil }; Spacer(); Button("Save") { model.rename(source == "Singers" ? "singers" : "venues",id:entity.id,name:renameText); editingEntity = nil }.disabled(renameText.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) } - }.padding(24).frame(width:360) - } - .confirmationDialog("Delete \(pendingDelete?.name ?? "entry")? Historical plays are kept. Venue memberships and queued entries for it will be removed.",isPresented:Binding(get:{ pendingDelete != nil },set:{ if !$0 { pendingDelete = nil } })) { - Button("Delete",role:.destructive) { if let entity = pendingDelete { model.delete(source == "Singers" ? "singers" : "venues",id:entity.id) }; pendingDelete = nil } - } - } - private var rosterSheet: some View { - VStack(alignment:.leading,spacing:16) { - Text("Singers at \(model.currentVenueName)").font(.title2.bold()) - Text("A singer can belong to any number of venues. Unchecking removes them from this venue only.").foregroundStyle(.secondary) - ScrollView { - VStack(alignment:.leading,spacing:12) { - ForEach(model.singers) { singer in - Toggle(singer.name,isOn:Binding(get:{ model.venueSingers.contains { $0.id == singer.id } },set:{ model.membership(singer:singer.id,included:$0) })) - } - }.frame(maxWidth:.infinity,alignment:.leading) - }.frame(minHeight:120,maxHeight:280) - HStack { - TextField("New singer name",text:$rosterNewName).textFieldStyle(.roundedBorder) - Button("Add") { model.perform { _ = try model.createEntity(.singer,name:rosterNewName); rosterNewName = "" } }.disabled(rosterNewName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - Spacer(); Button("Done") { managingRoster = false }.keyboardShortcut(.defaultAction) - } - }.padding(24).frame(width:460) - } - private var detailPanel: some View { - VStack(alignment:.leading,spacing:9) { - HStack(spacing:10) { - Picker("Current venue",selection:Binding(get:{ model.currentVenue },set:{ model.chooseVenue($0) })) { - Text("Select venue…").tag(nil as Int64?) - ForEach(model.venues) { Text($0.name).tag(Optional($0.id)) } - } - Button { model.creating = .venue } label: { Image(systemName:"plus.circle.fill") }.buttonStyle(.plain).help("Add venue") - Picker("Singer",selection:$model.selectedSinger) { - Text("None").tag(nil as Int64?) - ForEach(model.venueSingers) { Text($0.name).tag(Optional($0.id)) } - } - Button { model.creating = .singer } label: { Image(systemName:"plus.circle.fill") }.buttonStyle(.plain).help("Add singer") - Button("Queue Song") { if let selected { model.enqueue(selected) } }.disabled(selected == nil || model.currentVenue == nil) - } - PlaybackSettings(player:model.player,model:model,selectedSong:selected) - SeekBar(player:model.player) - }.padding(12).frame(maxWidth:.infinity,maxHeight:.infinity) - .background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - @State private var playlistName = "" - @State private var selectedPlaylist: Int64? - private var queuePane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { Text("Queue · \(model.currentVenueName)").font(.headline); Spacer(); Toggle("Auto play next",isOn:$model.autoAdvance).toggleStyle(.checkbox); Button("Play Next") { model.playQueueNext() }.disabled(model.queue.isEmpty) } - ScrollView { - VStack(spacing:0) { - ForEach(Array(model.queue.enumerated()),id:\.element.id) { index,row in - HStack { - Text("\(index+1)").foregroundStyle(.secondary).frame(width:24) - Text(row.singer).frame(width:140,alignment:.leading) - Text(row.title).lineLimit(1); Spacer() - Button { model.moveQueue(row.id,by:-1) } label: { Image(systemName:"arrow.up") }.disabled(index == 0) - Button { model.moveQueue(row.id,by:1) } label: { Image(systemName:"arrow.down") }.disabled(index == model.queue.count-1) - Button("Remove") { model.removeQueue(row.id) } - }.padding(.vertical,8) - } - if model.queue.isEmpty { Text("Choose a venue and singer, select a library song, then click Queue Song.").foregroundStyle(.secondary).padding(.top,30) } - } - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - @State private var historyAllVenues = false - private var displayedHistory: [Performance] { - if historyAllVenues { return (try? model.library?.history(venue:nil,singer:model.selectedSinger)) ?? [] } - return model.history.filter { model.selectedSinger == nil || $0.singer == model.singers.first(where: { $0.id == model.selectedSinger })?.name } - } - private var historyPane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { Text("History · \(historyAllVenues || model.currentVenue == nil ? "All venues" : model.currentVenueName)").font(.headline); Spacer(); Toggle("All venues",isOn:$historyAllVenues).toggleStyle(.checkbox) } - ScrollView { - LazyVStack(alignment:.leading,spacing:12) { - ForEach(displayedHistory) { row in - HStack { Text(row.date).font(.system(.caption,design:.monospaced)); Text(row.singer).frame(width:130,alignment:.leading); Text(row.song); Spacer(); Text(row.venue).foregroundStyle(.secondary) } - } - } - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - private var playlistPane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { - Picker("Playlist",selection:$selectedPlaylist) { Text("Choose…").tag(nil as Int64?); ForEach(model.playlists) { Text($0.name).tag(Optional($0.id)) } } - TextField("New playlist name",text:$playlistName).textFieldStyle(.roundedBorder) - Button("Create") { model.createPlaylist(playlistName); selectedPlaylist = model.playlists.first { $0.name == playlistName.trimmingCharacters(in:.whitespacesAndNewlines) }?.id; playlistName = "" }.disabled(playlistName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - if let selectedPlaylist { - Button("Rename") { model.rename("playlists",id:selectedPlaylist,name:playlistName); playlistName = "" }.disabled(playlistName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - Button("Delete",role:.destructive) { model.delete("playlists",id:selectedPlaylist); self.selectedPlaylist = nil } } - } - ScrollView { - if let selectedPlaylist { - let ids = (try? model.library?.playlistSongIDs(selectedPlaylist)) ?? [] - VStack(alignment:.leading,spacing:10) { - ForEach(ids,id:\.self) { id in - if let song = model.songs.first(where: { $0.id == id }) { - HStack { - Text(song.title); Spacer() - Button("Play") { model.perform { try model.play(song) } } - Button("Queue") { model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Button("Remove") { model.perform { try model.library?.removeFromPlaylist(selectedPlaylist,song:id); try model.refresh() } } - } - } - } - } - } - Text("Add songs using the library row’s context menu.").foregroundStyle(.secondary).padding(.top,20) - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - private var footer: some View { - HStack { - Button { importing = true } label: { Image(systemName: "plus").font(.system(size: 20, weight: .bold)).frame(width: 32, height: 24) } - .help("Import audio, MP3+G or ZIP").accessibilityLabel("Import songs") - RepeatButton(player: model.player).padding(.leading, 12) - Spacer() - Text("\(visibleSongs.count) \(visibleSongs.count == 1 ? "Song" : "Songs")").font(.system(size: 14, weight: .medium)) - Spacer() - Button { openWindow(id: "lyrics") } label: { Image(systemName: "rectangle.on.rectangle").frame(width: 32, height: 24) } - .help("Open video window").accessibilityLabel("Open video window") - }.buttonStyle(SilverSquareStyle()) - } - private func playSelected() { - guard let song = selectedSong else { return } - model.perform { try model.play(song) } - } - private func playNext() { - guard !visibleSongs.isEmpty else { return } - let index = visibleSongs.firstIndex { $0.id == selected } ?? -1 - selected = visibleSongs[(index + 1) % visibleSongs.count].id; playSelected() - } - private func addEntity() { - model.perform { - let kind: EntityKind = source == "Singers" ? .singer : .venue - let id = try model.createEntity(kind, name: name) - if kind == .singer { model.selectedSinger = id } else { model.chooseVenue(id) } - name = "" - } - } -} -private struct AddEntitySheet: View { - @ObservedObject var model: AppModel - let kind: EntityKind - let saved: (Int64) -> Void - @Environment(\.dismiss) private var dismiss - @State private var name = "" - @State private var error: String? - @FocusState private var focused: Bool - var body: some View { - VStack(alignment: .leading, spacing: 16) { - Text("New \(kind.title)").font(.title2.bold()) - TextField("\(kind.title) name", text: $name).textFieldStyle(.roundedBorder) - .focused($focused).onSubmit(save) - if let error { Text(error).foregroundStyle(.red).font(.callout) } - HStack { - Spacer() - Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction) - Button("Add \(kind.title)", action: save).keyboardShortcut(.defaultAction) - .disabled(name.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty) - } - }.padding(24).frame(width: 360).onAppear { focused = true } - } - private func save() { - do { let id = try model.createEntity(kind, name: name); saved(id); dismiss() } - catch { self.error = error.localizedDescription } - } -} -private struct TransportView: View { - @ObservedObject var player: Player - @Binding var search: String - let hasSelection: Bool - let play: () -> Void - let next: () -> Void - let display: () -> Void - var body: some View { - HStack(alignment: .top, spacing: 28) { - VStack(spacing: 15) { - HStack(spacing: 7) { - SilverButton(symbol: "backward.fill", label: "Back 10 seconds", size: 35, enabled: player.duration > 0) { player.seek(player.time - 10) } - SilverButton(symbol: player.playing ? "pause.fill" : "play.fill", label: player.playing ? "Pause" : "Play", size: 49, enabled: hasSelection || player.duration > 0) { - if player.duration > 0 { player.toggle() } else { play() } - } - SilverButton(symbol: "stop", label: "Stop", size: 46, enabled: player.duration > 0) { player.stop() } - SilverButton(symbol: "forward.fill", label: "Forward 10 seconds", size: 35, enabled: player.duration > 0) { player.seek(player.time + 10) } - SilverButton(symbol: "forward.end.fill", label: "Play next song", size: 26, enabled: hasSelection, action: next) - } - HStack(spacing: 9) { - Image(systemName: "speaker.fill").font(.system(size: 11)) - Slider(value: $player.volume, in: 0...1).controlSize(.small).tint(.gray).accessibilityLabel("Volume") - Image(systemName: "speaker.wave.3.fill").font(.system(size: 12)) - }.frame(width: 180) - }.frame(width: 220) - VStack(spacing: 0) { - Text(player.duration == 0 ? "Ready!" : player.title).font(.system(size: 15, weight: .medium)).lineLimit(1).padding(.horizontal, 20) - if player.duration > 0 { Text(player.playing ? "Playing" : "Paused").font(.system(size: 10)).foregroundStyle(.white.opacity(0.65)).padding(.top, 4) } - }.frame(maxWidth: .infinity).frame(height: 64) - .background(LinearGradient(colors: [Color(red: 0, green: 0.10, blue: 0.30), Classic.blue], startPoint: .top, endPoint: .bottom), in: Capsule()) - .overlay(Capsule().strokeBorder(LinearGradient(colors: [.black, .white], startPoint: .top, endPoint: .bottom), lineWidth: 1.5)) - .padding(.top, 14) - HStack(spacing: 12) { - TextField("Search", text: $search).textFieldStyle(.plain).font(.system(size: 16)) - .padding(.horizontal, 8).frame(width: 145, height: 28).background(Color(white: 0.07), in: RoundedRectangle(cornerRadius: 5)) - .overlay(RoundedRectangle(cornerRadius: 5).stroke(.white.opacity(0.1))) - SilverButton(symbol: "eye", label: "Open video window", size: 48, action: display) - }.padding(.top, 15) - }.foregroundStyle(.white).frame(height: 96) - } -} -private struct PlaybackSettings: View { - @ObservedObject var player: Player - @ObservedObject var model: AppModel - let selectedSong: Int64? - @State private var personalRating = 0 - var body: some View { - HStack(spacing:10) { - Text("Key") - Picker("Key",selection:$player.pitch) { ForEach(-12..<13) { Text(String(format:"%+d",$0)).tag(Double($0)) } }.labelsHidden().frame(width:70) - Text("Tempo") - Slider(value:$player.tempo,in:0.5...1.5,step:0.05).frame(width:85) - Text(String(format:"%.0f%%",player.tempo*100)).monospacedDigit().frame(width:40) - Text("Rating") - Picker("Singer rating",selection:$personalRating) { ForEach(0..<6) { Text($0 == 0 ? "Unrated" : String(repeating:"★",count:$0)).tag($0) } }.labelsHidden().frame(width:88).help("Singer-specific song rating") - Button("Save for Singer") { - if let song = player.currentSongID ?? selectedSong { model.savePreference(song:song,value:.init(pitch:player.pitch,tempo:player.tempo,rating:personalRating)) } - }.disabled(model.selectedSinger == nil || (player.currentSongID == nil && selectedSong == nil)) - Menu { - Button("Reset key / tempo") { player.pitch = 0; player.tempo = 1 } - ForEach([-1.0,-0.5,0,0.5,1.0],id:\.self) { offset in Button(String(format:"Graphics offset %+.1fs",offset)) { player.graphicsOffset = offset } } - } label: { Image(systemName:"slider.horizontal.3") }.menuStyle(.borderlessButton).frame(width:22).help("Playback settings") - }.font(.system(size:11)) - .onChange(of:model.selectedSinger) { _ in loadRating() } - .onChange(of:player.currentSongID) { _ in loadRating() } - .onChange(of:selectedSong) { _ in loadRating() } - } - private func loadRating() { if let song = player.currentSongID ?? selectedSong { personalRating = model.preference(song).rating } else { personalRating = 0 } } -} -private struct SeekBar: View { - @ObservedObject var player: Player - private func clock(_ seconds: Double) -> String { let n = Int(seconds); return String(format: "%d:%02d", n / 60, n % 60) } - var body: some View { - HStack(spacing: 10) { - Text(clock(player.time)) - Slider(value: Binding(get: { player.time }, set: { player.seek($0) }), in: 0...max(1, player.duration)) - .controlSize(.mini).tint(.gray).disabled(player.duration == 0).accessibilityLabel("Playback position") - Text(clock(player.duration)) - }.font(.system(size: 10, design: .monospaced)).foregroundStyle(.white.opacity(0.65)) - } -} -private struct RepeatButton: View { - @ObservedObject var player: Player - var body: some View { - Button { player.repeating.toggle() } label: { - Image(systemName: "repeat").font(.system(size: 18, weight: .semibold)) - .foregroundStyle(player.repeating ? Color.blue : Color(white: 0.25)).frame(width: 32, height: 24) - }.help(player.repeating ? "Repeat song: on" : "Repeat song: off").accessibilityLabel("Repeat song").accessibilityValue(player.repeating ? "On" : "Off") - } -} diff --git a/backups/before-tonight-drag-20261103-094630/KJamsClone/KJamsCloneApp.swift b/backups/before-tonight-drag-20261103-094630/KJamsClone/KJamsCloneApp.swift deleted file mode 100644 index 67647b3..0000000 --- a/backups/before-tonight-drag-20261103-094630/KJamsClone/KJamsCloneApp.swift +++ /dev/null @@ -1,1251 +0,0 @@ -import SwiftUI -import UniformTypeIdentifiers -import AVFoundation - -enum EntityKind: String, Identifiable { - case singer, venue - var id: String { rawValue } - var title: String { self == .singer ? "Singer" : "Venue" } - var table: String { self == .singer ? "singers" : "venues" } -} - -@MainActor final class AppModel: ObservableObject { - @Published var songs = [Song]() - @Published var singers = [PersonPlace]() - @Published var singerSongIDs = [Int64:[Int64]]() - @Published var favourites = [Int64:Set]() - @Published var musicStores = [MusicStore]() - @Published var readingDurations = false - var newSingerSongs = Set() - private var songIndex = [Int64:Song]() - @Published var venues = [PersonPlace]() - @Published var venueSingers = [PersonPlace]() - @Published var playlists = [PersonPlace]() - @Published var queue = [QueueEntry]() - @Published var tonightSongIDs = [Int64:[Int64]]() - @Published var history = [Performance]() - @Published private(set) var currentVenue: Int64? - @Published var selectedSinger: Int64? - @Published var autoAdvance = true - @Published var error: String? - @Published var creating: EntityKind? - let player: Player - private(set) var library: Library? - let root: URL - var currentVenueName: String { venues.first { $0.id == currentVenue }?.name ?? "No venue selected" } - init(storageURL: URL? = nil) { - root = storageURL ?? FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0].appendingPathComponent("KJamsClone") - player = Player(waveformCacheDirectory:root.appendingPathComponent("Waveforms")) - perform { - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - library = try Library(url:root.appendingPathComponent("Library.sqlite")); try refresh() - } - player.onFinished = { [weak self] in - guard let self, self.autoAdvance, !self.queue.isEmpty else { return } - self.playQueueNext() - } - } - func perform(_ work: () throws -> Void) { do { try work() } catch { self.error = error.localizedDescription } } - func refresh() throws { - guard let library else { throw LibraryError.message("Library unavailable") } - songs = try library.songs();songIndex = Dictionary(uniqueKeysWithValues:songs.map { ($0.id,$0) }); singers = try library.entities("singers"); venues = try library.entities("venues") - singerSongIDs = try library.singerSongIDs();favourites = try library.favouriteSongIDs();musicStores = try library.stores() - playlists = try library.entities("playlists"); currentVenue = try library.currentVenue() - venueSingers = try currentVenue.map { try library.members(of:$0) } ?? singers - if let selectedSinger, !venueSingers.contains(where: { $0.id == selectedSinger }) { self.selectedSinger = nil } - tonightSongIDs = try library.tonightSongIDs(venue:currentVenue) - queue = try library.queue(venue:currentVenue); history = try library.history(venue:currentVenue) - } - func chooseVenue(_ id: Int64?) { - perform { - guard let library else { throw LibraryError.message("Library unavailable") } - try library.selectVenue(id); selectedSinger = nil; try refresh() - } - } - func membership(singer: Int64, included: Bool) { - perform { - guard let library, let currentVenue else { throw LibraryError.message("Select a current venue first") } - try library.setMembership(singer:singer,venue:currentVenue,included:included); try refresh() - } - } - @discardableResult func createEntity(_ kind: EntityKind, name: String) throws -> Int64 { - guard let library else { throw LibraryError.message("Library unavailable") } - let trimmed = name.trimmingCharacters(in:.whitespacesAndNewlines) - try library.addEntity(kind.table,name:trimmed) - guard let entity = try library.entities(kind.table).first(where: { $0.name == trimmed }) else { throw LibraryError.message("Could not load new entry") } - if kind == .singer { - if let currentVenue { try library.setMembership(singer:entity.id,venue:currentVenue,included:true) } - selectedSinger = entity.id - } else { try library.selectVenue(entity.id); selectedSinger = nil } - try refresh(); return entity.id - } - func beginSinger(song: Int64? = nil) { newSingerSongs = Set(song.map { [$0] } ?? []); creating = .singer } - func songs(for singer: Int64) -> [Song] { - (singerSongIDs[singer] ?? []).compactMap { songIndex[$0] } - } - func assign(_ song: Int64, to singer: Int64, included: Bool = true) { - perform { - guard let library else { throw LibraryError.message("Library unavailable") } - if included { try library.assignSong(song,singer:singer) } else { try library.removeSingerSong(song,singer:singer) } - try refresh() - } - } - func createSinger(name: String, venue: Int64, songs: Set) throws -> Int64 { - guard let library else { throw LibraryError.message("Library unavailable") } - guard venues.contains(where: { $0.id == venue }) else { throw LibraryError.message("Choose a venue first") } - let name = name.trimmingCharacters(in:.whitespacesAndNewlines) - try library.execute("BEGIN IMMEDIATE") - let id: Int64 - do { - try library.addEntity("singers",name:name) - guard let singer = try library.entities("singers").first(where: { $0.name == name }) else { throw LibraryError.message("Could not load singer") } - id = singer.id - try library.setMembership(singer:id,venue:venue,included:true) - for song in songs { try library.assignSong(song,singer:id) } - try library.selectVenue(venue);try library.execute("COMMIT") - } catch { try? library.execute("ROLLBACK");throw error } - try refresh();selectedSinger = id;return id - } - func rename(_ table: String, id: Int64, name: String) { perform { try library?.rename(table,id:id,name:name); try refresh() } } - func delete(_ table: String, id: Int64) { perform { try library?.deleteEntity(table,id:id); try refresh() } } - func preference(_ song: Int64) -> SongPreference { - guard let library else { return .init() } - if let selectedSinger { return (try? library.preference(song:song,singer:selectedSinger)) ?? .init() } - return (try? library.defaultPreference(song:song)) ?? .init() - } - func savePreference(song: Int64, value: SongPreference) { - perform { - guard let library, let selectedSinger else { throw LibraryError.message("Select a singer to save their song preferences") } - try library.savePreference(song:song,singer:selectedSinger,value:value); try refresh() - } - } - func play(_ song: Song, singer: Int64? = nil) throws { - guard let library else { throw LibraryError.message("Library unavailable") } - let singer = singer ?? selectedSinger - if let singer, let currentVenue, try !library.members(of:currentVenue).contains(where: { $0.id == singer }) { throw LibraryError.message("This singer is not in the current venue") } - let preference = try singer.map { try library.preference(song:song.id,singer:$0) } ?? library.defaultPreference(song:song.id) - try player.load(song,preference:preference) - do { try library.updateDuration(song.id,seconds:player.duration);try library.record(song.id,singer:singer,venue:currentVenue); selectedSinger = singer; try refresh() } - catch { player.stop(); throw error } - } - func enqueue(_ song: Int64) { perform { try library?.enqueue(song:song,singer:selectedSinger,venue:currentVenue); try refresh() } } - func tonightSongs(for singer: Int64) -> [Song] { (tonightSongIDs[singer] ?? []).compactMap { songIndex[$0] } } - func addToTonight(_ song: Int64,singer: Int64? = nil) { - perform { - guard let library,let currentVenue,let singer = singer ?? selectedSinger else { throw LibraryError.message("Choose a current venue and singer, then add the song to Tonight") } - try library.addTonight(song:song,singer:singer,venue:currentVenue);try refresh() - } - } - func removeFromTonight(_ song: Int64,singer: Int64) { - perform { guard let library,let currentVenue else { return };try library.removeTonight(song:song,singer:singer,venue:currentVenue);try refresh() } - } - func playTonight(_ song: Song,singer: Int64) { - perform { - try play(song,singer:singer) - if let entry = queue.first(where:{ $0.songID == song.id && $0.singerID == singer }) { try library?.removeQueue(entry.id) } - try refresh() - } - } - func playQueueNext() { - perform { - guard let row = queue.first, let song = songs.first(where: { $0.id == row.songID }) else { return } - // Explicitly clear selection for unassigned queue entries. - selectedSinger = row.singerID - try play(song,singer:row.singerID); try library?.removeQueue(row.id); try refresh() - } - } - func moveQueue(_ id: Int64, by offset: Int) { perform { if let currentVenue { try library?.moveQueue(id,venue:currentVenue,by:offset); try refresh() } } } - func removeQueue(_ id: Int64) { perform { try library?.removeQueue(id); try refresh() } } - func createPlaylist(_ name: String) { perform { try library?.addEntity("playlists",name:name); try refresh() } } - func addToPlaylist(_ playlist: Int64, song: Int64) { perform { try library?.addToPlaylist(playlist,song:song); try refresh() } } - func setFavourite(_ song: Int64, singer: Int64, included: Bool) { perform { try library?.setFavourite(song:song,singer:singer,included:included);try refresh() } } - func updateTuning(_ song: Int64, pitch: Double? = nil, tempo: Double? = nil) { - perform { - guard let library else { throw LibraryError.message("Library unavailable") } - var value = preference(song) - if let pitch { value.pitch = pitch };if let tempo { value.tempo = tempo } - if let selectedSinger { try library.savePreference(song:song,singer:selectedSinger,value:value) } - else { try library.saveDefaultPreference(song:song,value:value) } - if player.currentSongID == song { if pitch != nil { player.pitch = value.pitch };if tempo != nil { player.tempo = value.tempo } } - try refresh() - } - } - func saveStore(_ store: MusicStore) throws { guard let library else { throw LibraryError.message("Library unavailable") };try library.saveStore(store);try refresh() } - func deleteStore(_ id: Int64) { perform { try library?.deleteStore(id);try refresh() } } - func scanDurations() { - guard !readingDurations else { return };readingDurations = true - let songs = self.songs.filter { $0.duration == 0 } - Task.detached(priority:.utility) { [weak self] in - var durations = [(Int64,Double)]() - for song in songs { - if let file = try? AVAudioFile(forReading:URL(fileURLWithPath:song.audio)) { durations.append((song.id,Double(file.length)/file.processingFormat.sampleRate)) } - } - let completedDurations = durations - await MainActor.run { [weak self] in - guard let self else { return } - self.perform { for (id,value) in completedDurations { try self.library?.updateDuration(id,seconds:value) };try self.refresh() } - self.readingDurations = false - } - } - } - func updateMetadata(_ song: Song,title: String,artist: String,album: String,label: String,rating: Int) throws { - guard let library else { throw LibraryError.message("Library unavailable") } - try library.updateMetadata(song:song.id,title:title,artist:artist,album:album,label:label,rating:rating) - if player.currentSongID == song.id { player.title = title.trimmingCharacters(in:.whitespacesAndNewlines) } - try refresh() - } - func importFiles(_ urls: [URL]) { perform { guard let library else { throw LibraryError.message("Library unavailable") }; try Importer(media:root.appendingPathComponent("Media")).run(urls,library:library); try refresh() } } -} -@main struct KJamsCloneApp: App { - @StateObject private var model = AppModel() - var body: some Scene { - Window("KJamsClone", id: "main") { - LibraryView(model: model).frame(minWidth: 1060, minHeight: 680).preferredColorScheme(.dark) - }.defaultSize(width: 1260, height: 840) - .commands { - CommandGroup(replacing: .newItem) { - Button("New Singer…") { model.beginSinger() }.keyboardShortcut("n", modifiers: [.command, .shift]) - Button("New Venue…") { model.creating = .venue }.keyboardShortcut("n", modifiers: [.command, .option]) - } - } - Window("Video", id: "lyrics") { - LyricsView(player: model.player).frame(minWidth: 480, minHeight: 320).preferredColorScheme(.dark) - }.defaultSize(width: 600, height: 400) - } -} -private enum Classic { - static let frame = Color(red: 0.15, green: 0.15, blue: 0.15) - static let navy = Color(red: 0.008, green: 0.065, blue: 0.16) - static let blue = Color(red: 0.015, green: 0.17, blue: 0.42) - static let header = Color(white: 0.115) - static let line = Color(white: 0.42) -} -struct LyricsView: View { - @ObservedObject var player: Player - var body: some View { - ZStack { - Color.black - if let image = player.image { - Image(decorative: image, scale: 1).interpolation(.none).resizable().aspectRatio(1.5, contentMode: .fit) - } - } - } -} -/// This is another view of the same published CGImage used by the Video window. -/// It owns no decoder, audio player or clock, so seeking/pause/tempo stay identical. -private struct SidebarVideoMonitor: View { - let player: Player - var body: some View { - VStack(alignment: .leading, spacing: 7) { - Label("Video Monitor", systemImage: "tv") - .font(.system(size: 11, weight: .medium)).foregroundStyle(.white.opacity(0.7)) - LyricsView(player: player) - .aspectRatio(1.5, contentMode: .fit) - .clipped() - .overlay(Rectangle().strokeBorder(.white.opacity(0.25), lineWidth: 1)) - .accessibilityLabel("Video monitor, synchronized with the Video window") - }.frame(maxWidth: .infinity) - } -} -private struct SilverSquareStyle: ButtonStyle { - func makeBody(configuration: Configuration) -> some View { - configuration.label.foregroundStyle(Color(white: 0.25)).padding(.horizontal, 6).padding(.vertical, 3) - .background(LinearGradient(colors: [Color(white: 0.95), Color(white: 0.64)], startPoint: .top, endPoint: .bottom), in: RoundedRectangle(cornerRadius: 4)) - .overlay(RoundedRectangle(cornerRadius: 4).strokeBorder(Color(white: 0.45), lineWidth: 1.5)) - .overlay(RoundedRectangle(cornerRadius: 3).strokeBorder(.white.opacity(0.7)).padding(3)) - .opacity(configuration.isPressed ? 0.7 : 1) - } -} -private struct SilverButton: View { - let symbol: String - let label: String - var size: CGFloat = 40 - var active = false - var enabled = true - let action: () -> Void - var body: some View { - Button(action: action) { - Image(systemName: symbol).font(.system(size: size * 0.41, weight: .semibold)) - .foregroundStyle(active ? Color.blue : Color(white: 0.24)) - .frame(width: size, height: size) - .background(LinearGradient(colors: [.white, Color(white: 0.85), Color(white: 0.63)], startPoint: .top, endPoint: .bottom), in: Circle()) - .overlay(Circle().strokeBorder(Color(white: 0.45), lineWidth: 1.5)) - .overlay(Circle().strokeBorder(.white.opacity(0.65), lineWidth: 1).padding(3)) - .shadow(color: .black.opacity(0.7), radius: 1, y: 1) - }.buttonStyle(.plain).disabled(!enabled).opacity(enabled ? 1 : 0.72) - .help(label).accessibilityLabel(label) - } -} -struct LibraryView: View { - @ObservedObject var model: AppModel - @State private var selected: Int64? - @State private var search = "" - @State private var name = "" - @State private var importing = false - @State private var source = "Library" - @State private var singersExpanded = true - @State private var expandedSingers = Set() - @State private var expandedSongLists = Set() - @State private var songPickerSinger: PersonPlace? - @State private var songPickerTonight = false - @State private var singerSections = [Int64:String]() - @State private var singerSelections = [Int64:Int64]() - @State private var presentedSinger: Int64? - @State private var singerSection = "All Songs" - @State private var storesExpanded = true - @State private var focusedStore: Int64? - @State private var editingSong: Song? - @State private var librarySort = "Song Name" - @State private var sortAscending = true - @Environment(\.openWindow) private var openWindow - private var visibleSongs: [Song] { - let filtered = model.songs.filter { search.isEmpty || ($0.title+" "+$0.artist+" "+$0.album).localizedCaseInsensitiveContains(search) } - return filtered.sorted { a,b in - if a.id == b.id { return false } - if librarySort == "Duration" { return a.duration == b.duration ? a.id < b.id : sortAscending ? a.duration < b.duration : a.duration > b.duration } - if librarySort == "Rating" { return a.rating == b.rating ? a.id < b.id : sortAscending ? a.rating < b.rating : a.rating > b.rating } - let first = librarySort == "Artist" ? a.artist : librarySort == "Album" ? a.album : a.title - let second = librarySort == "Artist" ? b.artist : librarySort == "Album" ? b.album : b.title - let order = first.localizedStandardCompare(second) - return order == .orderedSame ? a.id < b.id : sortAscending ? order == .orderedAscending : order == .orderedDescending - } - } - - private var selectedSong: Song? { model.songs.first { $0.id == selected } } - var body: some View { - VStack(spacing: 0) { - TransportView(player: model.player, search: $search, hasSelection: selectedSong != nil, - play: playSelected, next: playNext, display: { openWindow(id: "lyrics") }) - .padding(.horizontal, 18).padding(.top, 18).padding(.bottom, 22) - HSplitView { - sidebar.frame(minWidth: 190, idealWidth: 220, maxWidth: 240) - VStack(spacing: 12) { - if source == "Library" { songTable } - else if source == "Queue" { queuePane } - else if source == "History" { historyPane } - else if source == "Playlists" { playlistPane } - else if source == "Singer Songs" { singerSongPane } - else if source == "Music Stores" { MusicStoresPane(model:model,selected:$focusedStore) } - else { directory } - detailPanel.frame(height: 135) - }.padding(.leading, 12).frame(minWidth: 780) - }.padding(.horizontal, 18) - footer.padding(.horizontal, 18).padding(.vertical, 12) - } - .background(Classic.frame) - .sheet(item: $model.creating) { kind in - AddEntitySheet(model: model, kind: kind) { id in - if kind == .singer { expandedSingers.insert(id);expandedSongLists.insert(id);singersExpanded = true;showSinger(id,section:"All Songs") } else { model.chooseVenue(id) } - } - } - .sheet(item:$editingSong) { song in SongMetadataSheet(model:model,song:song) } - .sheet(item:$songPickerSinger) { singer in SingerSongsSheet(model:model,singer:singer,tonight:songPickerTonight) } - .onChange(of:selected) { song in - if source == "Singer Songs",let singer = model.selectedSinger,let song { singerSelections[singer] = song } - } - .onChange(of:model.selectedSinger) { singer in - if source == "Singer Songs",presentedSinger != singer { showSinger(singer,section:nil) } - } - .fileImporter(isPresented: $importing, allowedContentTypes: [.audio, .zip, UTType(filenameExtension: "cdg") ?? .data], allowsMultipleSelection: true) { result in - switch result { - case .success(let urls): model.importFiles(urls) - case .failure(let error): model.error = error.localizedDescription - } - } - .alert("KJamsClone", isPresented: Binding(get: { model.error != nil }, set: { if !$0 { model.error = nil } })) { - Button("OK") { model.error = nil } - } message: { Text(model.error ?? "") } - } - private func showSinger(_ id: Int64?,section: String? = nil) { - if source == "Singer Songs",let previous = presentedSinger { - singerSections[previous] = singerSection - if let selected { singerSelections[previous] = selected } - } - presentedSinger = id;model.selectedSinger = id - singerSection = section ?? id.flatMap { singerSections[$0] } ?? "Tonight" - if let id { singerSections[id] = singerSection;selected = singerSelections[id] } - source = "Singer Songs" - } - private func sourceCount(_ source: String) -> Int { - switch source { - case "Library": return model.songs.count - case "Singers": return model.venueSingers.count - case "Venues": return model.venues.count - case "Queue": return model.queue.count - case "History": return model.history.count - default: return model.playlists.count - } - } - private var sidebar: some View { - VStack(alignment:.leading,spacing:0) { - Text("Source").font(.system(size:15,weight:.semibold)).padding(.horizontal,10).frame(height:31) - .frame(maxWidth:.infinity,alignment:.leading).background(Classic.header) - ScrollView { - VStack(spacing:0) { - sourceRow("Library",icon:"music.note.house.fill",color:.yellow) - HStack(spacing:5) { - Button { singersExpanded.toggle() } label: { Image(systemName:singersExpanded ? "chevron.down" : "chevron.right").font(.system(size:10)).frame(width:12) }.buttonStyle(.plain).accessibilityLabel("Expand singers") - Button { source = "Singers" } label: { HStack { Image(systemName:"person.2.fill").foregroundStyle(.green);Text("Singers");Spacer();Text("\(model.venueSingers.count)").font(.caption).foregroundStyle(.secondary) } }.buttonStyle(.plain) - Button { model.beginSinger() } label: { Image(systemName:"plus.circle.fill").foregroundStyle(.green) }.buttonStyle(.plain).help("New singer and songs") - }.padding(.horizontal,10).frame(height:34).background(source == "Singers" ? Color.blue.opacity(0.65) : .clear) - if singersExpanded { - Text(model.currentVenueName).font(.system(size:10)).foregroundStyle(.secondary).lineLimit(1).padding(.leading,30).frame(maxWidth:.infinity,alignment:.leading).padding(.vertical,4) - ForEach(model.venueSingers) { singer in sidebarSinger(singer) } - if model.venueSingers.isEmpty { Text("Add a singer with +").font(.caption).foregroundStyle(.secondary).padding(8) } - } - HStack { - Button { storesExpanded.toggle() } label: { Image(systemName:storesExpanded ? "chevron.down" : "chevron.right").font(.system(size:10)) }.buttonStyle(.plain) - Button { source = "Music Stores" } label: { Label("Music Stores",systemImage:"bag.fill").foregroundStyle(.green);Spacer() }.buttonStyle(.plain) - }.padding(.horizontal,12).frame(height:34) - if storesExpanded { - ForEach(model.musicStores) { store in - Button { focusedStore = store.id;source = "Music Stores" } label: { Label(store.name,systemImage:"globe").font(.system(size:12)).lineLimit(1).padding(.leading,32).frame(maxWidth:.infinity,alignment:.leading).frame(height:26) }.buttonStyle(.plain) - } - Button("Configure Stores…") { source = "Music Stores" }.buttonStyle(.plain).font(.system(size:11)).foregroundStyle(.secondary).padding(.leading,32).frame(maxWidth:.infinity,alignment:.leading).frame(height:25) - } - sourceRow("Venues",icon:"building.2.fill",color:.cyan) - sourceRow("Queue",icon:"list.number",color:.orange) - sourceRow("History",icon:"clock.arrow.circlepath",color:.purple) - sourceRow("Playlists",icon:"music.note.list",color:.mint) - } - } - SidebarVideoMonitor(player:model.player).padding(10) - }.foregroundStyle(.white).background(Classic.navy).overlay(Rectangle().stroke(Classic.line,lineWidth:1)) - } - private func sourceRow(_ title: String, icon: String, color: Color) -> some View { - Button { source = title } label: { - HStack(spacing:10) { - Image(systemName:icon).foregroundStyle(color).frame(width:22) - Text(title).font(.system(size:16,weight:.medium));Spacer() - Text("\(sourceCount(title))").font(.system(size:11)).foregroundStyle(.white.opacity(0.6)) - }.padding(.horizontal,12).frame(height:34).contentShape(Rectangle()) - .background(source == title ? Color(red:0,green:0.36,blue:1) : .clear) - }.buttonStyle(.plain) - } - private func sidebarSinger(_ singer: PersonPlace) -> some View { - VStack(alignment:.leading,spacing:0) { - HStack(spacing:5) { - Button { - if expandedSingers.contains(singer.id) { expandedSingers.remove(singer.id) } else { expandedSingers.insert(singer.id) } - } label: { Image(systemName:expandedSingers.contains(singer.id) ? "chevron.down" : "chevron.right").font(.system(size:9)).frame(width:12) }.buttonStyle(.plain).accessibilityLabel("Expand \(singer.name)’s songs") - Button { showSinger(singer.id) } label: { - HStack(spacing:5) { Text(singer.name).lineLimit(1);Spacer();Text("\(model.singerSongIDs[singer.id]?.count ?? 0)").font(.system(size:10)).foregroundStyle(.secondary) } - }.buttonStyle(.plain) - Menu { - Button("Add to Tonight…") { showSinger(singer.id,section:"Tonight");songPickerTonight = true;songPickerSinger = singer } - Button("Manage All Songs…") { showSinger(singer.id,section:"All Songs");songPickerTonight = false;songPickerSinger = singer } - } label: { Image(systemName:"plus").font(.system(size:10,weight:.bold)) }.menuStyle(.borderlessButton).frame(width:16).help("Add songs to \(singer.name)’s Tonight or repertoire") - }.font(.system(size:13,weight:.medium)).padding(.leading,25).padding(.trailing,12).frame(height:29) - .background(model.selectedSinger == singer.id && source == "Singer Songs" ? Color.blue.opacity(0.25) : .clear) - if expandedSingers.contains(singer.id) { - singerFolder("Tonight",icon:"music.note.list",singer:singer) - singerFolder("Favourites",icon:"star.fill",singer:singer) - singerFolder("History",icon:"clock.arrow.circlepath",singer:singer) - HStack(spacing:3) { - Button { if expandedSongLists.contains(singer.id) { expandedSongLists.remove(singer.id) } else { expandedSongLists.insert(singer.id) } } label: { Image(systemName:expandedSongLists.contains(singer.id) ? "chevron.down" : "chevron.right").font(.system(size:9)) }.buttonStyle(.plain) - singerFolder("All Songs",icon:"folder",singer:singer) - }.padding(.leading,28) - if expandedSongLists.contains(singer.id) { - ForEach(model.songs(for:singer.id)) { song in - Button { showSinger(singer.id,section:"All Songs");selected = song.id;singerSelections[singer.id] = song.id } label: { - Label(song.title,systemImage:"music.note").font(.system(size:11)).lineLimit(1).frame(maxWidth:.infinity,alignment:.leading).padding(.leading,44).padding(.trailing,8).frame(height:25) - }.buttonStyle(.plain) - .contextMenu { - Button("Play for \(singer.name)") { model.selectedSinger = singer.id;model.perform { try model.play(song,singer:singer.id) } } - Button("Queue for \(singer.name)") { model.selectedSinger = singer.id;model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Button(model.favourites[singer.id]?.contains(song.id) == true ? "Remove Favourite" : "Add to Favourites") { model.setFavourite(song.id,singer:singer.id,included:model.favourites[singer.id]?.contains(song.id) != true) } - Button("Remove from Singer",role:.destructive) { model.assign(song.id,to:singer.id,included:false) } - } - } - if model.songs(for:singer.id).isEmpty { Text("No songs · use +").font(.system(size:10)).foregroundStyle(.secondary).padding(.leading,44).padding(.vertical,5) } - } - } - } - } - private func singerFolder(_ title: String, icon: String, singer: PersonPlace) -> some View { - Button { showSinger(singer.id,section:title) } label: { - Label { Text(title + (title == "Tonight" ? " (\(model.tonightSongIDs[singer.id]?.count ?? 0))" : "")) } icon: { if title == "Favourites" { GoldStar(filled:true,size:12) } else { Image(systemName:icon) } }.font(.system(size:11)).foregroundStyle(title == "Favourites" ? Color(red:1,green:0.75,blue:0.16) : Color.white.opacity(0.75)).padding(.leading,title == "All Songs" ? 0 : 43).frame(maxWidth:.infinity,alignment:.leading).frame(height:25) - }.buttonStyle(.plain) - } - private var singerSongPane: some View { - VStack(alignment:.leading,spacing:12) { - if let singer = model.singers.first(where:{ $0.id == model.selectedSinger }) { - HStack { Text("\(singer.name) · \(singerSection)").font(.headline);Spacer();Button(singerSection == "Tonight" ? "Add to Tonight…" : "Add Songs…") { songPickerTonight = singerSection == "Tonight";songPickerSinger = singer } } - Text("\(model.currentVenueName) · Singer song lists follow them across venues.").font(.caption).foregroundStyle(.secondary) - if singerSection == "History" { - ScrollView { LazyVStack(alignment:.leading,spacing:12) { ForEach(model.history.filter { $0.singerID == singer.id }) { row in HStack { Text(row.date).font(.caption.monospaced());Text(row.song);Spacer() } } } } - } else if singerSection == "Tonight" { - ScrollView { - VStack(spacing:10) { - ForEach(model.tonightSongs(for:singer.id)) { song in - HStack { - Button { model.setFavourite(song.id,singer:singer.id,included:model.favourites[singer.id]?.contains(song.id) != true) } label: { GoldStar(filled:model.favourites[singer.id]?.contains(song.id) == true,size:15) }.buttonStyle(.plain).help("Toggle favourite") - Text(song.title).lineLimit(1);Spacer() - Text(model.queue.contains(where:{ $0.songID == song.id && $0.singerID == singer.id }) ? "Queued" : "Ready").font(.caption).foregroundStyle(.secondary) - Button("Play") { model.playTonight(song,singer:singer.id) } - Button("Queue Again") { model.selectedSinger = singer.id;model.enqueue(song.id) } - Button("Remove") { model.removeFromTonight(song.id,singer:singer.id) } - }.padding(8).background(.white.opacity(0.035)) - } - if model.tonightSongs(for:singer.id).isEmpty { Text("No songs in \(singer.name)’s Tonight list. Use Add to Tonight… above.").foregroundStyle(.secondary).padding(.top,20) } - } - } - } else { - ScrollView { - VStack(spacing:10) { - ForEach(model.songs(for:singer.id).filter { singerSection != "Favourites" || model.favourites[singer.id]?.contains($0.id) == true }) { song in - HStack { - Button { model.setFavourite(song.id,singer:singer.id,included:model.favourites[singer.id]?.contains(song.id) != true) } label: { GoldStar(filled:model.favourites[singer.id]?.contains(song.id) == true,size:15) }.buttonStyle(.plain).help("Favourite for this singer") - Text(song.title).lineLimit(1);Spacer() - Button("Play") { model.selectedSinger = singer.id;model.perform { try model.play(song,singer:singer.id) } } - Button("Add to Tonight") { model.addToTonight(song.id,singer:singer.id) }.disabled(model.currentVenue == nil) - Button("Remove") { model.assign(song.id,to:singer.id,included:false) } - }.padding(8).background(.white.opacity(0.035)).contentShape(Rectangle()).onTapGesture { selected = song.id } - } - if model.songs(for:singer.id).isEmpty { Text("Use Add Songs… or the + beside this singer in the sidebar.").foregroundStyle(.secondary).padding(.top,25) } - } - } - } - } else { Text("Choose a singer from the sidebar.").foregroundStyle(.secondary);Spacer() } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - private var songTable: some View { - GeometryReader { geometry in - ScrollView(.horizontal) { - VStack(spacing: 0) { - tableHeader(width: max(geometry.size.width, 960)) - ScrollView(.vertical) { - LazyVStack(spacing: 0) { - ForEach(visibleSongs) { song in songRow(song, width: max(geometry.size.width, 960)) } - }.frame(maxWidth: .infinity, alignment: .topLeading) - } - }.frame(width: max(geometry.size.width, 960), height: geometry.size.height) - } - }.background(Classic.navy).overlay(Rectangle().stroke(Classic.line, lineWidth: 1)) - } - private func widths(_ total: CGFloat) -> [CGFloat] { [44,max(220,total-600),110,100,65,82,90,109] } - private func tableHeader(width: CGFloat) -> some View { - let sizes = widths(width) - return HStack(spacing:0) { - ForEach(Array(["ID","Song Name","Artist","Album","Duration","Pitch","Tempo","Rating"].enumerated()),id:\.offset) { index,title in - Button { - guard ["Song Name","Artist","Album","Duration","Rating"].contains(title) else { return } - if librarySort == title { sortAscending.toggle() } else { librarySort = title;sortAscending = true } - } label: { HStack(spacing:3) { Text(title);if librarySort == title { Image(systemName:sortAscending ? "chevron.up" : "chevron.down").font(.system(size:8)) } }.font(.system(size:12,weight:.medium)).lineLimit(1).padding(.leading,7).frame(width:sizes[index],height:30,alignment:.leading) } - .buttonStyle(.plain).overlay(alignment:.trailing) { Rectangle().fill(Classic.line).frame(width:1).padding(.vertical,4) } - } - }.foregroundStyle(.white).background(Classic.header).overlay(alignment:.bottom) { Rectangle().fill(Color(white:0.65)).frame(height:1) } - } - private func durationLabel(_ seconds: Double) -> String { seconds > 0 ? String(format:"%d:%02d",Int(seconds)/60,Int(seconds)%60) : "—" } - private func songRow(_ song: Song,width: CGFloat) -> some View { - let sizes = widths(width) - return HStack(spacing:0) { - Text("\(song.id)").foregroundStyle(.secondary).frame(width:sizes[0]) - Text(song.title).lineLimit(1).padding(.leading,7).frame(width:sizes[1],alignment:.leading) - Text(song.artist.isEmpty ? "—" : song.artist).foregroundStyle(.secondary).lineLimit(1).padding(.leading,7).frame(width:sizes[2],alignment:.leading) - Text(song.album.isEmpty ? "—" : song.album).foregroundStyle(.secondary).lineLimit(1).padding(.leading,7).frame(width:sizes[3],alignment:.leading) - Text(durationLabel(song.duration)).font(.system(size:11,design:.monospaced)).frame(width:sizes[4]) - HStack(spacing:2) { - Text(String(format:"%+.0f",model.preference(song.id).pitch)).font(.system(size:11,design:.monospaced)).frame(width:30) - Stepper("Pitch",value:Binding(get:{ model.preference(song.id).pitch },set:{ model.updateTuning(song.id,pitch:$0) }),in:-12...12,step:1).labelsHidden().controlSize(.mini).fixedSize() - }.frame(width:sizes[5]).help("Saved pitch; applies to the selected singer, or song default") - Picker("Tempo",selection:Binding(get:{ model.preference(song.id).tempo },set:{ model.updateTuning(song.id,tempo:$0) })) { - ForEach(10..<31) { Text("\($0*5)%").tag(Double($0)/20) } - }.labelsHidden().controlSize(.mini).frame(width:sizes[6]-8).padding(.horizontal,4).help("Saved tempo; applies live if this song is playing") - GoldRating(rating:Binding(get:{ song.rating },set:{ value in model.perform { try model.library?.rate(song.id,value);try model.refresh() } })).frame(width:sizes[7]) - }.font(.system(size:12)).foregroundStyle(.white).frame(height:30) - .background(selected == song.id ? Color.blue.opacity(0.5) : song.id % 2 == 0 ? Color.white.opacity(0.025) : .clear) - .contentShape(Rectangle()).onTapGesture(count:2) { selected = song.id;playSelected() }.onTapGesture { selected = song.id } - .contextMenu { - Button("Play") { selected = song.id; playSelected() } - Button("Edit Metadata…") { editingSong = song } - Menu("Add to Singer") { - ForEach(model.venueSingers) { singer in Button(singer.name) { model.assign(song.id,to:singer.id);model.selectedSinger = singer.id;expandedSingers.insert(singer.id) } } - Divider();Button("New Singer + This Song…") { model.beginSinger(song:song.id) } - } - Menu("Add to Tonight") { ForEach(model.venueSingers) { singer in Button(singer.name) { model.addToTonight(song.id,singer:singer.id) } } }.disabled(model.currentVenue == nil) - Button("Add to Current Venue Queue") { model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Menu("Add to Playlist") { ForEach(model.playlists) { playlist in Button(playlist.name) { model.addToPlaylist(playlist.id,song:song.id) } } } - } - } - @State private var managingRoster = false - @State private var rosterNewName = "" - @State private var editingEntity: PersonPlace? - @State private var renameText = "" - @State private var pendingDelete: PersonPlace? - private var directory: some View { - VStack(alignment:.leading,spacing:0) { - HStack { - Text(source == "Singers" ? "Singers · \(model.currentVenueName)" : "Venues").font(.headline) - Spacer() - if source == "Singers" { Button("Manage Venue Singers…") { managingRoster = true }.disabled(model.currentVenue == nil) } - Button(source == "Singers" ? "New Singer…" : "New Venue…") { if source == "Singers" { model.beginSinger() } else { model.creating = .venue } } - }.padding(12).background(Classic.header) - ScrollView { - VStack(alignment:.leading,spacing:0) { - if source == "Singers" && model.venueSingers.isEmpty { - Text("No singers at this venue. Add a singer or use Manage Venue Singers to include existing singers.").foregroundStyle(.secondary).padding() - } - ForEach(source == "Singers" ? model.venueSingers : model.venues) { entity in - HStack { - Button { - if source == "Singers" { model.selectedSinger = entity.id } else { model.chooseVenue(entity.id) } - } label: { - HStack { - Image(systemName:source == "Singers" ? "person.fill" : "building.2.fill") - Text(entity.name); Spacer() - if entity.id == (source == "Singers" ? model.selectedSinger : model.currentVenue) { - Text(source == "Singers" ? "Selected" : "Current venue").font(.caption).foregroundStyle(.cyan) - Image(systemName:"checkmark.circle.fill").foregroundStyle(.cyan) - } - }.contentShape(Rectangle()) - }.buttonStyle(.plain) - Button("Rename") { renameText = entity.name; editingEntity = entity } - Button("Delete",role:.destructive) { pendingDelete = entity } - }.padding(12) - } - } - } - HStack { - TextField(source == "Singers" ? "Singer name" : "Venue name",text:$name).textFieldStyle(.roundedBorder).onSubmit(addEntity) - Button(source == "Singers" ? "Add Singer" : "Add Venue",action:addEntity).disabled(name.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - }.padding(12) - }.foregroundStyle(.white).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - .sheet(isPresented:$managingRoster) { rosterSheet } - .sheet(item:$editingEntity) { entity in - VStack(alignment:.leading,spacing:16) { - Text("Rename \(source == "Singers" ? "Singer" : "Venue")").font(.headline) - TextField("Name",text:$renameText).textFieldStyle(.roundedBorder) - HStack { Button("Cancel") { editingEntity = nil }; Spacer(); Button("Save") { model.rename(source == "Singers" ? "singers" : "venues",id:entity.id,name:renameText); editingEntity = nil }.disabled(renameText.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) } - }.padding(24).frame(width:360) - } - .confirmationDialog("Delete \(pendingDelete?.name ?? "entry")? Historical plays are kept. Venue memberships and queued entries for it will be removed.",isPresented:Binding(get:{ pendingDelete != nil },set:{ if !$0 { pendingDelete = nil } })) { - Button("Delete",role:.destructive) { if let entity = pendingDelete { model.delete(source == "Singers" ? "singers" : "venues",id:entity.id) }; pendingDelete = nil } - } - } - private var rosterSheet: some View { - VStack(alignment:.leading,spacing:16) { - Text("Singers at \(model.currentVenueName)").font(.title2.bold()) - Text("A singer can belong to any number of venues. Unchecking removes them from this venue only.").foregroundStyle(.secondary) - ScrollView { - VStack(alignment:.leading,spacing:12) { - ForEach(model.singers) { singer in - Toggle(singer.name,isOn:Binding(get:{ model.venueSingers.contains { $0.id == singer.id } },set:{ model.membership(singer:singer.id,included:$0) })) - } - }.frame(maxWidth:.infinity,alignment:.leading) - }.frame(minHeight:120,maxHeight:280) - HStack { - TextField("New singer name",text:$rosterNewName).textFieldStyle(.roundedBorder) - Button("Add") { model.perform { _ = try model.createEntity(.singer,name:rosterNewName); rosterNewName = "" } }.disabled(rosterNewName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - Spacer(); Button("Done") { managingRoster = false }.keyboardShortcut(.defaultAction) - } - }.padding(24).frame(width:460) - } - private var detailPanel: some View { - VStack(alignment:.leading,spacing:9) { - HStack(spacing:10) { - Picker("Current venue",selection:Binding(get:{ model.currentVenue },set:{ model.chooseVenue($0) })) { - Text("Select venue…").tag(nil as Int64?) - ForEach(model.venues) { Text($0.name).tag(Optional($0.id)) } - } - Button { model.creating = .venue } label: { Image(systemName:"plus.circle.fill") }.buttonStyle(.plain).help("Add venue") - Picker("Singer",selection:$model.selectedSinger) { - Text("None").tag(nil as Int64?) - ForEach(model.venueSingers) { Text($0.name).tag(Optional($0.id)) } - } - Button { model.beginSinger() } label: { Image(systemName:"plus.circle.fill") }.buttonStyle(.plain).help("Add singer") - Menu("Add to Singer") { - ForEach(model.venueSingers) { singer in Button(singer.name) { if let selected { model.assign(selected,to:singer.id);model.selectedSinger = singer.id;expandedSingers.insert(singer.id) } } } - Divider();Button("New Singer + Song…") { model.beginSinger(song:selected) } - }.disabled(selected == nil) - Button("Add to Tonight") { if let selected { model.addToTonight(selected) } }.disabled(selected == nil || model.currentVenue == nil || model.selectedSinger == nil) - } - PlaybackSettings(player:model.player,model:model,selectedSong:selected) - SeekBar(player:model.player) - }.padding(12).frame(maxWidth:.infinity,maxHeight:.infinity) - .background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - @State private var playlistName = "" - @State private var selectedPlaylist: Int64? - private var queuePane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { Text("Queue · \(model.currentVenueName)").font(.headline); Spacer(); Toggle("Auto play next",isOn:$model.autoAdvance).toggleStyle(.checkbox); Button("Play Next") { model.playQueueNext() }.disabled(model.queue.isEmpty) } - ScrollView { - VStack(spacing:0) { - ForEach(Array(model.queue.enumerated()),id:\.element.id) { index,row in - HStack { - Text("\(index+1)").foregroundStyle(.secondary).frame(width:24) - Text(row.singer).frame(width:140,alignment:.leading) - Text(row.title).lineLimit(1); Spacer() - Button { model.moveQueue(row.id,by:-1) } label: { Image(systemName:"arrow.up") }.disabled(index == 0) - Button { model.moveQueue(row.id,by:1) } label: { Image(systemName:"arrow.down") }.disabled(index == model.queue.count-1) - Button("Remove") { model.removeQueue(row.id) } - }.padding(.vertical,8) - } - if model.queue.isEmpty { Text("Choose a venue and singer, select a library song, then click Queue Song.").foregroundStyle(.secondary).padding(.top,30) } - } - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - @State private var historyAllVenues = false - private var displayedHistory: [Performance] { - if historyAllVenues { return (try? model.library?.history(venue:nil,singer:model.selectedSinger)) ?? [] } - return model.history.filter { model.selectedSinger == nil || $0.singer == model.singers.first(where: { $0.id == model.selectedSinger })?.name } - } - private var historyPane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { Text("History · \(historyAllVenues || model.currentVenue == nil ? "All venues" : model.currentVenueName)").font(.headline); Spacer(); Toggle("All venues",isOn:$historyAllVenues).toggleStyle(.checkbox) } - ScrollView { - LazyVStack(alignment:.leading,spacing:12) { - ForEach(displayedHistory) { row in - HStack { Text(row.date).font(.system(.caption,design:.monospaced)); Text(row.singer).frame(width:130,alignment:.leading); Text(row.song); Spacer(); Text(row.venue).foregroundStyle(.secondary) } - } - } - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - private var playlistPane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { - Picker("Playlist",selection:$selectedPlaylist) { Text("Choose…").tag(nil as Int64?); ForEach(model.playlists) { Text($0.name).tag(Optional($0.id)) } } - TextField("New playlist name",text:$playlistName).textFieldStyle(.roundedBorder) - Button("Create") { model.createPlaylist(playlistName); selectedPlaylist = model.playlists.first { $0.name == playlistName.trimmingCharacters(in:.whitespacesAndNewlines) }?.id; playlistName = "" }.disabled(playlistName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - if let selectedPlaylist { - Button("Rename") { model.rename("playlists",id:selectedPlaylist,name:playlistName); playlistName = "" }.disabled(playlistName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - Button("Delete",role:.destructive) { model.delete("playlists",id:selectedPlaylist); self.selectedPlaylist = nil } } - } - ScrollView { - if let selectedPlaylist { - let ids = (try? model.library?.playlistSongIDs(selectedPlaylist)) ?? [] - VStack(alignment:.leading,spacing:10) { - ForEach(ids,id:\.self) { id in - if let song = model.songs.first(where: { $0.id == id }) { - HStack { - Text(song.title); Spacer() - Button("Play") { model.perform { try model.play(song) } } - Button("Queue") { model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Button("Remove") { model.perform { try model.library?.removeFromPlaylist(selectedPlaylist,song:id); try model.refresh() } } - } - } - } - } - } - Text("Add songs using the library row’s context menu.").foregroundStyle(.secondary).padding(.top,20) - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - private var footer: some View { - HStack { - Button { importing = true } label: { Image(systemName: "plus").font(.system(size: 20, weight: .bold)).frame(width: 32, height: 24) } - .help("Import audio, MP3+G or ZIP").accessibilityLabel("Import songs") - RepeatButton(player: model.player).padding(.leading, 12) - Button(model.readingDurations ? "Reading…" : "Read Durations") { model.scanDurations() }.controlSize(.small).disabled(model.readingDurations).help("Read durations for songs imported by older versions") - Button("Edit Metadata…") { editingSong = selectedSong }.controlSize(.small).disabled(selectedSong == nil) - Spacer() - Text("\(visibleSongs.count) \(visibleSongs.count == 1 ? "Song" : "Songs")").font(.system(size: 14, weight: .medium)) - Spacer() - Button { openWindow(id: "lyrics") } label: { Image(systemName: "rectangle.on.rectangle").frame(width: 32, height: 24) } - .help("Open video window").accessibilityLabel("Open video window") - }.buttonStyle(SilverSquareStyle()) - } - private func playSelected() { - guard let song = selectedSong else { return } - model.perform { try model.play(song) } - } - private func playNext() { - guard !visibleSongs.isEmpty else { return } - let index = visibleSongs.firstIndex { $0.id == selected } ?? -1 - selected = visibleSongs[(index + 1) % visibleSongs.count].id; playSelected() - } - private func addEntity() { - model.perform { - let kind: EntityKind = source == "Singers" ? .singer : .venue - let id = try model.createEntity(kind, name: name) - if kind == .singer { model.selectedSinger = id } else { model.chooseVenue(id) } - name = "" - } - } -} -/// Drawn with literal colours, so native menu/button tint cannot turn favourite stars white. -private struct GoldStar: View { - var filled: Bool - var size: CGFloat = 14 - var body: some View { - Canvas { context,bounds in - let centre = CGPoint(x:bounds.width/2,y:bounds.height/2),outer = min(bounds.width,bounds.height)*0.46 - var star = Path() - for point in 0..<10 { - let angle = Double(point)*Double.pi/5-Double.pi/2,radius = point % 2 == 0 ? outer : outer*0.43 - let p = CGPoint(x:centre.x+CGFloat(cos(angle))*radius,y:centre.y+CGFloat(sin(angle))*radius) - if point == 0 { star.move(to:p) } else { star.addLine(to:p) } - } - star.closeSubpath() - let gold = Color(red:1,green:0.73,blue:0.08) - if filled { context.fill(star,with:.color(gold)) } - else { context.stroke(star,with:.color(gold.opacity(0.7)),lineWidth:1) } - }.frame(width:size,height:size).accessibilityHidden(true) - } -} -private struct GoldRating: View { - @Binding var rating: Int - var body: some View { - HStack(spacing:2) { ForEach(1..<6) { value in Button { rating = rating == value ? 0 : value } label: { GoldStar(filled:value <= rating) }.buttonStyle(.plain).help("\(value) stars; click the selected rating to clear").accessibilityLabel("Set \(value) stars") } } - } -} -private struct SongMetadataSheet: View { - @ObservedObject var model: AppModel - let song: Song - @Environment(\.dismiss) private var dismiss - @State private var title = "" - @State private var artist = "" - @State private var album = "" - @State private var label = "" - @State private var rating = 0 - @State private var error: String? - var body: some View { - VStack(alignment:.leading,spacing:14) { - Text("Edit Song Metadata").font(.title2.bold()) - Grid(alignment:.leading,horizontalSpacing:12,verticalSpacing:10) { - GridRow { Text("Title");TextField("Title",text:$title) } - GridRow { Text("Artist");TextField("Artist",text:$artist) } - GridRow { Text("Album");TextField("Album",text:$album) } - GridRow { Text("Label");TextField("Label / publisher",text:$label) } - GridRow { Text("Rating");GoldRating(rating:$rating) } - }.textFieldStyle(.roundedBorder) - Text("Saved to your library. Embedded audio-file tags are not changed, and re-importing will preserve your library edits.").font(.caption).foregroundStyle(.secondary) - Text(URL(fileURLWithPath:song.audio).lastPathComponent).font(.caption.monospaced()).foregroundStyle(.secondary).lineLimit(1).truncationMode(.middle).help(song.audio) - if let error { Text(error).foregroundStyle(.red).font(.callout) } - HStack { Spacer();Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction);Button("Save") { save() }.keyboardShortcut(.defaultAction).disabled(title.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) } - }.padding(24).frame(width:500).background(Classic.frame).preferredColorScheme(.dark) - .onAppear { title = song.title;artist = song.artist;album = song.album;label = song.label;rating = song.rating } - } - private func save() { do { try model.updateMetadata(song,title:title,artist:artist,album:album,label:label,rating:rating);dismiss() } catch { self.error = error.localizedDescription } } -} -private struct MusicStoresPane: View { - @ObservedObject var model: AppModel - @Binding var selected: Int64? - @Environment(\.openURL) private var openURL - @State private var editor = false - @State private var editing: MusicStore? - @State private var search = "" - @State private var deleting: Int64? - var body: some View { - VStack(alignment:.leading,spacing:14) { - HStack { Text("Music Stores").font(.headline);Spacer();Button("Add Store…") { editing = nil;editor = true } } - Text("Define websites and optional catalogue-search URLs. Purchases and subscriptions are handled by the store in your browser.").font(.callout).foregroundStyle(.secondary) - HStack { TextField("Search store catalogue",text:$search).textFieldStyle(.roundedBorder);Text("{query} in a store’s search URL is replaced with this text.").font(.caption).foregroundStyle(.secondary) } - ScrollView { - VStack(alignment:.leading,spacing:12) { - ForEach(model.musicStores) { store in - VStack(alignment:.leading,spacing:8) { - HStack { Image(systemName:"bag.fill").foregroundStyle(.green);Text(store.name).font(.headline);Spacer() - Button("Open Store") { open(store,query:"") } - Button("Search") { open(store,query:search) }.disabled(search.isEmpty || store.searchTemplate.isEmpty) - Button("Edit") { editing = store;editor = true } - Button("Delete",role:.destructive) { deleting = store.id } - } - Text(store.url).font(.caption).foregroundStyle(.secondary).textSelection(.enabled) - }.padding(12).background(selected == store.id ? Color.blue.opacity(0.15) : Color.white.opacity(0.035)).contentShape(Rectangle()).onTapGesture { selected = store.id } - } - if model.musicStores.isEmpty { Text("No stores configured. Add a store name and website address to get started.").foregroundStyle(.secondary).padding(.top,20) } - } - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - .sheet(isPresented:$editor) { MusicStoreEditor(model:model,store:editing) } - .confirmationDialog("Delete this store definition?",isPresented:Binding(get:{ deleting != nil },set:{ if !$0 { deleting = nil } })) { - Button("Delete",role:.destructive) { if let deleting { model.deleteStore(deleting) };deleting = nil } - } - } - private func open(_ store: MusicStore,query: String) { - do { openURL(try store.destination(query:query)) } catch { model.error = error.localizedDescription } - } -} -private struct MusicStoreEditor: View { - @ObservedObject var model: AppModel - let store: MusicStore? - @Environment(\.dismiss) private var dismiss - @State private var name = "" - @State private var url = "" - @State private var search = "" - @State private var error: String? - var body: some View { - VStack(alignment:.leading,spacing:14) { - Text(store == nil ? "Add Music Store" : "Edit Music Store").font(.title2.bold()) - TextField("Store name",text:$name).textFieldStyle(.roundedBorder) - TextField("Website URL — https://example.com",text:$url).textFieldStyle(.roundedBorder) - TextField("Optional search URL — https://example.com/search?q={query}",text:$search).textFieldStyle(.roundedBorder) - Text("Use {query} where the search words belong. Only http:// and https:// websites are accepted.").font(.caption).foregroundStyle(.secondary) - if let error { Text(error).foregroundStyle(.red).font(.callout) } - HStack { Spacer();Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction);Button("Save") { save() }.keyboardShortcut(.defaultAction).disabled(name.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty || url.isEmpty) } - }.padding(24).frame(width:500).background(Classic.frame).preferredColorScheme(.dark) - .onAppear { name = store?.name ?? "";url = store?.url ?? "";search = store?.searchTemplate ?? "" } - } - private func save() { do { try model.saveStore(.init(id:store?.id ?? 0,name:name,url:url,searchTemplate:search));dismiss() } catch { self.error = error.localizedDescription } } -} -private struct SingerSongsSheet: View { - @ObservedObject var model: AppModel - let singer: PersonPlace - var tonight = false - @Environment(\.dismiss) private var dismiss - @State private var search = "" - @State private var importing = false - var body: some View { - VStack(alignment:.leading,spacing:14) { - Text(tonight ? "Tonight for \(singer.name)" : "Songs for \(singer.name)").font(.title2.bold()) - Text(tonight ? "Tick songs for this venue’s Tonight list. They stay here after playback and when switching singers." : "Tick songs to add them to this singer’s repertoire.").font(.callout).foregroundStyle(.secondary) - TextField("Search library",text:$search).textFieldStyle(.roundedBorder) - ScrollView { - LazyVStack(alignment:.leading,spacing:12) { - ForEach(model.songs.filter { search.isEmpty || $0.title.localizedCaseInsensitiveContains(search) }) { song in - HStack { - Toggle(song.title,isOn:Binding(get:{ tonight ? model.tonightSongIDs[singer.id]?.contains(song.id) == true : model.singerSongIDs[singer.id]?.contains(song.id) == true },set:{ included in - if tonight { if included { model.addToTonight(song.id,singer:singer.id) } else { model.removeFromTonight(song.id,singer:singer.id) } } - else { model.assign(song.id,to:singer.id,included:included) } - })).toggleStyle(.checkbox) - Spacer() - Button { model.setFavourite(song.id,singer:singer.id,included:model.favourites[singer.id]?.contains(song.id) != true) } label: { GoldStar(filled:model.favourites[singer.id]?.contains(song.id) == true,size:15) }.buttonStyle(.plain).help("Toggle favourite") - } - } - if model.songs.isEmpty { Text("Your library is empty. Import audio or MP3+G below.").foregroundStyle(.secondary) } - }.frame(maxWidth:.infinity,alignment:.leading) - }.frame(height:270) - HStack { Button("Import Songs…") { importing = true };Spacer();Button("Done") { dismiss() }.keyboardShortcut(.defaultAction) } - }.padding(24).frame(width:520).background(Classic.frame).preferredColorScheme(.dark) - .fileImporter(isPresented:$importing,allowedContentTypes:[.audio,.zip,UTType(filenameExtension:"cdg") ?? .data],allowsMultipleSelection:true) { result in - switch result { case .success(let urls):model.importFiles(urls);case .failure(let error):model.error = error.localizedDescription } - } - } -} -private struct AddEntitySheet: View { - @ObservedObject var model: AppModel - let kind: EntityKind - let saved: (Int64) -> Void - @Environment(\.dismiss) private var dismiss - @State private var name = "" - @State private var error: String? - @State private var venue: Int64? - @State private var songs = Set() - @State private var search = "" - @FocusState private var focused: Bool - var body: some View { - VStack(alignment:.leading,spacing:16) { - Text(kind == .singer ? "New Singer + Songs" : "New Venue").font(.title2.bold()) - TextField("\(kind.title) name",text:$name).textFieldStyle(.roundedBorder).focused($focused).onSubmit(save) - if kind == .singer { - Picker("Venue",selection:$venue) { Text("Choose a venue…").tag(nil as Int64?);ForEach(model.venues) { Text($0.name).tag(Optional($0.id)) } } - Text(venue == nil ? "Create a venue first, then add a singer to it." : "This singer will join the selected venue and become active.").font(.caption).foregroundStyle(.secondary) - Text("Add songs now (optional)").font(.headline) - TextField("Search library",text:$search).textFieldStyle(.roundedBorder) - ScrollView { - LazyVStack(alignment:.leading,spacing:10) { - ForEach(model.songs.filter { search.isEmpty || $0.title.localizedCaseInsensitiveContains(search) }) { song in - Toggle(song.title,isOn:Binding(get:{ songs.contains(song.id) },set:{ if $0 { songs.insert(song.id) } else { songs.remove(song.id) } })).toggleStyle(.checkbox) - } - if model.songs.isEmpty { Text("No library songs yet. You can add songs from the singer’s + button after importing.").font(.callout).foregroundStyle(.secondary) } - }.frame(maxWidth:.infinity,alignment:.leading) - }.frame(height:190) - } - if let error { Text(error).foregroundStyle(.red).font(.callout) } - HStack { Spacer();Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction) - Button(kind == .singer ? "Add Singer & Songs" : "Add Venue",action:save).keyboardShortcut(.defaultAction) - .disabled(name.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty || (kind == .singer && venue == nil)) - } - }.padding(24).frame(width:kind == .singer ? 500 : 360).background(Classic.frame).preferredColorScheme(.dark) - .onAppear { focused = true;venue = model.currentVenue ?? model.venues.first?.id;songs = model.newSingerSongs } - } - private func save() { - do { - let id: Int64 - if kind == .singer { guard let venue else { throw LibraryError.message("Choose a venue") };id = try model.createSinger(name:name,venue:venue,songs:songs) } - else { id = try model.createEntity(kind,name:name) } - saved(id);dismiss() - } catch { self.error = error.localizedDescription } - } -} -private struct TransportView: View { - @ObservedObject var player: Player - @Binding var search: String - let hasSelection: Bool - let play: () -> Void - let next: () -> Void - let display: () -> Void - var body: some View { - HStack(alignment: .top, spacing: 28) { - VStack(spacing: 15) { - HStack(spacing: 7) { - SilverButton(symbol: "backward.fill", label: "Back 10 seconds", size: 35, enabled: player.duration > 0) { player.seek(player.time - 10) } - SilverButton(symbol: player.playing ? "pause.fill" : "play.fill", label: player.playing ? "Pause" : "Play", size: 49, enabled: hasSelection || player.duration > 0) { - if player.duration > 0 { player.toggle() } else { play() } - } - SilverButton(symbol: "stop", label: "Stop", size: 46, enabled: player.duration > 0) { player.stop() } - SilverButton(symbol: "forward.fill", label: "Forward 10 seconds", size: 35, enabled: player.duration > 0) { player.seek(player.time + 10) } - SilverButton(symbol: "forward.end.fill", label: "Play next song", size: 26, enabled: hasSelection, action: next) - } - HStack(spacing: 9) { - Image(systemName: "speaker.fill").font(.system(size: 11)) - Slider(value: $player.volume, in: 0...1).controlSize(.small).tint(.gray).accessibilityLabel("Volume") - Image(systemName: "speaker.wave.3.fill").font(.system(size: 12)) - }.frame(width: 180) - }.frame(width: 220) - NowPlayingWaveform(player: player).padding(.top, 4) - HStack(spacing: 12) { - TextField("Search", text: $search).textFieldStyle(.plain).font(.system(size: 16)) - .padding(.horizontal, 8).frame(width: 145, height: 28).background(Color(white: 0.07), in: RoundedRectangle(cornerRadius: 5)) - .overlay(RoundedRectangle(cornerRadius: 5).stroke(.white.opacity(0.1))) - SilverButton(symbol: "eye", label: "Open video window", size: 48, action: display) - }.padding(.top, 15) - }.foregroundStyle(.white).frame(height: 130) - } -} -private struct NowPlayingWaveform: View { - @ObservedObject var player: Player - @State private var mixer = false - @State private var zoom: Double = 1 - @State private var hoverX: CGFloat? - @State private var scrubStart: Double? - @State private var resumeAfterScrub = false - @State private var scrubSong: Int64? - private var span: Double { max(0.001,player.duration/zoom) } - private var windowStart: Double { scrubStart ?? min(max(0,player.time-span/2),max(0,player.duration-span)) } - private var progress: Double { player.duration > 0 ? min(1,max(0,(player.time-windowStart)/span)) : 0 } - private func clock(_ value: Double) -> String { let n = max(0,Int(value));return String(format:"%d:%02d",n/60,n%60) } - private func preciseClock(_ value: Double) -> String { String(format:"%d:%05.2f",max(0,Int(value))/60,max(0,value).truncatingRemainder(dividingBy:60)) } - private func bandColor(_ index: Int) -> Color { - guard player.waveformBands.indices.contains(index) else { return .cyan } - let band = player.waveformBands[index] - let largest = max(0.000001,max(band.low,max(band.mid,band.high))) - let low = Double(band.low/largest),mid = Double(band.mid/largest),high = Double(band.high/largest) - return Color(red:min(1,pow(low,1.2)+mid*0.12+high*0.6),green:min(1,low*0.08+pow(mid,1.5)*0.97+high*0.1),blue:min(1,low*0.07+mid*0.22+high)) - } - var body: some View { - VStack(alignment:.leading,spacing:5) { - Text(player.duration > 0 ? player.title : "Ready to play").font(.system(size:13,weight:.semibold)).foregroundStyle(Color(white:0.94)) - .lineLimit(1).truncationMode(.middle).frame(maxWidth:.infinity,alignment:.leading).help(player.title) - GeometryReader { geometry in - Canvas { context,size in - let top: CGFloat = 10,plotHeight = size.height-top,mid = top+plotHeight/2 - var centre = Path();centre.move(to:CGPoint(x:0,y:mid));centre.addLine(to:CGPoint(x:size.width,y:mid)) - context.stroke(centre,with:.color(.white.opacity(0.13)),lineWidth:0.5) - if player.duration > 0 { - let step = [0.1,0.25,0.5,1.0,2,5,10,15,30,60,120,300,600,1800,3600].first { $0 >= span/5 } ?? 3600 - let first = floor(windowStart/(step/4))*(step/4) - for t in stride(from:first,through:min(player.duration,windowStart+span),by:step/4) { - let x = size.width*(t-windowStart)/span - if x < 0 { continue } - let major = abs(t/step-(t/step).rounded()) < 0.001 - var tick = Path();tick.move(to:CGPoint(x:x,y:top));tick.addLine(to:CGPoint(x:x,y:size.height)) - context.stroke(tick,with:.color(major ? .yellow.opacity(0.65) : .white.opacity(0.16)),lineWidth:major ? 0.8 : 0.5) - if major && x < size.width-25 { - context.draw(Text(span < 10 ? preciseClock(t) : clock(t)).font(.system(size:8,design:.monospaced)).foregroundColor(.gray),at:CGPoint(x:x+3,y:3),anchor:.leading) - } - } - } - if !player.waveform.isEmpty { - let count = max(1,Int(size.width/2)),step = size.width/CGFloat(count) - for bar in 0.. 0,geometry.size.width > 0 else { return } - if scrubStart == nil { - scrubStart = windowStart;scrubSong = player.currentSongID;resumeAfterScrub = player.playing - if player.playing { player.toggle() } - } - guard scrubSong == player.currentSongID else { return } - hoverX = value.location.x - let target = windowStart+Double(min(1,max(0,value.location.x/geometry.size.width)))*span - if abs(target-player.time) > 0.02 { player.seek(target) } - }.onEnded { value in - if scrubStart == nil { - if player.duration > 0 { player.seek(windowStart+Double(min(1,max(0,value.location.x/max(1,geometry.size.width))))*span) } - return - } - let target = windowStart+Double(min(1,max(0,value.location.x/max(1,geometry.size.width))))*span - if scrubSong == player.currentSongID { - player.seek(target) - if resumeAfterScrub && !player.playing && target < player.duration-0.01 { player.toggle() } - } - scrubStart = nil;resumeAfterScrub = false;scrubSong = nil - }).help("Hover for exact time. Drag to scrub; playback resumes on release. Zoom for fine positioning.") - .accessibilityLabel("Audio waveform").accessibilityValue("\(clock(player.time)) of \(clock(player.duration))") - .accessibilityAdjustableAction { direction in if direction == .increment { player.seek(player.time+5) } else if direction == .decrement { player.seek(player.time-5) } } - }.frame(height:60) - HStack(spacing:5) { - Circle().fill(player.playing ? Color.green : Color.orange).frame(width:4,height:4) - Text(player.duration == 0 ? "NO TRACK LOADED" : player.playing ? "PLAYING" : "PAUSED").tracking(1) - if player.waveformUnavailable { Text("· Waveform unavailable").foregroundStyle(.secondary) } - Spacer(minLength:0) - Button { zoom = max(1,zoom/2) } label: { Image(systemName:"minus.magnifyingglass") }.buttonStyle(.plain).disabled(zoom <= 1).help("Zoom out") - Button { zoom = min(32,zoom*2) } label: { Image(systemName:"plus.magnifyingglass") }.buttonStyle(.plain).disabled(zoom >= 32).help("Zoom in for precise scrubbing") - Menu("\(Int(zoom))×") { ForEach([1.0,2,4,8,16,32],id:\.self) { value in Button("\(Int(value))× zoom") { zoom = value } } }.menuStyle(.borderlessButton).frame(width:34).help("Waveform zoom around the playhead") - Menu { Button("Re-analyse Waveform") { player.reanalyseWaveform() }.disabled(player.duration == 0) - Text(player.waveformLoading ? "Analysing…" : player.waveformFromCache ? "Loaded saved waveform" : player.waveformSaved ? "Analysis saved" : "No saved analysis") - } label: { Image(systemName:"waveform") }.menuStyle(.borderlessButton).frame(width:20).help("Waveform cache and re-analysis") - Button("EQ / TONE") { mixer.toggle() }.buttonStyle(.plain).foregroundStyle(.white.opacity(0.85)) - .padding(.horizontal,6).padding(.vertical,2).background(.white.opacity(0.08),in:RoundedRectangle(cornerRadius:3)) - .popover(isPresented:$mixer) { ToneMixerView(player:player) } - Text("\(clock(player.time)) / \(clock(player.duration))").monospacedDigit().padding(.leading,5) - }.font(.system(size:9,weight:.medium)).foregroundStyle(Color(white:0.6)) - }.padding(.horizontal,12).padding(.vertical,9).frame(maxWidth:.infinity).frame(height:120) - .background(Color(red:0.025,green:0.028,blue:0.035)).overlay(Rectangle().strokeBorder(Color(white:0.24),lineWidth:1)) - } -} -private struct ToneKnob: View { - let title: String - @Binding var value: Double - let range: ClosedRange - var filter = false - @State private var initial: Double? - private var fraction: Double { min(1,max(0,(value-range.lowerBound)/(range.upperBound-range.lowerBound))) } - private var display: String { - if filter { return abs(value) < 0.01 ? "OFF" : value < 0 ? "LOW PASS" : "HIGH PASS" } - return String(format:"%+.1f dB",value) - } - var body: some View { - VStack(spacing:4) { - ZStack { - Circle().trim(from:0,to:0.75).stroke(Color(white:0.21),style:StrokeStyle(lineWidth:4,lineCap:.round)).rotationEffect(.degrees(135)) - Circle().trim(from:0,to:0.75*fraction).stroke(Color(white:0.48),style:StrokeStyle(lineWidth:3,lineCap:.round)).rotationEffect(.degrees(135)) - Circle().fill(LinearGradient(colors:[Color(white:0.19),Color(white:0.09)],startPoint:.top,endPoint:.bottom)).padding(6).overlay(Circle().stroke(.black.opacity(0.65),lineWidth:1.5).padding(6)) - Capsule().fill(.white).frame(width:2,height:12).offset(y:-13).rotationEffect(.degrees(-135+270*fraction)) - }.frame(width:50,height:50).contentShape(Circle()) - .gesture(DragGesture(minimumDistance:0).onChanged { gesture in - if initial == nil { initial = value } - value = min(range.upperBound,max(range.lowerBound,(initial ?? value)-Double(gesture.translation.height)/130*(range.upperBound-range.lowerBound))) - }.onEnded { _ in initial = nil }) - .simultaneousGesture(TapGesture(count:2).onEnded { value = 0 }) - .accessibilityElement().accessibilityLabel(title).accessibilityValue(display) - .accessibilityAdjustableAction { direction in - let change = (range.upperBound-range.lowerBound)/24 - value = min(range.upperBound,max(range.lowerBound,value+(direction == .increment ? change : -change))) - }.help("Drag up/down to adjust. Double-click to reset.") - Text(title).font(.system(size:10,weight:.bold)).foregroundStyle(Color(white:0.6)) - Text(display).font(.system(size:8,design:.monospaced)).foregroundStyle(Color(white:0.45)) - } - } -} -private struct StereoMeter: View { - @ObservedObject var player: Player - private func normal(_ level: Float) -> Double { max(0,min(1,(20*log10(Double(max(level,0.000001)))+60)/60)) } - var body: some View { - HStack(spacing:3) { - ForEach(0..<2) { channel in - VStack(spacing:2) { - ForEach((0..<24).reversed(),id:\.self) { segment in - let on = Double(segment)/24 < normal(channel == 0 ? player.leftLevel : player.rightLevel) - Rectangle().fill(on ? (segment > 21 ? Color.red : segment > 17 ? Color.yellow : Color.green) : Color.black.opacity(0.5)) - } - } - } - }.frame(width:23,height:125).accessibilityLabel("Stereo output levels") - } -} -private struct MixerFader: View { - @Binding var value: Double - var body: some View { - GeometryReader { geometry in - let travel = geometry.size.height-22 - ZStack(alignment:.top) { - VStack { ForEach(0..<7) { _ in Rectangle().fill(.white.opacity(0.09)).frame(height:1);Spacer(minLength:0) } }.padding(.vertical,11) - Capsule().fill(.black.opacity(0.8)).frame(width:5).padding(.vertical,8) - RoundedRectangle(cornerRadius:5).fill(LinearGradient(colors:[Color(white:0.45),Color(white:0.23)],startPoint:.top,endPoint:.bottom)) - .frame(width:45,height:20).overlay(Rectangle().fill(.white.opacity(0.15)).frame(width:18,height:1)) - .offset(y:(1-value)*travel) - }.frame(maxWidth:.infinity).contentShape(Rectangle()) - .gesture(DragGesture(minimumDistance:0).onChanged { value = min(1,max(0,1-Double(($0.location.y-11)/travel))) }) - }.frame(width:56,height:135).accessibilityLabel("Master volume").accessibilityValue("\(Int(value*100)) percent") - .accessibilityAdjustableAction { direction in value = min(1,max(0,value+(direction == .increment ? 0.05 : -0.05))) } - } -} -private struct ToneMixerView: View { - @ObservedObject var player: Player - var body: some View { - VStack(spacing:14) { - HStack { Text("TONE / MIXER").font(.system(size:12,weight:.bold));Spacer();Toggle("EQ",isOn:$player.toneEnabled).toggleStyle(.switch).controlSize(.mini) } - HStack(alignment:.top,spacing:28) { - VStack(spacing:8) { - ToneKnob(title:"HIGH",value:$player.highGain,range:-12...12) - ToneKnob(title:"MID",value:$player.midGain,range:-12...12) - ToneKnob(title:"LOW",value:$player.lowGain,range:-12...12) - } - VStack(spacing:15) { - ToneKnob(title:"FILTER",value:$player.filter,range:-1...1,filter:true) - HStack(spacing:20) { StereoMeter(player:player);MixerFader(value:$player.volume) } - Text(player.volume <= 0 ? "−∞ dB" : String(format:"%+.1f dB",20*log10(player.volume))).font(.system(size:10,design:.monospaced)).foregroundStyle(.secondary) - } - }.padding(.horizontal,15) - HStack { Text("Drag knobs · Double-click to reset").font(.system(size:9)).foregroundStyle(.secondary);Spacer();Button("Reset EQ") { player.resetTone() }.controlSize(.small) } - }.padding(18).frame(width:270).background(Color(white:0.105)).preferredColorScheme(.dark) - } -} -private struct PlaybackSettings: View { - @ObservedObject var player: Player - @ObservedObject var model: AppModel - let selectedSong: Int64? - @State private var personalRating = 0 - var body: some View { - HStack(spacing:10) { - Text("Key") - Picker("Key",selection:$player.pitch) { ForEach(-12..<13) { Text(String(format:"%+d",$0)).tag(Double($0)) } }.labelsHidden().frame(width:70) - Text("Tempo") - Slider(value:$player.tempo,in:0.5...1.5,step:0.05).frame(width:85) - Text(String(format:"%.0f%%",player.tempo*100)).monospacedDigit().frame(width:40) - Text("Rating") - GoldRating(rating:$personalRating).frame(width:88).help("Singer-specific song rating") - Button("Save for Singer") { - if let song = player.currentSongID ?? selectedSong { model.savePreference(song:song,value:.init(pitch:player.pitch,tempo:player.tempo,rating:personalRating)) } - }.disabled(model.selectedSinger == nil || (player.currentSongID == nil && selectedSong == nil)) - Menu { - Button("Reset key / tempo") { player.pitch = 0; player.tempo = 1 } - ForEach([-1.0,-0.5,0,0.5,1.0],id:\.self) { offset in Button(String(format:"Graphics offset %+.1fs",offset)) { player.graphicsOffset = offset } } - } label: { Image(systemName:"slider.horizontal.3") }.menuStyle(.borderlessButton).frame(width:22).help("Playback settings") - }.font(.system(size:11)) - .onChange(of:model.selectedSinger) { _ in loadRating() } - .onChange(of:player.currentSongID) { _ in loadRating() } - .onChange(of:selectedSong) { _ in loadRating() } - } - private func loadRating() { if let song = player.currentSongID ?? selectedSong { personalRating = model.preference(song).rating } else { personalRating = 0 } } -} -private struct SeekBar: View { - @ObservedObject var player: Player - private func clock(_ seconds: Double) -> String { let n = Int(seconds); return String(format: "%d:%02d", n / 60, n % 60) } - var body: some View { - HStack(spacing: 10) { - Text(clock(player.time)) - Slider(value: Binding(get: { player.time }, set: { player.seek($0) }), in: 0...max(1, player.duration)) - .controlSize(.mini).tint(.gray).disabled(player.duration == 0).accessibilityLabel("Playback position") - Text(clock(player.duration)) - }.font(.system(size: 10, design: .monospaced)).foregroundStyle(.white.opacity(0.65)) - } -} -private struct RepeatButton: View { - @ObservedObject var player: Player - var body: some View { - Button { player.repeating.toggle() } label: { - Image(systemName: "repeat").font(.system(size: 18, weight: .semibold)) - .foregroundStyle(player.repeating ? Color.blue : Color(white: 0.25)).frame(width: 32, height: 24) - }.help(player.repeating ? "Repeat song: on" : "Repeat song: off").accessibilityLabel("Repeat song").accessibilityValue(player.repeating ? "On" : "Off") - } -} diff --git a/backups/before-tonight-drag-20261103-094630/KJamsClone/Library.swift b/backups/before-tonight-drag-20261103-094630/KJamsClone/Library.swift deleted file mode 100644 index 5c7ccae..0000000 --- a/backups/before-tonight-drag-20261103-094630/KJamsClone/Library.swift +++ /dev/null @@ -1,317 +0,0 @@ -import Foundation -import SQLite3 - -struct Song: Identifiable, Hashable { - var id: Int64 - var title: String - var audio: String - var cdg: String? - var rating: Int - var plays: Int - var artist: String = "" - var album: String = "" - var label: String = "" - var duration: Double = 0 -} -struct MusicStore: Identifiable, Hashable { - var id: Int64 - var name: String - var url: String - var searchTemplate: String - func destination(query: String = "") throws -> URL { - let query = query.trimmingCharacters(in:.whitespacesAndNewlines) - let encoded = query.addingPercentEncoding(withAllowedCharacters:CharacterSet(charactersIn:"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~")) ?? "" - let value = query.isEmpty || searchTemplate.isEmpty ? url : searchTemplate.replacingOccurrences(of:"{query}",with:encoded) - guard let result = URL(string:value), ["http","https"].contains(result.scheme?.lowercased() ?? ""), result.host?.isEmpty == false, result.user == nil, result.password == nil else { throw LibraryError.message("Use a valid http:// or https:// store URL without credentials") } - return result - } -} -struct PersonPlace: Identifiable, Hashable { var id: Int64; var name: String } -struct SongPreference: Equatable { - var pitch: Double = 0 - var tempo: Double = 1 - var rating: Int = 0 -} -struct Performance: Identifiable { - var id: Int64 - var song: String - var singer: String - var venue: String - var date: String - var singerID: Int64? - var songID: Int64? -} -struct QueueEntry: Identifiable { - var id: Int64 - var songID: Int64 - var singerID: Int64? - var title: String - var singer: String -} -enum LibraryError: LocalizedError { - case message(String) - var errorDescription: String? { if case .message(let s) = self { return s }; return nil } -} -final class Library { - private var db: OpaquePointer? - init(url: URL) throws { - guard sqlite3_open(url.path, &db) == SQLITE_OK else { throw LibraryError.message("Cannot open library") } - try execute("PRAGMA foreign_keys=ON") - try execute("CREATE TABLE IF NOT EXISTS songs(id INTEGER PRIMARY KEY,title TEXT NOT NULL,audio TEXT UNIQUE NOT NULL,cdg TEXT,rating INTEGER NOT NULL DEFAULT 0 CHECK(rating BETWEEN 0 AND 5),plays INTEGER NOT NULL DEFAULT 0)") - try execute("CREATE TABLE IF NOT EXISTS singers(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS venues(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS history(id INTEGER PRIMARY KEY,song INTEGER REFERENCES songs(id),singer INTEGER REFERENCES singers(id),venue INTEGER REFERENCES venues(id),played TEXT DEFAULT CURRENT_TIMESTAMP)") - // Additive migration: preserve older libraries and infer existing memberships from history. - for column in ["artist", "album", "label"] { - if try !columns("songs").contains(column) { try execute("ALTER TABLE songs ADD COLUMN \(column) TEXT NOT NULL DEFAULT ''") } - } - try execute("CREATE TABLE IF NOT EXISTS venue_singers(venue INTEGER NOT NULL REFERENCES venues(id) ON DELETE CASCADE,singer INTEGER NOT NULL REFERENCES singers(id) ON DELETE CASCADE,PRIMARY KEY(venue,singer))") - if try schemaVersion() < 3 { try execute("INSERT OR IGNORE INTO venue_singers SELECT DISTINCT venue,singer FROM history WHERE venue IS NOT NULL AND singer IS NOT NULL") } - try execute("CREATE TABLE IF NOT EXISTS settings(key TEXT PRIMARY KEY,value TEXT)") - try execute("CREATE TABLE IF NOT EXISTS preferences(song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,singer INTEGER NOT NULL REFERENCES singers(id) ON DELETE CASCADE,pitch REAL NOT NULL DEFAULT 0 CHECK(pitch BETWEEN -12 AND 12),tempo REAL NOT NULL DEFAULT 1 CHECK(tempo BETWEEN 0.5 AND 1.5),rating INTEGER NOT NULL DEFAULT 0 CHECK(rating BETWEEN 0 AND 5),PRIMARY KEY(song,singer))") - try execute("CREATE TABLE IF NOT EXISTS queue(id INTEGER PRIMARY KEY,venue INTEGER REFERENCES venues(id) ON DELETE CASCADE,song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,singer INTEGER REFERENCES singers(id) ON DELETE CASCADE,position INTEGER NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS playlists(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS playlist_songs(playlist INTEGER NOT NULL REFERENCES playlists(id) ON DELETE CASCADE,song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,position INTEGER NOT NULL,PRIMARY KEY(playlist,song))") - try execute("CREATE TABLE IF NOT EXISTS singer_songs(singer INTEGER NOT NULL REFERENCES singers(id) ON DELETE CASCADE,song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,position INTEGER NOT NULL,PRIMARY KEY(singer,song))") - if try schemaVersion() < 4 { - try execute("INSERT OR IGNORE INTO singer_songs(singer,song,position) SELECT singer,song,MIN(id) FROM history WHERE singer IS NOT NULL AND song IS NOT NULL GROUP BY singer,song") - try execute("INSERT OR IGNORE INTO singer_songs(singer,song,position) SELECT singer,song,0 FROM preferences") - } - if try !columns("songs").contains("duration") { try execute("ALTER TABLE songs ADD COLUMN duration REAL NOT NULL DEFAULT 0") } - if try !columns("singer_songs").contains("favourite") { try execute("ALTER TABLE singer_songs ADD COLUMN favourite INTEGER NOT NULL DEFAULT 0 CHECK(favourite IN (0,1))") } - if try schemaVersion() < 5 { try execute("UPDATE singer_songs SET favourite=1 WHERE EXISTS(SELECT 1 FROM preferences WHERE preferences.singer=singer_songs.singer AND preferences.song=singer_songs.song AND preferences.rating>=4)") } - try execute("CREATE TABLE IF NOT EXISTS song_settings(song INTEGER PRIMARY KEY REFERENCES songs(id) ON DELETE CASCADE,pitch REAL NOT NULL DEFAULT 0 CHECK(pitch BETWEEN -12 AND 12),tempo REAL NOT NULL DEFAULT 1 CHECK(tempo BETWEEN 0.5 AND 1.5))") - try execute("CREATE TABLE IF NOT EXISTS music_stores(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL,url TEXT NOT NULL,search_template TEXT NOT NULL DEFAULT '')") - if try !columns("songs").contains("metadata_edited") { try execute("ALTER TABLE songs ADD COLUMN metadata_edited INTEGER NOT NULL DEFAULT 0") } - try execute("CREATE TABLE IF NOT EXISTS singer_tonight(venue INTEGER NOT NULL,singer INTEGER NOT NULL,song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,position INTEGER NOT NULL,PRIMARY KEY(venue,singer,song),FOREIGN KEY(venue,singer) REFERENCES venue_singers(venue,singer) ON DELETE CASCADE)") - if try schemaVersion() < 7 { - try execute("INSERT OR IGNORE INTO singer_tonight(venue,singer,song,position) SELECT queue.venue,queue.singer,queue.song,MIN(queue.position) FROM queue JOIN venue_singers ON venue_singers.venue=queue.venue AND venue_singers.singer=queue.singer WHERE queue.singer IS NOT NULL GROUP BY queue.venue,queue.singer,queue.song") - } - try execute("PRAGMA user_version=7") - } - deinit { sqlite3_close(db) } - private func statement(_ sql: String, _ values: [String?]) throws -> OpaquePointer { - var s: OpaquePointer? - guard sqlite3_prepare_v2(db, sql, -1, &s, nil) == SQLITE_OK, let s else { throw error() } - for (i,v) in values.enumerated() { - let code = v.map { sqlite3_bind_text(s, Int32(i + 1), $0, -1, unsafeBitCast(-1, to: sqlite3_destructor_type.self)) } ?? sqlite3_bind_null(s, Int32(i + 1)) - if code != SQLITE_OK { sqlite3_finalize(s); throw error() } - } - return s - } - private func error() -> LibraryError { .message(String(cString: sqlite3_errmsg(db))) } - func execute(_ sql: String, _ values: [String?] = []) throws { - let s = try statement(sql, values); defer { sqlite3_finalize(s) } - guard sqlite3_step(s) == SQLITE_DONE else { throw error() } - } - func songs() throws -> [Song] { - let s = try statement("SELECT id,title,audio,cdg,rating,plays,artist,album,label,duration FROM songs ORDER BY title COLLATE NOCASE", []); defer { sqlite3_finalize(s) } - var result = [Song]() - while true { - let code = sqlite3_step(s); if code == SQLITE_DONE { break }; guard code == SQLITE_ROW else { throw error() } - result.append(Song(id: sqlite3_column_int64(s,0), title: String(cString: sqlite3_column_text(s,1)), audio: String(cString: sqlite3_column_text(s,2)), cdg: sqlite3_column_text(s,3).map { String(cString:$0) }, rating: Int(sqlite3_column_int(s,4)), plays: Int(sqlite3_column_int(s,5)), artist: text(s,6), album: text(s,7), label: text(s,8),duration:sqlite3_column_double(s,9))) - } - return result - } - func add(title: String, audio: String, cdg: String?, artist: String = "", album: String = "", label: String = "", duration: Double = 0) throws { - try execute("INSERT INTO songs(title,audio,cdg,artist,album,label,duration) VALUES(?,?,?,?,?,?,?) ON CONFLICT(audio) DO UPDATE SET cdg=COALESCE(excluded.cdg,songs.cdg),artist=CASE WHEN songs.metadata_edited=0 AND excluded.artist!='' THEN excluded.artist ELSE songs.artist END,album=CASE WHEN songs.metadata_edited=0 AND excluded.album!='' THEN excluded.album ELSE songs.album END,label=CASE WHEN songs.metadata_edited=0 AND excluded.label!='' THEN excluded.label ELSE songs.label END,duration=CASE WHEN excluded.duration>0 THEN excluded.duration ELSE songs.duration END", [title,audio,cdg,artist,album,label,String(duration)]) - } - func rate(_ id: Int64, _ rating: Int) throws { try execute("UPDATE songs SET rating=? WHERE id=?", [String(rating),String(id)]) } - func entities(_ table: String) throws -> [PersonPlace] { - precondition(["singers","venues","playlists"].contains(table)) - let s = try statement("SELECT id,name FROM \(table) ORDER BY name", []); defer { sqlite3_finalize(s) } - var rows = [PersonPlace]() - while sqlite3_step(s) == SQLITE_ROW { rows.append(.init(id: sqlite3_column_int64(s,0), name: String(cString: sqlite3_column_text(s,1)))) } - return rows - } - func addEntity(_ table: String, name: String) throws { - precondition(["singers","venues","playlists"].contains(table)) - let name = name.trimmingCharacters(in: .whitespacesAndNewlines) - guard !name.isEmpty else { throw LibraryError.message("Enter a name") } - try execute("INSERT OR IGNORE INTO \(table)(name) VALUES(?)", [name]) - } - func record(_ song: Int64, singer: Int64?, venue: Int64?) throws { - try execute("BEGIN IMMEDIATE") - do { - if let singer { try assignSong(song,singer:singer) } - try execute("INSERT INTO history(song,singer,venue) VALUES(?,?,?)", [String(song),singer.map(String.init),venue.map(String.init)]) - try execute("UPDATE songs SET plays=plays+1 WHERE id=?", [String(song)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK"); throw error } - } - - private func text(_ s: OpaquePointer, _ index: Int32) -> String { sqlite3_column_text(s,index).map { String(cString:$0) } ?? "" } - private func schemaVersion() throws -> Int { - let s = try statement("PRAGMA user_version",[]); defer { sqlite3_finalize(s) } - return sqlite3_step(s) == SQLITE_ROW ? Int(sqlite3_column_int(s,0)) : 0 - } - private func columns(_ table: String) throws -> Set { - let s = try statement("PRAGMA table_info(\(table))", []); defer { sqlite3_finalize(s) } - var result = Set(); while sqlite3_step(s) == SQLITE_ROW { result.insert(text(s,1)) }; return result - } - func members(of venue: Int64) throws -> [PersonPlace] { - let s = try statement("SELECT singers.id,singers.name FROM singers JOIN venue_singers ON singers.id=venue_singers.singer WHERE venue=? ORDER BY name", [String(venue)]); defer { sqlite3_finalize(s) } - var result = [PersonPlace](); while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),name:text(s,1))) }; return result - } - func setMembership(singer: Int64, venue: Int64, included: Bool) throws { - try execute(included ? "INSERT OR IGNORE INTO venue_singers(venue,singer) VALUES(?,?)" : "DELETE FROM venue_singers WHERE venue=? AND singer=?", [String(venue),String(singer)]) - if !included { try execute("DELETE FROM queue WHERE venue=? AND singer=?",[String(venue),String(singer)]) } - } - func currentVenue() throws -> Int64? { - let s = try statement("SELECT venues.id FROM venues JOIN settings ON CAST(settings.value AS INTEGER)=venues.id WHERE settings.key='currentVenue'", []); defer { sqlite3_finalize(s) } - return sqlite3_step(s) == SQLITE_ROW ? sqlite3_column_int64(s,0) : nil - } - func selectVenue(_ id: Int64?) throws { - if let id { - guard try entities("venues").contains(where: { $0.id == id }) else { throw LibraryError.message("Venue no longer exists") } - } - try execute("INSERT INTO settings(key,value) VALUES('currentVenue',?) ON CONFLICT(key) DO UPDATE SET value=excluded.value",[id.map(String.init)]) - } - func rename(_ table: String, id: Int64, name: String) throws { - precondition(["singers","venues","playlists"].contains(table)) - let name = name.trimmingCharacters(in:.whitespacesAndNewlines) - guard !name.isEmpty else { throw LibraryError.message("Enter a name") } - try execute("UPDATE \(table) SET name=? WHERE id=?",[name,String(id)]) - } - func deleteEntity(_ table: String, id: Int64) throws { - precondition(["singers","venues","playlists"].contains(table)) - try execute("BEGIN IMMEDIATE") - do { - if table == "singers" { try execute("UPDATE history SET singer=NULL WHERE singer=?",[String(id)]) } - if table == "venues" { - try execute("UPDATE history SET venue=NULL WHERE venue=?",[String(id)]) - try execute("DELETE FROM settings WHERE key='currentVenue' AND value=?",[String(id)]) - } - try execute("DELETE FROM \(table) WHERE id=?",[String(id)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK"); throw error } - } - func preference(song: Int64, singer: Int64) throws -> SongPreference { - let s = try statement("SELECT pitch,tempo,rating FROM preferences WHERE song=? AND singer=?",[String(song),String(singer)]); defer { sqlite3_finalize(s) } - guard sqlite3_step(s) == SQLITE_ROW else { return try defaultPreference(song:song) } - return .init(pitch:sqlite3_column_double(s,0),tempo:sqlite3_column_double(s,1),rating:Int(sqlite3_column_int(s,2))) - } - func savePreference(song: Int64, singer: Int64, value: SongPreference) throws { - try execute("INSERT INTO preferences(song,singer,pitch,tempo,rating) VALUES(?,?,?,?,?) ON CONFLICT(song,singer) DO UPDATE SET pitch=excluded.pitch,tempo=excluded.tempo,rating=excluded.rating",[String(song),String(singer),String(value.pitch),String(value.tempo),String(value.rating)]) - } - func history(venue: Int64?, singer: Int64? = nil) throws -> [Performance] { - let s = try statement("SELECT history.id,COALESCE(songs.title,'Deleted song'),COALESCE(singers.name,'—'),COALESCE(venues.name,'—'),played,history.singer,history.song FROM history LEFT JOIN songs ON songs.id=history.song LEFT JOIN singers ON singers.id=history.singer LEFT JOIN venues ON venues.id=history.venue WHERE (? IS NULL OR history.venue=?) AND (? IS NULL OR history.singer=?) ORDER BY history.id DESC",[venue.map(String.init),venue.map(String.init),singer.map(String.init),singer.map(String.init)]); defer { sqlite3_finalize(s) } - var result = [Performance](); while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),song:text(s,1),singer:text(s,2),venue:text(s,3),date:text(s,4),singerID:sqlite3_column_type(s,5) == SQLITE_NULL ? nil : sqlite3_column_int64(s,5),songID:sqlite3_column_type(s,6) == SQLITE_NULL ? nil : sqlite3_column_int64(s,6))) }; return result - } - func enqueue(song: Int64, singer: Int64?, venue: Int64?) throws { - guard let venue else { throw LibraryError.message("Select a current venue before adding to its queue") } - if let singer, try !members(of:venue).contains(where: { $0.id == singer }) { throw LibraryError.message("Add this singer to the current venue first") } - try execute("BEGIN IMMEDIATE") - do { - if let singer { - try assignSong(song,singer:singer) - try execute("INSERT OR IGNORE INTO singer_tonight(venue,singer,song,position) VALUES(?,?,?,(SELECT COALESCE(MAX(position),0)+1 FROM singer_tonight WHERE venue=? AND singer=?))",[String(venue),String(singer),String(song),String(venue),String(singer)]) - } - try execute("INSERT INTO queue(venue,song,singer,position) VALUES(?,?,?,(SELECT COALESCE(MAX(position),0)+1 FROM queue WHERE venue=?))",[String(venue),String(song),singer.map(String.init),String(venue)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK");throw error } - } - func queue(venue: Int64?) throws -> [QueueEntry] { - guard let venue else { return [] } - let s = try statement("SELECT queue.id,queue.song,queue.singer,songs.title,COALESCE(singers.name,'No singer') FROM queue JOIN songs ON songs.id=queue.song LEFT JOIN singers ON singers.id=queue.singer WHERE queue.venue=? ORDER BY queue.position,queue.id",[String(venue)]); defer { sqlite3_finalize(s) } - var result = [QueueEntry](); while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),songID:sqlite3_column_int64(s,1),singerID:sqlite3_column_type(s,2) == SQLITE_NULL ? nil : sqlite3_column_int64(s,2),title:text(s,3),singer:text(s,4))) }; return result - } - func removeQueue(_ id: Int64) throws { try execute("DELETE FROM queue WHERE id=?",[String(id)]) } - func moveQueue(_ id: Int64, venue: Int64, by offset: Int) throws { - var rows = try queue(venue:venue) - guard let index = rows.firstIndex(where: { $0.id == id }), rows.indices.contains(index+offset) else { return } - rows.swapAt(index,index+offset) - try execute("BEGIN IMMEDIATE") - do { for (i,row) in rows.enumerated() { try execute("UPDATE queue SET position=? WHERE id=?",[String(i),String(row.id)]) }; try execute("COMMIT") } - catch { try? execute("ROLLBACK"); throw error } - } - func addToPlaylist(_ playlist: Int64, song: Int64) throws { - try execute("INSERT OR IGNORE INTO playlist_songs(playlist,song,position) VALUES(?,?,(SELECT COALESCE(MAX(position),0)+1 FROM playlist_songs WHERE playlist=?))",[String(playlist),String(song),String(playlist)]) - } - func playlistSongIDs(_ playlist: Int64) throws -> [Int64] { - let s = try statement("SELECT song FROM playlist_songs WHERE playlist=? ORDER BY position",[String(playlist)]); defer { sqlite3_finalize(s) } - var ids = [Int64](); while sqlite3_step(s) == SQLITE_ROW { ids.append(sqlite3_column_int64(s,0)) }; return ids - } - func removeFromPlaylist(_ playlist: Int64, song: Int64) throws { try execute("DELETE FROM playlist_songs WHERE playlist=? AND song=?",[String(playlist),String(song)]) } - func assignSong(_ song: Int64, singer: Int64) throws { - try execute("INSERT OR IGNORE INTO singer_songs(singer,song,position) VALUES(?,?,(SELECT COALESCE(MAX(position),0)+1 FROM singer_songs WHERE singer=?))",[String(singer),String(song),String(singer)]) - } - func removeSingerSong(_ song: Int64, singer: Int64) throws { - try execute("DELETE FROM singer_songs WHERE singer=? AND song=?",[String(singer),String(song)]) - } - func singerSongIDs() throws -> [Int64:[Int64]] { - let s = try statement("SELECT singer,song FROM singer_songs ORDER BY singer,position,song",[]); defer { sqlite3_finalize(s) } - var result = [Int64:[Int64]]() - while sqlite3_step(s) == SQLITE_ROW { result[sqlite3_column_int64(s,0),default:[]].append(sqlite3_column_int64(s,1)) } - return result - } - func defaultPreference(song: Int64) throws -> SongPreference { - let s = try statement("SELECT pitch,tempo FROM song_settings WHERE song=?",[String(song)]);defer { sqlite3_finalize(s) } - guard sqlite3_step(s) == SQLITE_ROW else { return .init() } - return .init(pitch:sqlite3_column_double(s,0),tempo:sqlite3_column_double(s,1),rating:0) - } - func saveDefaultPreference(song: Int64, value: SongPreference) throws { - try execute("INSERT INTO song_settings(song,pitch,tempo) VALUES(?,?,?) ON CONFLICT(song) DO UPDATE SET pitch=excluded.pitch,tempo=excluded.tempo",[String(song),String(value.pitch),String(value.tempo)]) - } - func updateDuration(_ song: Int64, seconds: Double) throws { - guard seconds.isFinite && seconds >= 0 else { return } - try execute("UPDATE songs SET duration=? WHERE id=?",[String(seconds),String(song)]) - } - func setFavourite(song: Int64, singer: Int64, included: Bool) throws { - if included { try assignSong(song,singer:singer) } - try execute("UPDATE singer_songs SET favourite=? WHERE singer=? AND song=?",[included ? "1" : "0",String(singer),String(song)]) - } - func favouriteSongIDs() throws -> [Int64:Set] { - let s = try statement("SELECT singer,song FROM singer_songs WHERE favourite=1",[]);defer { sqlite3_finalize(s) } - var result = [Int64:Set]() - while sqlite3_step(s) == SQLITE_ROW { result[sqlite3_column_int64(s,0),default:[]].insert(sqlite3_column_int64(s,1)) };return result - } - func stores() throws -> [MusicStore] { - let s = try statement("SELECT id,name,url,search_template FROM music_stores ORDER BY name",[]);defer { sqlite3_finalize(s) } - var result = [MusicStore]() - while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),name:text(s,1),url:text(s,2),searchTemplate:text(s,3))) };return result - } - func saveStore(_ store: MusicStore) throws { - let name = store.name.trimmingCharacters(in:.whitespacesAndNewlines),url = store.url.trimmingCharacters(in:.whitespacesAndNewlines),search = store.searchTemplate.trimmingCharacters(in:.whitespacesAndNewlines) - guard !name.isEmpty else { throw LibraryError.message("Enter a store name") } - let cleaned = MusicStore(id:store.id,name:name,url:url,searchTemplate:search) - _ = try cleaned.destination() - if !search.isEmpty { - guard search.contains("{query}") else { throw LibraryError.message("Search URL must contain {query}") } - _ = try cleaned.destination(query:"test") - } - if store.id == 0 { try execute("INSERT INTO music_stores(name,url,search_template) VALUES(?,?,?)",[name,url,search]) } - else { try execute("UPDATE music_stores SET name=?,url=?,search_template=? WHERE id=?",[name,url,search,String(store.id)]) } - } - func deleteStore(_ id: Int64) throws { try execute("DELETE FROM music_stores WHERE id=?",[String(id)]) } - func updateMetadata(song: Int64,title: String,artist: String,album: String,label: String,rating: Int) throws { - let title = title.trimmingCharacters(in:.whitespacesAndNewlines) - guard !title.isEmpty else { throw LibraryError.message("Song title cannot be empty") } - try execute("UPDATE songs SET title=?,artist=?,album=?,label=?,rating=?,metadata_edited=1 WHERE id=?",[title,artist.trimmingCharacters(in:.whitespacesAndNewlines),album.trimmingCharacters(in:.whitespacesAndNewlines),label.trimmingCharacters(in:.whitespacesAndNewlines),String(rating),String(song)]) - guard sqlite3_changes(db) == 1 else { throw LibraryError.message("Song no longer exists") } - } - func tonightSongIDs(venue: Int64?) throws -> [Int64:[Int64]] { - guard let venue else { return [:] } - let s = try statement("SELECT singer,song FROM singer_tonight WHERE venue=? ORDER BY position,song",[String(venue)]);defer { sqlite3_finalize(s) } - var result = [Int64:[Int64]]() - while sqlite3_step(s) == SQLITE_ROW { result[sqlite3_column_int64(s,0),default:[]].append(sqlite3_column_int64(s,1)) };return result - } - func addTonight(song: Int64,singer: Int64,venue: Int64) throws { - guard try members(of:venue).contains(where:{ $0.id == singer }) else { throw LibraryError.message("This singer is not a member of the current venue") } - try execute("BEGIN IMMEDIATE") - do { - try assignSong(song,singer:singer) - try execute("INSERT OR IGNORE INTO singer_tonight(venue,singer,song,position) VALUES(?,?,?,(SELECT COALESCE(MAX(position),0)+1 FROM singer_tonight WHERE venue=? AND singer=?))",[String(venue),String(singer),String(song),String(venue),String(singer)]) - try execute("INSERT INTO queue(venue,song,singer,position) SELECT ?,?,?,(SELECT COALESCE(MAX(position),0)+1 FROM queue WHERE venue=?) WHERE NOT EXISTS(SELECT 1 FROM queue WHERE venue=? AND singer=? AND song=?)",[String(venue),String(song),String(singer),String(venue),String(venue),String(singer),String(song)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK");throw error } - } - func removeTonight(song: Int64,singer: Int64,venue: Int64) throws { - try execute("BEGIN IMMEDIATE") - do { - try execute("DELETE FROM singer_tonight WHERE venue=? AND singer=? AND song=?",[String(venue),String(singer),String(song)]) - try execute("DELETE FROM queue WHERE venue=? AND singer=? AND song=?",[String(venue),String(singer),String(song)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK");throw error } - } -} diff --git a/backups/before-tonight-drag-20261103-094630/KJamsCloneTests/KJamsCloneTests.swift b/backups/before-tonight-drag-20261103-094630/KJamsCloneTests/KJamsCloneTests.swift deleted file mode 100644 index 67ecbe3..0000000 --- a/backups/before-tonight-drag-20261103-094630/KJamsCloneTests/KJamsCloneTests.swift +++ /dev/null @@ -1,504 +0,0 @@ -import XCTest -import AVFoundation -@testable import KJamsClone - -final class KJamsCloneTests: XCTestCase { - func packet(_ instruction: UInt8, _ data: [UInt8]) -> [UInt8] { [9,instruction,0,0] + Array((data + Array(repeating: 0,count:16)).prefix(16)) + [0,0,0,0] } - func testPresetTileXORAndInvalidCoordinates() { - var d = CDGDecoder() - d.apply(packet(1,[3,0])); XCTAssertEqual(d.pixels[0],3) - d.apply(packet(6,[0,5,1,1] + Array(repeating:63,count:12))) - XCTAssertEqual(d.pixels[12*300+6],5) - d.apply(packet(38,[0,5,1,1] + Array(repeating:63,count:12))) - XCTAssertEqual(d.pixels[12*300+6],0) - let old = d.pixels; d.apply(packet(6,[1,2,31,63])); XCTAssertEqual(d.pixels,old) - } - func testSeekAndTruncatedPacket() { - var d = CDGDecoder() - let data = Data(packet(1,[2,0]) + packet(1,[7,0]) + [9]) - d.render(data,at:1); XCTAssertEqual(d.pixels[0],7); XCTAssertEqual(d.packetIndex,2) - d.render(data,at:1.0/300); XCTAssertEqual(d.pixels[0],2) - d.render(data,at:0); XCTAssertEqual(d.pixels[0],0) - } - func testPaletteBorderScrollAndImage() { - var d = CDGDecoder() - d.apply(packet(30,[63,63])); XCTAssertEqual(d.palette[0],0xFFFFFFFF) - d.apply(packet(2,[4])); XCTAssertEqual(d.pixels[0],4); XCTAssertEqual(d.pixels[12*300+6],0) - d.apply(packet(20,[3,16,0])); XCTAssertEqual(d.pixels[100*300],3) - d.apply(packet(24,[0,32,0])); XCTAssertEqual(d.pixels[100*300+294],3) - XCTAssertEqual(d.image()?.width,288) - } - func testSQLitePersistenceDedupRatingsAndHistory() throws { - let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at: folder,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:folder) } - let url = folder.appendingPathComponent("test.sqlite") - do { - let db = try Library(url:url) - try db.add(title:"Singer's Song",audio:"/test.mp3",cdg:nil) - try db.add(title:"Duplicate",audio:"/test.mp3",cdg:"/test.cdg") - let song = try XCTUnwrap(db.songs().first) - try db.rate(song.id,5); XCTAssertThrowsError(try db.rate(song.id,6)) - try db.addEntity("singers",name:"O'Neil"); try db.addEntity("venues",name:"Hall") - try db.record(song.id,singer:db.entities("singers").first?.id,venue:db.entities("venues").first?.id) - } - let reopened = try Library(url:url); let songs = try reopened.songs() - XCTAssertEqual(songs.count,1); XCTAssertEqual(songs[0].rating,5); XCTAssertEqual(songs[0].plays,1); XCTAssertEqual(songs[0].cdg,"/test.cdg") - XCTAssertEqual(try reopened.entities("singers").first?.name,"O'Neil") - } - func testPairedImportAndContentDedup() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let audio = root.appendingPathComponent("Test.mp3"), cdg = root.appendingPathComponent("Test.CDG") - try Data([1,2,3]).write(to:audio); try Data(packet(1,[2,0])).write(to:cdg) - let db = try Library(url:root.appendingPathComponent("test.sqlite")) - let importer = Importer(media:root.appendingPathComponent("Media")) - try importer.run([audio],library:db); try importer.run([audio],library:db) - XCTAssertEqual(try db.songs().count,1) - XCTAssertNotNil(try db.songs().first?.cdg) - } - - func testZippedMP3GImportAndUnsafeArchiveRejection() throws { - let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:folder,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:folder) } - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let db = try Library(url:folder.appendingPathComponent("db.sqlite")) - let importer = Importer(media:folder.appendingPathComponent("Media")) - try importer.run([fixtures.appendingPathComponent("Demo.zip")],library:db) - let song = try XCTUnwrap(db.songs().first) - XCTAssertEqual(song.title,"Demo"); XCTAssertNotNil(song.cdg) - XCTAssertTrue(FileManager.default.fileExists(atPath:song.audio)) - XCTAssertThrowsError(try importer.run([fixtures.appendingPathComponent("Unsafe.zip")],library:db)) - } - @MainActor func testMP3PlaybackPauseAndSeek() throws { - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let player = Player() - defer { player.stop() } - try player.load(Song(id:1,title:"Demo",audio:fixtures.appendingPathComponent("Demo.mp3").path,cdg:fixtures.appendingPathComponent("Demo.cdg").path,rating:0,plays:0)) - XCTAssertGreaterThan(player.duration,3.9); XCTAssertTrue(player.playing) - player.toggle(); XCTAssertFalse(player.playing) - player.seek(2); XCTAssertEqual(player.time,2,accuracy:0.05); XCTAssertNotNil(player.image) - player.seek(0.1); XCTAssertEqual(player.time,0.1,accuracy:0.05) - } - @MainActor func testCreateSingerAndVenueThroughAppModel() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - defer { try? FileManager.default.removeItem(at: root) } - let model = AppModel(storageURL: root) - XCTAssertNil(model.error) - let singer = try model.createEntity(.singer, name: " Alex ") - let venue = try model.createEntity(.venue, name: "Town Hall") - XCTAssertEqual(model.singers.first?.name, "Alex") - XCTAssertEqual(model.venues.first?.name, "Town Hall") - XCTAssertEqual(try model.createEntity(.singer, name: "Alex"), singer) - XCTAssertEqual(model.singers.count, 1) - XCTAssertThrowsError(try model.createEntity(.venue, name: " ")) - let reopened = AppModel(storageURL: root) - XCTAssertEqual(reopened.singers.first?.id, singer) - XCTAssertEqual(reopened.venues.first?.id, venue) - } - - @MainActor func testVenuesShareSingersAndRememberSelection() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - defer { try? FileManager.default.removeItem(at:root) } - let model = AppModel(storageURL:root) - let hall = try model.createEntity(.venue,name:"Hall") - let alex = try model.createEntity(.singer,name:"Alex") - let club = try model.createEntity(.venue,name:"Club") - XCTAssertTrue(model.venueSingers.isEmpty) - model.membership(singer:alex,included:true) - XCTAssertEqual(model.venueSingers.map(\.id),[alex]) - model.chooseVenue(hall); XCTAssertEqual(model.venueSingers.map(\.id),[alex]) - model.chooseVenue(club); model.membership(singer:alex,included:false) - XCTAssertTrue(model.venueSingers.isEmpty) - let reopened = AppModel(storageURL:root) - XCTAssertEqual(reopened.currentVenue,club); XCTAssertTrue(reopened.venueSingers.isEmpty) - reopened.chooseVenue(hall); XCTAssertEqual(reopened.venueSingers.map(\.id),[alex]) - XCTAssertEqual(reopened.singers.count,1) - } - func testMigrationAndMembershipRemovalDoesNotReappear() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let url = root.appendingPathComponent("db.sqlite") - var singer: Int64 = 0, venue: Int64 = 0 - do { - let db = try Library(url:url) - try db.add(title:"Song",audio:"/a.mp3",cdg:nil) - try db.addEntity("singers",name:"Alex"); try db.addEntity("venues",name:"Hall") - singer = try XCTUnwrap(db.entities("singers").first?.id); venue = try XCTUnwrap(db.entities("venues").first?.id) - try db.record(XCTUnwrap(db.songs().first?.id),singer:singer,venue:venue) - try db.execute("PRAGMA user_version=1") - } - do { - let migrated = try Library(url:url) - XCTAssertEqual(try migrated.members(of:venue).map(\.id),[singer]) - try migrated.setMembership(singer:singer,venue:venue,included:false) - } - let reopened = try Library(url:url) - XCTAssertTrue(try reopened.members(of:venue).isEmpty) - XCTAssertEqual(try reopened.history(venue:venue).count,1) - } - func testQueuePlaylistsPreferencesAndDeletion() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let db = try Library(url:root.appendingPathComponent("db.sqlite")) - try db.add(title:"First",audio:"/1.mp3",cdg:nil) - try db.add(title:"Second",audio:"/2.mp3",cdg:nil) - let songs = try db.songs() - try db.addEntity("singers",name:"Alex"); try db.addEntity("venues",name:"Hall"); try db.addEntity("venues",name:"Club") - let singer = try XCTUnwrap(db.entities("singers").first?.id) - let hall = try XCTUnwrap(db.entities("venues").first(where: { $0.name == "Hall" })?.id) - let club = try XCTUnwrap(db.entities("venues").first(where: { $0.name == "Club" })?.id) - XCTAssertThrowsError(try db.enqueue(song:songs[0].id,singer:singer,venue:hall)) - try db.setMembership(singer:singer,venue:hall,included:true) - try db.enqueue(song:songs[0].id,singer:singer,venue:hall); try db.enqueue(song:songs[1].id,singer:singer,venue:hall) - XCTAssertTrue(try db.queue(venue:club).isEmpty) - let second = try XCTUnwrap(db.queue(venue:hall).last) - try db.moveQueue(second.id,venue:hall,by:-1) - XCTAssertEqual(try db.queue(venue:hall).first?.songID,songs[1].id) - let preference = SongPreference(pitch:3,tempo:0.85,rating:4) - try db.savePreference(song:songs[0].id,singer:singer,value:preference) - XCTAssertEqual(try db.preference(song:songs[0].id,singer:singer),preference) - XCTAssertThrowsError(try db.savePreference(song:songs[0].id,singer:singer,value:.init(pitch:99))) - try db.addEntity("playlists",name:"Party") - let playlist = try XCTUnwrap(db.entities("playlists").first?.id) - try db.addToPlaylist(playlist,song:songs[0].id); try db.addToPlaylist(playlist,song:songs[0].id) - XCTAssertEqual(try db.playlistSongIDs(playlist),[songs[0].id]) - try db.record(songs[0].id,singer:singer,venue:hall) - try db.rename("singers",id:singer,name:"Alex Jones") - XCTAssertEqual(try db.history(venue:hall).first?.singer,"Alex Jones") - try db.deleteEntity("singers",id:singer) - XCTAssertTrue(try db.queue(venue:hall).isEmpty) - XCTAssertEqual(try db.history(venue:hall).count,1) - try db.selectVenue(hall); try db.deleteEntity("venues",id:hall) - XCTAssertNil(try db.currentVenue()); XCTAssertEqual(try db.history(venue:nil).count,1) - } - @MainActor func testTempoSourceClockPauseAndResume() async throws { - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let player = Player(); defer { player.stop() } - let song = Song(id:1,title:"Demo",audio:fixtures.appendingPathComponent("Demo.mp3").path,cdg:fixtures.appendingPathComponent("Demo.cdg").path,rating:0,plays:0) - try player.load(song,preference:.init(pitch:2,tempo:1.5,rating:3)) - XCTAssertEqual(player.pitch,2); XCTAssertEqual(player.tempo,1.5) - try await Task.sleep(nanoseconds:500_000_000) - XCTAssertGreaterThan(player.time,0.45); XCTAssertLessThan(player.time,1.3) - player.toggle(); let paused = player.time - try await Task.sleep(nanoseconds:100_000_000) - XCTAssertEqual(player.time,paused,accuracy:0.025) - player.seek(1.5); player.toggle() - try await Task.sleep(nanoseconds:200_000_000) - XCTAssertGreaterThan(player.time,1.6); XCTAssertNotNil(player.image) - } - func testNewTestMediaMetadataAndCDGPairImport() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let db = try Library(url:root.appendingPathComponent("db.sqlite")) - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let importer = Importer(media:root.appendingPathComponent("Media")) - try importer.run([fixtures.appendingPathComponent("TestTrack.cdg")],library:db) - let song = try XCTUnwrap(db.songs().first) - XCTAssertEqual(song.title,"MP3 Plus G Test") - XCTAssertEqual(song.artist,"KJamsClone Test Generator") - XCTAssertNotNil(song.cdg) - let bytes = try Data(contentsOf:fixtures.appendingPathComponent("TestTrack.cdg")) - XCTAssertEqual(bytes.count,20*300*24) - var decoder = CDGDecoder(); decoder.render(bytes,at:2) - XCTAssertTrue(decoder.pixels.contains(1)); XCTAssertTrue(decoder.pixels.contains(2)) - } - @MainActor func testAutomaticVenueQueueAdvancesAndRecordsSinger() async throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - defer { try? FileManager.default.removeItem(at:root) } - let model = AppModel(storageURL:root); defer { model.player.stop() } - _ = try model.createEntity(.venue,name:"Test Hall") - _ = try model.createEntity(.singer,name:"Alex") - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - model.importFiles([fixtures.appendingPathComponent("Demo.zip")]) - let song = try XCTUnwrap(model.songs.first) - model.enqueue(song.id); model.enqueue(song.id); model.playQueueNext() - XCTAssertEqual(model.queue.count,1); XCTAssertEqual(model.history.count,1) - model.player.seek(model.player.duration-0.1) - for _ in 0..<25 { - if model.queue.isEmpty { break } - try await Task.sleep(nanoseconds:100_000_000) - } - XCTAssertNil(model.error); XCTAssertTrue(model.queue.isEmpty) - XCTAssertEqual(model.history.count,2); XCTAssertEqual(model.history.first?.singer,"Alex") - } - func testWaveformRepresentsSilenceAndSignalInTimeOrder() throws { - let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:folder,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:folder) } - let url = folder.appendingPathComponent("signal.wav") - let format = try XCTUnwrap(AVAudioFormat(standardFormatWithSampleRate:8000,channels:1)) - do { - let file = try AVAudioFile(forWriting:url,settings:format.settings) - let buffer = try XCTUnwrap(AVAudioPCMBuffer(pcmFormat:format,frameCapacity:4096)); buffer.frameLength = 4096 - let samples = try XCTUnwrap(buffer.floatChannelData?[0]) - for i in 0..<4096 { samples[i] = i < 2048 ? 0 : Float(sin(Double(i)*0.2)*0.5) } - try file.write(from:buffer) - } - let envelope = try AudioWaveform.read(url:url,bins:32) - XCTAssertEqual(envelope.count,32) - XCTAssertTrue(envelope.prefix(16).allSatisfy { $0 == 0 }) - XCTAssertTrue(envelope.suffix(16).allSatisfy { $0 > 0.8 && $0 <= 1 }) - XCTAssertThrowsError(try AudioWaveform.read(url:url,cancelled:{true})) - } - @MainActor func testWaveformAnalysisAndStopClearsTrackData() async throws { - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let player = Player(); defer { player.stop() } - try player.load(Song(id:1,title:"Demo",audio:fixtures.appendingPathComponent("Demo.mp3").path,cdg:nil,rating:0,plays:0)) - player.toggle() - for _ in 0..<50 { - if !player.waveformLoading { break } - try await Task.sleep(nanoseconds:20_000_000) - } - XCTAssertEqual(player.waveform.count,4096) - XCTAssertFalse(player.waveformUnavailable) - player.stop() - XCTAssertTrue(player.waveform.isEmpty) - XCTAssertFalse(player.waveformLoading) - try await Task.sleep(nanoseconds:50_000_000) - XCTAssertTrue(player.waveform.isEmpty) - } - - @MainActor func testConnectedSingerCreationAndSharedRepertoire() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - defer { try? FileManager.default.removeItem(at:root) } - let model = AppModel(storageURL:root) - let hall = try model.createEntity(.venue,name:"Hall") - try model.library?.add(title:"Song",audio:"/sample.mp3",cdg:nil);try model.refresh() - let song = try XCTUnwrap(model.songs.first?.id) - let alex = try model.createSinger(name:" Alex ",venue:hall,songs:[song]) - XCTAssertEqual(model.selectedSinger,alex);XCTAssertEqual(model.currentVenue,hall) - XCTAssertEqual(model.venueSingers.map(\.id),[alex]);XCTAssertEqual(model.songs(for:alex).map(\.id),[song]) - XCTAssertThrowsError(try model.createSinger(name:"Broken",venue:hall,songs:[999999])) - XCTAssertFalse(try XCTUnwrap(model.library).entities("singers").contains { $0.name == "Broken" }) - let club = try model.createEntity(.venue,name:"Club");model.membership(singer:alex,included:true) - XCTAssertEqual(model.songs(for:alex).map(\.id),[song]) - model.assign(song,to:alex);XCTAssertEqual(model.songs(for:alex).count,1) - let reopened = AppModel(storageURL:root) - XCTAssertEqual(reopened.currentVenue,club);XCTAssertEqual(reopened.songs(for:alex).map(\.id),[song]) - reopened.assign(song,to:alex,included:false) - XCTAssertTrue(AppModel(storageURL:root).songs(for:alex).isEmpty) - } - func testQueueRemembersSingerSongWithoutDuplicatingAssignment() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let db = try Library(url:root.appendingPathComponent("db.sqlite")) - try db.addEntity("singers",name:"Alex");try db.addEntity("venues",name:"Hall") - try db.add(title:"Song",audio:"/a.mp3",cdg:nil) - let singer = try XCTUnwrap(db.entities("singers").first?.id),venue = try XCTUnwrap(db.entities("venues").first?.id),song = try XCTUnwrap(db.songs().first?.id) - try db.setMembership(singer:singer,venue:venue,included:true) - try db.enqueue(song:song,singer:singer,venue:venue);try db.enqueue(song:song,singer:singer,venue:venue) - XCTAssertEqual(try db.singerSongIDs()[singer],[song]);XCTAssertEqual(try db.queue(venue:venue).count,2) - try db.removeSingerSong(song,singer:singer) - XCTAssertNil(try db.singerSongIDs()[singer]);XCTAssertEqual(try db.songs().count,1) - } - func testFrequencyBandsDistinguishBassAndTreble() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let url = root.appendingPathComponent("bands.wav") - let format = try XCTUnwrap(AVAudioFormat(standardFormatWithSampleRate:16000,channels:1)) - do { - let file = try AVAudioFile(forWriting:url,settings:format.settings) - let buffer = try XCTUnwrap(AVAudioPCMBuffer(pcmFormat:format,frameCapacity:8192));buffer.frameLength = 8192 - for i in 0..<8192 { buffer.floatChannelData![0][i] = Float(sin(Double(i)*2*Double.pi*(i < 4096 ? 80 : 6000)/16000)*0.2) } - try file.write(from:buffer) - } - let analysis = try AudioWaveform.analyse(url:url,bins:32) - XCTAssertGreaterThan(analysis.bands[8].low,analysis.bands[8].high*3) - XCTAssertGreaterThan(analysis.bands[24].high,analysis.bands[24].low*3) - } - private func toneRMS(frequency: Double, low: Double = 0, filter: Double = 0, enabled: Bool = true) throws -> Double { - let engine = AVAudioEngine(),node = AVAudioPlayerNode(),eq = AVAudioUnitEQ(numberOfBands:4) - let format = try XCTUnwrap(AVAudioFormat(standardFormatWithSampleRate:44100,channels:1)) - engine.attach(node);engine.attach(eq);engine.connect(node,to:eq,format:format);engine.connect(eq,to:engine.mainMixerNode,format:format) - AudioTone.configure(eq,sampleRate:44100,low:low,mid:0,high:0,filter:filter,enabled:enabled) - try engine.enableManualRenderingMode(.offline,format:format,maximumFrameCount:1024) - let input = try XCTUnwrap(AVAudioPCMBuffer(pcmFormat:format,frameCapacity:32768));input.frameLength = 32768 - for i in 0..<32768 { input.floatChannelData![0][i] = Float(sin(Double(i)*2*Double.pi*frequency/44100)*0.1) } - node.scheduleBuffer(input);try engine.start();node.play();defer { node.stop();engine.stop() } - let output = try XCTUnwrap(AVAudioPCMBuffer(pcmFormat:format,frameCapacity:1024)) - var energy: Double = 0,count = 0 - for block in 0..<12 { - let status = try engine.renderOffline(1024,to:output) - XCTAssertEqual(status,.success) - if block >= 2 { for i in 0..]() - @Published var musicStores = [MusicStore]() - @Published var readingDurations = false - var newSingerSongs = Set() - private var songIndex = [Int64:Song]() - @Published var venues = [PersonPlace]() - @Published var venueSingers = [PersonPlace]() - @Published var playlists = [PersonPlace]() - @Published var queue = [QueueEntry]() - @Published var history = [Performance]() - @Published private(set) var currentVenue: Int64? - @Published var selectedSinger: Int64? - @Published var autoAdvance = true - @Published var error: String? - @Published var creating: EntityKind? - let player: Player - private(set) var library: Library? - let root: URL - var currentVenueName: String { venues.first { $0.id == currentVenue }?.name ?? "No venue selected" } - init(storageURL: URL? = nil) { - root = storageURL ?? FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0].appendingPathComponent("KJamsClone") - player = Player(waveformCacheDirectory:root.appendingPathComponent("Waveforms")) - perform { - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - library = try Library(url:root.appendingPathComponent("Library.sqlite")); try refresh() - } - player.onFinished = { [weak self] in - guard let self, self.autoAdvance, !self.queue.isEmpty else { return } - self.playQueueNext() - } - } - func perform(_ work: () throws -> Void) { do { try work() } catch { self.error = error.localizedDescription } } - func refresh() throws { - guard let library else { throw LibraryError.message("Library unavailable") } - songs = try library.songs();songIndex = Dictionary(uniqueKeysWithValues:songs.map { ($0.id,$0) }); singers = try library.entities("singers"); venues = try library.entities("venues") - singerSongIDs = try library.singerSongIDs();favourites = try library.favouriteSongIDs();musicStores = try library.stores() - playlists = try library.entities("playlists"); currentVenue = try library.currentVenue() - venueSingers = try currentVenue.map { try library.members(of:$0) } ?? singers - if let selectedSinger, !venueSingers.contains(where: { $0.id == selectedSinger }) { self.selectedSinger = nil } - queue = try library.queue(venue:currentVenue); history = try library.history(venue:currentVenue) - } - func chooseVenue(_ id: Int64?) { - perform { - guard let library else { throw LibraryError.message("Library unavailable") } - try library.selectVenue(id); selectedSinger = nil; try refresh() - } - } - func membership(singer: Int64, included: Bool) { - perform { - guard let library, let currentVenue else { throw LibraryError.message("Select a current venue first") } - try library.setMembership(singer:singer,venue:currentVenue,included:included); try refresh() - } - } - @discardableResult func createEntity(_ kind: EntityKind, name: String) throws -> Int64 { - guard let library else { throw LibraryError.message("Library unavailable") } - let trimmed = name.trimmingCharacters(in:.whitespacesAndNewlines) - try library.addEntity(kind.table,name:trimmed) - guard let entity = try library.entities(kind.table).first(where: { $0.name == trimmed }) else { throw LibraryError.message("Could not load new entry") } - if kind == .singer { - if let currentVenue { try library.setMembership(singer:entity.id,venue:currentVenue,included:true) } - selectedSinger = entity.id - } else { try library.selectVenue(entity.id); selectedSinger = nil } - try refresh(); return entity.id - } - func beginSinger(song: Int64? = nil) { newSingerSongs = Set(song.map { [$0] } ?? []); creating = .singer } - func songs(for singer: Int64) -> [Song] { - (singerSongIDs[singer] ?? []).compactMap { songIndex[$0] } - } - func assign(_ song: Int64, to singer: Int64, included: Bool = true) { - perform { - guard let library else { throw LibraryError.message("Library unavailable") } - if included { try library.assignSong(song,singer:singer) } else { try library.removeSingerSong(song,singer:singer) } - try refresh() - } - } - func createSinger(name: String, venue: Int64, songs: Set) throws -> Int64 { - guard let library else { throw LibraryError.message("Library unavailable") } - guard venues.contains(where: { $0.id == venue }) else { throw LibraryError.message("Choose a venue first") } - let name = name.trimmingCharacters(in:.whitespacesAndNewlines) - try library.execute("BEGIN IMMEDIATE") - let id: Int64 - do { - try library.addEntity("singers",name:name) - guard let singer = try library.entities("singers").first(where: { $0.name == name }) else { throw LibraryError.message("Could not load singer") } - id = singer.id - try library.setMembership(singer:id,venue:venue,included:true) - for song in songs { try library.assignSong(song,singer:id) } - try library.selectVenue(venue);try library.execute("COMMIT") - } catch { try? library.execute("ROLLBACK");throw error } - try refresh();selectedSinger = id;return id - } - func rename(_ table: String, id: Int64, name: String) { perform { try library?.rename(table,id:id,name:name); try refresh() } } - func delete(_ table: String, id: Int64) { perform { try library?.deleteEntity(table,id:id); try refresh() } } - func preference(_ song: Int64) -> SongPreference { - guard let library else { return .init() } - if let selectedSinger { return (try? library.preference(song:song,singer:selectedSinger)) ?? .init() } - return (try? library.defaultPreference(song:song)) ?? .init() - } - func savePreference(song: Int64, value: SongPreference) { - perform { - guard let library, let selectedSinger else { throw LibraryError.message("Select a singer to save their song preferences") } - try library.savePreference(song:song,singer:selectedSinger,value:value); try refresh() - } - } - func play(_ song: Song, singer: Int64? = nil) throws { - guard let library else { throw LibraryError.message("Library unavailable") } - let singer = singer ?? selectedSinger - if let singer, let currentVenue, try !library.members(of:currentVenue).contains(where: { $0.id == singer }) { throw LibraryError.message("This singer is not in the current venue") } - let preference = try singer.map { try library.preference(song:song.id,singer:$0) } ?? library.defaultPreference(song:song.id) - try player.load(song,preference:preference) - do { try library.updateDuration(song.id,seconds:player.duration);try library.record(song.id,singer:singer,venue:currentVenue); selectedSinger = singer; try refresh() } - catch { player.stop(); throw error } - } - func enqueue(_ song: Int64) { perform { try library?.enqueue(song:song,singer:selectedSinger,venue:currentVenue); try refresh() } } - func playQueueNext() { - perform { - guard let row = queue.first, let song = songs.first(where: { $0.id == row.songID }) else { return } - // Explicitly clear selection for unassigned queue entries. - selectedSinger = row.singerID - try play(song,singer:row.singerID); try library?.removeQueue(row.id); try refresh() - } - } - func moveQueue(_ id: Int64, by offset: Int) { perform { if let currentVenue { try library?.moveQueue(id,venue:currentVenue,by:offset); try refresh() } } } - func removeQueue(_ id: Int64) { perform { try library?.removeQueue(id); try refresh() } } - func createPlaylist(_ name: String) { perform { try library?.addEntity("playlists",name:name); try refresh() } } - func addToPlaylist(_ playlist: Int64, song: Int64) { perform { try library?.addToPlaylist(playlist,song:song); try refresh() } } - func setFavourite(_ song: Int64, singer: Int64, included: Bool) { perform { try library?.setFavourite(song:song,singer:singer,included:included);try refresh() } } - func updateTuning(_ song: Int64, pitch: Double? = nil, tempo: Double? = nil) { - perform { - guard let library else { throw LibraryError.message("Library unavailable") } - var value = preference(song) - if let pitch { value.pitch = pitch };if let tempo { value.tempo = tempo } - if let selectedSinger { try library.savePreference(song:song,singer:selectedSinger,value:value) } - else { try library.saveDefaultPreference(song:song,value:value) } - if player.currentSongID == song { if pitch != nil { player.pitch = value.pitch };if tempo != nil { player.tempo = value.tempo } } - try refresh() - } - } - func saveStore(_ store: MusicStore) throws { guard let library else { throw LibraryError.message("Library unavailable") };try library.saveStore(store);try refresh() } - func deleteStore(_ id: Int64) { perform { try library?.deleteStore(id);try refresh() } } - func scanDurations() { - guard !readingDurations else { return };readingDurations = true - let songs = self.songs.filter { $0.duration == 0 } - Task.detached(priority:.utility) { [weak self] in - var durations = [(Int64,Double)]() - for song in songs { - if let file = try? AVAudioFile(forReading:URL(fileURLWithPath:song.audio)) { durations.append((song.id,Double(file.length)/file.processingFormat.sampleRate)) } - } - let completedDurations = durations - await MainActor.run { [weak self] in - guard let self else { return } - self.perform { for (id,value) in completedDurations { try self.library?.updateDuration(id,seconds:value) };try self.refresh() } - self.readingDurations = false - } - } - } - func updateMetadata(_ song: Song,title: String,artist: String,album: String,label: String,rating: Int) throws { - guard let library else { throw LibraryError.message("Library unavailable") } - try library.updateMetadata(song:song.id,title:title,artist:artist,album:album,label:label,rating:rating) - if player.currentSongID == song.id { player.title = title.trimmingCharacters(in:.whitespacesAndNewlines) } - try refresh() - } - func importFiles(_ urls: [URL]) { perform { guard let library else { throw LibraryError.message("Library unavailable") }; try Importer(media:root.appendingPathComponent("Media")).run(urls,library:library); try refresh() } } -} -@main struct KJamsCloneApp: App { - @StateObject private var model = AppModel() - var body: some Scene { - Window("KJamsClone", id: "main") { - LibraryView(model: model).frame(minWidth: 1060, minHeight: 680).preferredColorScheme(.dark) - }.defaultSize(width: 1260, height: 840) - .commands { - CommandGroup(replacing: .newItem) { - Button("New Singer…") { model.beginSinger() }.keyboardShortcut("n", modifiers: [.command, .shift]) - Button("New Venue…") { model.creating = .venue }.keyboardShortcut("n", modifiers: [.command, .option]) - } - } - Window("Video", id: "lyrics") { - LyricsView(player: model.player).frame(minWidth: 480, minHeight: 320).preferredColorScheme(.dark) - }.defaultSize(width: 600, height: 400) - } -} -private enum Classic { - static let frame = Color(red: 0.15, green: 0.15, blue: 0.15) - static let navy = Color(red: 0.008, green: 0.065, blue: 0.16) - static let blue = Color(red: 0.015, green: 0.17, blue: 0.42) - static let header = Color(white: 0.115) - static let line = Color(white: 0.42) -} -struct LyricsView: View { - @ObservedObject var player: Player - var body: some View { - ZStack { - Color.black - if let image = player.image { - Image(decorative: image, scale: 1).interpolation(.none).resizable().aspectRatio(1.5, contentMode: .fit) - } - } - } -} -/// This is another view of the same published CGImage used by the Video window. -/// It owns no decoder, audio player or clock, so seeking/pause/tempo stay identical. -private struct SidebarVideoMonitor: View { - let player: Player - var body: some View { - VStack(alignment: .leading, spacing: 7) { - Label("Video Monitor", systemImage: "tv") - .font(.system(size: 11, weight: .medium)).foregroundStyle(.white.opacity(0.7)) - LyricsView(player: player) - .aspectRatio(1.5, contentMode: .fit) - .clipped() - .overlay(Rectangle().strokeBorder(.white.opacity(0.25), lineWidth: 1)) - .accessibilityLabel("Video monitor, synchronized with the Video window") - }.frame(maxWidth: .infinity) - } -} -private struct SilverSquareStyle: ButtonStyle { - func makeBody(configuration: Configuration) -> some View { - configuration.label.foregroundStyle(Color(white: 0.25)).padding(.horizontal, 6).padding(.vertical, 3) - .background(LinearGradient(colors: [Color(white: 0.95), Color(white: 0.64)], startPoint: .top, endPoint: .bottom), in: RoundedRectangle(cornerRadius: 4)) - .overlay(RoundedRectangle(cornerRadius: 4).strokeBorder(Color(white: 0.45), lineWidth: 1.5)) - .overlay(RoundedRectangle(cornerRadius: 3).strokeBorder(.white.opacity(0.7)).padding(3)) - .opacity(configuration.isPressed ? 0.7 : 1) - } -} -private struct SilverButton: View { - let symbol: String - let label: String - var size: CGFloat = 40 - var active = false - var enabled = true - let action: () -> Void - var body: some View { - Button(action: action) { - Image(systemName: symbol).font(.system(size: size * 0.41, weight: .semibold)) - .foregroundStyle(active ? Color.blue : Color(white: 0.24)) - .frame(width: size, height: size) - .background(LinearGradient(colors: [.white, Color(white: 0.85), Color(white: 0.63)], startPoint: .top, endPoint: .bottom), in: Circle()) - .overlay(Circle().strokeBorder(Color(white: 0.45), lineWidth: 1.5)) - .overlay(Circle().strokeBorder(.white.opacity(0.65), lineWidth: 1).padding(3)) - .shadow(color: .black.opacity(0.7), radius: 1, y: 1) - }.buttonStyle(.plain).disabled(!enabled).opacity(enabled ? 1 : 0.72) - .help(label).accessibilityLabel(label) - } -} -struct LibraryView: View { - @ObservedObject var model: AppModel - @State private var selected: Int64? - @State private var search = "" - @State private var name = "" - @State private var importing = false - @State private var source = "Library" - @State private var singersExpanded = true - @State private var expandedSingers = Set() - @State private var expandedSongLists = Set() - @State private var songPickerSinger: PersonPlace? - @State private var singerSection = "All Songs" - @State private var storesExpanded = true - @State private var focusedStore: Int64? - @State private var editingSong: Song? - @State private var librarySort = "Song Name" - @State private var sortAscending = true - @Environment(\.openWindow) private var openWindow - private var visibleSongs: [Song] { - let filtered = model.songs.filter { search.isEmpty || ($0.title+" "+$0.artist+" "+$0.album).localizedCaseInsensitiveContains(search) } - return filtered.sorted { a,b in - if a.id == b.id { return false } - if librarySort == "Duration" { return a.duration == b.duration ? a.id < b.id : sortAscending ? a.duration < b.duration : a.duration > b.duration } - if librarySort == "Rating" { return a.rating == b.rating ? a.id < b.id : sortAscending ? a.rating < b.rating : a.rating > b.rating } - let first = librarySort == "Artist" ? a.artist : librarySort == "Album" ? a.album : a.title - let second = librarySort == "Artist" ? b.artist : librarySort == "Album" ? b.album : b.title - let order = first.localizedStandardCompare(second) - return order == .orderedSame ? a.id < b.id : sortAscending ? order == .orderedAscending : order == .orderedDescending - } - } - - private var selectedSong: Song? { model.songs.first { $0.id == selected } } - var body: some View { - VStack(spacing: 0) { - TransportView(player: model.player, search: $search, hasSelection: selectedSong != nil, - play: playSelected, next: playNext, display: { openWindow(id: "lyrics") }) - .padding(.horizontal, 18).padding(.top, 18).padding(.bottom, 22) - HSplitView { - sidebar.frame(minWidth: 190, idealWidth: 220, maxWidth: 240) - VStack(spacing: 12) { - if source == "Library" { songTable } - else if source == "Queue" { queuePane } - else if source == "History" { historyPane } - else if source == "Playlists" { playlistPane } - else if source == "Singer Songs" { singerSongPane } - else if source == "Music Stores" { MusicStoresPane(model:model,selected:$focusedStore) } - else { directory } - detailPanel.frame(height: 135) - }.padding(.leading, 12).frame(minWidth: 780) - }.padding(.horizontal, 18) - footer.padding(.horizontal, 18).padding(.vertical, 12) - } - .background(Classic.frame) - .sheet(item: $model.creating) { kind in - AddEntitySheet(model: model, kind: kind) { id in - if kind == .singer { model.selectedSinger = id;expandedSingers.insert(id);expandedSongLists.insert(id);singersExpanded = true;singerSection = "All Songs";source = "Singer Songs" } else { model.chooseVenue(id) } - } - } - .sheet(item:$editingSong) { song in SongMetadataSheet(model:model,song:song) } - .sheet(item:$songPickerSinger) { singer in SingerSongsSheet(model:model,singer:singer) } - .fileImporter(isPresented: $importing, allowedContentTypes: [.audio, .zip, UTType(filenameExtension: "cdg") ?? .data], allowsMultipleSelection: true) { result in - switch result { - case .success(let urls): model.importFiles(urls) - case .failure(let error): model.error = error.localizedDescription - } - } - .alert("KJamsClone", isPresented: Binding(get: { model.error != nil }, set: { if !$0 { model.error = nil } })) { - Button("OK") { model.error = nil } - } message: { Text(model.error ?? "") } - } - private func sourceCount(_ source: String) -> Int { - switch source { - case "Library": return model.songs.count - case "Singers": return model.venueSingers.count - case "Venues": return model.venues.count - case "Queue": return model.queue.count - case "History": return model.history.count - default: return model.playlists.count - } - } - private var sidebar: some View { - VStack(alignment:.leading,spacing:0) { - Text("Source").font(.system(size:15,weight:.semibold)).padding(.horizontal,10).frame(height:31) - .frame(maxWidth:.infinity,alignment:.leading).background(Classic.header) - ScrollView { - VStack(spacing:0) { - sourceRow("Library",icon:"music.note.house.fill",color:.yellow) - HStack(spacing:5) { - Button { singersExpanded.toggle() } label: { Image(systemName:singersExpanded ? "chevron.down" : "chevron.right").font(.system(size:10)).frame(width:12) }.buttonStyle(.plain).accessibilityLabel("Expand singers") - Button { source = "Singers" } label: { HStack { Image(systemName:"person.2.fill").foregroundStyle(.green);Text("Singers");Spacer();Text("\(model.venueSingers.count)").font(.caption).foregroundStyle(.secondary) } }.buttonStyle(.plain) - Button { model.beginSinger() } label: { Image(systemName:"plus.circle.fill").foregroundStyle(.green) }.buttonStyle(.plain).help("New singer and songs") - }.padding(.horizontal,10).frame(height:34).background(source == "Singers" ? Color.blue.opacity(0.65) : .clear) - if singersExpanded { - Text(model.currentVenueName).font(.system(size:10)).foregroundStyle(.secondary).lineLimit(1).padding(.leading,30).frame(maxWidth:.infinity,alignment:.leading).padding(.vertical,4) - ForEach(model.venueSingers) { singer in sidebarSinger(singer) } - if model.venueSingers.isEmpty { Text("Add a singer with +").font(.caption).foregroundStyle(.secondary).padding(8) } - } - HStack { - Button { storesExpanded.toggle() } label: { Image(systemName:storesExpanded ? "chevron.down" : "chevron.right").font(.system(size:10)) }.buttonStyle(.plain) - Button { source = "Music Stores" } label: { Label("Music Stores",systemImage:"bag.fill").foregroundStyle(.green);Spacer() }.buttonStyle(.plain) - }.padding(.horizontal,12).frame(height:34) - if storesExpanded { - ForEach(model.musicStores) { store in - Button { focusedStore = store.id;source = "Music Stores" } label: { Label(store.name,systemImage:"globe").font(.system(size:12)).lineLimit(1).padding(.leading,32).frame(maxWidth:.infinity,alignment:.leading).frame(height:26) }.buttonStyle(.plain) - } - Button("Configure Stores…") { source = "Music Stores" }.buttonStyle(.plain).font(.system(size:11)).foregroundStyle(.secondary).padding(.leading,32).frame(maxWidth:.infinity,alignment:.leading).frame(height:25) - } - sourceRow("Venues",icon:"building.2.fill",color:.cyan) - sourceRow("Queue",icon:"list.number",color:.orange) - sourceRow("History",icon:"clock.arrow.circlepath",color:.purple) - sourceRow("Playlists",icon:"music.note.list",color:.mint) - } - } - SidebarVideoMonitor(player:model.player).padding(10) - }.foregroundStyle(.white).background(Classic.navy).overlay(Rectangle().stroke(Classic.line,lineWidth:1)) - } - private func sourceRow(_ title: String, icon: String, color: Color) -> some View { - Button { source = title } label: { - HStack(spacing:10) { - Image(systemName:icon).foregroundStyle(color).frame(width:22) - Text(title).font(.system(size:16,weight:.medium));Spacer() - Text("\(sourceCount(title))").font(.system(size:11)).foregroundStyle(.white.opacity(0.6)) - }.padding(.horizontal,12).frame(height:34).contentShape(Rectangle()) - .background(source == title ? Color(red:0,green:0.36,blue:1) : .clear) - }.buttonStyle(.plain) - } - private func sidebarSinger(_ singer: PersonPlace) -> some View { - VStack(alignment:.leading,spacing:0) { - HStack(spacing:5) { - Button { - if expandedSingers.contains(singer.id) { expandedSingers.remove(singer.id) } else { expandedSingers.insert(singer.id) } - } label: { Image(systemName:expandedSingers.contains(singer.id) ? "chevron.down" : "chevron.right").font(.system(size:9)).frame(width:12) }.buttonStyle(.plain).accessibilityLabel("Expand \(singer.name)’s songs") - Button { model.selectedSinger = singer.id;singerSection = "All Songs";source = "Singer Songs" } label: { - HStack(spacing:5) { Text(singer.name).lineLimit(1);Spacer();Text("\(model.singerSongIDs[singer.id]?.count ?? 0)").font(.system(size:10)).foregroundStyle(.secondary) } - }.buttonStyle(.plain) - Button { model.selectedSinger = singer.id;songPickerSinger = singer;expandedSingers.insert(singer.id) } label: { Image(systemName:"plus").font(.system(size:10,weight:.bold)) }.buttonStyle(.plain).help("Add songs to \(singer.name)") - }.font(.system(size:13,weight:.medium)).padding(.leading,25).padding(.trailing,12).frame(height:29) - .background(model.selectedSinger == singer.id && source == "Singer Songs" ? Color.blue.opacity(0.25) : .clear) - if expandedSingers.contains(singer.id) { - singerFolder("Tonight",icon:"music.note.list",singer:singer) - singerFolder("Favourites",icon:"star.fill",singer:singer) - singerFolder("History",icon:"clock.arrow.circlepath",singer:singer) - HStack(spacing:3) { - Button { if expandedSongLists.contains(singer.id) { expandedSongLists.remove(singer.id) } else { expandedSongLists.insert(singer.id) } } label: { Image(systemName:expandedSongLists.contains(singer.id) ? "chevron.down" : "chevron.right").font(.system(size:9)) }.buttonStyle(.plain) - singerFolder("All Songs",icon:"folder",singer:singer) - }.padding(.leading,28) - if expandedSongLists.contains(singer.id) { - ForEach(model.songs(for:singer.id)) { song in - Button { model.selectedSinger = singer.id;selected = song.id;singerSection = "All Songs";source = "Singer Songs" } label: { - Label(song.title,systemImage:"music.note").font(.system(size:11)).lineLimit(1).frame(maxWidth:.infinity,alignment:.leading).padding(.leading,44).padding(.trailing,8).frame(height:25) - }.buttonStyle(.plain) - .contextMenu { - Button("Play for \(singer.name)") { model.selectedSinger = singer.id;model.perform { try model.play(song,singer:singer.id) } } - Button("Queue for \(singer.name)") { model.selectedSinger = singer.id;model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Button(model.favourites[singer.id]?.contains(song.id) == true ? "Remove Favourite" : "Add to Favourites") { model.setFavourite(song.id,singer:singer.id,included:model.favourites[singer.id]?.contains(song.id) != true) } - Button("Remove from Singer",role:.destructive) { model.assign(song.id,to:singer.id,included:false) } - } - } - if model.songs(for:singer.id).isEmpty { Text("No songs · use +").font(.system(size:10)).foregroundStyle(.secondary).padding(.leading,44).padding(.vertical,5) } - } - } - } - } - private func singerFolder(_ title: String, icon: String, singer: PersonPlace) -> some View { - Button { model.selectedSinger = singer.id;singerSection = title;source = "Singer Songs" } label: { - Label(title,systemImage:icon).font(.system(size:11)).foregroundStyle(title == "Favourites" ? Color(red:1,green:0.75,blue:0.16) : Color.white.opacity(0.75)).padding(.leading,title == "All Songs" ? 0 : 43).frame(maxWidth:.infinity,alignment:.leading).frame(height:25) - }.buttonStyle(.plain) - } - private var singerSongPane: some View { - VStack(alignment:.leading,spacing:12) { - if let singer = model.singers.first(where:{ $0.id == model.selectedSinger }) { - HStack { Text("\(singer.name) · \(singerSection)").font(.headline);Spacer();Button("Add Songs…") { songPickerSinger = singer } } - Text("\(model.currentVenueName) · Singer song lists follow them across venues.").font(.caption).foregroundStyle(.secondary) - if singerSection == "History" { - ScrollView { LazyVStack(alignment:.leading,spacing:12) { ForEach(model.history.filter { $0.singerID == singer.id }) { row in HStack { Text(row.date).font(.caption.monospaced());Text(row.song);Spacer() } } } } - } else if singerSection == "Tonight" { - ScrollView { VStack(spacing:10) { ForEach(model.queue.filter { $0.singerID == singer.id }) { row in HStack { Text(row.title);Spacer();Button("Play") { model.perform { if let song = model.songs.first(where:{ $0.id == row.songID }) { try model.play(song,singer:singer.id);try model.library?.removeQueue(row.id);try model.refresh() } } };Button("Remove") { model.removeQueue(row.id) } } };if model.queue.filter({ $0.singerID == singer.id }).isEmpty { Text("No songs queued for this singer at this venue.").foregroundStyle(.secondary) } } } - } else { - ScrollView { - VStack(spacing:10) { - ForEach(model.songs(for:singer.id).filter { singerSection != "Favourites" || model.favourites[singer.id]?.contains($0.id) == true }) { song in - HStack { - Button { model.setFavourite(song.id,singer:singer.id,included:model.favourites[singer.id]?.contains(song.id) != true) } label: { Image(systemName:model.favourites[singer.id]?.contains(song.id) == true ? "star.fill" : "star").foregroundStyle(Color(red:1,green:0.75,blue:0.16)) }.buttonStyle(.plain).help("Favourite for this singer") - Text(song.title).lineLimit(1);Spacer() - Button("Play") { model.selectedSinger = singer.id;model.perform { try model.play(song,singer:singer.id) } } - Button("Tonight") { model.selectedSinger = singer.id;model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Button("Remove") { model.assign(song.id,to:singer.id,included:false) } - }.padding(8).background(.white.opacity(0.035)).contentShape(Rectangle()).onTapGesture { selected = song.id } - } - if model.songs(for:singer.id).isEmpty { Text("Use Add Songs… or the + beside this singer in the sidebar.").foregroundStyle(.secondary).padding(.top,25) } - } - } - } - } else { Text("Choose a singer from the sidebar.").foregroundStyle(.secondary);Spacer() } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - private var songTable: some View { - GeometryReader { geometry in - ScrollView(.horizontal) { - VStack(spacing: 0) { - tableHeader(width: max(geometry.size.width, 960)) - ScrollView(.vertical) { - LazyVStack(spacing: 0) { - ForEach(visibleSongs) { song in songRow(song, width: max(geometry.size.width, 960)) } - }.frame(maxWidth: .infinity, alignment: .topLeading) - } - }.frame(width: max(geometry.size.width, 960), height: geometry.size.height) - } - }.background(Classic.navy).overlay(Rectangle().stroke(Classic.line, lineWidth: 1)) - } - private func widths(_ total: CGFloat) -> [CGFloat] { [44,max(220,total-600),110,100,65,82,90,109] } - private func tableHeader(width: CGFloat) -> some View { - let sizes = widths(width) - return HStack(spacing:0) { - ForEach(Array(["ID","Song Name","Artist","Album","Duration","Pitch","Tempo","Rating"].enumerated()),id:\.offset) { index,title in - Button { - guard ["Song Name","Artist","Album","Duration","Rating"].contains(title) else { return } - if librarySort == title { sortAscending.toggle() } else { librarySort = title;sortAscending = true } - } label: { HStack(spacing:3) { Text(title);if librarySort == title { Image(systemName:sortAscending ? "chevron.up" : "chevron.down").font(.system(size:8)) } }.font(.system(size:12,weight:.medium)).lineLimit(1).padding(.leading,7).frame(width:sizes[index],height:30,alignment:.leading) } - .buttonStyle(.plain).overlay(alignment:.trailing) { Rectangle().fill(Classic.line).frame(width:1).padding(.vertical,4) } - } - }.foregroundStyle(.white).background(Classic.header).overlay(alignment:.bottom) { Rectangle().fill(Color(white:0.65)).frame(height:1) } - } - private func durationLabel(_ seconds: Double) -> String { seconds > 0 ? String(format:"%d:%02d",Int(seconds)/60,Int(seconds)%60) : "—" } - private func songRow(_ song: Song,width: CGFloat) -> some View { - let sizes = widths(width) - return HStack(spacing:0) { - Text("\(song.id)").foregroundStyle(.secondary).frame(width:sizes[0]) - Text(song.title).lineLimit(1).padding(.leading,7).frame(width:sizes[1],alignment:.leading) - Text(song.artist.isEmpty ? "—" : song.artist).foregroundStyle(.secondary).lineLimit(1).padding(.leading,7).frame(width:sizes[2],alignment:.leading) - Text(song.album.isEmpty ? "—" : song.album).foregroundStyle(.secondary).lineLimit(1).padding(.leading,7).frame(width:sizes[3],alignment:.leading) - Text(durationLabel(song.duration)).font(.system(size:11,design:.monospaced)).frame(width:sizes[4]) - HStack(spacing:2) { - Text(String(format:"%+.0f",model.preference(song.id).pitch)).font(.system(size:11,design:.monospaced)).frame(width:30) - Stepper("Pitch",value:Binding(get:{ model.preference(song.id).pitch },set:{ model.updateTuning(song.id,pitch:$0) }),in:-12...12,step:1).labelsHidden().controlSize(.mini).fixedSize() - }.frame(width:sizes[5]).help("Saved pitch; applies to the selected singer, or song default") - Picker("Tempo",selection:Binding(get:{ model.preference(song.id).tempo },set:{ model.updateTuning(song.id,tempo:$0) })) { - ForEach(10..<31) { Text("\($0*5)%").tag(Double($0)/20) } - }.labelsHidden().controlSize(.mini).frame(width:sizes[6]-8).padding(.horizontal,4).help("Saved tempo; applies live if this song is playing") - Menu { ForEach(0..<6) { value in Button(value == 0 ? "Unrated" : String(repeating:"★",count:value)) { model.perform { try model.library?.rate(song.id,value);try model.refresh() } } } } label: { - Text(song.rating == 0 ? "☆☆☆☆☆" : String(repeating:"★",count:song.rating)+String(repeating:"☆",count:5-song.rating)).font(.system(size:12)).foregroundStyle(song.rating == 0 ? Color.gray : Color(red:1,green:0.75,blue:0.16)) - }.menuStyle(.borderlessButton).frame(width:sizes[7]-14).padding(.horizontal,7) - }.font(.system(size:12)).foregroundStyle(.white).frame(height:30) - .background(selected == song.id ? Color.blue.opacity(0.5) : song.id % 2 == 0 ? Color.white.opacity(0.025) : .clear) - .contentShape(Rectangle()).onTapGesture(count:2) { selected = song.id;playSelected() }.onTapGesture { selected = song.id } - .contextMenu { - Button("Play") { selected = song.id; playSelected() } - Button("Edit Metadata…") { editingSong = song } - Menu("Add to Singer") { - ForEach(model.venueSingers) { singer in Button(singer.name) { model.assign(song.id,to:singer.id);model.selectedSinger = singer.id;expandedSingers.insert(singer.id) } } - Divider();Button("New Singer + This Song…") { model.beginSinger(song:song.id) } - } - Button("Add to Current Venue Queue") { model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Menu("Add to Playlist") { ForEach(model.playlists) { playlist in Button(playlist.name) { model.addToPlaylist(playlist.id,song:song.id) } } } - } - } - @State private var managingRoster = false - @State private var rosterNewName = "" - @State private var editingEntity: PersonPlace? - @State private var renameText = "" - @State private var pendingDelete: PersonPlace? - private var directory: some View { - VStack(alignment:.leading,spacing:0) { - HStack { - Text(source == "Singers" ? "Singers · \(model.currentVenueName)" : "Venues").font(.headline) - Spacer() - if source == "Singers" { Button("Manage Venue Singers…") { managingRoster = true }.disabled(model.currentVenue == nil) } - Button(source == "Singers" ? "New Singer…" : "New Venue…") { if source == "Singers" { model.beginSinger() } else { model.creating = .venue } } - }.padding(12).background(Classic.header) - ScrollView { - VStack(alignment:.leading,spacing:0) { - if source == "Singers" && model.venueSingers.isEmpty { - Text("No singers at this venue. Add a singer or use Manage Venue Singers to include existing singers.").foregroundStyle(.secondary).padding() - } - ForEach(source == "Singers" ? model.venueSingers : model.venues) { entity in - HStack { - Button { - if source == "Singers" { model.selectedSinger = entity.id } else { model.chooseVenue(entity.id) } - } label: { - HStack { - Image(systemName:source == "Singers" ? "person.fill" : "building.2.fill") - Text(entity.name); Spacer() - if entity.id == (source == "Singers" ? model.selectedSinger : model.currentVenue) { - Text(source == "Singers" ? "Selected" : "Current venue").font(.caption).foregroundStyle(.cyan) - Image(systemName:"checkmark.circle.fill").foregroundStyle(.cyan) - } - }.contentShape(Rectangle()) - }.buttonStyle(.plain) - Button("Rename") { renameText = entity.name; editingEntity = entity } - Button("Delete",role:.destructive) { pendingDelete = entity } - }.padding(12) - } - } - } - HStack { - TextField(source == "Singers" ? "Singer name" : "Venue name",text:$name).textFieldStyle(.roundedBorder).onSubmit(addEntity) - Button(source == "Singers" ? "Add Singer" : "Add Venue",action:addEntity).disabled(name.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - }.padding(12) - }.foregroundStyle(.white).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - .sheet(isPresented:$managingRoster) { rosterSheet } - .sheet(item:$editingEntity) { entity in - VStack(alignment:.leading,spacing:16) { - Text("Rename \(source == "Singers" ? "Singer" : "Venue")").font(.headline) - TextField("Name",text:$renameText).textFieldStyle(.roundedBorder) - HStack { Button("Cancel") { editingEntity = nil }; Spacer(); Button("Save") { model.rename(source == "Singers" ? "singers" : "venues",id:entity.id,name:renameText); editingEntity = nil }.disabled(renameText.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) } - }.padding(24).frame(width:360) - } - .confirmationDialog("Delete \(pendingDelete?.name ?? "entry")? Historical plays are kept. Venue memberships and queued entries for it will be removed.",isPresented:Binding(get:{ pendingDelete != nil },set:{ if !$0 { pendingDelete = nil } })) { - Button("Delete",role:.destructive) { if let entity = pendingDelete { model.delete(source == "Singers" ? "singers" : "venues",id:entity.id) }; pendingDelete = nil } - } - } - private var rosterSheet: some View { - VStack(alignment:.leading,spacing:16) { - Text("Singers at \(model.currentVenueName)").font(.title2.bold()) - Text("A singer can belong to any number of venues. Unchecking removes them from this venue only.").foregroundStyle(.secondary) - ScrollView { - VStack(alignment:.leading,spacing:12) { - ForEach(model.singers) { singer in - Toggle(singer.name,isOn:Binding(get:{ model.venueSingers.contains { $0.id == singer.id } },set:{ model.membership(singer:singer.id,included:$0) })) - } - }.frame(maxWidth:.infinity,alignment:.leading) - }.frame(minHeight:120,maxHeight:280) - HStack { - TextField("New singer name",text:$rosterNewName).textFieldStyle(.roundedBorder) - Button("Add") { model.perform { _ = try model.createEntity(.singer,name:rosterNewName); rosterNewName = "" } }.disabled(rosterNewName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - Spacer(); Button("Done") { managingRoster = false }.keyboardShortcut(.defaultAction) - } - }.padding(24).frame(width:460) - } - private var detailPanel: some View { - VStack(alignment:.leading,spacing:9) { - HStack(spacing:10) { - Picker("Current venue",selection:Binding(get:{ model.currentVenue },set:{ model.chooseVenue($0) })) { - Text("Select venue…").tag(nil as Int64?) - ForEach(model.venues) { Text($0.name).tag(Optional($0.id)) } - } - Button { model.creating = .venue } label: { Image(systemName:"plus.circle.fill") }.buttonStyle(.plain).help("Add venue") - Picker("Singer",selection:$model.selectedSinger) { - Text("None").tag(nil as Int64?) - ForEach(model.venueSingers) { Text($0.name).tag(Optional($0.id)) } - } - Button { model.beginSinger() } label: { Image(systemName:"plus.circle.fill") }.buttonStyle(.plain).help("Add singer") - Menu("Add to Singer") { - ForEach(model.venueSingers) { singer in Button(singer.name) { if let selected { model.assign(selected,to:singer.id);model.selectedSinger = singer.id;expandedSingers.insert(singer.id) } } } - Divider();Button("New Singer + Song…") { model.beginSinger(song:selected) } - }.disabled(selected == nil) - Button("Queue") { if let selected { model.enqueue(selected) } }.disabled(selected == nil || model.currentVenue == nil) - } - PlaybackSettings(player:model.player,model:model,selectedSong:selected) - SeekBar(player:model.player) - }.padding(12).frame(maxWidth:.infinity,maxHeight:.infinity) - .background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - @State private var playlistName = "" - @State private var selectedPlaylist: Int64? - private var queuePane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { Text("Queue · \(model.currentVenueName)").font(.headline); Spacer(); Toggle("Auto play next",isOn:$model.autoAdvance).toggleStyle(.checkbox); Button("Play Next") { model.playQueueNext() }.disabled(model.queue.isEmpty) } - ScrollView { - VStack(spacing:0) { - ForEach(Array(model.queue.enumerated()),id:\.element.id) { index,row in - HStack { - Text("\(index+1)").foregroundStyle(.secondary).frame(width:24) - Text(row.singer).frame(width:140,alignment:.leading) - Text(row.title).lineLimit(1); Spacer() - Button { model.moveQueue(row.id,by:-1) } label: { Image(systemName:"arrow.up") }.disabled(index == 0) - Button { model.moveQueue(row.id,by:1) } label: { Image(systemName:"arrow.down") }.disabled(index == model.queue.count-1) - Button("Remove") { model.removeQueue(row.id) } - }.padding(.vertical,8) - } - if model.queue.isEmpty { Text("Choose a venue and singer, select a library song, then click Queue Song.").foregroundStyle(.secondary).padding(.top,30) } - } - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - @State private var historyAllVenues = false - private var displayedHistory: [Performance] { - if historyAllVenues { return (try? model.library?.history(venue:nil,singer:model.selectedSinger)) ?? [] } - return model.history.filter { model.selectedSinger == nil || $0.singer == model.singers.first(where: { $0.id == model.selectedSinger })?.name } - } - private var historyPane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { Text("History · \(historyAllVenues || model.currentVenue == nil ? "All venues" : model.currentVenueName)").font(.headline); Spacer(); Toggle("All venues",isOn:$historyAllVenues).toggleStyle(.checkbox) } - ScrollView { - LazyVStack(alignment:.leading,spacing:12) { - ForEach(displayedHistory) { row in - HStack { Text(row.date).font(.system(.caption,design:.monospaced)); Text(row.singer).frame(width:130,alignment:.leading); Text(row.song); Spacer(); Text(row.venue).foregroundStyle(.secondary) } - } - } - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - private var playlistPane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { - Picker("Playlist",selection:$selectedPlaylist) { Text("Choose…").tag(nil as Int64?); ForEach(model.playlists) { Text($0.name).tag(Optional($0.id)) } } - TextField("New playlist name",text:$playlistName).textFieldStyle(.roundedBorder) - Button("Create") { model.createPlaylist(playlistName); selectedPlaylist = model.playlists.first { $0.name == playlistName.trimmingCharacters(in:.whitespacesAndNewlines) }?.id; playlistName = "" }.disabled(playlistName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - if let selectedPlaylist { - Button("Rename") { model.rename("playlists",id:selectedPlaylist,name:playlistName); playlistName = "" }.disabled(playlistName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - Button("Delete",role:.destructive) { model.delete("playlists",id:selectedPlaylist); self.selectedPlaylist = nil } } - } - ScrollView { - if let selectedPlaylist { - let ids = (try? model.library?.playlistSongIDs(selectedPlaylist)) ?? [] - VStack(alignment:.leading,spacing:10) { - ForEach(ids,id:\.self) { id in - if let song = model.songs.first(where: { $0.id == id }) { - HStack { - Text(song.title); Spacer() - Button("Play") { model.perform { try model.play(song) } } - Button("Queue") { model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Button("Remove") { model.perform { try model.library?.removeFromPlaylist(selectedPlaylist,song:id); try model.refresh() } } - } - } - } - } - } - Text("Add songs using the library row’s context menu.").foregroundStyle(.secondary).padding(.top,20) - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - private var footer: some View { - HStack { - Button { importing = true } label: { Image(systemName: "plus").font(.system(size: 20, weight: .bold)).frame(width: 32, height: 24) } - .help("Import audio, MP3+G or ZIP").accessibilityLabel("Import songs") - RepeatButton(player: model.player).padding(.leading, 12) - Button(model.readingDurations ? "Reading…" : "Read Durations") { model.scanDurations() }.controlSize(.small).disabled(model.readingDurations).help("Read durations for songs imported by older versions") - Button("Edit Metadata…") { editingSong = selectedSong }.controlSize(.small).disabled(selectedSong == nil) - Spacer() - Text("\(visibleSongs.count) \(visibleSongs.count == 1 ? "Song" : "Songs")").font(.system(size: 14, weight: .medium)) - Spacer() - Button { openWindow(id: "lyrics") } label: { Image(systemName: "rectangle.on.rectangle").frame(width: 32, height: 24) } - .help("Open video window").accessibilityLabel("Open video window") - }.buttonStyle(SilverSquareStyle()) - } - private func playSelected() { - guard let song = selectedSong else { return } - model.perform { try model.play(song) } - } - private func playNext() { - guard !visibleSongs.isEmpty else { return } - let index = visibleSongs.firstIndex { $0.id == selected } ?? -1 - selected = visibleSongs[(index + 1) % visibleSongs.count].id; playSelected() - } - private func addEntity() { - model.perform { - let kind: EntityKind = source == "Singers" ? .singer : .venue - let id = try model.createEntity(kind, name: name) - if kind == .singer { model.selectedSinger = id } else { model.chooseVenue(id) } - name = "" - } - } -} -private struct SongMetadataSheet: View { - @ObservedObject var model: AppModel - let song: Song - @Environment(\.dismiss) private var dismiss - @State private var title = "" - @State private var artist = "" - @State private var album = "" - @State private var label = "" - @State private var rating = 0 - @State private var error: String? - var body: some View { - VStack(alignment:.leading,spacing:14) { - Text("Edit Song Metadata").font(.title2.bold()) - Grid(alignment:.leading,horizontalSpacing:12,verticalSpacing:10) { - GridRow { Text("Title");TextField("Title",text:$title) } - GridRow { Text("Artist");TextField("Artist",text:$artist) } - GridRow { Text("Album");TextField("Album",text:$album) } - GridRow { Text("Label");TextField("Label / publisher",text:$label) } - GridRow { Text("Rating");Picker("Rating",selection:$rating) { ForEach(0..<6) { Text($0 == 0 ? "Unrated" : String(repeating:"★",count:$0)).tag($0) } }.labelsHidden() } - }.textFieldStyle(.roundedBorder) - Text("Saved to your library. Embedded audio-file tags are not changed, and re-importing will preserve your library edits.").font(.caption).foregroundStyle(.secondary) - Text(URL(fileURLWithPath:song.audio).lastPathComponent).font(.caption.monospaced()).foregroundStyle(.secondary).lineLimit(1).truncationMode(.middle).help(song.audio) - if let error { Text(error).foregroundStyle(.red).font(.callout) } - HStack { Spacer();Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction);Button("Save") { save() }.keyboardShortcut(.defaultAction).disabled(title.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) } - }.padding(24).frame(width:500).background(Classic.frame).preferredColorScheme(.dark) - .onAppear { title = song.title;artist = song.artist;album = song.album;label = song.label;rating = song.rating } - } - private func save() { do { try model.updateMetadata(song,title:title,artist:artist,album:album,label:label,rating:rating);dismiss() } catch { self.error = error.localizedDescription } } -} -private struct MusicStoresPane: View { - @ObservedObject var model: AppModel - @Binding var selected: Int64? - @Environment(\.openURL) private var openURL - @State private var editor = false - @State private var editing: MusicStore? - @State private var search = "" - @State private var deleting: Int64? - var body: some View { - VStack(alignment:.leading,spacing:14) { - HStack { Text("Music Stores").font(.headline);Spacer();Button("Add Store…") { editing = nil;editor = true } } - Text("Define websites and optional catalogue-search URLs. Purchases and subscriptions are handled by the store in your browser.").font(.callout).foregroundStyle(.secondary) - HStack { TextField("Search store catalogue",text:$search).textFieldStyle(.roundedBorder);Text("{query} in a store’s search URL is replaced with this text.").font(.caption).foregroundStyle(.secondary) } - ScrollView { - VStack(alignment:.leading,spacing:12) { - ForEach(model.musicStores) { store in - VStack(alignment:.leading,spacing:8) { - HStack { Image(systemName:"bag.fill").foregroundStyle(.green);Text(store.name).font(.headline);Spacer() - Button("Open Store") { open(store,query:"") } - Button("Search") { open(store,query:search) }.disabled(search.isEmpty || store.searchTemplate.isEmpty) - Button("Edit") { editing = store;editor = true } - Button("Delete",role:.destructive) { deleting = store.id } - } - Text(store.url).font(.caption).foregroundStyle(.secondary).textSelection(.enabled) - }.padding(12).background(selected == store.id ? Color.blue.opacity(0.15) : Color.white.opacity(0.035)).contentShape(Rectangle()).onTapGesture { selected = store.id } - } - if model.musicStores.isEmpty { Text("No stores configured. Add a store name and website address to get started.").foregroundStyle(.secondary).padding(.top,20) } - } - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - .sheet(isPresented:$editor) { MusicStoreEditor(model:model,store:editing) } - .confirmationDialog("Delete this store definition?",isPresented:Binding(get:{ deleting != nil },set:{ if !$0 { deleting = nil } })) { - Button("Delete",role:.destructive) { if let deleting { model.deleteStore(deleting) };deleting = nil } - } - } - private func open(_ store: MusicStore,query: String) { - do { openURL(try store.destination(query:query)) } catch { model.error = error.localizedDescription } - } -} -private struct MusicStoreEditor: View { - @ObservedObject var model: AppModel - let store: MusicStore? - @Environment(\.dismiss) private var dismiss - @State private var name = "" - @State private var url = "" - @State private var search = "" - @State private var error: String? - var body: some View { - VStack(alignment:.leading,spacing:14) { - Text(store == nil ? "Add Music Store" : "Edit Music Store").font(.title2.bold()) - TextField("Store name",text:$name).textFieldStyle(.roundedBorder) - TextField("Website URL — https://example.com",text:$url).textFieldStyle(.roundedBorder) - TextField("Optional search URL — https://example.com/search?q={query}",text:$search).textFieldStyle(.roundedBorder) - Text("Use {query} where the search words belong. Only http:// and https:// websites are accepted.").font(.caption).foregroundStyle(.secondary) - if let error { Text(error).foregroundStyle(.red).font(.callout) } - HStack { Spacer();Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction);Button("Save") { save() }.keyboardShortcut(.defaultAction).disabled(name.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty || url.isEmpty) } - }.padding(24).frame(width:500).background(Classic.frame).preferredColorScheme(.dark) - .onAppear { name = store?.name ?? "";url = store?.url ?? "";search = store?.searchTemplate ?? "" } - } - private func save() { do { try model.saveStore(.init(id:store?.id ?? 0,name:name,url:url,searchTemplate:search));dismiss() } catch { self.error = error.localizedDescription } } -} -private struct SingerSongsSheet: View { - @ObservedObject var model: AppModel - let singer: PersonPlace - @Environment(\.dismiss) private var dismiss - @State private var search = "" - @State private var importing = false - var body: some View { - VStack(alignment:.leading,spacing:14) { - Text("Songs for \(singer.name)").font(.title2.bold()) - Text("Tick songs to add them to this singer. Unticking removes only the assignment.").font(.callout).foregroundStyle(.secondary) - TextField("Search library",text:$search).textFieldStyle(.roundedBorder) - ScrollView { - LazyVStack(alignment:.leading,spacing:12) { - ForEach(model.songs.filter { search.isEmpty || $0.title.localizedCaseInsensitiveContains(search) }) { song in - Toggle(song.title,isOn:Binding(get:{ model.singerSongIDs[singer.id]?.contains(song.id) == true },set:{ model.assign(song.id,to:singer.id,included:$0) })).toggleStyle(.checkbox) - } - if model.songs.isEmpty { Text("Your library is empty. Import audio or MP3+G below.").foregroundStyle(.secondary) } - }.frame(maxWidth:.infinity,alignment:.leading) - }.frame(height:270) - HStack { Button("Import Songs…") { importing = true };Spacer();Button("Done") { dismiss() }.keyboardShortcut(.defaultAction) } - }.padding(24).frame(width:520).background(Classic.frame).preferredColorScheme(.dark) - .fileImporter(isPresented:$importing,allowedContentTypes:[.audio,.zip,UTType(filenameExtension:"cdg") ?? .data],allowsMultipleSelection:true) { result in - switch result { case .success(let urls):model.importFiles(urls);case .failure(let error):model.error = error.localizedDescription } - } - } -} -private struct AddEntitySheet: View { - @ObservedObject var model: AppModel - let kind: EntityKind - let saved: (Int64) -> Void - @Environment(\.dismiss) private var dismiss - @State private var name = "" - @State private var error: String? - @State private var venue: Int64? - @State private var songs = Set() - @State private var search = "" - @FocusState private var focused: Bool - var body: some View { - VStack(alignment:.leading,spacing:16) { - Text(kind == .singer ? "New Singer + Songs" : "New Venue").font(.title2.bold()) - TextField("\(kind.title) name",text:$name).textFieldStyle(.roundedBorder).focused($focused).onSubmit(save) - if kind == .singer { - Picker("Venue",selection:$venue) { Text("Choose a venue…").tag(nil as Int64?);ForEach(model.venues) { Text($0.name).tag(Optional($0.id)) } } - Text(venue == nil ? "Create a venue first, then add a singer to it." : "This singer will join the selected venue and become active.").font(.caption).foregroundStyle(.secondary) - Text("Add songs now (optional)").font(.headline) - TextField("Search library",text:$search).textFieldStyle(.roundedBorder) - ScrollView { - LazyVStack(alignment:.leading,spacing:10) { - ForEach(model.songs.filter { search.isEmpty || $0.title.localizedCaseInsensitiveContains(search) }) { song in - Toggle(song.title,isOn:Binding(get:{ songs.contains(song.id) },set:{ if $0 { songs.insert(song.id) } else { songs.remove(song.id) } })).toggleStyle(.checkbox) - } - if model.songs.isEmpty { Text("No library songs yet. You can add songs from the singer’s + button after importing.").font(.callout).foregroundStyle(.secondary) } - }.frame(maxWidth:.infinity,alignment:.leading) - }.frame(height:190) - } - if let error { Text(error).foregroundStyle(.red).font(.callout) } - HStack { Spacer();Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction) - Button(kind == .singer ? "Add Singer & Songs" : "Add Venue",action:save).keyboardShortcut(.defaultAction) - .disabled(name.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty || (kind == .singer && venue == nil)) - } - }.padding(24).frame(width:kind == .singer ? 500 : 360).background(Classic.frame).preferredColorScheme(.dark) - .onAppear { focused = true;venue = model.currentVenue ?? model.venues.first?.id;songs = model.newSingerSongs } - } - private func save() { - do { - let id: Int64 - if kind == .singer { guard let venue else { throw LibraryError.message("Choose a venue") };id = try model.createSinger(name:name,venue:venue,songs:songs) } - else { id = try model.createEntity(kind,name:name) } - saved(id);dismiss() - } catch { self.error = error.localizedDescription } - } -} -private struct TransportView: View { - @ObservedObject var player: Player - @Binding var search: String - let hasSelection: Bool - let play: () -> Void - let next: () -> Void - let display: () -> Void - var body: some View { - HStack(alignment: .top, spacing: 28) { - VStack(spacing: 15) { - HStack(spacing: 7) { - SilverButton(symbol: "backward.fill", label: "Back 10 seconds", size: 35, enabled: player.duration > 0) { player.seek(player.time - 10) } - SilverButton(symbol: player.playing ? "pause.fill" : "play.fill", label: player.playing ? "Pause" : "Play", size: 49, enabled: hasSelection || player.duration > 0) { - if player.duration > 0 { player.toggle() } else { play() } - } - SilverButton(symbol: "stop", label: "Stop", size: 46, enabled: player.duration > 0) { player.stop() } - SilverButton(symbol: "forward.fill", label: "Forward 10 seconds", size: 35, enabled: player.duration > 0) { player.seek(player.time + 10) } - SilverButton(symbol: "forward.end.fill", label: "Play next song", size: 26, enabled: hasSelection, action: next) - } - HStack(spacing: 9) { - Image(systemName: "speaker.fill").font(.system(size: 11)) - Slider(value: $player.volume, in: 0...1).controlSize(.small).tint(.gray).accessibilityLabel("Volume") - Image(systemName: "speaker.wave.3.fill").font(.system(size: 12)) - }.frame(width: 180) - }.frame(width: 220) - NowPlayingWaveform(player: player).padding(.top, 4) - HStack(spacing: 12) { - TextField("Search", text: $search).textFieldStyle(.plain).font(.system(size: 16)) - .padding(.horizontal, 8).frame(width: 145, height: 28).background(Color(white: 0.07), in: RoundedRectangle(cornerRadius: 5)) - .overlay(RoundedRectangle(cornerRadius: 5).stroke(.white.opacity(0.1))) - SilverButton(symbol: "eye", label: "Open video window", size: 48, action: display) - }.padding(.top, 15) - }.foregroundStyle(.white).frame(height: 130) - } -} -private struct NowPlayingWaveform: View { - @ObservedObject var player: Player - @State private var mixer = false - @State private var zoom: Double = 1 - @State private var hoverX: CGFloat? - @State private var scrubStart: Double? - @State private var resumeAfterScrub = false - @State private var scrubSong: Int64? - private var span: Double { max(0.001,player.duration/zoom) } - private var windowStart: Double { scrubStart ?? min(max(0,player.time-span/2),max(0,player.duration-span)) } - private var progress: Double { player.duration > 0 ? min(1,max(0,(player.time-windowStart)/span)) : 0 } - private func clock(_ value: Double) -> String { let n = max(0,Int(value));return String(format:"%d:%02d",n/60,n%60) } - private func preciseClock(_ value: Double) -> String { String(format:"%d:%05.2f",max(0,Int(value))/60,max(0,value).truncatingRemainder(dividingBy:60)) } - private func bandColor(_ index: Int) -> Color { - guard player.waveformBands.indices.contains(index) else { return .cyan } - let band = player.waveformBands[index] - let largest = max(0.000001,max(band.low,max(band.mid,band.high))) - let low = Double(band.low/largest),mid = Double(band.mid/largest),high = Double(band.high/largest) - return Color(red:min(1,pow(low,1.2)+mid*0.12+high*0.6),green:min(1,low*0.08+pow(mid,1.5)*0.97+high*0.1),blue:min(1,low*0.07+mid*0.22+high)) - } - var body: some View { - VStack(alignment:.leading,spacing:5) { - Text(player.duration > 0 ? player.title : "Ready to play").font(.system(size:13,weight:.semibold)).foregroundStyle(Color(white:0.94)) - .lineLimit(1).truncationMode(.middle).frame(maxWidth:.infinity,alignment:.leading).help(player.title) - GeometryReader { geometry in - Canvas { context,size in - let top: CGFloat = 10,plotHeight = size.height-top,mid = top+plotHeight/2 - var centre = Path();centre.move(to:CGPoint(x:0,y:mid));centre.addLine(to:CGPoint(x:size.width,y:mid)) - context.stroke(centre,with:.color(.white.opacity(0.13)),lineWidth:0.5) - if player.duration > 0 { - let step = [0.1,0.25,0.5,1.0,2,5,10,15,30,60,120,300,600,1800,3600].first { $0 >= span/5 } ?? 3600 - let first = floor(windowStart/(step/4))*(step/4) - for t in stride(from:first,through:min(player.duration,windowStart+span),by:step/4) { - let x = size.width*(t-windowStart)/span - if x < 0 { continue } - let major = abs(t/step-(t/step).rounded()) < 0.001 - var tick = Path();tick.move(to:CGPoint(x:x,y:top));tick.addLine(to:CGPoint(x:x,y:size.height)) - context.stroke(tick,with:.color(major ? .yellow.opacity(0.65) : .white.opacity(0.16)),lineWidth:major ? 0.8 : 0.5) - if major && x < size.width-25 { - context.draw(Text(span < 10 ? preciseClock(t) : clock(t)).font(.system(size:8,design:.monospaced)).foregroundColor(.gray),at:CGPoint(x:x+3,y:3),anchor:.leading) - } - } - } - if !player.waveform.isEmpty { - let count = max(1,Int(size.width/2)),step = size.width/CGFloat(count) - for bar in 0.. 0,geometry.size.width > 0 else { return } - if scrubStart == nil { - scrubStart = windowStart;scrubSong = player.currentSongID;resumeAfterScrub = player.playing - if player.playing { player.toggle() } - } - guard scrubSong == player.currentSongID else { return } - hoverX = value.location.x - let target = windowStart+Double(min(1,max(0,value.location.x/geometry.size.width)))*span - if abs(target-player.time) > 0.02 { player.seek(target) } - }.onEnded { value in - if scrubStart == nil { - if player.duration > 0 { player.seek(windowStart+Double(min(1,max(0,value.location.x/max(1,geometry.size.width))))*span) } - return - } - let target = windowStart+Double(min(1,max(0,value.location.x/max(1,geometry.size.width))))*span - if scrubSong == player.currentSongID { - player.seek(target) - if resumeAfterScrub && !player.playing && target < player.duration-0.01 { player.toggle() } - } - scrubStart = nil;resumeAfterScrub = false;scrubSong = nil - }).help("Hover for exact time. Drag to scrub; playback resumes on release. Zoom for fine positioning.") - .accessibilityLabel("Audio waveform").accessibilityValue("\(clock(player.time)) of \(clock(player.duration))") - .accessibilityAdjustableAction { direction in if direction == .increment { player.seek(player.time+5) } else if direction == .decrement { player.seek(player.time-5) } } - }.frame(height:60) - HStack(spacing:5) { - Circle().fill(player.playing ? Color.green : Color.orange).frame(width:4,height:4) - Text(player.duration == 0 ? "NO TRACK LOADED" : player.playing ? "PLAYING" : "PAUSED").tracking(1) - if player.waveformUnavailable { Text("· Waveform unavailable").foregroundStyle(.secondary) } - Spacer(minLength:0) - Button { zoom = max(1,zoom/2) } label: { Image(systemName:"minus.magnifyingglass") }.buttonStyle(.plain).disabled(zoom <= 1).help("Zoom out") - Button { zoom = min(32,zoom*2) } label: { Image(systemName:"plus.magnifyingglass") }.buttonStyle(.plain).disabled(zoom >= 32).help("Zoom in for precise scrubbing") - Menu("\(Int(zoom))×") { ForEach([1.0,2,4,8,16,32],id:\.self) { value in Button("\(Int(value))× zoom") { zoom = value } } }.menuStyle(.borderlessButton).frame(width:34).help("Waveform zoom around the playhead") - Menu { Button("Re-analyse Waveform") { player.reanalyseWaveform() }.disabled(player.duration == 0) - Text(player.waveformLoading ? "Analysing…" : player.waveformFromCache ? "Loaded saved waveform" : player.waveformSaved ? "Analysis saved" : "No saved analysis") - } label: { Image(systemName:"waveform") }.menuStyle(.borderlessButton).frame(width:20).help("Waveform cache and re-analysis") - Button("EQ / TONE") { mixer.toggle() }.buttonStyle(.plain).foregroundStyle(.white.opacity(0.85)) - .padding(.horizontal,6).padding(.vertical,2).background(.white.opacity(0.08),in:RoundedRectangle(cornerRadius:3)) - .popover(isPresented:$mixer) { ToneMixerView(player:player) } - Text("\(clock(player.time)) / \(clock(player.duration))").monospacedDigit().padding(.leading,5) - }.font(.system(size:9,weight:.medium)).foregroundStyle(Color(white:0.6)) - }.padding(.horizontal,12).padding(.vertical,9).frame(maxWidth:.infinity).frame(height:120) - .background(Color(red:0.025,green:0.028,blue:0.035)).overlay(Rectangle().strokeBorder(Color(white:0.24),lineWidth:1)) - } -} -private struct ToneKnob: View { - let title: String - @Binding var value: Double - let range: ClosedRange - var filter = false - @State private var initial: Double? - private var fraction: Double { min(1,max(0,(value-range.lowerBound)/(range.upperBound-range.lowerBound))) } - private var display: String { - if filter { return abs(value) < 0.01 ? "OFF" : value < 0 ? "LOW PASS" : "HIGH PASS" } - return String(format:"%+.1f dB",value) - } - var body: some View { - VStack(spacing:4) { - ZStack { - Circle().trim(from:0,to:0.75).stroke(Color(white:0.21),style:StrokeStyle(lineWidth:4,lineCap:.round)).rotationEffect(.degrees(135)) - Circle().trim(from:0,to:0.75*fraction).stroke(Color(white:0.48),style:StrokeStyle(lineWidth:3,lineCap:.round)).rotationEffect(.degrees(135)) - Circle().fill(LinearGradient(colors:[Color(white:0.19),Color(white:0.09)],startPoint:.top,endPoint:.bottom)).padding(6).overlay(Circle().stroke(.black.opacity(0.65),lineWidth:1.5).padding(6)) - Capsule().fill(.white).frame(width:2,height:12).offset(y:-13).rotationEffect(.degrees(-135+270*fraction)) - }.frame(width:50,height:50).contentShape(Circle()) - .gesture(DragGesture(minimumDistance:0).onChanged { gesture in - if initial == nil { initial = value } - value = min(range.upperBound,max(range.lowerBound,(initial ?? value)-Double(gesture.translation.height)/130*(range.upperBound-range.lowerBound))) - }.onEnded { _ in initial = nil }) - .simultaneousGesture(TapGesture(count:2).onEnded { value = 0 }) - .accessibilityElement().accessibilityLabel(title).accessibilityValue(display) - .accessibilityAdjustableAction { direction in - let change = (range.upperBound-range.lowerBound)/24 - value = min(range.upperBound,max(range.lowerBound,value+(direction == .increment ? change : -change))) - }.help("Drag up/down to adjust. Double-click to reset.") - Text(title).font(.system(size:10,weight:.bold)).foregroundStyle(Color(white:0.6)) - Text(display).font(.system(size:8,design:.monospaced)).foregroundStyle(Color(white:0.45)) - } - } -} -private struct StereoMeter: View { - @ObservedObject var player: Player - private func normal(_ level: Float) -> Double { max(0,min(1,(20*log10(Double(max(level,0.000001)))+60)/60)) } - var body: some View { - HStack(spacing:3) { - ForEach(0..<2) { channel in - VStack(spacing:2) { - ForEach((0..<24).reversed(),id:\.self) { segment in - let on = Double(segment)/24 < normal(channel == 0 ? player.leftLevel : player.rightLevel) - Rectangle().fill(on ? (segment > 21 ? Color.red : segment > 17 ? Color.yellow : Color.green) : Color.black.opacity(0.5)) - } - } - } - }.frame(width:23,height:125).accessibilityLabel("Stereo output levels") - } -} -private struct MixerFader: View { - @Binding var value: Double - var body: some View { - GeometryReader { geometry in - let travel = geometry.size.height-22 - ZStack(alignment:.top) { - VStack { ForEach(0..<7) { _ in Rectangle().fill(.white.opacity(0.09)).frame(height:1);Spacer(minLength:0) } }.padding(.vertical,11) - Capsule().fill(.black.opacity(0.8)).frame(width:5).padding(.vertical,8) - RoundedRectangle(cornerRadius:5).fill(LinearGradient(colors:[Color(white:0.45),Color(white:0.23)],startPoint:.top,endPoint:.bottom)) - .frame(width:45,height:20).overlay(Rectangle().fill(.white.opacity(0.15)).frame(width:18,height:1)) - .offset(y:(1-value)*travel) - }.frame(maxWidth:.infinity).contentShape(Rectangle()) - .gesture(DragGesture(minimumDistance:0).onChanged { value = min(1,max(0,1-Double(($0.location.y-11)/travel))) }) - }.frame(width:56,height:135).accessibilityLabel("Master volume").accessibilityValue("\(Int(value*100)) percent") - .accessibilityAdjustableAction { direction in value = min(1,max(0,value+(direction == .increment ? 0.05 : -0.05))) } - } -} -private struct ToneMixerView: View { - @ObservedObject var player: Player - var body: some View { - VStack(spacing:14) { - HStack { Text("TONE / MIXER").font(.system(size:12,weight:.bold));Spacer();Toggle("EQ",isOn:$player.toneEnabled).toggleStyle(.switch).controlSize(.mini) } - HStack(alignment:.top,spacing:28) { - VStack(spacing:8) { - ToneKnob(title:"HIGH",value:$player.highGain,range:-12...12) - ToneKnob(title:"MID",value:$player.midGain,range:-12...12) - ToneKnob(title:"LOW",value:$player.lowGain,range:-12...12) - } - VStack(spacing:15) { - ToneKnob(title:"FILTER",value:$player.filter,range:-1...1,filter:true) - HStack(spacing:20) { StereoMeter(player:player);MixerFader(value:$player.volume) } - Text(player.volume <= 0 ? "−∞ dB" : String(format:"%+.1f dB",20*log10(player.volume))).font(.system(size:10,design:.monospaced)).foregroundStyle(.secondary) - } - }.padding(.horizontal,15) - HStack { Text("Drag knobs · Double-click to reset").font(.system(size:9)).foregroundStyle(.secondary);Spacer();Button("Reset EQ") { player.resetTone() }.controlSize(.small) } - }.padding(18).frame(width:270).background(Color(white:0.105)).preferredColorScheme(.dark) - } -} -private struct PlaybackSettings: View { - @ObservedObject var player: Player - @ObservedObject var model: AppModel - let selectedSong: Int64? - @State private var personalRating = 0 - var body: some View { - HStack(spacing:10) { - Text("Key") - Picker("Key",selection:$player.pitch) { ForEach(-12..<13) { Text(String(format:"%+d",$0)).tag(Double($0)) } }.labelsHidden().frame(width:70) - Text("Tempo") - Slider(value:$player.tempo,in:0.5...1.5,step:0.05).frame(width:85) - Text(String(format:"%.0f%%",player.tempo*100)).monospacedDigit().frame(width:40) - Text("Rating") - Picker("Singer rating",selection:$personalRating) { ForEach(0..<6) { Text($0 == 0 ? "Unrated" : String(repeating:"★",count:$0)).tag($0) } }.labelsHidden().frame(width:88).help("Singer-specific song rating") - Button("Save for Singer") { - if let song = player.currentSongID ?? selectedSong { model.savePreference(song:song,value:.init(pitch:player.pitch,tempo:player.tempo,rating:personalRating)) } - }.disabled(model.selectedSinger == nil || (player.currentSongID == nil && selectedSong == nil)) - Menu { - Button("Reset key / tempo") { player.pitch = 0; player.tempo = 1 } - ForEach([-1.0,-0.5,0,0.5,1.0],id:\.self) { offset in Button(String(format:"Graphics offset %+.1fs",offset)) { player.graphicsOffset = offset } } - } label: { Image(systemName:"slider.horizontal.3") }.menuStyle(.borderlessButton).frame(width:22).help("Playback settings") - }.font(.system(size:11)) - .onChange(of:model.selectedSinger) { _ in loadRating() } - .onChange(of:player.currentSongID) { _ in loadRating() } - .onChange(of:selectedSong) { _ in loadRating() } - } - private func loadRating() { if let song = player.currentSongID ?? selectedSong { personalRating = model.preference(song).rating } else { personalRating = 0 } } -} -private struct SeekBar: View { - @ObservedObject var player: Player - private func clock(_ seconds: Double) -> String { let n = Int(seconds); return String(format: "%d:%02d", n / 60, n % 60) } - var body: some View { - HStack(spacing: 10) { - Text(clock(player.time)) - Slider(value: Binding(get: { player.time }, set: { player.seek($0) }), in: 0...max(1, player.duration)) - .controlSize(.mini).tint(.gray).disabled(player.duration == 0).accessibilityLabel("Playback position") - Text(clock(player.duration)) - }.font(.system(size: 10, design: .monospaced)).foregroundStyle(.white.opacity(0.65)) - } -} -private struct RepeatButton: View { - @ObservedObject var player: Player - var body: some View { - Button { player.repeating.toggle() } label: { - Image(systemName: "repeat").font(.system(size: 18, weight: .semibold)) - .foregroundStyle(player.repeating ? Color.blue : Color(white: 0.25)).frame(width: 32, height: 24) - }.help(player.repeating ? "Repeat song: on" : "Repeat song: off").accessibilityLabel("Repeat song").accessibilityValue(player.repeating ? "On" : "Off") - } -} diff --git a/backups/before-tonight-fix-20261103-092811/KJamsClone/Library.swift b/backups/before-tonight-fix-20261103-092811/KJamsClone/Library.swift deleted file mode 100644 index ded33f3..0000000 --- a/backups/before-tonight-fix-20261103-092811/KJamsClone/Library.swift +++ /dev/null @@ -1,286 +0,0 @@ -import Foundation -import SQLite3 - -struct Song: Identifiable, Hashable { - var id: Int64 - var title: String - var audio: String - var cdg: String? - var rating: Int - var plays: Int - var artist: String = "" - var album: String = "" - var label: String = "" - var duration: Double = 0 -} -struct MusicStore: Identifiable, Hashable { - var id: Int64 - var name: String - var url: String - var searchTemplate: String - func destination(query: String = "") throws -> URL { - let query = query.trimmingCharacters(in:.whitespacesAndNewlines) - let encoded = query.addingPercentEncoding(withAllowedCharacters:CharacterSet(charactersIn:"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~")) ?? "" - let value = query.isEmpty || searchTemplate.isEmpty ? url : searchTemplate.replacingOccurrences(of:"{query}",with:encoded) - guard let result = URL(string:value), ["http","https"].contains(result.scheme?.lowercased() ?? ""), result.host?.isEmpty == false, result.user == nil, result.password == nil else { throw LibraryError.message("Use a valid http:// or https:// store URL without credentials") } - return result - } -} -struct PersonPlace: Identifiable, Hashable { var id: Int64; var name: String } -struct SongPreference: Equatable { - var pitch: Double = 0 - var tempo: Double = 1 - var rating: Int = 0 -} -struct Performance: Identifiable { - var id: Int64 - var song: String - var singer: String - var venue: String - var date: String - var singerID: Int64? - var songID: Int64? -} -struct QueueEntry: Identifiable { - var id: Int64 - var songID: Int64 - var singerID: Int64? - var title: String - var singer: String -} -enum LibraryError: LocalizedError { - case message(String) - var errorDescription: String? { if case .message(let s) = self { return s }; return nil } -} -final class Library { - private var db: OpaquePointer? - init(url: URL) throws { - guard sqlite3_open(url.path, &db) == SQLITE_OK else { throw LibraryError.message("Cannot open library") } - try execute("PRAGMA foreign_keys=ON") - try execute("CREATE TABLE IF NOT EXISTS songs(id INTEGER PRIMARY KEY,title TEXT NOT NULL,audio TEXT UNIQUE NOT NULL,cdg TEXT,rating INTEGER NOT NULL DEFAULT 0 CHECK(rating BETWEEN 0 AND 5),plays INTEGER NOT NULL DEFAULT 0)") - try execute("CREATE TABLE IF NOT EXISTS singers(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS venues(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS history(id INTEGER PRIMARY KEY,song INTEGER REFERENCES songs(id),singer INTEGER REFERENCES singers(id),venue INTEGER REFERENCES venues(id),played TEXT DEFAULT CURRENT_TIMESTAMP)") - // Additive migration: preserve older libraries and infer existing memberships from history. - for column in ["artist", "album", "label"] { - if try !columns("songs").contains(column) { try execute("ALTER TABLE songs ADD COLUMN \(column) TEXT NOT NULL DEFAULT ''") } - } - try execute("CREATE TABLE IF NOT EXISTS venue_singers(venue INTEGER NOT NULL REFERENCES venues(id) ON DELETE CASCADE,singer INTEGER NOT NULL REFERENCES singers(id) ON DELETE CASCADE,PRIMARY KEY(venue,singer))") - if try schemaVersion() < 3 { try execute("INSERT OR IGNORE INTO venue_singers SELECT DISTINCT venue,singer FROM history WHERE venue IS NOT NULL AND singer IS NOT NULL") } - try execute("CREATE TABLE IF NOT EXISTS settings(key TEXT PRIMARY KEY,value TEXT)") - try execute("CREATE TABLE IF NOT EXISTS preferences(song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,singer INTEGER NOT NULL REFERENCES singers(id) ON DELETE CASCADE,pitch REAL NOT NULL DEFAULT 0 CHECK(pitch BETWEEN -12 AND 12),tempo REAL NOT NULL DEFAULT 1 CHECK(tempo BETWEEN 0.5 AND 1.5),rating INTEGER NOT NULL DEFAULT 0 CHECK(rating BETWEEN 0 AND 5),PRIMARY KEY(song,singer))") - try execute("CREATE TABLE IF NOT EXISTS queue(id INTEGER PRIMARY KEY,venue INTEGER REFERENCES venues(id) ON DELETE CASCADE,song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,singer INTEGER REFERENCES singers(id) ON DELETE CASCADE,position INTEGER NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS playlists(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS playlist_songs(playlist INTEGER NOT NULL REFERENCES playlists(id) ON DELETE CASCADE,song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,position INTEGER NOT NULL,PRIMARY KEY(playlist,song))") - try execute("CREATE TABLE IF NOT EXISTS singer_songs(singer INTEGER NOT NULL REFERENCES singers(id) ON DELETE CASCADE,song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,position INTEGER NOT NULL,PRIMARY KEY(singer,song))") - if try schemaVersion() < 4 { - try execute("INSERT OR IGNORE INTO singer_songs(singer,song,position) SELECT singer,song,MIN(id) FROM history WHERE singer IS NOT NULL AND song IS NOT NULL GROUP BY singer,song") - try execute("INSERT OR IGNORE INTO singer_songs(singer,song,position) SELECT singer,song,0 FROM preferences") - } - if try !columns("songs").contains("duration") { try execute("ALTER TABLE songs ADD COLUMN duration REAL NOT NULL DEFAULT 0") } - if try !columns("singer_songs").contains("favourite") { try execute("ALTER TABLE singer_songs ADD COLUMN favourite INTEGER NOT NULL DEFAULT 0 CHECK(favourite IN (0,1))") } - if try schemaVersion() < 5 { try execute("UPDATE singer_songs SET favourite=1 WHERE EXISTS(SELECT 1 FROM preferences WHERE preferences.singer=singer_songs.singer AND preferences.song=singer_songs.song AND preferences.rating>=4)") } - try execute("CREATE TABLE IF NOT EXISTS song_settings(song INTEGER PRIMARY KEY REFERENCES songs(id) ON DELETE CASCADE,pitch REAL NOT NULL DEFAULT 0 CHECK(pitch BETWEEN -12 AND 12),tempo REAL NOT NULL DEFAULT 1 CHECK(tempo BETWEEN 0.5 AND 1.5))") - try execute("CREATE TABLE IF NOT EXISTS music_stores(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL,url TEXT NOT NULL,search_template TEXT NOT NULL DEFAULT '')") - if try !columns("songs").contains("metadata_edited") { try execute("ALTER TABLE songs ADD COLUMN metadata_edited INTEGER NOT NULL DEFAULT 0") } - try execute("PRAGMA user_version=6") - } - deinit { sqlite3_close(db) } - private func statement(_ sql: String, _ values: [String?]) throws -> OpaquePointer { - var s: OpaquePointer? - guard sqlite3_prepare_v2(db, sql, -1, &s, nil) == SQLITE_OK, let s else { throw error() } - for (i,v) in values.enumerated() { - let code = v.map { sqlite3_bind_text(s, Int32(i + 1), $0, -1, unsafeBitCast(-1, to: sqlite3_destructor_type.self)) } ?? sqlite3_bind_null(s, Int32(i + 1)) - if code != SQLITE_OK { sqlite3_finalize(s); throw error() } - } - return s - } - private func error() -> LibraryError { .message(String(cString: sqlite3_errmsg(db))) } - func execute(_ sql: String, _ values: [String?] = []) throws { - let s = try statement(sql, values); defer { sqlite3_finalize(s) } - guard sqlite3_step(s) == SQLITE_DONE else { throw error() } - } - func songs() throws -> [Song] { - let s = try statement("SELECT id,title,audio,cdg,rating,plays,artist,album,label,duration FROM songs ORDER BY title COLLATE NOCASE", []); defer { sqlite3_finalize(s) } - var result = [Song]() - while true { - let code = sqlite3_step(s); if code == SQLITE_DONE { break }; guard code == SQLITE_ROW else { throw error() } - result.append(Song(id: sqlite3_column_int64(s,0), title: String(cString: sqlite3_column_text(s,1)), audio: String(cString: sqlite3_column_text(s,2)), cdg: sqlite3_column_text(s,3).map { String(cString:$0) }, rating: Int(sqlite3_column_int(s,4)), plays: Int(sqlite3_column_int(s,5)), artist: text(s,6), album: text(s,7), label: text(s,8),duration:sqlite3_column_double(s,9))) - } - return result - } - func add(title: String, audio: String, cdg: String?, artist: String = "", album: String = "", label: String = "", duration: Double = 0) throws { - try execute("INSERT INTO songs(title,audio,cdg,artist,album,label,duration) VALUES(?,?,?,?,?,?,?) ON CONFLICT(audio) DO UPDATE SET cdg=COALESCE(excluded.cdg,songs.cdg),artist=CASE WHEN songs.metadata_edited=0 AND excluded.artist!='' THEN excluded.artist ELSE songs.artist END,album=CASE WHEN songs.metadata_edited=0 AND excluded.album!='' THEN excluded.album ELSE songs.album END,label=CASE WHEN songs.metadata_edited=0 AND excluded.label!='' THEN excluded.label ELSE songs.label END,duration=CASE WHEN excluded.duration>0 THEN excluded.duration ELSE songs.duration END", [title,audio,cdg,artist,album,label,String(duration)]) - } - func rate(_ id: Int64, _ rating: Int) throws { try execute("UPDATE songs SET rating=? WHERE id=?", [String(rating),String(id)]) } - func entities(_ table: String) throws -> [PersonPlace] { - precondition(["singers","venues","playlists"].contains(table)) - let s = try statement("SELECT id,name FROM \(table) ORDER BY name", []); defer { sqlite3_finalize(s) } - var rows = [PersonPlace]() - while sqlite3_step(s) == SQLITE_ROW { rows.append(.init(id: sqlite3_column_int64(s,0), name: String(cString: sqlite3_column_text(s,1)))) } - return rows - } - func addEntity(_ table: String, name: String) throws { - precondition(["singers","venues","playlists"].contains(table)) - let name = name.trimmingCharacters(in: .whitespacesAndNewlines) - guard !name.isEmpty else { throw LibraryError.message("Enter a name") } - try execute("INSERT OR IGNORE INTO \(table)(name) VALUES(?)", [name]) - } - func record(_ song: Int64, singer: Int64?, venue: Int64?) throws { - try execute("BEGIN IMMEDIATE") - do { - if let singer { try assignSong(song,singer:singer) } - try execute("INSERT INTO history(song,singer,venue) VALUES(?,?,?)", [String(song),singer.map(String.init),venue.map(String.init)]) - try execute("UPDATE songs SET plays=plays+1 WHERE id=?", [String(song)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK"); throw error } - } - - private func text(_ s: OpaquePointer, _ index: Int32) -> String { sqlite3_column_text(s,index).map { String(cString:$0) } ?? "" } - private func schemaVersion() throws -> Int { - let s = try statement("PRAGMA user_version",[]); defer { sqlite3_finalize(s) } - return sqlite3_step(s) == SQLITE_ROW ? Int(sqlite3_column_int(s,0)) : 0 - } - private func columns(_ table: String) throws -> Set { - let s = try statement("PRAGMA table_info(\(table))", []); defer { sqlite3_finalize(s) } - var result = Set(); while sqlite3_step(s) == SQLITE_ROW { result.insert(text(s,1)) }; return result - } - func members(of venue: Int64) throws -> [PersonPlace] { - let s = try statement("SELECT singers.id,singers.name FROM singers JOIN venue_singers ON singers.id=venue_singers.singer WHERE venue=? ORDER BY name", [String(venue)]); defer { sqlite3_finalize(s) } - var result = [PersonPlace](); while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),name:text(s,1))) }; return result - } - func setMembership(singer: Int64, venue: Int64, included: Bool) throws { - try execute(included ? "INSERT OR IGNORE INTO venue_singers(venue,singer) VALUES(?,?)" : "DELETE FROM venue_singers WHERE venue=? AND singer=?", [String(venue),String(singer)]) - if !included { try execute("DELETE FROM queue WHERE venue=? AND singer=?",[String(venue),String(singer)]) } - } - func currentVenue() throws -> Int64? { - let s = try statement("SELECT venues.id FROM venues JOIN settings ON CAST(settings.value AS INTEGER)=venues.id WHERE settings.key='currentVenue'", []); defer { sqlite3_finalize(s) } - return sqlite3_step(s) == SQLITE_ROW ? sqlite3_column_int64(s,0) : nil - } - func selectVenue(_ id: Int64?) throws { - if let id { - guard try entities("venues").contains(where: { $0.id == id }) else { throw LibraryError.message("Venue no longer exists") } - } - try execute("INSERT INTO settings(key,value) VALUES('currentVenue',?) ON CONFLICT(key) DO UPDATE SET value=excluded.value",[id.map(String.init)]) - } - func rename(_ table: String, id: Int64, name: String) throws { - precondition(["singers","venues","playlists"].contains(table)) - let name = name.trimmingCharacters(in:.whitespacesAndNewlines) - guard !name.isEmpty else { throw LibraryError.message("Enter a name") } - try execute("UPDATE \(table) SET name=? WHERE id=?",[name,String(id)]) - } - func deleteEntity(_ table: String, id: Int64) throws { - precondition(["singers","venues","playlists"].contains(table)) - try execute("BEGIN IMMEDIATE") - do { - if table == "singers" { try execute("UPDATE history SET singer=NULL WHERE singer=?",[String(id)]) } - if table == "venues" { - try execute("UPDATE history SET venue=NULL WHERE venue=?",[String(id)]) - try execute("DELETE FROM settings WHERE key='currentVenue' AND value=?",[String(id)]) - } - try execute("DELETE FROM \(table) WHERE id=?",[String(id)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK"); throw error } - } - func preference(song: Int64, singer: Int64) throws -> SongPreference { - let s = try statement("SELECT pitch,tempo,rating FROM preferences WHERE song=? AND singer=?",[String(song),String(singer)]); defer { sqlite3_finalize(s) } - guard sqlite3_step(s) == SQLITE_ROW else { return try defaultPreference(song:song) } - return .init(pitch:sqlite3_column_double(s,0),tempo:sqlite3_column_double(s,1),rating:Int(sqlite3_column_int(s,2))) - } - func savePreference(song: Int64, singer: Int64, value: SongPreference) throws { - try execute("INSERT INTO preferences(song,singer,pitch,tempo,rating) VALUES(?,?,?,?,?) ON CONFLICT(song,singer) DO UPDATE SET pitch=excluded.pitch,tempo=excluded.tempo,rating=excluded.rating",[String(song),String(singer),String(value.pitch),String(value.tempo),String(value.rating)]) - } - func history(venue: Int64?, singer: Int64? = nil) throws -> [Performance] { - let s = try statement("SELECT history.id,COALESCE(songs.title,'Deleted song'),COALESCE(singers.name,'—'),COALESCE(venues.name,'—'),played,history.singer,history.song FROM history LEFT JOIN songs ON songs.id=history.song LEFT JOIN singers ON singers.id=history.singer LEFT JOIN venues ON venues.id=history.venue WHERE (? IS NULL OR history.venue=?) AND (? IS NULL OR history.singer=?) ORDER BY history.id DESC",[venue.map(String.init),venue.map(String.init),singer.map(String.init),singer.map(String.init)]); defer { sqlite3_finalize(s) } - var result = [Performance](); while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),song:text(s,1),singer:text(s,2),venue:text(s,3),date:text(s,4),singerID:sqlite3_column_type(s,5) == SQLITE_NULL ? nil : sqlite3_column_int64(s,5),songID:sqlite3_column_type(s,6) == SQLITE_NULL ? nil : sqlite3_column_int64(s,6))) }; return result - } - func enqueue(song: Int64, singer: Int64?, venue: Int64?) throws { - guard let venue else { throw LibraryError.message("Select a current venue before adding to its queue") } - if let singer, try !members(of:venue).contains(where: { $0.id == singer }) { throw LibraryError.message("Add this singer to the current venue first") } - try execute("BEGIN IMMEDIATE") - do { - if let singer { try assignSong(song,singer:singer) } - try execute("INSERT INTO queue(venue,song,singer,position) VALUES(?,?,?,(SELECT COALESCE(MAX(position),0)+1 FROM queue WHERE venue=?))",[String(venue),String(song),singer.map(String.init),String(venue)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK");throw error } - } - func queue(venue: Int64?) throws -> [QueueEntry] { - guard let venue else { return [] } - let s = try statement("SELECT queue.id,queue.song,queue.singer,songs.title,COALESCE(singers.name,'No singer') FROM queue JOIN songs ON songs.id=queue.song LEFT JOIN singers ON singers.id=queue.singer WHERE queue.venue=? ORDER BY queue.position,queue.id",[String(venue)]); defer { sqlite3_finalize(s) } - var result = [QueueEntry](); while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),songID:sqlite3_column_int64(s,1),singerID:sqlite3_column_type(s,2) == SQLITE_NULL ? nil : sqlite3_column_int64(s,2),title:text(s,3),singer:text(s,4))) }; return result - } - func removeQueue(_ id: Int64) throws { try execute("DELETE FROM queue WHERE id=?",[String(id)]) } - func moveQueue(_ id: Int64, venue: Int64, by offset: Int) throws { - var rows = try queue(venue:venue) - guard let index = rows.firstIndex(where: { $0.id == id }), rows.indices.contains(index+offset) else { return } - rows.swapAt(index,index+offset) - try execute("BEGIN IMMEDIATE") - do { for (i,row) in rows.enumerated() { try execute("UPDATE queue SET position=? WHERE id=?",[String(i),String(row.id)]) }; try execute("COMMIT") } - catch { try? execute("ROLLBACK"); throw error } - } - func addToPlaylist(_ playlist: Int64, song: Int64) throws { - try execute("INSERT OR IGNORE INTO playlist_songs(playlist,song,position) VALUES(?,?,(SELECT COALESCE(MAX(position),0)+1 FROM playlist_songs WHERE playlist=?))",[String(playlist),String(song),String(playlist)]) - } - func playlistSongIDs(_ playlist: Int64) throws -> [Int64] { - let s = try statement("SELECT song FROM playlist_songs WHERE playlist=? ORDER BY position",[String(playlist)]); defer { sqlite3_finalize(s) } - var ids = [Int64](); while sqlite3_step(s) == SQLITE_ROW { ids.append(sqlite3_column_int64(s,0)) }; return ids - } - func removeFromPlaylist(_ playlist: Int64, song: Int64) throws { try execute("DELETE FROM playlist_songs WHERE playlist=? AND song=?",[String(playlist),String(song)]) } - func assignSong(_ song: Int64, singer: Int64) throws { - try execute("INSERT OR IGNORE INTO singer_songs(singer,song,position) VALUES(?,?,(SELECT COALESCE(MAX(position),0)+1 FROM singer_songs WHERE singer=?))",[String(singer),String(song),String(singer)]) - } - func removeSingerSong(_ song: Int64, singer: Int64) throws { - try execute("DELETE FROM singer_songs WHERE singer=? AND song=?",[String(singer),String(song)]) - } - func singerSongIDs() throws -> [Int64:[Int64]] { - let s = try statement("SELECT singer,song FROM singer_songs ORDER BY singer,position,song",[]); defer { sqlite3_finalize(s) } - var result = [Int64:[Int64]]() - while sqlite3_step(s) == SQLITE_ROW { result[sqlite3_column_int64(s,0),default:[]].append(sqlite3_column_int64(s,1)) } - return result - } - func defaultPreference(song: Int64) throws -> SongPreference { - let s = try statement("SELECT pitch,tempo FROM song_settings WHERE song=?",[String(song)]);defer { sqlite3_finalize(s) } - guard sqlite3_step(s) == SQLITE_ROW else { return .init() } - return .init(pitch:sqlite3_column_double(s,0),tempo:sqlite3_column_double(s,1),rating:0) - } - func saveDefaultPreference(song: Int64, value: SongPreference) throws { - try execute("INSERT INTO song_settings(song,pitch,tempo) VALUES(?,?,?) ON CONFLICT(song) DO UPDATE SET pitch=excluded.pitch,tempo=excluded.tempo",[String(song),String(value.pitch),String(value.tempo)]) - } - func updateDuration(_ song: Int64, seconds: Double) throws { - guard seconds.isFinite && seconds >= 0 else { return } - try execute("UPDATE songs SET duration=? WHERE id=?",[String(seconds),String(song)]) - } - func setFavourite(song: Int64, singer: Int64, included: Bool) throws { - if included { try assignSong(song,singer:singer) } - try execute("UPDATE singer_songs SET favourite=? WHERE singer=? AND song=?",[included ? "1" : "0",String(singer),String(song)]) - } - func favouriteSongIDs() throws -> [Int64:Set] { - let s = try statement("SELECT singer,song FROM singer_songs WHERE favourite=1",[]);defer { sqlite3_finalize(s) } - var result = [Int64:Set]() - while sqlite3_step(s) == SQLITE_ROW { result[sqlite3_column_int64(s,0),default:[]].insert(sqlite3_column_int64(s,1)) };return result - } - func stores() throws -> [MusicStore] { - let s = try statement("SELECT id,name,url,search_template FROM music_stores ORDER BY name",[]);defer { sqlite3_finalize(s) } - var result = [MusicStore]() - while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),name:text(s,1),url:text(s,2),searchTemplate:text(s,3))) };return result - } - func saveStore(_ store: MusicStore) throws { - let name = store.name.trimmingCharacters(in:.whitespacesAndNewlines),url = store.url.trimmingCharacters(in:.whitespacesAndNewlines),search = store.searchTemplate.trimmingCharacters(in:.whitespacesAndNewlines) - guard !name.isEmpty else { throw LibraryError.message("Enter a store name") } - let cleaned = MusicStore(id:store.id,name:name,url:url,searchTemplate:search) - _ = try cleaned.destination() - if !search.isEmpty { - guard search.contains("{query}") else { throw LibraryError.message("Search URL must contain {query}") } - _ = try cleaned.destination(query:"test") - } - if store.id == 0 { try execute("INSERT INTO music_stores(name,url,search_template) VALUES(?,?,?)",[name,url,search]) } - else { try execute("UPDATE music_stores SET name=?,url=?,search_template=? WHERE id=?",[name,url,search,String(store.id)]) } - } - func deleteStore(_ id: Int64) throws { try execute("DELETE FROM music_stores WHERE id=?",[String(id)]) } - func updateMetadata(song: Int64,title: String,artist: String,album: String,label: String,rating: Int) throws { - let title = title.trimmingCharacters(in:.whitespacesAndNewlines) - guard !title.isEmpty else { throw LibraryError.message("Song title cannot be empty") } - try execute("UPDATE songs SET title=?,artist=?,album=?,label=?,rating=?,metadata_edited=1 WHERE id=?",[title,artist.trimmingCharacters(in:.whitespacesAndNewlines),album.trimmingCharacters(in:.whitespacesAndNewlines),label.trimmingCharacters(in:.whitespacesAndNewlines),String(rating),String(song)]) - guard sqlite3_changes(db) == 1 else { throw LibraryError.message("Song no longer exists") } - } -} diff --git a/backups/before-tonight-fix-20261103-092811/KJamsCloneTests/KJamsCloneTests.swift b/backups/before-tonight-fix-20261103-092811/KJamsCloneTests/KJamsCloneTests.swift deleted file mode 100644 index d39aa54..0000000 --- a/backups/before-tonight-fix-20261103-092811/KJamsCloneTests/KJamsCloneTests.swift +++ /dev/null @@ -1,455 +0,0 @@ -import XCTest -import AVFoundation -@testable import KJamsClone - -final class KJamsCloneTests: XCTestCase { - func packet(_ instruction: UInt8, _ data: [UInt8]) -> [UInt8] { [9,instruction,0,0] + Array((data + Array(repeating: 0,count:16)).prefix(16)) + [0,0,0,0] } - func testPresetTileXORAndInvalidCoordinates() { - var d = CDGDecoder() - d.apply(packet(1,[3,0])); XCTAssertEqual(d.pixels[0],3) - d.apply(packet(6,[0,5,1,1] + Array(repeating:63,count:12))) - XCTAssertEqual(d.pixels[12*300+6],5) - d.apply(packet(38,[0,5,1,1] + Array(repeating:63,count:12))) - XCTAssertEqual(d.pixels[12*300+6],0) - let old = d.pixels; d.apply(packet(6,[1,2,31,63])); XCTAssertEqual(d.pixels,old) - } - func testSeekAndTruncatedPacket() { - var d = CDGDecoder() - let data = Data(packet(1,[2,0]) + packet(1,[7,0]) + [9]) - d.render(data,at:1); XCTAssertEqual(d.pixels[0],7); XCTAssertEqual(d.packetIndex,2) - d.render(data,at:1.0/300); XCTAssertEqual(d.pixels[0],2) - d.render(data,at:0); XCTAssertEqual(d.pixels[0],0) - } - func testPaletteBorderScrollAndImage() { - var d = CDGDecoder() - d.apply(packet(30,[63,63])); XCTAssertEqual(d.palette[0],0xFFFFFFFF) - d.apply(packet(2,[4])); XCTAssertEqual(d.pixels[0],4); XCTAssertEqual(d.pixels[12*300+6],0) - d.apply(packet(20,[3,16,0])); XCTAssertEqual(d.pixels[100*300],3) - d.apply(packet(24,[0,32,0])); XCTAssertEqual(d.pixels[100*300+294],3) - XCTAssertEqual(d.image()?.width,288) - } - func testSQLitePersistenceDedupRatingsAndHistory() throws { - let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at: folder,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:folder) } - let url = folder.appendingPathComponent("test.sqlite") - do { - let db = try Library(url:url) - try db.add(title:"Singer's Song",audio:"/test.mp3",cdg:nil) - try db.add(title:"Duplicate",audio:"/test.mp3",cdg:"/test.cdg") - let song = try XCTUnwrap(db.songs().first) - try db.rate(song.id,5); XCTAssertThrowsError(try db.rate(song.id,6)) - try db.addEntity("singers",name:"O'Neil"); try db.addEntity("venues",name:"Hall") - try db.record(song.id,singer:db.entities("singers").first?.id,venue:db.entities("venues").first?.id) - } - let reopened = try Library(url:url); let songs = try reopened.songs() - XCTAssertEqual(songs.count,1); XCTAssertEqual(songs[0].rating,5); XCTAssertEqual(songs[0].plays,1); XCTAssertEqual(songs[0].cdg,"/test.cdg") - XCTAssertEqual(try reopened.entities("singers").first?.name,"O'Neil") - } - func testPairedImportAndContentDedup() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let audio = root.appendingPathComponent("Test.mp3"), cdg = root.appendingPathComponent("Test.CDG") - try Data([1,2,3]).write(to:audio); try Data(packet(1,[2,0])).write(to:cdg) - let db = try Library(url:root.appendingPathComponent("test.sqlite")) - let importer = Importer(media:root.appendingPathComponent("Media")) - try importer.run([audio],library:db); try importer.run([audio],library:db) - XCTAssertEqual(try db.songs().count,1) - XCTAssertNotNil(try db.songs().first?.cdg) - } - - func testZippedMP3GImportAndUnsafeArchiveRejection() throws { - let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:folder,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:folder) } - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let db = try Library(url:folder.appendingPathComponent("db.sqlite")) - let importer = Importer(media:folder.appendingPathComponent("Media")) - try importer.run([fixtures.appendingPathComponent("Demo.zip")],library:db) - let song = try XCTUnwrap(db.songs().first) - XCTAssertEqual(song.title,"Demo"); XCTAssertNotNil(song.cdg) - XCTAssertTrue(FileManager.default.fileExists(atPath:song.audio)) - XCTAssertThrowsError(try importer.run([fixtures.appendingPathComponent("Unsafe.zip")],library:db)) - } - @MainActor func testMP3PlaybackPauseAndSeek() throws { - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let player = Player() - defer { player.stop() } - try player.load(Song(id:1,title:"Demo",audio:fixtures.appendingPathComponent("Demo.mp3").path,cdg:fixtures.appendingPathComponent("Demo.cdg").path,rating:0,plays:0)) - XCTAssertGreaterThan(player.duration,3.9); XCTAssertTrue(player.playing) - player.toggle(); XCTAssertFalse(player.playing) - player.seek(2); XCTAssertEqual(player.time,2,accuracy:0.05); XCTAssertNotNil(player.image) - player.seek(0.1); XCTAssertEqual(player.time,0.1,accuracy:0.05) - } - @MainActor func testCreateSingerAndVenueThroughAppModel() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - defer { try? FileManager.default.removeItem(at: root) } - let model = AppModel(storageURL: root) - XCTAssertNil(model.error) - let singer = try model.createEntity(.singer, name: " Alex ") - let venue = try model.createEntity(.venue, name: "Town Hall") - XCTAssertEqual(model.singers.first?.name, "Alex") - XCTAssertEqual(model.venues.first?.name, "Town Hall") - XCTAssertEqual(try model.createEntity(.singer, name: "Alex"), singer) - XCTAssertEqual(model.singers.count, 1) - XCTAssertThrowsError(try model.createEntity(.venue, name: " ")) - let reopened = AppModel(storageURL: root) - XCTAssertEqual(reopened.singers.first?.id, singer) - XCTAssertEqual(reopened.venues.first?.id, venue) - } - - @MainActor func testVenuesShareSingersAndRememberSelection() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - defer { try? FileManager.default.removeItem(at:root) } - let model = AppModel(storageURL:root) - let hall = try model.createEntity(.venue,name:"Hall") - let alex = try model.createEntity(.singer,name:"Alex") - let club = try model.createEntity(.venue,name:"Club") - XCTAssertTrue(model.venueSingers.isEmpty) - model.membership(singer:alex,included:true) - XCTAssertEqual(model.venueSingers.map(\.id),[alex]) - model.chooseVenue(hall); XCTAssertEqual(model.venueSingers.map(\.id),[alex]) - model.chooseVenue(club); model.membership(singer:alex,included:false) - XCTAssertTrue(model.venueSingers.isEmpty) - let reopened = AppModel(storageURL:root) - XCTAssertEqual(reopened.currentVenue,club); XCTAssertTrue(reopened.venueSingers.isEmpty) - reopened.chooseVenue(hall); XCTAssertEqual(reopened.venueSingers.map(\.id),[alex]) - XCTAssertEqual(reopened.singers.count,1) - } - func testMigrationAndMembershipRemovalDoesNotReappear() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let url = root.appendingPathComponent("db.sqlite") - var singer: Int64 = 0, venue: Int64 = 0 - do { - let db = try Library(url:url) - try db.add(title:"Song",audio:"/a.mp3",cdg:nil) - try db.addEntity("singers",name:"Alex"); try db.addEntity("venues",name:"Hall") - singer = try XCTUnwrap(db.entities("singers").first?.id); venue = try XCTUnwrap(db.entities("venues").first?.id) - try db.record(XCTUnwrap(db.songs().first?.id),singer:singer,venue:venue) - try db.execute("PRAGMA user_version=1") - } - do { - let migrated = try Library(url:url) - XCTAssertEqual(try migrated.members(of:venue).map(\.id),[singer]) - try migrated.setMembership(singer:singer,venue:venue,included:false) - } - let reopened = try Library(url:url) - XCTAssertTrue(try reopened.members(of:venue).isEmpty) - XCTAssertEqual(try reopened.history(venue:venue).count,1) - } - func testQueuePlaylistsPreferencesAndDeletion() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let db = try Library(url:root.appendingPathComponent("db.sqlite")) - try db.add(title:"First",audio:"/1.mp3",cdg:nil) - try db.add(title:"Second",audio:"/2.mp3",cdg:nil) - let songs = try db.songs() - try db.addEntity("singers",name:"Alex"); try db.addEntity("venues",name:"Hall"); try db.addEntity("venues",name:"Club") - let singer = try XCTUnwrap(db.entities("singers").first?.id) - let hall = try XCTUnwrap(db.entities("venues").first(where: { $0.name == "Hall" })?.id) - let club = try XCTUnwrap(db.entities("venues").first(where: { $0.name == "Club" })?.id) - XCTAssertThrowsError(try db.enqueue(song:songs[0].id,singer:singer,venue:hall)) - try db.setMembership(singer:singer,venue:hall,included:true) - try db.enqueue(song:songs[0].id,singer:singer,venue:hall); try db.enqueue(song:songs[1].id,singer:singer,venue:hall) - XCTAssertTrue(try db.queue(venue:club).isEmpty) - let second = try XCTUnwrap(db.queue(venue:hall).last) - try db.moveQueue(second.id,venue:hall,by:-1) - XCTAssertEqual(try db.queue(venue:hall).first?.songID,songs[1].id) - let preference = SongPreference(pitch:3,tempo:0.85,rating:4) - try db.savePreference(song:songs[0].id,singer:singer,value:preference) - XCTAssertEqual(try db.preference(song:songs[0].id,singer:singer),preference) - XCTAssertThrowsError(try db.savePreference(song:songs[0].id,singer:singer,value:.init(pitch:99))) - try db.addEntity("playlists",name:"Party") - let playlist = try XCTUnwrap(db.entities("playlists").first?.id) - try db.addToPlaylist(playlist,song:songs[0].id); try db.addToPlaylist(playlist,song:songs[0].id) - XCTAssertEqual(try db.playlistSongIDs(playlist),[songs[0].id]) - try db.record(songs[0].id,singer:singer,venue:hall) - try db.rename("singers",id:singer,name:"Alex Jones") - XCTAssertEqual(try db.history(venue:hall).first?.singer,"Alex Jones") - try db.deleteEntity("singers",id:singer) - XCTAssertTrue(try db.queue(venue:hall).isEmpty) - XCTAssertEqual(try db.history(venue:hall).count,1) - try db.selectVenue(hall); try db.deleteEntity("venues",id:hall) - XCTAssertNil(try db.currentVenue()); XCTAssertEqual(try db.history(venue:nil).count,1) - } - @MainActor func testTempoSourceClockPauseAndResume() async throws { - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let player = Player(); defer { player.stop() } - let song = Song(id:1,title:"Demo",audio:fixtures.appendingPathComponent("Demo.mp3").path,cdg:fixtures.appendingPathComponent("Demo.cdg").path,rating:0,plays:0) - try player.load(song,preference:.init(pitch:2,tempo:1.5,rating:3)) - XCTAssertEqual(player.pitch,2); XCTAssertEqual(player.tempo,1.5) - try await Task.sleep(nanoseconds:500_000_000) - XCTAssertGreaterThan(player.time,0.45); XCTAssertLessThan(player.time,1.3) - player.toggle(); let paused = player.time - try await Task.sleep(nanoseconds:100_000_000) - XCTAssertEqual(player.time,paused,accuracy:0.025) - player.seek(1.5); player.toggle() - try await Task.sleep(nanoseconds:200_000_000) - XCTAssertGreaterThan(player.time,1.6); XCTAssertNotNil(player.image) - } - func testNewTestMediaMetadataAndCDGPairImport() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let db = try Library(url:root.appendingPathComponent("db.sqlite")) - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let importer = Importer(media:root.appendingPathComponent("Media")) - try importer.run([fixtures.appendingPathComponent("TestTrack.cdg")],library:db) - let song = try XCTUnwrap(db.songs().first) - XCTAssertEqual(song.title,"MP3 Plus G Test") - XCTAssertEqual(song.artist,"KJamsClone Test Generator") - XCTAssertNotNil(song.cdg) - let bytes = try Data(contentsOf:fixtures.appendingPathComponent("TestTrack.cdg")) - XCTAssertEqual(bytes.count,20*300*24) - var decoder = CDGDecoder(); decoder.render(bytes,at:2) - XCTAssertTrue(decoder.pixels.contains(1)); XCTAssertTrue(decoder.pixels.contains(2)) - } - @MainActor func testAutomaticVenueQueueAdvancesAndRecordsSinger() async throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - defer { try? FileManager.default.removeItem(at:root) } - let model = AppModel(storageURL:root); defer { model.player.stop() } - _ = try model.createEntity(.venue,name:"Test Hall") - _ = try model.createEntity(.singer,name:"Alex") - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - model.importFiles([fixtures.appendingPathComponent("Demo.zip")]) - let song = try XCTUnwrap(model.songs.first) - model.enqueue(song.id); model.enqueue(song.id); model.playQueueNext() - XCTAssertEqual(model.queue.count,1); XCTAssertEqual(model.history.count,1) - model.player.seek(model.player.duration-0.1) - for _ in 0..<25 { - if model.queue.isEmpty { break } - try await Task.sleep(nanoseconds:100_000_000) - } - XCTAssertNil(model.error); XCTAssertTrue(model.queue.isEmpty) - XCTAssertEqual(model.history.count,2); XCTAssertEqual(model.history.first?.singer,"Alex") - } - func testWaveformRepresentsSilenceAndSignalInTimeOrder() throws { - let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:folder,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:folder) } - let url = folder.appendingPathComponent("signal.wav") - let format = try XCTUnwrap(AVAudioFormat(standardFormatWithSampleRate:8000,channels:1)) - do { - let file = try AVAudioFile(forWriting:url,settings:format.settings) - let buffer = try XCTUnwrap(AVAudioPCMBuffer(pcmFormat:format,frameCapacity:4096)); buffer.frameLength = 4096 - let samples = try XCTUnwrap(buffer.floatChannelData?[0]) - for i in 0..<4096 { samples[i] = i < 2048 ? 0 : Float(sin(Double(i)*0.2)*0.5) } - try file.write(from:buffer) - } - let envelope = try AudioWaveform.read(url:url,bins:32) - XCTAssertEqual(envelope.count,32) - XCTAssertTrue(envelope.prefix(16).allSatisfy { $0 == 0 }) - XCTAssertTrue(envelope.suffix(16).allSatisfy { $0 > 0.8 && $0 <= 1 }) - XCTAssertThrowsError(try AudioWaveform.read(url:url,cancelled:{true})) - } - @MainActor func testWaveformAnalysisAndStopClearsTrackData() async throws { - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let player = Player(); defer { player.stop() } - try player.load(Song(id:1,title:"Demo",audio:fixtures.appendingPathComponent("Demo.mp3").path,cdg:nil,rating:0,plays:0)) - player.toggle() - for _ in 0..<50 { - if !player.waveformLoading { break } - try await Task.sleep(nanoseconds:20_000_000) - } - XCTAssertEqual(player.waveform.count,4096) - XCTAssertFalse(player.waveformUnavailable) - player.stop() - XCTAssertTrue(player.waveform.isEmpty) - XCTAssertFalse(player.waveformLoading) - try await Task.sleep(nanoseconds:50_000_000) - XCTAssertTrue(player.waveform.isEmpty) - } - - @MainActor func testConnectedSingerCreationAndSharedRepertoire() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - defer { try? FileManager.default.removeItem(at:root) } - let model = AppModel(storageURL:root) - let hall = try model.createEntity(.venue,name:"Hall") - try model.library?.add(title:"Song",audio:"/sample.mp3",cdg:nil);try model.refresh() - let song = try XCTUnwrap(model.songs.first?.id) - let alex = try model.createSinger(name:" Alex ",venue:hall,songs:[song]) - XCTAssertEqual(model.selectedSinger,alex);XCTAssertEqual(model.currentVenue,hall) - XCTAssertEqual(model.venueSingers.map(\.id),[alex]);XCTAssertEqual(model.songs(for:alex).map(\.id),[song]) - XCTAssertThrowsError(try model.createSinger(name:"Broken",venue:hall,songs:[999999])) - XCTAssertFalse(try XCTUnwrap(model.library).entities("singers").contains { $0.name == "Broken" }) - let club = try model.createEntity(.venue,name:"Club");model.membership(singer:alex,included:true) - XCTAssertEqual(model.songs(for:alex).map(\.id),[song]) - model.assign(song,to:alex);XCTAssertEqual(model.songs(for:alex).count,1) - let reopened = AppModel(storageURL:root) - XCTAssertEqual(reopened.currentVenue,club);XCTAssertEqual(reopened.songs(for:alex).map(\.id),[song]) - reopened.assign(song,to:alex,included:false) - XCTAssertTrue(AppModel(storageURL:root).songs(for:alex).isEmpty) - } - func testQueueRemembersSingerSongWithoutDuplicatingAssignment() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let db = try Library(url:root.appendingPathComponent("db.sqlite")) - try db.addEntity("singers",name:"Alex");try db.addEntity("venues",name:"Hall") - try db.add(title:"Song",audio:"/a.mp3",cdg:nil) - let singer = try XCTUnwrap(db.entities("singers").first?.id),venue = try XCTUnwrap(db.entities("venues").first?.id),song = try XCTUnwrap(db.songs().first?.id) - try db.setMembership(singer:singer,venue:venue,included:true) - try db.enqueue(song:song,singer:singer,venue:venue);try db.enqueue(song:song,singer:singer,venue:venue) - XCTAssertEqual(try db.singerSongIDs()[singer],[song]);XCTAssertEqual(try db.queue(venue:venue).count,2) - try db.removeSingerSong(song,singer:singer) - XCTAssertNil(try db.singerSongIDs()[singer]);XCTAssertEqual(try db.songs().count,1) - } - func testFrequencyBandsDistinguishBassAndTreble() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let url = root.appendingPathComponent("bands.wav") - let format = try XCTUnwrap(AVAudioFormat(standardFormatWithSampleRate:16000,channels:1)) - do { - let file = try AVAudioFile(forWriting:url,settings:format.settings) - let buffer = try XCTUnwrap(AVAudioPCMBuffer(pcmFormat:format,frameCapacity:8192));buffer.frameLength = 8192 - for i in 0..<8192 { buffer.floatChannelData![0][i] = Float(sin(Double(i)*2*Double.pi*(i < 4096 ? 80 : 6000)/16000)*0.2) } - try file.write(from:buffer) - } - let analysis = try AudioWaveform.analyse(url:url,bins:32) - XCTAssertGreaterThan(analysis.bands[8].low,analysis.bands[8].high*3) - XCTAssertGreaterThan(analysis.bands[24].high,analysis.bands[24].low*3) - } - private func toneRMS(frequency: Double, low: Double = 0, filter: Double = 0, enabled: Bool = true) throws -> Double { - let engine = AVAudioEngine(),node = AVAudioPlayerNode(),eq = AVAudioUnitEQ(numberOfBands:4) - let format = try XCTUnwrap(AVAudioFormat(standardFormatWithSampleRate:44100,channels:1)) - engine.attach(node);engine.attach(eq);engine.connect(node,to:eq,format:format);engine.connect(eq,to:engine.mainMixerNode,format:format) - AudioTone.configure(eq,sampleRate:44100,low:low,mid:0,high:0,filter:filter,enabled:enabled) - try engine.enableManualRenderingMode(.offline,format:format,maximumFrameCount:1024) - let input = try XCTUnwrap(AVAudioPCMBuffer(pcmFormat:format,frameCapacity:32768));input.frameLength = 32768 - for i in 0..<32768 { input.floatChannelData![0][i] = Float(sin(Double(i)*2*Double.pi*frequency/44100)*0.1) } - node.scheduleBuffer(input);try engine.start();node.play();defer { node.stop();engine.stop() } - let output = try XCTUnwrap(AVAudioPCMBuffer(pcmFormat:format,frameCapacity:1024)) - var energy: Double = 0,count = 0 - for block in 0..<12 { - let status = try engine.renderOffline(1024,to:output) - XCTAssertEqual(status,.success) - if block >= 2 { for i in 0.. String { metadata.first { $0.commonKey == key }?.stringValue ?? "" } - let taggedTitle = tag(.commonKeyTitle) - try library.add(title: taggedTitle.isEmpty ? audio.deletingPathExtension().lastPathComponent : taggedTitle, - audio: dest.path, cdg: graphics, artist: tag(.commonKeyArtist), album: tag(.commonKeyAlbumName), label: tag(.commonKeyPublisher)) - } - } - private func process(_ arguments: [String]) throws -> String { - let task = Process(); task.executableURL = URL(fileURLWithPath: "/usr/bin/unzip"); task.arguments = arguments - let out = Pipe(); task.standardOutput = out - let err = FileHandle.nullDevice; task.standardError = err - try task.run() - let bytes = out.fileHandleForReading.readDataToEndOfFile(); task.waitUntilExit() - guard task.terminationStatus == 0 else { throw LibraryError.message("Cannot read ZIP archive") } - return String(decoding: bytes, as: UTF8.self) - } -} diff --git a/backups/before-venues-20261102-231352/KJamsClone/KJamsCloneApp.swift b/backups/before-venues-20261102-231352/KJamsClone/KJamsCloneApp.swift deleted file mode 100644 index e448694..0000000 --- a/backups/before-venues-20261102-231352/KJamsClone/KJamsCloneApp.swift +++ /dev/null @@ -1,379 +0,0 @@ -import SwiftUI -import UniformTypeIdentifiers - -enum EntityKind: String, Identifiable { - case singer, venue - var id: String { rawValue } - var title: String { self == .singer ? "Singer" : "Venue" } - var table: String { self == .singer ? "singers" : "venues" } -} - -@MainActor final class AppModel: ObservableObject { - @Published var songs = [Song]() - @Published var singers = [PersonPlace]() - @Published var venues = [PersonPlace]() - @Published var error: String? - @Published var creating: EntityKind? - let player = Player() - private(set) var library: Library? - let root: URL - init(storageURL: URL? = nil) { - root = storageURL ?? FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0].appendingPathComponent("KJamsClone") - perform { - try FileManager.default.createDirectory(at: root, withIntermediateDirectories: true) - library = try Library(url: root.appendingPathComponent("Library.sqlite")); try refresh() - } - } - func perform(_ work: () throws -> Void) { do { try work() } catch { self.error = error.localizedDescription } } - func refresh() throws { guard let library else { return }; songs = try library.songs(); singers = try library.entities("singers"); venues = try library.entities("venues") } - @discardableResult func createEntity(_ kind: EntityKind, name: String) throws -> Int64 { - guard let library else { throw LibraryError.message("Library unavailable") } - let trimmed = name.trimmingCharacters(in: .whitespacesAndNewlines) - try library.addEntity(kind.table, name: trimmed) - try refresh() - let entities = kind == .singer ? singers : venues - guard let entity = entities.first(where: { $0.name == trimmed }) else { - throw LibraryError.message("The new \(kind.title.lowercased()) could not be loaded") - } - return entity.id - } - func importFiles(_ urls: [URL]) { perform { guard let library else { throw LibraryError.message("Library unavailable") }; try Importer(media: root.appendingPathComponent("Media")).run(urls, library: library); try refresh() } } -} -@main struct KJamsCloneApp: App { - @StateObject private var model = AppModel() - var body: some Scene { - Window("KJamsClone", id: "main") { - LibraryView(model: model).frame(minWidth: 1060, minHeight: 680).preferredColorScheme(.dark) - }.defaultSize(width: 1260, height: 840) - .commands { - CommandGroup(replacing: .newItem) { - Button("New Singer…") { model.creating = .singer }.keyboardShortcut("n", modifiers: [.command, .shift]) - Button("New Venue…") { model.creating = .venue }.keyboardShortcut("n", modifiers: [.command, .option]) - } - } - Window("Video", id: "lyrics") { - LyricsView(player: model.player).frame(minWidth: 480, minHeight: 320).preferredColorScheme(.dark) - }.defaultSize(width: 600, height: 400) - } -} -private enum Classic { - static let frame = Color(red: 0.15, green: 0.15, blue: 0.15) - static let navy = Color(red: 0.008, green: 0.065, blue: 0.16) - static let blue = Color(red: 0.015, green: 0.17, blue: 0.42) - static let header = Color(white: 0.115) - static let line = Color(white: 0.42) -} -struct LyricsView: View { - @ObservedObject var player: Player - var body: some View { - ZStack { - Color.black - if let image = player.image { - Image(decorative: image, scale: 1).interpolation(.none).resizable().aspectRatio(1.5, contentMode: .fit) - } - } - } -} -private struct SilverSquareStyle: ButtonStyle { - func makeBody(configuration: Configuration) -> some View { - configuration.label.foregroundStyle(Color(white: 0.25)).padding(.horizontal, 6).padding(.vertical, 3) - .background(LinearGradient(colors: [Color(white: 0.95), Color(white: 0.64)], startPoint: .top, endPoint: .bottom), in: RoundedRectangle(cornerRadius: 4)) - .overlay(RoundedRectangle(cornerRadius: 4).strokeBorder(Color(white: 0.45), lineWidth: 1.5)) - .overlay(RoundedRectangle(cornerRadius: 3).strokeBorder(.white.opacity(0.7)).padding(3)) - .opacity(configuration.isPressed ? 0.7 : 1) - } -} -private struct SilverButton: View { - let symbol: String - let label: String - var size: CGFloat = 40 - var active = false - var enabled = true - let action: () -> Void - var body: some View { - Button(action: action) { - Image(systemName: symbol).font(.system(size: size * 0.41, weight: .semibold)) - .foregroundStyle(active ? Color.blue : Color(white: 0.24)) - .frame(width: size, height: size) - .background(LinearGradient(colors: [.white, Color(white: 0.85), Color(white: 0.63)], startPoint: .top, endPoint: .bottom), in: Circle()) - .overlay(Circle().strokeBorder(Color(white: 0.45), lineWidth: 1.5)) - .overlay(Circle().strokeBorder(.white.opacity(0.65), lineWidth: 1).padding(3)) - .shadow(color: .black.opacity(0.7), radius: 1, y: 1) - }.buttonStyle(.plain).disabled(!enabled).opacity(enabled ? 1 : 0.72) - .help(label).accessibilityLabel(label) - } -} -struct LibraryView: View { - @ObservedObject var model: AppModel - @State private var selected: Int64? - @State private var singer: Int64? - @State private var venue: Int64? - @State private var search = "" - @State private var name = "" - @State private var importing = false - @State private var source = "Library" - @Environment(\.openWindow) private var openWindow - private var visibleSongs: [Song] { model.songs.filter { search.isEmpty || $0.title.localizedCaseInsensitiveContains(search) } } - private var selectedSong: Song? { model.songs.first { $0.id == selected } } - var body: some View { - VStack(spacing: 0) { - TransportView(player: model.player, search: $search, hasSelection: selectedSong != nil, - play: playSelected, next: playNext, display: { openWindow(id: "lyrics") }) - .padding(.horizontal, 18).padding(.top, 18).padding(.bottom, 22) - HSplitView { - sidebar.frame(minWidth: 190, idealWidth: 220, maxWidth: 240) - VStack(spacing: 12) { - if source == "Library" { songTable } else { directory } - detailPanel.frame(height: 84) - }.padding(.leading, 12).frame(minWidth: 780) - }.padding(.horizontal, 18) - footer.padding(.horizontal, 18).padding(.vertical, 12) - } - .background(Classic.frame) - .sheet(item: $model.creating) { kind in - AddEntitySheet(model: model, kind: kind) { id in - if kind == .singer { singer = id } else { venue = id } - } - } - .fileImporter(isPresented: $importing, allowedContentTypes: [.audio, .zip, UTType(filenameExtension: "cdg") ?? .data], allowsMultipleSelection: true) { result in - switch result { - case .success(let urls): model.importFiles(urls) - case .failure(let error): model.error = error.localizedDescription - } - } - .alert("KJamsClone", isPresented: Binding(get: { model.error != nil }, set: { if !$0 { model.error = nil } })) { - Button("OK") { model.error = nil } - } message: { Text(model.error ?? "") } - } - private var sidebar: some View { - VStack(alignment: .leading, spacing: 0) { - Text("Source").font(.system(size: 15, weight: .semibold)).padding(.horizontal, 10).frame(height: 31) - .frame(maxWidth: .infinity, alignment: .leading).background(Classic.header) - ForEach([("Library", "music.note.house.fill", Color.yellow), ("Singers", "person.2.fill", Color.green), ("Venues", "building.2.fill", Color.cyan)], id: \.0) { item in - Button { source = item.0 } label: { - HStack(spacing: 10) { - Image(systemName: item.1).foregroundStyle(item.2).frame(width: 22) - Text(item.0).font(.system(size: 16, weight: .medium)) - Spacer() - Text("\(item.0 == "Library" ? model.songs.count : item.0 == "Singers" ? model.singers.count : model.venues.count)") - .font(.system(size: 11)).foregroundStyle(.white.opacity(0.6)) - }.padding(.horizontal, 12).frame(height: 34).contentShape(Rectangle()) - .background(source == item.0 ? Color(red: 0, green: 0.36, blue: 1) : .clear) - }.buttonStyle(.plain) - } - Spacer() - }.foregroundStyle(.white).background(Classic.navy).overlay(Rectangle().stroke(Classic.line, lineWidth: 1)) - } - private var songTable: some View { - GeometryReader { geometry in - ScrollView(.horizontal) { - VStack(spacing: 0) { - tableHeader(width: max(geometry.size.width, 790)) - ScrollView(.vertical) { - LazyVStack(spacing: 0) { - ForEach(visibleSongs) { song in songRow(song, width: max(geometry.size.width, 790)) } - }.frame(maxWidth: .infinity, alignment: .topLeading) - } - }.frame(width: max(geometry.size.width, 790), height: geometry.size.height) - } - }.background(Classic.navy).overlay(Rectangle().stroke(Classic.line, lineWidth: 1)) - } - private func widths(_ total: CGFloat) -> [CGFloat] { - [42, max(200, total - 598), 100, 100, 76, 86, 72, 122] - } - private func tableHeader(width: CGFloat) -> some View { - let sizes = widths(width) - return HStack(spacing: 0) { - ForEach(Array(["PLI", "Song Name", "Artist", "Album", "Label", "Key Adjust", "Tempo", "Rating"].enumerated()), id: \.offset) { index, title in - Text(title).font(.system(size: 13, weight: .medium)).lineLimit(1) - .padding(.leading, 7).frame(width: sizes[index], height: 30, alignment: .leading) - .overlay(alignment: .trailing) { Rectangle().fill(Classic.line).frame(width: 1).padding(.vertical, 4) } - } - }.foregroundStyle(.white).background(Classic.header) - .overlay(alignment: .bottom) { Rectangle().fill(Color(white: 0.65)).frame(height: 1) } - } - private func songRow(_ song: Song, width: CGFloat) -> some View { - let sizes = widths(width) - return HStack(spacing: 0) { - Image(systemName: song.cdg == nil ? "music.note" : "music.note.tv") - .foregroundStyle(.white.opacity(0.75)).frame(width: sizes[0]) - Text(song.title).lineLimit(1).padding(.leading, 7).frame(width: sizes[1], alignment: .leading) - ForEach(2..<7) { index in - Text(index == 4 ? (song.cdg == nil ? "Audio" : "MP3+G") : "—") - .foregroundStyle(.white.opacity(0.5)).padding(.leading, 7).frame(width: sizes[index], alignment: .leading) - } - Menu { - ForEach(0..<6) { value in - Button(value == 0 ? "Unrated" : String(repeating: "★", count: value)) { - model.perform { try model.library?.rate(song.id, value); try model.refresh() } - } - } - } label: { - Text(song.rating == 0 ? "☆☆☆☆☆" : String(repeating: "★", count: song.rating) + String(repeating: "☆", count: 5 - song.rating)) - .font(.system(size: 13)).foregroundStyle(song.rating == 0 ? Color.gray : Color.yellow) - }.menuStyle(.borderlessButton).frame(width: sizes[7] - 14).padding(.horizontal, 7).help("Set song rating") - }.font(.system(size: 13)).foregroundStyle(.white).frame(height: 30) - .background(selected == song.id ? Color(red: 0, green: 0.28, blue: 0.72) : .clear) - .contentShape(Rectangle()).onTapGesture(count: 2) { selected = song.id; playSelected() } - .onTapGesture { selected = song.id } - } - private var directory: some View { - VStack(alignment: .leading, spacing: 0) { - HStack { - Text(source).font(.system(size: 14, weight: .semibold)) - Spacer() - Button(source == "Singers" ? "New Singer…" : "New Venue…") { model.creating = source == "Singers" ? .singer : .venue } - }.padding(.horizontal, 12).frame(height: 36).background(Classic.header) - ScrollView { - VStack(alignment: .leading, spacing: 0) { - ForEach(source == "Singers" ? model.singers : model.venues) { entity in - Button { - if source == "Singers" { singer = entity.id } else { venue = entity.id } - } label: { - HStack { Image(systemName: source == "Singers" ? "person.fill" : "building.2.fill"); Text(entity.name); Spacer() - if entity.id == (source == "Singers" ? singer : venue) { Image(systemName: "checkmark") } - }.padding(12).contentShape(Rectangle()) - }.buttonStyle(.plain) - } - } - } - HStack { - TextField(source == "Singers" ? "Singer name" : "Venue name", text: $name).textFieldStyle(.roundedBorder).onSubmit(addEntity) - Button("Add \(source == "Singers" ? "Singer" : "Venue")", action: addEntity).disabled(name.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty) - }.padding(12) - }.foregroundStyle(.white).background(Classic.navy).overlay(Rectangle().stroke(Classic.line, lineWidth: 1)) - } - private var detailPanel: some View { - VStack(alignment: .leading, spacing: 8) { - HStack(spacing: 16) { - Picker("Singer", selection: $singer) { Text("None").tag(nil as Int64?); ForEach(model.singers) { Text($0.name).tag(Optional($0.id)) } } - Button { model.creating = .singer } label: { Image(systemName: "plus.circle.fill") } - .buttonStyle(.plain).help("Add singer").accessibilityLabel("Add singer") - Picker("Venue", selection: $venue) { Text("None").tag(nil as Int64?); ForEach(model.venues) { Text($0.name).tag(Optional($0.id)) } } - Button { model.creating = .venue } label: { Image(systemName: "plus.circle.fill") } - .buttonStyle(.plain).help("Add venue").accessibilityLabel("Add venue") - Text(selectedSong.map { "\($0.plays) plays" } ?? "No song selected").foregroundStyle(.white.opacity(0.55)).font(.system(size: 11)) - } - SeekBar(player: model.player) - }.padding(12).frame(maxWidth: .infinity, maxHeight: .infinity) - .background(Classic.navy).overlay(Rectangle().stroke(Classic.line, lineWidth: 1)) - } - private var footer: some View { - HStack { - Button { importing = true } label: { Image(systemName: "plus").font(.system(size: 20, weight: .bold)).frame(width: 32, height: 24) } - .help("Import audio, MP3+G or ZIP").accessibilityLabel("Import songs") - RepeatButton(player: model.player).padding(.leading, 12) - Spacer() - Text("\(visibleSongs.count) \(visibleSongs.count == 1 ? "Song" : "Songs")").font(.system(size: 14, weight: .medium)) - Spacer() - Button { openWindow(id: "lyrics") } label: { Image(systemName: "rectangle.on.rectangle").frame(width: 32, height: 24) } - .help("Open video window").accessibilityLabel("Open video window") - }.buttonStyle(SilverSquareStyle()) - } - private func playSelected() { - guard let song = selectedSong else { return } - model.perform { try model.player.load(song); try model.library?.record(song.id, singer: singer, venue: venue); try model.refresh() } - } - private func playNext() { - guard !visibleSongs.isEmpty else { return } - let index = visibleSongs.firstIndex { $0.id == selected } ?? -1 - selected = visibleSongs[(index + 1) % visibleSongs.count].id; playSelected() - } - private func addEntity() { - model.perform { - let kind: EntityKind = source == "Singers" ? .singer : .venue - let id = try model.createEntity(kind, name: name) - if kind == .singer { singer = id } else { venue = id } - name = "" - } - } -} -private struct AddEntitySheet: View { - @ObservedObject var model: AppModel - let kind: EntityKind - let saved: (Int64) -> Void - @Environment(\.dismiss) private var dismiss - @State private var name = "" - @State private var error: String? - @FocusState private var focused: Bool - var body: some View { - VStack(alignment: .leading, spacing: 16) { - Text("New \(kind.title)").font(.title2.bold()) - TextField("\(kind.title) name", text: $name).textFieldStyle(.roundedBorder) - .focused($focused).onSubmit(save) - if let error { Text(error).foregroundStyle(.red).font(.callout) } - HStack { - Spacer() - Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction) - Button("Add \(kind.title)", action: save).keyboardShortcut(.defaultAction) - .disabled(name.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty) - } - }.padding(24).frame(width: 360).onAppear { focused = true } - } - private func save() { - do { let id = try model.createEntity(kind, name: name); saved(id); dismiss() } - catch { self.error = error.localizedDescription } - } -} -private struct TransportView: View { - @ObservedObject var player: Player - @Binding var search: String - let hasSelection: Bool - let play: () -> Void - let next: () -> Void - let display: () -> Void - var body: some View { - HStack(alignment: .top, spacing: 28) { - VStack(spacing: 15) { - HStack(spacing: 7) { - SilverButton(symbol: "backward.fill", label: "Back 10 seconds", size: 35, enabled: player.duration > 0) { player.seek(player.time - 10) } - SilverButton(symbol: player.playing ? "pause.fill" : "play.fill", label: player.playing ? "Pause" : "Play", size: 49, enabled: hasSelection || player.duration > 0) { - if player.duration > 0 { player.toggle() } else { play() } - } - SilverButton(symbol: "stop", label: "Stop", size: 46, enabled: player.duration > 0) { player.stop() } - SilverButton(symbol: "forward.fill", label: "Forward 10 seconds", size: 35, enabled: player.duration > 0) { player.seek(player.time + 10) } - SilverButton(symbol: "forward.end.fill", label: "Play next song", size: 26, enabled: hasSelection, action: next) - } - HStack(spacing: 9) { - Image(systemName: "speaker.fill").font(.system(size: 11)) - Slider(value: $player.volume, in: 0...1).controlSize(.small).tint(.gray).accessibilityLabel("Volume") - Image(systemName: "speaker.wave.3.fill").font(.system(size: 12)) - }.frame(width: 180) - }.frame(width: 220) - VStack(spacing: 0) { - Text(player.duration == 0 ? "Ready!" : player.title).font(.system(size: 15, weight: .medium)).lineLimit(1).padding(.horizontal, 20) - if player.duration > 0 { Text(player.playing ? "Playing" : "Paused").font(.system(size: 10)).foregroundStyle(.white.opacity(0.65)).padding(.top, 4) } - }.frame(maxWidth: .infinity).frame(height: 64) - .background(LinearGradient(colors: [Color(red: 0, green: 0.10, blue: 0.30), Classic.blue], startPoint: .top, endPoint: .bottom), in: Capsule()) - .overlay(Capsule().strokeBorder(LinearGradient(colors: [.black, .white], startPoint: .top, endPoint: .bottom), lineWidth: 1.5)) - .padding(.top, 14) - HStack(spacing: 12) { - TextField("Search", text: $search).textFieldStyle(.plain).font(.system(size: 16)) - .padding(.horizontal, 8).frame(width: 145, height: 28).background(Color(white: 0.07), in: RoundedRectangle(cornerRadius: 5)) - .overlay(RoundedRectangle(cornerRadius: 5).stroke(.white.opacity(0.1))) - SilverButton(symbol: "eye", label: "Open video window", size: 48, action: display) - }.padding(.top, 15) - }.foregroundStyle(.white).frame(height: 96) - } -} -private struct SeekBar: View { - @ObservedObject var player: Player - private func clock(_ seconds: Double) -> String { let n = Int(seconds); return String(format: "%d:%02d", n / 60, n % 60) } - var body: some View { - HStack(spacing: 10) { - Text(clock(player.time)) - Slider(value: Binding(get: { player.time }, set: { player.seek($0) }), in: 0...max(1, player.duration)) - .controlSize(.mini).tint(.gray).disabled(player.duration == 0).accessibilityLabel("Playback position") - Text(clock(player.duration)) - }.font(.system(size: 10, design: .monospaced)).foregroundStyle(.white.opacity(0.65)) - } -} -private struct RepeatButton: View { - @ObservedObject var player: Player - var body: some View { - Button { player.repeating.toggle() } label: { - Image(systemName: "repeat").font(.system(size: 18, weight: .semibold)) - .foregroundStyle(player.repeating ? Color.blue : Color(white: 0.25)).frame(width: 32, height: 24) - }.help(player.repeating ? "Repeat song: on" : "Repeat song: off").accessibilityLabel("Repeat song").accessibilityValue(player.repeating ? "On" : "Off") - } -} diff --git a/backups/before-venues-20261102-231352/KJamsClone/Library.swift b/backups/before-venues-20261102-231352/KJamsClone/Library.swift deleted file mode 100644 index 5bc07da..0000000 --- a/backups/before-venues-20261102-231352/KJamsClone/Library.swift +++ /dev/null @@ -1,196 +0,0 @@ -import Foundation -import SQLite3 - -struct Song: Identifiable, Hashable { - var id: Int64 - var title: String - var audio: String - var cdg: String? - var rating: Int - var plays: Int - var artist: String = "" - var album: String = "" - var label: String = "" -} -struct PersonPlace: Identifiable, Hashable { var id: Int64; var name: String } -struct SongPreference: Equatable { - var pitch: Double = 0 - var tempo: Double = 1 - var rating: Int = 0 -} -struct Performance: Identifiable { - var id: Int64 - var song: String - var singer: String - var venue: String - var date: String -} -struct QueueEntry: Identifiable { - var id: Int64 - var songID: Int64 - var singerID: Int64? - var title: String - var singer: String -} -enum LibraryError: LocalizedError { - case message(String) - var errorDescription: String? { if case .message(let s) = self { return s }; return nil } -} -final class Library { - private var db: OpaquePointer? - init(url: URL) throws { - guard sqlite3_open(url.path, &db) == SQLITE_OK else { throw LibraryError.message("Cannot open library") } - try execute("PRAGMA foreign_keys=ON") - try execute("CREATE TABLE IF NOT EXISTS songs(id INTEGER PRIMARY KEY,title TEXT NOT NULL,audio TEXT UNIQUE NOT NULL,cdg TEXT,rating INTEGER NOT NULL DEFAULT 0 CHECK(rating BETWEEN 0 AND 5),plays INTEGER NOT NULL DEFAULT 0)") - try execute("CREATE TABLE IF NOT EXISTS singers(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS venues(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS history(id INTEGER PRIMARY KEY,song INTEGER REFERENCES songs(id),singer INTEGER REFERENCES singers(id),venue INTEGER REFERENCES venues(id),played TEXT DEFAULT CURRENT_TIMESTAMP)") - // Additive migration: preserve older libraries and infer existing memberships from history. - for column in ["artist", "album", "label"] { - if try !columns("songs").contains(column) { try execute("ALTER TABLE songs ADD COLUMN \(column) TEXT NOT NULL DEFAULT ''") } - } - try execute("CREATE TABLE IF NOT EXISTS venue_singers(venue INTEGER NOT NULL REFERENCES venues(id) ON DELETE CASCADE,singer INTEGER NOT NULL REFERENCES singers(id) ON DELETE CASCADE,PRIMARY KEY(venue,singer))") - if try schemaVersion() < 3 { try execute("INSERT OR IGNORE INTO venue_singers SELECT DISTINCT venue,singer FROM history WHERE venue IS NOT NULL AND singer IS NOT NULL") } - try execute("CREATE TABLE IF NOT EXISTS settings(key TEXT PRIMARY KEY,value TEXT)") - try execute("CREATE TABLE IF NOT EXISTS preferences(song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,singer INTEGER NOT NULL REFERENCES singers(id) ON DELETE CASCADE,pitch REAL NOT NULL DEFAULT 0 CHECK(pitch BETWEEN -12 AND 12),tempo REAL NOT NULL DEFAULT 1 CHECK(tempo BETWEEN 0.5 AND 1.5),rating INTEGER NOT NULL DEFAULT 0 CHECK(rating BETWEEN 0 AND 5),PRIMARY KEY(song,singer))") - try execute("CREATE TABLE IF NOT EXISTS queue(id INTEGER PRIMARY KEY,venue INTEGER REFERENCES venues(id) ON DELETE CASCADE,song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,singer INTEGER REFERENCES singers(id) ON DELETE CASCADE,position INTEGER NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS playlists(id INTEGER PRIMARY KEY,name TEXT UNIQUE NOT NULL)") - try execute("CREATE TABLE IF NOT EXISTS playlist_songs(playlist INTEGER NOT NULL REFERENCES playlists(id) ON DELETE CASCADE,song INTEGER NOT NULL REFERENCES songs(id) ON DELETE CASCADE,position INTEGER NOT NULL,PRIMARY KEY(playlist,song))") - try execute("PRAGMA user_version=3") - } - deinit { sqlite3_close(db) } - private func statement(_ sql: String, _ values: [String?]) throws -> OpaquePointer { - var s: OpaquePointer? - guard sqlite3_prepare_v2(db, sql, -1, &s, nil) == SQLITE_OK, let s else { throw error() } - for (i,v) in values.enumerated() { - let code = v.map { sqlite3_bind_text(s, Int32(i + 1), $0, -1, unsafeBitCast(-1, to: sqlite3_destructor_type.self)) } ?? sqlite3_bind_null(s, Int32(i + 1)) - if code != SQLITE_OK { sqlite3_finalize(s); throw error() } - } - return s - } - private func error() -> LibraryError { .message(String(cString: sqlite3_errmsg(db))) } - func execute(_ sql: String, _ values: [String?] = []) throws { - let s = try statement(sql, values); defer { sqlite3_finalize(s) } - guard sqlite3_step(s) == SQLITE_DONE else { throw error() } - } - func songs() throws -> [Song] { - let s = try statement("SELECT id,title,audio,cdg,rating,plays,artist,album,label FROM songs ORDER BY title COLLATE NOCASE", []); defer { sqlite3_finalize(s) } - var result = [Song]() - while true { - let code = sqlite3_step(s); if code == SQLITE_DONE { break }; guard code == SQLITE_ROW else { throw error() } - result.append(Song(id: sqlite3_column_int64(s,0), title: String(cString: sqlite3_column_text(s,1)), audio: String(cString: sqlite3_column_text(s,2)), cdg: sqlite3_column_text(s,3).map { String(cString:$0) }, rating: Int(sqlite3_column_int(s,4)), plays: Int(sqlite3_column_int(s,5)), artist: text(s,6), album: text(s,7), label: text(s,8))) - } - return result - } - func add(title: String, audio: String, cdg: String?, artist: String = "", album: String = "", label: String = "") throws { - try execute("INSERT INTO songs(title,audio,cdg,artist,album,label) VALUES(?,?,?,?,?,?) ON CONFLICT(audio) DO UPDATE SET cdg=COALESCE(excluded.cdg,songs.cdg),artist=CASE WHEN excluded.artist!='' THEN excluded.artist ELSE songs.artist END,album=CASE WHEN excluded.album!='' THEN excluded.album ELSE songs.album END,label=CASE WHEN excluded.label!='' THEN excluded.label ELSE songs.label END", [title,audio,cdg,artist,album,label]) - } - func rate(_ id: Int64, _ rating: Int) throws { try execute("UPDATE songs SET rating=? WHERE id=?", [String(rating),String(id)]) } - func entities(_ table: String) throws -> [PersonPlace] { - precondition(["singers","venues","playlists"].contains(table)) - let s = try statement("SELECT id,name FROM \(table) ORDER BY name", []); defer { sqlite3_finalize(s) } - var rows = [PersonPlace]() - while sqlite3_step(s) == SQLITE_ROW { rows.append(.init(id: sqlite3_column_int64(s,0), name: String(cString: sqlite3_column_text(s,1)))) } - return rows - } - func addEntity(_ table: String, name: String) throws { - precondition(["singers","venues","playlists"].contains(table)) - let name = name.trimmingCharacters(in: .whitespacesAndNewlines) - guard !name.isEmpty else { throw LibraryError.message("Enter a name") } - try execute("INSERT OR IGNORE INTO \(table)(name) VALUES(?)", [name]) - } - func record(_ song: Int64, singer: Int64?, venue: Int64?) throws { - try execute("BEGIN IMMEDIATE") - do { - try execute("INSERT INTO history(song,singer,venue) VALUES(?,?,?)", [String(song),singer.map(String.init),venue.map(String.init)]) - try execute("UPDATE songs SET plays=plays+1 WHERE id=?", [String(song)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK"); throw error } - } - - private func text(_ s: OpaquePointer, _ index: Int32) -> String { sqlite3_column_text(s,index).map { String(cString:$0) } ?? "" } - private func schemaVersion() throws -> Int { - let s = try statement("PRAGMA user_version",[]); defer { sqlite3_finalize(s) } - return sqlite3_step(s) == SQLITE_ROW ? Int(sqlite3_column_int(s,0)) : 0 - } - private func columns(_ table: String) throws -> Set { - let s = try statement("PRAGMA table_info(\(table))", []); defer { sqlite3_finalize(s) } - var result = Set(); while sqlite3_step(s) == SQLITE_ROW { result.insert(text(s,1)) }; return result - } - func members(of venue: Int64) throws -> [PersonPlace] { - let s = try statement("SELECT singers.id,singers.name FROM singers JOIN venue_singers ON singers.id=venue_singers.singer WHERE venue=? ORDER BY name", [String(venue)]); defer { sqlite3_finalize(s) } - var result = [PersonPlace](); while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),name:text(s,1))) }; return result - } - func setMembership(singer: Int64, venue: Int64, included: Bool) throws { - try execute(included ? "INSERT OR IGNORE INTO venue_singers(venue,singer) VALUES(?,?)" : "DELETE FROM venue_singers WHERE venue=? AND singer=?", [String(venue),String(singer)]) - if !included { try execute("DELETE FROM queue WHERE venue=? AND singer=?",[String(venue),String(singer)]) } - } - func currentVenue() throws -> Int64? { - let s = try statement("SELECT venues.id FROM venues JOIN settings ON CAST(settings.value AS INTEGER)=venues.id WHERE settings.key='currentVenue'", []); defer { sqlite3_finalize(s) } - return sqlite3_step(s) == SQLITE_ROW ? sqlite3_column_int64(s,0) : nil - } - func selectVenue(_ id: Int64?) throws { - if let id { - guard try entities("venues").contains(where: { $0.id == id }) else { throw LibraryError.message("Venue no longer exists") } - } - try execute("INSERT INTO settings(key,value) VALUES('currentVenue',?) ON CONFLICT(key) DO UPDATE SET value=excluded.value",[id.map(String.init)]) - } - func rename(_ table: String, id: Int64, name: String) throws { - precondition(["singers","venues","playlists"].contains(table)) - let name = name.trimmingCharacters(in:.whitespacesAndNewlines) - guard !name.isEmpty else { throw LibraryError.message("Enter a name") } - try execute("UPDATE \(table) SET name=? WHERE id=?",[name,String(id)]) - } - func deleteEntity(_ table: String, id: Int64) throws { - precondition(["singers","venues","playlists"].contains(table)) - try execute("BEGIN IMMEDIATE") - do { - if table == "singers" { try execute("UPDATE history SET singer=NULL WHERE singer=?",[String(id)]) } - if table == "venues" { - try execute("UPDATE history SET venue=NULL WHERE venue=?",[String(id)]) - try execute("DELETE FROM settings WHERE key='currentVenue' AND value=?",[String(id)]) - } - try execute("DELETE FROM \(table) WHERE id=?",[String(id)]) - try execute("COMMIT") - } catch { try? execute("ROLLBACK"); throw error } - } - func preference(song: Int64, singer: Int64) throws -> SongPreference { - let s = try statement("SELECT pitch,tempo,rating FROM preferences WHERE song=? AND singer=?",[String(song),String(singer)]); defer { sqlite3_finalize(s) } - guard sqlite3_step(s) == SQLITE_ROW else { return .init() } - return .init(pitch:sqlite3_column_double(s,0),tempo:sqlite3_column_double(s,1),rating:Int(sqlite3_column_int(s,2))) - } - func savePreference(song: Int64, singer: Int64, value: SongPreference) throws { - try execute("INSERT INTO preferences(song,singer,pitch,tempo,rating) VALUES(?,?,?,?,?) ON CONFLICT(song,singer) DO UPDATE SET pitch=excluded.pitch,tempo=excluded.tempo,rating=excluded.rating",[String(song),String(singer),String(value.pitch),String(value.tempo),String(value.rating)]) - } - func history(venue: Int64?, singer: Int64? = nil) throws -> [Performance] { - let s = try statement("SELECT history.id,COALESCE(songs.title,'Deleted song'),COALESCE(singers.name,'—'),COALESCE(venues.name,'—'),played FROM history LEFT JOIN songs ON songs.id=history.song LEFT JOIN singers ON singers.id=history.singer LEFT JOIN venues ON venues.id=history.venue WHERE (? IS NULL OR history.venue=?) AND (? IS NULL OR history.singer=?) ORDER BY history.id DESC",[venue.map(String.init),venue.map(String.init),singer.map(String.init),singer.map(String.init)]); defer { sqlite3_finalize(s) } - var result = [Performance](); while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),song:text(s,1),singer:text(s,2),venue:text(s,3),date:text(s,4))) }; return result - } - func enqueue(song: Int64, singer: Int64?, venue: Int64?) throws { - guard let venue else { throw LibraryError.message("Select a current venue before adding to its queue") } - if let singer, try !members(of:venue).contains(where: { $0.id == singer }) { throw LibraryError.message("Add this singer to the current venue first") } - try execute("INSERT INTO queue(venue,song,singer,position) VALUES(?,?,?,(SELECT COALESCE(MAX(position),0)+1 FROM queue WHERE venue=?))",[String(venue),String(song),singer.map(String.init),String(venue)]) - } - func queue(venue: Int64?) throws -> [QueueEntry] { - guard let venue else { return [] } - let s = try statement("SELECT queue.id,queue.song,queue.singer,songs.title,COALESCE(singers.name,'No singer') FROM queue JOIN songs ON songs.id=queue.song LEFT JOIN singers ON singers.id=queue.singer WHERE queue.venue=? ORDER BY position,id",[String(venue)]); defer { sqlite3_finalize(s) } - var result = [QueueEntry](); while sqlite3_step(s) == SQLITE_ROW { result.append(.init(id:sqlite3_column_int64(s,0),songID:sqlite3_column_int64(s,1),singerID:sqlite3_column_type(s,2) == SQLITE_NULL ? nil : sqlite3_column_int64(s,2),title:text(s,3),singer:text(s,4))) }; return result - } - func removeQueue(_ id: Int64) throws { try execute("DELETE FROM queue WHERE id=?",[String(id)]) } - func moveQueue(_ id: Int64, venue: Int64, by offset: Int) throws { - var rows = try queue(venue:venue) - guard let index = rows.firstIndex(where: { $0.id == id }), rows.indices.contains(index+offset) else { return } - rows.swapAt(index,index+offset) - try execute("BEGIN IMMEDIATE") - do { for (i,row) in rows.enumerated() { try execute("UPDATE queue SET position=? WHERE id=?",[String(i),String(row.id)]) }; try execute("COMMIT") } - catch { try? execute("ROLLBACK"); throw error } - } - func addToPlaylist(_ playlist: Int64, song: Int64) throws { - try execute("INSERT OR IGNORE INTO playlist_songs(playlist,song,position) VALUES(?,?,(SELECT COALESCE(MAX(position),0)+1 FROM playlist_songs WHERE playlist=?))",[String(playlist),String(song),String(playlist)]) - } - func playlistSongIDs(_ playlist: Int64) throws -> [Int64] { - let s = try statement("SELECT song FROM playlist_songs WHERE playlist=? ORDER BY position",[String(playlist)]); defer { sqlite3_finalize(s) } - var ids = [Int64](); while sqlite3_step(s) == SQLITE_ROW { ids.append(sqlite3_column_int64(s,0)) }; return ids - } - func removeFromPlaylist(_ playlist: Int64, song: Int64) throws { try execute("DELETE FROM playlist_songs WHERE playlist=? AND song=?",[String(playlist),String(song)]) } -} diff --git a/backups/before-venues-20261102-231352/KJamsClone/Player.swift b/backups/before-venues-20261102-231352/KJamsClone/Player.swift deleted file mode 100644 index 54b56af..0000000 --- a/backups/before-venues-20261102-231352/KJamsClone/Player.swift +++ /dev/null @@ -1,92 +0,0 @@ -import SwiftUI -import AVFoundation - -/// Audio source-frame time drives CDG, including when the time-pitch unit changes tempo. -@MainActor final class Player: ObservableObject { - @Published var image: CGImage? - @Published var playing = false - @Published var time: Double = 0 - @Published var duration: Double = 0 - @Published var title = "Select a song" - @Published var volume: Double = 0.8 { didSet { engine.mainMixerNode.outputVolume = Float(volume) } } - @Published var repeating = false - @Published var pitch: Double = 0 { didSet { effect.pitch = Float(pitch * 100) } } - @Published var tempo: Double = 1 { didSet { effect.rate = Float(tempo) } } - @Published var graphicsOffset: Double = 0 - private(set) var currentSongID: Int64? - var onFinished: (() -> Void)? - private let engine = AVAudioEngine() - private let node = AVAudioPlayerNode() - private let effect = AVAudioUnitTimePitch() - private var file: AVAudioFile? - private var anchor: Double = 0 - private var generation = UUID() - private var cdg = Data() - private var decoder = CDGDecoder() - private var timer: Timer? - init() { engine.attach(node); engine.attach(effect) } - func load(_ song: Song, preference: SongPreference = .init()) throws { - stop() - do { - let loaded = try AVAudioFile(forReading: URL(fileURLWithPath:song.audio)) - let graphics = try song.cdg.map { try Data(contentsOf:URL(fileURLWithPath:$0)) } ?? Data() - guard loaded.length > 0 else { throw LibraryError.message("Audio file is empty") } - engine.connect(node,to:effect,format:loaded.processingFormat) - engine.connect(effect,to:engine.mainMixerNode,format:loaded.processingFormat) - file = loaded; cdg = graphics; decoder = CDGDecoder() - duration = Double(loaded.length) / loaded.processingFormat.sampleRate - title = song.title; currentSongID = song.id - pitch = preference.pitch; tempo = preference.tempo - engine.mainMixerNode.outputVolume = Float(volume) - engine.prepare(); try engine.start() - schedule(at:0, play:true); startTimer(); tick() - } catch { stop(); throw error } - } - private func schedule(at seconds: Double, play: Bool) { - guard let file else { return } - generation = UUID(); let token = generation - node.stop() - let rate = file.processingFormat.sampleRate - let start = min(file.length, max(0, AVAudioFramePosition(seconds * rate))) - anchor = Double(start) / rate; time = anchor - guard start < file.length else { playing = false; render(); return } - node.scheduleSegment(file, startingFrame:start, frameCount:AVAudioFrameCount(min(file.length-start,Int64(UInt32.max))), at:nil, completionCallbackType:.dataPlayedBack) { [weak self] _ in - Task { @MainActor in - guard let self, self.generation == token else { return } - if self.repeating { self.schedule(at:0,play:true) } - else { - self.playing = false; self.time = self.duration; self.render() - self.timer?.invalidate(); self.timer = nil; self.onFinished?() - } - } - } - if play { node.play() }; playing = play; render() - } - private func startTimer() { - timer?.invalidate() - timer = Timer.scheduledTimer(withTimeInterval:1.0/30,repeats:true) { [weak self] _ in Task { @MainActor in self?.tick() } } - } - func toggle() { - guard file != nil else { return } - if playing { tick(); node.pause(); playing = false } - else if time >= duration { schedule(at:0,play:true); startTimer() } - else { node.play(); playing = true; startTimer() } - } - func stop() { - generation = UUID(); timer?.invalidate(); timer = nil; node.stop(); engine.stop() - engine.disconnectNodeOutput(node); engine.disconnectNodeOutput(effect) - file = nil; playing = false; time = 0; anchor = 0; duration = 0; image = nil; currentSongID = nil; title = "Select a song" - } - func seek(_ value: Double) { - guard file != nil, value.isFinite else { return } - schedule(at:min(max(value,0),duration), play:playing) - startTimer() - } - private func render() { decoder.render(cdg,at:max(0,time+graphicsOffset)); image = cdg.isEmpty ? nil : decoder.image() } - private func tick() { - if playing, let file, let renderTime = node.lastRenderTime, let playerTime = node.playerTime(forNodeTime:renderTime) { - time = min(duration,anchor + Double(playerTime.sampleTime) / file.processingFormat.sampleRate) - } - render() - } -} diff --git a/backups/before-venues-20261102-231352/KJamsCloneTests/KJamsCloneTests.swift b/backups/before-venues-20261102-231352/KJamsCloneTests/KJamsCloneTests.swift deleted file mode 100644 index 0b1e3de..0000000 --- a/backups/before-venues-20261102-231352/KJamsCloneTests/KJamsCloneTests.swift +++ /dev/null @@ -1,100 +0,0 @@ -import XCTest -@testable import KJamsClone - -final class KJamsCloneTests: XCTestCase { - func packet(_ instruction: UInt8, _ data: [UInt8]) -> [UInt8] { [9,instruction,0,0] + Array((data + Array(repeating: 0,count:16)).prefix(16)) + [0,0,0,0] } - func testPresetTileXORAndInvalidCoordinates() { - var d = CDGDecoder() - d.apply(packet(1,[3,0])); XCTAssertEqual(d.pixels[0],3) - d.apply(packet(6,[0,5,1,1] + Array(repeating:63,count:12))) - XCTAssertEqual(d.pixels[12*300+6],5) - d.apply(packet(38,[0,5,1,1] + Array(repeating:63,count:12))) - XCTAssertEqual(d.pixels[12*300+6],0) - let old = d.pixels; d.apply(packet(6,[1,2,31,63])); XCTAssertEqual(d.pixels,old) - } - func testSeekAndTruncatedPacket() { - var d = CDGDecoder() - let data = Data(packet(1,[2,0]) + packet(1,[7,0]) + [9]) - d.render(data,at:1); XCTAssertEqual(d.pixels[0],7); XCTAssertEqual(d.packetIndex,2) - d.render(data,at:1.0/300); XCTAssertEqual(d.pixels[0],2) - d.render(data,at:0); XCTAssertEqual(d.pixels[0],0) - } - func testPaletteBorderScrollAndImage() { - var d = CDGDecoder() - d.apply(packet(30,[63,63])); XCTAssertEqual(d.palette[0],0xFFFFFFFF) - d.apply(packet(2,[4])); XCTAssertEqual(d.pixels[0],4); XCTAssertEqual(d.pixels[12*300+6],0) - d.apply(packet(20,[3,16,0])); XCTAssertEqual(d.pixels[100*300],3) - d.apply(packet(24,[0,32,0])); XCTAssertEqual(d.pixels[100*300+294],3) - XCTAssertEqual(d.image()?.width,288) - } - func testSQLitePersistenceDedupRatingsAndHistory() throws { - let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at: folder,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:folder) } - let url = folder.appendingPathComponent("test.sqlite") - do { - let db = try Library(url:url) - try db.add(title:"Singer's Song",audio:"/test.mp3",cdg:nil) - try db.add(title:"Duplicate",audio:"/test.mp3",cdg:"/test.cdg") - let song = try XCTUnwrap(db.songs().first) - try db.rate(song.id,5); XCTAssertThrowsError(try db.rate(song.id,6)) - try db.addEntity("singers",name:"O'Neil"); try db.addEntity("venues",name:"Hall") - try db.record(song.id,singer:db.entities("singers").first?.id,venue:db.entities("venues").first?.id) - } - let reopened = try Library(url:url); let songs = try reopened.songs() - XCTAssertEqual(songs.count,1); XCTAssertEqual(songs[0].rating,5); XCTAssertEqual(songs[0].plays,1); XCTAssertEqual(songs[0].cdg,"/test.cdg") - XCTAssertEqual(try reopened.entities("singers").first?.name,"O'Neil") - } - func testPairedImportAndContentDedup() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let audio = root.appendingPathComponent("Test.mp3"), cdg = root.appendingPathComponent("Test.CDG") - try Data([1,2,3]).write(to:audio); try Data(packet(1,[2,0])).write(to:cdg) - let db = try Library(url:root.appendingPathComponent("test.sqlite")) - let importer = Importer(media:root.appendingPathComponent("Media")) - try importer.run([audio],library:db); try importer.run([audio],library:db) - XCTAssertEqual(try db.songs().count,1) - XCTAssertNotNil(try db.songs().first?.cdg) - } - - func testZippedMP3GImportAndUnsafeArchiveRejection() throws { - let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:folder,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:folder) } - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let db = try Library(url:folder.appendingPathComponent("db.sqlite")) - let importer = Importer(media:folder.appendingPathComponent("Media")) - try importer.run([fixtures.appendingPathComponent("Demo.zip")],library:db) - let song = try XCTUnwrap(db.songs().first) - XCTAssertEqual(song.title,"Demo"); XCTAssertNotNil(song.cdg) - XCTAssertTrue(FileManager.default.fileExists(atPath:song.audio)) - XCTAssertThrowsError(try importer.run([fixtures.appendingPathComponent("Unsafe.zip")],library:db)) - } - @MainActor func testMP3PlaybackPauseAndSeek() throws { - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let player = Player() - defer { player.stop() } - try player.load(Song(id:1,title:"Demo",audio:fixtures.appendingPathComponent("Demo.mp3").path,cdg:fixtures.appendingPathComponent("Demo.cdg").path,rating:0,plays:0)) - XCTAssertGreaterThan(player.duration,3.9); XCTAssertTrue(player.playing) - player.toggle(); XCTAssertFalse(player.playing) - player.seek(2); XCTAssertEqual(player.time,2,accuracy:0.05); XCTAssertNotNil(player.image) - player.seek(0.1); XCTAssertEqual(player.time,0.1,accuracy:0.05) - } - @MainActor func testCreateSingerAndVenueThroughAppModel() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - defer { try? FileManager.default.removeItem(at: root) } - let model = AppModel(storageURL: root) - XCTAssertNil(model.error) - let singer = try model.createEntity(.singer, name: " Alex ") - let venue = try model.createEntity(.venue, name: "Town Hall") - XCTAssertEqual(model.singers.first?.name, "Alex") - XCTAssertEqual(model.venues.first?.name, "Town Hall") - XCTAssertEqual(try model.createEntity(.singer, name: "Alex"), singer) - XCTAssertEqual(model.singers.count, 1) - XCTAssertThrowsError(try model.createEntity(.venue, name: " ")) - let reopened = AppModel(storageURL: root) - XCTAssertEqual(reopened.singers.first?.id, singer) - XCTAssertEqual(reopened.venues.first?.id, venue) - } -} diff --git a/backups/before-venues-20261102-231352/README.md b/backups/before-venues-20261102-231352/README.md deleted file mode 100644 index 07a0f6c..0000000 --- a/backups/before-venues-20261102-231352/README.md +++ /dev/null @@ -1,71 +0,0 @@ -# KJamsClone — initial macOS implementation, v0.1.0 - -This is a real Xcode application project, not a Swift Package renamed as one. -Open **KJamsClone.xcodeproj**. Its required project file is -**KJamsClone.xcodeproj/project.pbxproj**. No version-control restoration, -project generator, third-party packages, or network downloads are needed. - -## Start - -1. Extract the whole source ZIP to a writable folder. Do not open the project from inside the archive. -2. Open `KJamsClone/KJamsClone.xcodeproj` in Xcode, select the **KJamsClone** scheme and **My Mac**, then Run. -3. Click the **+ import button** and select `Fixtures/Demo.zip` for an original four-second tone and animated tile demonstration. This is a decoder demonstration, not a song with lyrics. -4. Double-click the imported song. Use the **eye button** to open the Video window, then move it onto another monitor or use macOS's window fullscreen control. -5. Double-click a library row to play it; the large Play/Pause button resumes or pauses the current track. The smaller transport buttons seek back/forward ten seconds and play the next song. The volume slider and repeat button control actual playback. Use the + button to import and the eye button to open the Video window. -6. Import your own `.mp3` and matching `.cdg` files, or a ZIP containing those files. Names must match, ignoring case, in the same folder. Select the audio file; its sibling CDG is found automatically. Audio-only MP3/WAV/M4A and WAV+G are also accepted. - -App deployment target: macOS 13+. Verified here with Xcode 27.2 on Apple Silicon macOS 27.2; older systems and Intel execution have not been tested. The build produces arm64 and x86_64 slices. XCTest execution with this Xcode may require macOS 14+. - -## Implemented - -| Feature | Scope | -| --- | --- | -| macOS app | Screenshot-inspired charcoal/silver controls, navy source sidebar and library grid, blue status capsule, library/search, rating menu, separate Video window | -| MP3+G | AVAudioPlayer master clock; CDG packets decoded at 300 packets/sec; play, pause, resume, stop, seek, volume and repeat | -| CDG | Memory/border preset, normal/XOR tiles, low/high palette, scroll preset/copy with fine offsets, transparent color; 288×192 cropped graphics | -| ZIP import | Automatic extraction and pairing, nested folders, traversal/symlink rejection; system `/usr/bin/unzip` | -| Library | SQLite persistence, copied media, SHA-256 audio-content deduplication for the same extension, search by filename title | -| Ratings | Persistent per-song 0–5 stars | -| Singers / venues | Create, list, select; persistent SQLite records | -| Play history | Song/singer/venue/timestamp stored on each new song start; play counts shown | -| Tests | Eight XCTest cases covering decoder behavior, backward seeking, SQLite reopening, ratings, play counts, pair/dedup import, ZIP import/rejection, real MP3 loading/pause/seeking | -| Scripts | Debug build, tests, unsigned Release app ZIP | - -Library and copied media are stored under `~/Library/Application Support/KJamsClone/`. -Imported source files remain untouched. Back up that entire folder together; paths are absolute. -No music catalogue or copyrighted songs are included. Demo tone/graphics are original and may be used freely. - -## Incomplete / unverified - -This is **not a complete kJams replacement or production-qualified release**. -There is no singer rotation queue, playlist management, history browser, singer/venue editing or deletion, per-singer ratings/preferences, pitch/tempo adjustment, crossfade, key detection, metadata tag parsing, physical CD ripping, or standalone CDG-only playback. Titles come from filenames. The rating is global per song. Play counts count playback starts, not completed performances. - -Synthetic fixtures and automated MP3 checks passed; real commercial karaoke collections, long performances, audible output quality, visual lyric accuracy, external monitors, and full UI interactions have not been manually validated. The decoder ignores parity/error correction, unsupported instructions and channel selection; all tile channels are combined. CDG has no adjustable synchronization offset. Backward seeking rebuilds graphics from packet zero on the main thread. Large imports also run on the main thread, without progress/cancel controls or archive expansion limits; use trusted, reasonably sized archives. Importing multiple files is not one database/filesystem transaction. A failed import may leave copied media to clean up. The app is intentionally not sandboxed, signed for distribution, or notarized. It has the default macOS application icon. - -## Build, test, release - -Run from this extracted project folder: - -```sh -./scripts/build.sh -./scripts/test.sh -./scripts/release.sh -``` - -Scripts work from any working directory and stop on failure. Build products go under `build/` and `build-release/`; release output is `dist/KJamsClone-unsigned-macOS.zip`. Release builds disable signing. Developer ID signing and Apple notarization must be added before distributing the app to other users. The source ZIP contains neither personal media nor your library database. - -`../../docs/VERIFICATION.md` records the checks performed on this delivery. `verification/` contains the corresponding build/test excerpts. - -## Implementation reference - -CDG packet layout and commands were implemented using Jim Bumgardner's [CD+G Revealed](https://jbum.com/cdg_revealed.html) as a format reference. The implementation is original Swift code; no third-party player source is bundled. - -## Screenshot-inspired interface - -The interface follows the supplied reference: charcoal frame, silver transport controls, blue status capsule, navy panes, compact column headings, source selection and bottom song count. Library, Singers and Venues are functional sources. Third-party music stores and playlists from the reference are not implemented. Artist, Album, Key Adjust and Tempo columns show dashes because those features are not available; the Label column identifies the imported format. Rating menus persist changes. The separate Video window remains black when no graphics are loaded. - -## Single main window and adding people / places - -The app uses a single main library window; the File menu has no New Window command. The optional Video display remains separate for karaoke output. - -Choose **File → New Singer…** or **File → New Venue…**, enter a name, then click Add. You can also use **New Singer… / New Venue…** at the top of the matching source pane, or the + button beside the singer/venue selector. New entries save to SQLite, appear immediately, and become selected for subsequent playback. Empty names are rejected, and adding an existing name selects its existing record. diff --git a/backups/before-venues-20261102-231352/verification/ui-preview.png b/backups/before-venues-20261102-231352/verification/ui-preview.png deleted file mode 100644 index 743dfe5..0000000 Binary files a/backups/before-venues-20261102-231352/verification/ui-preview.png and /dev/null differ diff --git a/backups/before-venues-20261102-231352/verification/xcode-test.log b/backups/before-venues-20261102-231352/verification/xcode-test.log deleted file mode 100644 index 48799b5..0000000 --- a/backups/before-venues-20261102-231352/verification/xcode-test.log +++ /dev/null @@ -1,335 +0,0 @@ -Command line invocation: - /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project KJamsClone.xcodeproj -scheme KJamsClone -configuration Debug -destination platform=macOS -derivedDataPath "/Users/markgregory/Documents/ChatGPT/KJams Clone/KJamsClone/build" CODE_SIGNING_ALLOWED=NO test - -Build settings from command line: - CODE_SIGNING_ALLOWED = NO - ---- xcodebuild: WARNING: Using the first of multiple matching destinations: -{ platform:macOS, arch:arm64, id:00006030-000C01641102001C, name:My Mac } -{ platform:macOS, arch:x86_64, id:00006030-000C01641102001C, name:My Mac } -ComputePackagePrebuildTargetDependencyGraph - -Prepare packages - -CreateBuildRequest - -SendProjectDescription - -CreateBuildOperation - -ComputeTargetDependencyGraph -note: Building targets in dependency order -note: Target dependency graph (2 targets) - Target 'KJamsCloneTests' in project 'KJamsClone' - ➜ Explicit dependency on target 'KJamsClone' in project 'KJamsClone' - Target 'KJamsClone' in project 'KJamsClone' (no dependencies) - -GatherProvisioningInputs - -CreateBuildDescription - -ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc --version - -ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -v -E -dM -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -x c -c /dev/null - -ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld -version_details - -Build description signature: a878cb40dda8511ba7445beb2d96bb25 -Build description path: /Users/markgregory/Documents/ChatGPT/KJams Clone/KJamsClone/build/Build/Intermediates.noindex/XCBuildData/a878cb40dda8511ba7445beb2d96bb25.xcbuilddata -ClangStatCache /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-stat-cache /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-a7ff82d74745d5ef33555b35c4238456.sdkstatcache - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/KJamsClone.xcodeproj - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-stat-cache /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -o /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-a7ff82d74745d5ef33555b35c4238456.sdkstatcache - -SwiftDriver KJamsClone normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-SwiftDriver -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsClone -Onone @/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone.SwiftFileList -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target x86_64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -F /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-generated-files.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-own-target-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-project-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/DerivedSources-normal/x86_64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/DerivedSources/x86_64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone-Swift.h -working-directory /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone -experimental-emit-module-separately -disable-cmo - -SwiftDriver KJamsClone normal arm64 com.apple.xcode.tools.swift.compiler (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-SwiftDriver -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsClone -Onone @/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone.SwiftFileList -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target arm64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -F /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-generated-files.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-own-target-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-project-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/DerivedSources-normal/arm64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/DerivedSources/arm64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone-Swift.h -working-directory /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone -experimental-emit-module-separately -disable-cmo - -SwiftEmitModule normal x86_64 Emitting\ module\ for\ KJamsClone (in target 'KJamsClone' from project 'KJamsClone') - -SwiftCompile normal x86_64 (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - - -SwiftEmitModule normal arm64 Emitting\ module\ for\ KJamsClone (in target 'KJamsClone' from project 'KJamsClone') - -SwiftCompile normal arm64 (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - - -SwiftCompile normal arm64 Compiling\ KJamsCloneApp.swift /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/KJamsClone/KJamsCloneApp.swift (in target 'KJamsClone' from project 'KJamsClone') - -SwiftCompile normal arm64 /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/KJamsClone/KJamsCloneApp.swift (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-SwiftPerFileCompile KJamsCloneApp.swift - -SwiftCompile normal x86_64 Compiling\ KJamsCloneApp.swift /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/KJamsClone/KJamsCloneApp.swift (in target 'KJamsClone' from project 'KJamsClone') - -SwiftCompile normal x86_64 /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/KJamsClone/KJamsCloneApp.swift (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-SwiftPerFileCompile KJamsCloneApp.swift - -SwiftDriverJobDiscovery normal arm64 Emitting module for KJamsClone (in target 'KJamsClone' from project 'KJamsClone') - -SwiftDriver\ Compilation\ Requirements KJamsClone normal arm64 com.apple.xcode.tools.swift.compiler (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-Swift-Compilation-Requirements -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsClone -Onone @/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone.SwiftFileList -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target arm64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -F /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-generated-files.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-own-target-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-project-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/DerivedSources-normal/arm64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/DerivedSources/arm64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone-Swift.h -working-directory /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone -experimental-emit-module-separately -disable-cmo - -Copy /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/Project/arm64-apple-macos.swiftsourceinfo /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone.swiftsourceinfo (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone.swiftsourceinfo /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/Project/arm64-apple-macos.swiftsourceinfo - -SwiftDriverJobDiscovery normal x86_64 Emitting module for KJamsClone (in target 'KJamsClone' from project 'KJamsClone') - -SwiftDriver\ Compilation\ Requirements KJamsClone normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-Swift-Compilation-Requirements -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsClone -Onone @/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone.SwiftFileList -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target x86_64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -F /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-generated-files.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-own-target-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-project-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/DerivedSources-normal/x86_64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/DerivedSources/x86_64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone-Swift.h -working-directory /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone -experimental-emit-module-separately -disable-cmo - -Copy /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/arm64-apple-macos.swiftmodule /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone.swiftmodule (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone.swiftmodule /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/arm64-apple-macos.swiftmodule - -Copy /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/arm64-apple-macos.abi.json /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone.abi.json (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone.abi.json /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/arm64-apple-macos.abi.json - -Copy /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/x86_64-apple-macos.swiftmodule /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone.swiftmodule (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone.swiftmodule /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/x86_64-apple-macos.swiftmodule - -Copy /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/Project/x86_64-apple-macos.swiftsourceinfo /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone.swiftsourceinfo (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone.swiftsourceinfo /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/Project/x86_64-apple-macos.swiftsourceinfo - -Copy /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/x86_64-apple-macos.abi.json /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone.abi.json (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone.abi.json /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/x86_64-apple-macos.abi.json - -SwiftDriver KJamsCloneTests normal arm64 com.apple.xcode.tools.swift.compiler (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-SwiftDriver -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsCloneTests -Onone @/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests.SwiftFileList -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins/testing -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target arm64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -Isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -parse-as-library -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-generated-files.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-own-target-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-project-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/DerivedSources-normal/arm64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/DerivedSources/arm64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests-Swift.h -working-directory /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone -experimental-emit-module-separately -disable-cmo - -SwiftDriver KJamsCloneTests normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-SwiftDriver -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsCloneTests -Onone @/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests.SwiftFileList -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins/testing -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target x86_64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -Isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -parse-as-library -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-generated-files.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-own-target-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-project-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/DerivedSources-normal/x86_64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/DerivedSources/x86_64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests-Swift.h -working-directory /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone -experimental-emit-module-separately -disable-cmo - -SwiftEmitModule normal arm64 Emitting\ module\ for\ KJamsCloneTests (in target 'KJamsCloneTests' from project 'KJamsClone') - -SwiftCompile normal arm64 (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - - -SwiftEmitModule normal x86_64 Emitting\ module\ for\ KJamsCloneTests (in target 'KJamsCloneTests' from project 'KJamsClone') - -SwiftCompile normal x86_64 (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - - -SwiftCompile normal arm64 Compiling\ KJamsCloneTests.swift /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift (in target 'KJamsCloneTests' from project 'KJamsClone') - -SwiftCompile normal arm64 /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-SwiftPerFileCompile KJamsCloneTests.swift - -SwiftCompile normal x86_64 Compiling\ KJamsCloneTests.swift /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift (in target 'KJamsCloneTests' from project 'KJamsClone') - -SwiftCompile normal x86_64 /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-SwiftPerFileCompile KJamsCloneTests.swift - -SwiftDriverJobDiscovery normal arm64 Emitting module for KJamsCloneTests (in target 'KJamsCloneTests' from project 'KJamsClone') - -SwiftDriver\ Compilation\ Requirements KJamsCloneTests normal arm64 com.apple.xcode.tools.swift.compiler (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-Swift-Compilation-Requirements -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsCloneTests -Onone @/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests.SwiftFileList -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins/testing -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target arm64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -Isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -parse-as-library -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-generated-files.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-own-target-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-project-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/DerivedSources-normal/arm64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/DerivedSources/arm64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests-Swift.h -working-directory /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone -experimental-emit-module-separately -disable-cmo - -Copy /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsCloneTests.swiftmodule/Project/arm64-apple-macos.swiftsourceinfo /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests.swiftsourceinfo (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests.swiftsourceinfo /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsCloneTests.swiftmodule/Project/arm64-apple-macos.swiftsourceinfo - -SwiftDriverJobDiscovery normal x86_64 Emitting module for KJamsCloneTests (in target 'KJamsCloneTests' from project 'KJamsClone') - -Copy /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsCloneTests.swiftmodule/arm64-apple-macos.swiftmodule /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests.swiftmodule (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests.swiftmodule /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsCloneTests.swiftmodule/arm64-apple-macos.swiftmodule - -Copy /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsCloneTests.swiftmodule/arm64-apple-macos.abi.json /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests.abi.json (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests.abi.json /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsCloneTests.swiftmodule/arm64-apple-macos.abi.json - -SwiftDriver\ Compilation\ Requirements KJamsCloneTests normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-Swift-Compilation-Requirements -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsCloneTests -Onone @/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests.SwiftFileList -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins/testing -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target x86_64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -Isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -parse-as-library -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-generated-files.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-own-target-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-project-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/DerivedSources-normal/x86_64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/DerivedSources/x86_64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests-Swift.h -working-directory /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone -experimental-emit-module-separately -disable-cmo - -Copy /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsCloneTests.swiftmodule/x86_64-apple-macos.abi.json /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests.abi.json (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests.abi.json /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsCloneTests.swiftmodule/x86_64-apple-macos.abi.json - -Copy /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsCloneTests.swiftmodule/x86_64-apple-macos.swiftmodule /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests.swiftmodule (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests.swiftmodule /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsCloneTests.swiftmodule/x86_64-apple-macos.swiftmodule - -Copy /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsCloneTests.swiftmodule/Project/x86_64-apple-macos.swiftsourceinfo /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests.swiftsourceinfo (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests.swiftsourceinfo /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsCloneTests.swiftmodule/Project/x86_64-apple-macos.swiftsourceinfo - -SwiftDriverJobDiscovery normal x86_64 Compiling KJamsCloneTests.swift (in target 'KJamsCloneTests' from project 'KJamsClone') - -SwiftDriverJobDiscovery normal arm64 Compiling KJamsCloneTests.swift (in target 'KJamsCloneTests' from project 'KJamsClone') - -SwiftDriver\ Compilation KJamsCloneTests normal arm64 com.apple.xcode.tools.swift.compiler (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-Swift-Compilation -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsCloneTests -Onone @/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests.SwiftFileList -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins/testing -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target arm64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -Isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -parse-as-library -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-generated-files.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-own-target-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-project-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/DerivedSources-normal/arm64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/DerivedSources/arm64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests-Swift.h -working-directory /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone -experimental-emit-module-separately -disable-cmo - -SwiftDriver\ Compilation KJamsCloneTests normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-Swift-Compilation -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsCloneTests -Onone @/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests.SwiftFileList -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins/testing -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target x86_64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -Isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -parse-as-library -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-generated-files.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-own-target-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests-project-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/DerivedSources-normal/x86_64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/DerivedSources/x86_64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests-Swift.h -working-directory /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone -experimental-emit-module-separately -disable-cmo - -SwiftDriverJobDiscovery normal x86_64 Compiling KJamsCloneApp.swift (in target 'KJamsClone' from project 'KJamsClone') - -SwiftDriver\ Compilation KJamsClone normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-Swift-Compilation -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsClone -Onone @/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone.SwiftFileList -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target x86_64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -F /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-generated-files.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-own-target-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-project-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/DerivedSources-normal/x86_64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/DerivedSources/x86_64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone-Swift.h -working-directory /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone -experimental-emit-module-separately -disable-cmo - -Ld /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/Binary/KJamsClone.debug.dylib normal x86_64 (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target x86_64-apple-macos13.0 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -Os -Xlinker -no_warn_duplicate_libraries -L/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -L/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -F/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -F/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -filelist /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone.LinkFileList -install_name @rpath/KJamsClone.debug.dylib -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -object_path_lto -Xlinker /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone_lto.o -rdynamic -Xlinker -dependency_info -Xlinker /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone_dependency_info.dat -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone.swiftmodule -lsqlite3 -Xlinker -alias -Xlinker _main -Xlinker ___debug_main_executable_dylib_entry_point -o /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/Binary/KJamsClone.debug.dylib - -SwiftDriverJobDiscovery normal arm64 Compiling KJamsCloneApp.swift (in target 'KJamsClone' from project 'KJamsClone') - -SwiftDriver\ Compilation KJamsClone normal arm64 com.apple.xcode.tools.swift.compiler (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-Swift-Compilation -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsClone -Onone @/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone.SwiftFileList -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target arm64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -F /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-generated-files.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-own-target-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-project-headers.hmap -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/DerivedSources-normal/arm64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/DerivedSources/arm64 -Xcc -I/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone-Swift.h -working-directory /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone -experimental-emit-module-separately -disable-cmo - -Ld /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/Binary/KJamsClone.debug.dylib normal arm64 (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target arm64-apple-macos13.0 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -Os -Xlinker -no_warn_duplicate_libraries -L/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -L/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -F/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -F/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -filelist /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone.LinkFileList -install_name @rpath/KJamsClone.debug.dylib -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -object_path_lto -Xlinker /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone_lto.o -rdynamic -Xlinker -dependency_info -Xlinker /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone_dependency_info.dat -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone.swiftmodule -lsqlite3 -Xlinker -alias -Xlinker _main -Xlinker ___debug_main_executable_dylib_entry_point -o /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/Binary/KJamsClone.debug.dylib - -ConstructStubExecutorLinkFileList /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-ExecutorLinkFileList-normal-x86_64.txt (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - construct-stub-executor-link-file-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/Binary/KJamsClone.debug.dylib /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/libPreviewsJITStubExecutor_no_swift_entry_point.a /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/libPreviewsJITStubExecutor.a --output /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-ExecutorLinkFileList-normal-x86_64.txt -note: Using stub executor library with Swift entry point. (in target 'KJamsClone' from project 'KJamsClone') - -ConstructStubExecutorLinkFileList /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-ExecutorLinkFileList-normal-arm64.txt (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - construct-stub-executor-link-file-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/Binary/KJamsClone.debug.dylib /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/libPreviewsJITStubExecutor_no_swift_entry_point.a /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/libPreviewsJITStubExecutor.a --output /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-ExecutorLinkFileList-normal-arm64.txt -note: Using stub executor library with Swift entry point. (in target 'KJamsClone' from project 'KJamsClone') - -CreateUniversalBinary /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/MacOS/KJamsClone.debug.dylib normal arm64\ x86_64 (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo -create /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/Binary/KJamsClone.debug.dylib /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/Binary/KJamsClone.debug.dylib -output /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/MacOS/KJamsClone.debug.dylib - -Ld /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/Binary/KJamsClone normal x86_64 (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target x86_64-apple-macos13.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -Os -Xlinker -no_warn_duplicate_libraries -L/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -F/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -Xlinker -rpath -Xlinker @executable_path -rdynamic -e ___debug_blank_executor_main -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __debug_dylib -Xlinker /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-DebugDylibPath-normal-x86_64.txt -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __debug_instlnm -Xlinker /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-DebugDylibInstallName-normal-x86_64.txt -Xlinker -filelist -Xlinker /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-ExecutorLinkFileList-normal-x86_64.txt /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/Binary/KJamsClone.debug.dylib -o /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/Binary/KJamsClone - -Ld /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/Binary/KJamsClone normal arm64 (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target arm64-apple-macos13.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -Os -Xlinker -no_warn_duplicate_libraries -L/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -F/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -Xlinker -rpath -Xlinker @executable_path -rdynamic -e ___debug_blank_executor_main -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __debug_dylib -Xlinker /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-DebugDylibPath-normal-arm64.txt -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __debug_instlnm -Xlinker /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-DebugDylibInstallName-normal-arm64.txt -Xlinker -filelist -Xlinker /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone-ExecutorLinkFileList-normal-arm64.txt /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/Binary/KJamsClone.debug.dylib -o /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/Binary/KJamsClone - -CreateUniversalBinary /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/MacOS/KJamsClone normal arm64\ x86_64 (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo -create /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/Binary/KJamsClone /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/Binary/KJamsClone -output /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/MacOS/KJamsClone - -CopySwiftLibs /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-swiftStdLibTool --copy --verbose --scan-executable /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/MacOS/KJamsClone.debug.dylib --scan-folder /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/Frameworks --scan-folder /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/PlugIns --scan-folder /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/Library/SystemExtensions --scan-folder /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/Extensions --platform macosx --toolchain /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain --destination /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/Frameworks --strip-bitcode --strip-bitcode-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bitcode_strip --emit-dependency-info /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/SwiftStdLibToolInputDependencies.dep --filter-for-swift-os --back-deploy-swift-span -Ignoring --strip-bitcode because --sign was not passed - -ExtractAppIntentsMetadata (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/appintentsmetadataprocessor --toolchain-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain --module-name KJamsClone --sdk-root /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk --xcode-version 27B52 --platform-family macOS --deployment-target 13.0 --bundle-identifier com.kjamsclone.app --output /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/Resources --target-triple arm64-apple-macos13.0 --target-triple x86_64-apple-macos13.0 --binary-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/MacOS/KJamsClone --dependency-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone_dependency_info.dat --dependency-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone_dependency_info.dat --stringsdata-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/ExtractedAppShortcutsMetadata.stringsdata --stringsdata-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/ExtractedAppShortcutsMetadata.stringsdata --source-file-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone.SwiftFileList --source-file-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone.SwiftFileList --metadata-file-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone.DependencyMetadataFileList --static-metadata-file-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/KJamsClone.DependencyStaticMetadataFileList --swift-const-vals-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/arm64/KJamsClone.SwiftConstValuesFileList --swift-const-vals-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/Objects-normal/x86_64/KJamsClone.SwiftConstValuesFileList --compile-time-extraction --deployment-aware-processing --no-app-shortcuts-localization -2026-11-02 22:56:14.618 appintentsmetadataprocessor[18810:6291935] Starting App Intents metadata extraction -2026-11-02 22:56:14.619 appintentsmetadataprocessor[18810:6291935] warning: Metadata extraction skipped, no AppIntents.framework dependency found - -ProcessInfoPlistFile /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/Info.plist /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/empty-KJamsClone.plist (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-infoPlistUtility /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsClone.build/empty-KJamsClone.plist -producttype com.apple.product-type.application -genpkginfo /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/PkgInfo -expandbuildsettings -platform macosx -o /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/Info.plist - -Ld /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/Binary/KJamsCloneTests normal arm64 (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target arm64-apple-macos13.0 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -Os -Xlinker -no_warn_duplicate_libraries -L/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -L/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -F/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -filelist /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests.LinkFileList -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @loader_path/../Frameworks -Xlinker -rpath -Xlinker @executable_path/../Frameworks -bundle_loader /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/MacOS/KJamsClone -Xlinker -object_path_lto -Xlinker /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests_lto.o -rdynamic -Xlinker -dependency_info -Xlinker /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests_dependency_info.dat -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests.swiftmodule -lsqlite3 -Xlinker -needed_framework -Xlinker XCTest -framework XCTest -Xlinker -needed-lXCTestSwiftSupport -lXCTestSwiftSupport /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/MacOS/KJamsClone.debug.dylib -o /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/Binary/KJamsCloneTests -/Users/markgregory/Documents/ChatGPT/KJams Clone/KJamsClone/KJamsClone.xcodeproj: KJamsCloneTests: ld: warning: building for macOS-13.0, but linking with dylib '@rpath/XCTest.framework/Versions/A/XCTest' which was built for newer version 14.0 -/Users/markgregory/Documents/ChatGPT/KJams Clone/KJamsClone/KJamsClone.xcodeproj: KJamsCloneTests: ld: warning: building for macOS-13.0, but linking with dylib '@rpath/libXCTestSwiftSupport.dylib' which was built for newer version 14.0 - -Ld /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/Binary/KJamsCloneTests normal x86_64 (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target x86_64-apple-macos13.0 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -Os -Xlinker -no_warn_duplicate_libraries -L/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -L/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -F/Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -filelist /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests.LinkFileList -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @loader_path/../Frameworks -Xlinker -rpath -Xlinker @executable_path/../Frameworks -bundle_loader /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/MacOS/KJamsClone -Xlinker -object_path_lto -Xlinker /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests_lto.o -rdynamic -Xlinker -dependency_info -Xlinker /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests_dependency_info.dat -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests.swiftmodule -lsqlite3 -Xlinker -needed_framework -Xlinker XCTest -framework XCTest -Xlinker -needed-lXCTestSwiftSupport -lXCTestSwiftSupport /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/MacOS/KJamsClone.debug.dylib -o /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/Binary/KJamsCloneTests -/Users/markgregory/Documents/ChatGPT/KJams Clone/KJamsClone/KJamsClone.xcodeproj: KJamsCloneTests: ld: warning: building for macOS-13.0, but linking with dylib '@rpath/XCTest.framework/Versions/A/XCTest' which was built for newer version 14.0 -/Users/markgregory/Documents/ChatGPT/KJams Clone/KJamsClone/KJamsClone.xcodeproj: KJamsCloneTests: ld: warning: building for macOS-13.0, but linking with dylib '@rpath/libXCTestSwiftSupport.dylib' which was built for newer version 14.0 - -ProcessInfoPlistFile /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/PlugIns/KJamsCloneTests.xctest/Contents/Info.plist /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/empty-KJamsCloneTests.plist (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-infoPlistUtility /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/empty-KJamsCloneTests.plist -producttype com.apple.product-type.bundle.unit-test -expandbuildsettings -platform macosx -o /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/PlugIns/KJamsCloneTests.xctest/Contents/Info.plist - -CreateUniversalBinary /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/PlugIns/KJamsCloneTests.xctest/Contents/MacOS/KJamsCloneTests normal arm64\ x86_64 (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo -create /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/Binary/KJamsCloneTests /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/Binary/KJamsCloneTests -output /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/PlugIns/KJamsCloneTests.xctest/Contents/MacOS/KJamsCloneTests - -CopySwiftLibs /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/PlugIns/KJamsCloneTests.xctest (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-swiftStdLibTool --copy --verbose --scan-executable /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/PlugIns/KJamsCloneTests.xctest/Contents/MacOS/KJamsCloneTests --scan-folder /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/PlugIns/KJamsCloneTests.xctest/Contents/Frameworks --scan-folder /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/PlugIns/KJamsCloneTests.xctest/Contents/PlugIns --scan-folder /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/PlugIns/KJamsCloneTests.xctest/Contents/Library/SystemExtensions --scan-folder /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/PlugIns/KJamsCloneTests.xctest/Contents/Extensions --platform macosx --toolchain /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain --destination /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/PlugIns/KJamsCloneTests.xctest/Contents/Frameworks --strip-bitcode --scan-executable /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/libXCTestSwiftSupport.dylib --strip-bitcode-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bitcode_strip --emit-dependency-info /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/SwiftStdLibToolInputDependencies.dep --filter-for-swift-os --back-deploy-swift-span -Ignoring --strip-bitcode because --sign was not passed - -ExtractAppIntentsMetadata (in target 'KJamsCloneTests' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/appintentsmetadataprocessor --toolchain-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain --module-name KJamsCloneTests --sdk-root /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk --xcode-version 27B52 --platform-family macOS --deployment-target 13.0 --bundle-identifier com.kjamsclone.tests --output /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/PlugIns/KJamsCloneTests.xctest/Contents/Resources --target-triple arm64-apple-macos13.0 --target-triple x86_64-apple-macos13.0 --binary-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app/Contents/PlugIns/KJamsCloneTests.xctest/Contents/MacOS/KJamsCloneTests --dependency-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests_dependency_info.dat --dependency-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests_dependency_info.dat --stringsdata-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/ExtractedAppShortcutsMetadata.stringsdata --stringsdata-file /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/ExtractedAppShortcutsMetadata.stringsdata --source-file-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests.SwiftFileList --source-file-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests.SwiftFileList --metadata-file-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests.DependencyMetadataFileList --static-metadata-file-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/KJamsCloneTests.DependencyStaticMetadataFileList --swift-const-vals-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/arm64/KJamsCloneTests.SwiftConstValuesFileList --swift-const-vals-list /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/KJamsClone.build/Debug/KJamsCloneTests.build/Objects-normal/x86_64/KJamsCloneTests.SwiftConstValuesFileList --compile-time-extraction --deployment-aware-processing --no-app-shortcuts-localization -2026-11-02 22:56:14.898 appintentsmetadataprocessor[18816:6291965] Starting App Intents metadata extraction -2026-11-02 22:56:14.900 appintentsmetadataprocessor[18816:6291965] warning: Metadata extraction skipped, no AppIntents.framework dependency found - -Validate /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-validationUtility /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app -no-validate-extension -infoplist-subpath Contents/Info.plist - -RegisterWithLaunchServices /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app (in target 'KJamsClone' from project 'KJamsClone') - cd /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone - builtin-lsregisterurl --record-path /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Intermediates.noindex/XCBuildData/registered-launchservices.txt -- /System/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks/LaunchServices.framework/Versions/Current/Support/lsregister -f -R -trusted /Users/markgregory/Documents/ChatGPT/KJams\ Clone/KJamsClone/build/Build/Products/Debug/KJamsClone.app - -PruneExplicitPrecompiledModules /Users/markgregory/Documents/ChatGPT/KJams Clone/KJamsClone/build/SDKExplicitPrecompiledModules - -PruneExplicitPrecompiledModules /Users/markgregory/Documents/ChatGPT/KJams Clone/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules - -PruneExplicitPrecompiledModules /Users/markgregory/Documents/ChatGPT/KJams Clone/KJamsClone/build/Build/Intermediates.noindex/ExplicitPrecompiledModules - -2026-11-02 22:56:15.285436+0000 KJamsClone[18818:6292041] [Connection] Unable to get remoteObjectProxy, error: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.linkd.autoShortcut" UserInfo={NSDebugDescription=connection to service named com.apple.linkd.autoShortcut} -2026-11-02 22:56:15.285622+0000 KJamsClone[18818:6292041] [Application] Error registering app with AppIntents framework: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.linkd.autoShortcut" UserInfo={NSDebugDescription=connection to service named com.apple.linkd.autoShortcut} -2026-11-02 22:56:15.314863+0000 KJamsClone[18818:6292016] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/54/8knnwrw15j74z4w2z_3_25q00000gn/T/com.kjamsclone.app.savedState -Test Suite 'All tests' started at 2026-11-02 22:56:15.497. -Test Suite 'KJamsCloneTests.xctest' started at 2026-11-02 22:56:15.497. -Test Suite 'KJamsCloneTests' started at 2026-11-02 22:56:15.497. -Test Case '-[KJamsCloneTests.KJamsCloneTests testCreateSingerAndVenueThroughAppModel]' started. -Test Case '-[KJamsCloneTests.KJamsCloneTests testCreateSingerAndVenueThroughAppModel]' passed (0.004 seconds). -Test Case '-[KJamsCloneTests.KJamsCloneTests testMP3PlaybackPauseAndSeek]' started. -2026-11-02 22:56:15.520156+0000 KJamsClone[18818:6292016] [plugin] AddInstanceForFactory: No factory registered for id F8BB1C28-BAE8-11D6-9C31-00039315CD46 -Test Case '-[KJamsCloneTests.KJamsCloneTests testMP3PlaybackPauseAndSeek]' passed (0.198 seconds). -Test Case '-[KJamsCloneTests.KJamsCloneTests testPairedImportAndContentDedup]' started. -Test Case '-[KJamsCloneTests.KJamsCloneTests testPairedImportAndContentDedup]' passed (0.005 seconds). -Test Case '-[KJamsCloneTests.KJamsCloneTests testPaletteBorderScrollAndImage]' started. -Test Case '-[KJamsCloneTests.KJamsCloneTests testPaletteBorderScrollAndImage]' passed (0.032 seconds). -Test Case '-[KJamsCloneTests.KJamsCloneTests testPresetTileXORAndInvalidCoordinates]' started. -Test Case '-[KJamsCloneTests.KJamsCloneTests testPresetTileXORAndInvalidCoordinates]' passed (0.001 seconds). -Test Case '-[KJamsCloneTests.KJamsCloneTests testSeekAndTruncatedPacket]' started. -Test Case '-[KJamsCloneTests.KJamsCloneTests testSeekAndTruncatedPacket]' passed (0.001 seconds). -Test Case '-[KJamsCloneTests.KJamsCloneTests testSQLitePersistenceDedupRatingsAndHistory]' started. -Test Case '-[KJamsCloneTests.KJamsCloneTests testSQLitePersistenceDedupRatingsAndHistory]' passed (0.004 seconds). -Test Case '-[KJamsCloneTests.KJamsCloneTests testZippedMP3GImportAndUnsafeArchiveRejection]' started. -Test Case '-[KJamsCloneTests.KJamsCloneTests testZippedMP3GImportAndUnsafeArchiveRejection]' passed (0.016 seconds). -Test Suite 'KJamsCloneTests' passed at 2026-11-02 22:56:15.760. - Executed 8 tests, with 0 failures (0 unexpected) in 0.262 (0.263) seconds -Test Suite 'KJamsCloneTests.xctest' passed at 2026-11-02 22:56:15.760. - Executed 8 tests, with 0 failures (0 unexpected) in 0.262 (0.263) seconds -Test Suite 'All tests' passed at 2026-11-02 22:56:15.760. - Executed 8 tests, with 0 failures (0 unexpected) in 0.262 (0.264) seconds -2026-11-02 22:56:16.045 xcodebuild[18779:6291628] [MT] IDETestOperationsObserverDebug: 1.114 elapsed -- Testing started completed. -2026-11-02 22:56:16.045 xcodebuild[18779:6291628] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start -2026-11-02 22:56:16.045 xcodebuild[18779:6291628] [MT] IDETestOperationsObserverDebug: 1.114 sec, +1.114 sec -- end - -Test session results, code coverage, and logs: - /Users/markgregory/Documents/ChatGPT/KJams Clone/KJamsClone/build/Logs/Test/Test-KJamsClone-2026.11.02_22-56-11-+0000.xcresult - -** TEST SUCCEEDED ** - -Testing started diff --git a/backups/before-waveform-20261103-082733/KJamsClone/KJamsCloneApp.swift b/backups/before-waveform-20261103-082733/KJamsClone/KJamsCloneApp.swift deleted file mode 100644 index 8fcc73e..0000000 --- a/backups/before-waveform-20261103-082733/KJamsClone/KJamsCloneApp.swift +++ /dev/null @@ -1,636 +0,0 @@ -import SwiftUI -import UniformTypeIdentifiers - -enum EntityKind: String, Identifiable { - case singer, venue - var id: String { rawValue } - var title: String { self == .singer ? "Singer" : "Venue" } - var table: String { self == .singer ? "singers" : "venues" } -} - -@MainActor final class AppModel: ObservableObject { - @Published var songs = [Song]() - @Published var singers = [PersonPlace]() - @Published var venues = [PersonPlace]() - @Published var venueSingers = [PersonPlace]() - @Published var playlists = [PersonPlace]() - @Published var queue = [QueueEntry]() - @Published var history = [Performance]() - @Published private(set) var currentVenue: Int64? - @Published var selectedSinger: Int64? - @Published var autoAdvance = true - @Published var error: String? - @Published var creating: EntityKind? - let player = Player() - private(set) var library: Library? - let root: URL - var currentVenueName: String { venues.first { $0.id == currentVenue }?.name ?? "No venue selected" } - init(storageURL: URL? = nil) { - root = storageURL ?? FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0].appendingPathComponent("KJamsClone") - perform { - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - library = try Library(url:root.appendingPathComponent("Library.sqlite")); try refresh() - } - player.onFinished = { [weak self] in - guard let self, self.autoAdvance, !self.queue.isEmpty else { return } - self.playQueueNext() - } - } - func perform(_ work: () throws -> Void) { do { try work() } catch { self.error = error.localizedDescription } } - func refresh() throws { - guard let library else { throw LibraryError.message("Library unavailable") } - songs = try library.songs(); singers = try library.entities("singers"); venues = try library.entities("venues") - playlists = try library.entities("playlists"); currentVenue = try library.currentVenue() - venueSingers = try currentVenue.map { try library.members(of:$0) } ?? singers - if let selectedSinger, !venueSingers.contains(where: { $0.id == selectedSinger }) { self.selectedSinger = nil } - queue = try library.queue(venue:currentVenue); history = try library.history(venue:currentVenue) - } - func chooseVenue(_ id: Int64?) { - perform { - guard let library else { throw LibraryError.message("Library unavailable") } - try library.selectVenue(id); selectedSinger = nil; try refresh() - } - } - func membership(singer: Int64, included: Bool) { - perform { - guard let library, let currentVenue else { throw LibraryError.message("Select a current venue first") } - try library.setMembership(singer:singer,venue:currentVenue,included:included); try refresh() - } - } - @discardableResult func createEntity(_ kind: EntityKind, name: String) throws -> Int64 { - guard let library else { throw LibraryError.message("Library unavailable") } - let trimmed = name.trimmingCharacters(in:.whitespacesAndNewlines) - try library.addEntity(kind.table,name:trimmed) - guard let entity = try library.entities(kind.table).first(where: { $0.name == trimmed }) else { throw LibraryError.message("Could not load new entry") } - if kind == .singer { - if let currentVenue { try library.setMembership(singer:entity.id,venue:currentVenue,included:true) } - selectedSinger = entity.id - } else { try library.selectVenue(entity.id); selectedSinger = nil } - try refresh(); return entity.id - } - func rename(_ table: String, id: Int64, name: String) { perform { try library?.rename(table,id:id,name:name); try refresh() } } - func delete(_ table: String, id: Int64) { perform { try library?.deleteEntity(table,id:id); try refresh() } } - func preference(_ song: Int64) -> SongPreference { - guard let library, let selectedSinger else { return .init() } - return (try? library.preference(song:song,singer:selectedSinger)) ?? .init() - } - func savePreference(song: Int64, value: SongPreference) { - perform { - guard let library, let selectedSinger else { throw LibraryError.message("Select a singer to save their song preferences") } - try library.savePreference(song:song,singer:selectedSinger,value:value); try refresh() - } - } - func play(_ song: Song, singer: Int64? = nil) throws { - guard let library else { throw LibraryError.message("Library unavailable") } - let singer = singer ?? selectedSinger - if let singer, let currentVenue, try !library.members(of:currentVenue).contains(where: { $0.id == singer }) { throw LibraryError.message("This singer is not in the current venue") } - let preference = try singer.map { try library.preference(song:song.id,singer:$0) } ?? SongPreference() - try player.load(song,preference:preference) - do { try library.record(song.id,singer:singer,venue:currentVenue); selectedSinger = singer; try refresh() } - catch { player.stop(); throw error } - } - func enqueue(_ song: Int64) { perform { try library?.enqueue(song:song,singer:selectedSinger,venue:currentVenue); try refresh() } } - func playQueueNext() { - perform { - guard let row = queue.first, let song = songs.first(where: { $0.id == row.songID }) else { return } - // Explicitly clear selection for unassigned queue entries. - selectedSinger = row.singerID - try play(song,singer:row.singerID); try library?.removeQueue(row.id); try refresh() - } - } - func moveQueue(_ id: Int64, by offset: Int) { perform { if let currentVenue { try library?.moveQueue(id,venue:currentVenue,by:offset); try refresh() } } } - func removeQueue(_ id: Int64) { perform { try library?.removeQueue(id); try refresh() } } - func createPlaylist(_ name: String) { perform { try library?.addEntity("playlists",name:name); try refresh() } } - func addToPlaylist(_ playlist: Int64, song: Int64) { perform { try library?.addToPlaylist(playlist,song:song); try refresh() } } - func importFiles(_ urls: [URL]) { perform { guard let library else { throw LibraryError.message("Library unavailable") }; try Importer(media:root.appendingPathComponent("Media")).run(urls,library:library); try refresh() } } -} -@main struct KJamsCloneApp: App { - @StateObject private var model = AppModel() - var body: some Scene { - Window("KJamsClone", id: "main") { - LibraryView(model: model).frame(minWidth: 1060, minHeight: 680).preferredColorScheme(.dark) - }.defaultSize(width: 1260, height: 840) - .commands { - CommandGroup(replacing: .newItem) { - Button("New Singer…") { model.creating = .singer }.keyboardShortcut("n", modifiers: [.command, .shift]) - Button("New Venue…") { model.creating = .venue }.keyboardShortcut("n", modifiers: [.command, .option]) - } - } - Window("Video", id: "lyrics") { - LyricsView(player: model.player).frame(minWidth: 480, minHeight: 320).preferredColorScheme(.dark) - }.defaultSize(width: 600, height: 400) - } -} -private enum Classic { - static let frame = Color(red: 0.15, green: 0.15, blue: 0.15) - static let navy = Color(red: 0.008, green: 0.065, blue: 0.16) - static let blue = Color(red: 0.015, green: 0.17, blue: 0.42) - static let header = Color(white: 0.115) - static let line = Color(white: 0.42) -} -struct LyricsView: View { - @ObservedObject var player: Player - var body: some View { - ZStack { - Color.black - if let image = player.image { - Image(decorative: image, scale: 1).interpolation(.none).resizable().aspectRatio(1.5, contentMode: .fit) - } - } - } -} -/// This is another view of the same published CGImage used by the Video window. -/// It owns no decoder, audio player or clock, so seeking/pause/tempo stay identical. -private struct SidebarVideoMonitor: View { - let player: Player - var body: some View { - VStack(alignment: .leading, spacing: 7) { - Label("Video Monitor", systemImage: "tv") - .font(.system(size: 11, weight: .medium)).foregroundStyle(.white.opacity(0.7)) - LyricsView(player: player) - .aspectRatio(1.5, contentMode: .fit) - .clipped() - .overlay(Rectangle().strokeBorder(.white.opacity(0.25), lineWidth: 1)) - .accessibilityLabel("Video monitor, synchronized with the Video window") - }.frame(maxWidth: .infinity) - } -} -private struct SilverSquareStyle: ButtonStyle { - func makeBody(configuration: Configuration) -> some View { - configuration.label.foregroundStyle(Color(white: 0.25)).padding(.horizontal, 6).padding(.vertical, 3) - .background(LinearGradient(colors: [Color(white: 0.95), Color(white: 0.64)], startPoint: .top, endPoint: .bottom), in: RoundedRectangle(cornerRadius: 4)) - .overlay(RoundedRectangle(cornerRadius: 4).strokeBorder(Color(white: 0.45), lineWidth: 1.5)) - .overlay(RoundedRectangle(cornerRadius: 3).strokeBorder(.white.opacity(0.7)).padding(3)) - .opacity(configuration.isPressed ? 0.7 : 1) - } -} -private struct SilverButton: View { - let symbol: String - let label: String - var size: CGFloat = 40 - var active = false - var enabled = true - let action: () -> Void - var body: some View { - Button(action: action) { - Image(systemName: symbol).font(.system(size: size * 0.41, weight: .semibold)) - .foregroundStyle(active ? Color.blue : Color(white: 0.24)) - .frame(width: size, height: size) - .background(LinearGradient(colors: [.white, Color(white: 0.85), Color(white: 0.63)], startPoint: .top, endPoint: .bottom), in: Circle()) - .overlay(Circle().strokeBorder(Color(white: 0.45), lineWidth: 1.5)) - .overlay(Circle().strokeBorder(.white.opacity(0.65), lineWidth: 1).padding(3)) - .shadow(color: .black.opacity(0.7), radius: 1, y: 1) - }.buttonStyle(.plain).disabled(!enabled).opacity(enabled ? 1 : 0.72) - .help(label).accessibilityLabel(label) - } -} -struct LibraryView: View { - @ObservedObject var model: AppModel - @State private var selected: Int64? - @State private var search = "" - @State private var name = "" - @State private var importing = false - @State private var source = "Library" - @Environment(\.openWindow) private var openWindow - private var visibleSongs: [Song] { model.songs.filter { search.isEmpty || ($0.title+" "+$0.artist+" "+$0.album).localizedCaseInsensitiveContains(search) } } - private var selectedSong: Song? { model.songs.first { $0.id == selected } } - var body: some View { - VStack(spacing: 0) { - TransportView(player: model.player, search: $search, hasSelection: selectedSong != nil, - play: playSelected, next: playNext, display: { openWindow(id: "lyrics") }) - .padding(.horizontal, 18).padding(.top, 18).padding(.bottom, 22) - HSplitView { - sidebar.frame(minWidth: 190, idealWidth: 220, maxWidth: 240) - VStack(spacing: 12) { - if source == "Library" { songTable } - else if source == "Queue" { queuePane } - else if source == "History" { historyPane } - else if source == "Playlists" { playlistPane } - else { directory } - detailPanel.frame(height: 135) - }.padding(.leading, 12).frame(minWidth: 780) - }.padding(.horizontal, 18) - footer.padding(.horizontal, 18).padding(.vertical, 12) - } - .background(Classic.frame) - .sheet(item: $model.creating) { kind in - AddEntitySheet(model: model, kind: kind) { id in - if kind == .singer { model.selectedSinger = id } else { model.chooseVenue(id) } - } - } - .fileImporter(isPresented: $importing, allowedContentTypes: [.audio, .zip, UTType(filenameExtension: "cdg") ?? .data], allowsMultipleSelection: true) { result in - switch result { - case .success(let urls): model.importFiles(urls) - case .failure(let error): model.error = error.localizedDescription - } - } - .alert("KJamsClone", isPresented: Binding(get: { model.error != nil }, set: { if !$0 { model.error = nil } })) { - Button("OK") { model.error = nil } - } message: { Text(model.error ?? "") } - } - private func sourceCount(_ source: String) -> Int { - switch source { - case "Library": return model.songs.count - case "Singers": return model.venueSingers.count - case "Venues": return model.venues.count - case "Queue": return model.queue.count - case "History": return model.history.count - default: return model.playlists.count - } - } - private var sidebar: some View { - VStack(alignment: .leading, spacing: 0) { - Text("Source").font(.system(size: 15, weight: .semibold)).padding(.horizontal, 10).frame(height: 31) - .frame(maxWidth: .infinity, alignment: .leading).background(Classic.header) - ForEach([("Library", "music.note.house.fill", Color.yellow), ("Singers", "person.2.fill", Color.green), ("Venues", "building.2.fill", Color.cyan), ("Queue", "list.number", Color.orange), ("History", "clock.arrow.circlepath", Color.purple), ("Playlists", "music.note.list", Color.mint)], id: \.0) { item in - Button { source = item.0 } label: { - HStack(spacing: 10) { - Image(systemName: item.1).foregroundStyle(item.2).frame(width: 22) - Text(item.0).font(.system(size: 16, weight: .medium)) - Spacer() - Text("\(sourceCount(item.0))") - .font(.system(size: 11)).foregroundStyle(.white.opacity(0.6)) - }.padding(.horizontal, 12).frame(height: 34).contentShape(Rectangle()) - .background(source == item.0 ? Color(red: 0, green: 0.36, blue: 1) : .clear) - }.buttonStyle(.plain) - } - Spacer(minLength: 12) - SidebarVideoMonitor(player: model.player).padding(10) - }.foregroundStyle(.white).background(Classic.navy).overlay(Rectangle().stroke(Classic.line, lineWidth: 1)) - } - private var songTable: some View { - GeometryReader { geometry in - ScrollView(.horizontal) { - VStack(spacing: 0) { - tableHeader(width: max(geometry.size.width, 790)) - ScrollView(.vertical) { - LazyVStack(spacing: 0) { - ForEach(visibleSongs) { song in songRow(song, width: max(geometry.size.width, 790)) } - }.frame(maxWidth: .infinity, alignment: .topLeading) - } - }.frame(width: max(geometry.size.width, 790), height: geometry.size.height) - } - }.background(Classic.navy).overlay(Rectangle().stroke(Classic.line, lineWidth: 1)) - } - private func widths(_ total: CGFloat) -> [CGFloat] { - [42, max(200, total - 598), 100, 100, 76, 86, 72, 122] - } - private func tableHeader(width: CGFloat) -> some View { - let sizes = widths(width) - return HStack(spacing: 0) { - ForEach(Array(["PLI", "Song Name", "Artist", "Album", "Label", "Key Adjust", "Tempo", "Rating"].enumerated()), id: \.offset) { index, title in - Text(title).font(.system(size: 13, weight: .medium)).lineLimit(1) - .padding(.leading, 7).frame(width: sizes[index], height: 30, alignment: .leading) - .overlay(alignment: .trailing) { Rectangle().fill(Classic.line).frame(width: 1).padding(.vertical, 4) } - } - }.foregroundStyle(.white).background(Classic.header) - .overlay(alignment: .bottom) { Rectangle().fill(Color(white: 0.65)).frame(height: 1) } - } - private func cellText(_ song: Song, column: Int) -> String { - switch column { - case 2: return song.artist.isEmpty ? "—" : song.artist - case 3: return song.album.isEmpty ? "—" : song.album - case 4: return song.label.isEmpty ? (song.cdg == nil ? "Audio" : URL(fileURLWithPath:song.audio).pathExtension.uppercased()+"+G") : song.label - case 5: return String(format:"%+.0f",model.preference(song.id).pitch) - default: return String(format:"%.0f%%",model.preference(song.id).tempo*100) - } - } - private func songRow(_ song: Song, width: CGFloat) -> some View { - let sizes = widths(width) - return HStack(spacing: 0) { - Image(systemName: song.cdg == nil ? "music.note" : "music.note.tv") - .foregroundStyle(.white.opacity(0.75)).frame(width: sizes[0]) - Text(song.title).lineLimit(1).padding(.leading, 7).frame(width: sizes[1], alignment: .leading) - ForEach(2..<7) { index in - Text(cellText(song, column: index)) - .foregroundStyle(.white.opacity(0.5)).padding(.leading, 7).frame(width: sizes[index], alignment: .leading) - } - Menu { - ForEach(0..<6) { value in - Button(value == 0 ? "Unrated" : String(repeating: "★", count: value)) { - model.perform { try model.library?.rate(song.id, value); try model.refresh() } - } - } - } label: { - Text(song.rating == 0 ? "☆☆☆☆☆" : String(repeating: "★", count: song.rating) + String(repeating: "☆", count: 5 - song.rating)) - .font(.system(size: 13)).foregroundStyle(song.rating == 0 ? Color.gray : Color.yellow) - }.menuStyle(.borderlessButton).frame(width: sizes[7] - 14).padding(.horizontal, 7).help("Set song rating") - }.font(.system(size: 13)).foregroundStyle(.white).frame(height: 30) - .background(selected == song.id ? Color(red: 0, green: 0.28, blue: 0.72) : .clear) - .contentShape(Rectangle()).onTapGesture(count: 2) { selected = song.id; playSelected() } - .onTapGesture { selected = song.id } - .contextMenu { - Button("Play") { selected = song.id; playSelected() } - Button("Add to Current Venue Queue") { model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Menu("Add to Playlist") { ForEach(model.playlists) { playlist in Button(playlist.name) { model.addToPlaylist(playlist.id,song:song.id) } } } - } - } - @State private var managingRoster = false - @State private var rosterNewName = "" - @State private var editingEntity: PersonPlace? - @State private var renameText = "" - @State private var pendingDelete: PersonPlace? - private var directory: some View { - VStack(alignment:.leading,spacing:0) { - HStack { - Text(source == "Singers" ? "Singers · \(model.currentVenueName)" : "Venues").font(.headline) - Spacer() - if source == "Singers" { Button("Manage Venue Singers…") { managingRoster = true }.disabled(model.currentVenue == nil) } - Button(source == "Singers" ? "New Singer…" : "New Venue…") { model.creating = source == "Singers" ? .singer : .venue } - }.padding(12).background(Classic.header) - ScrollView { - VStack(alignment:.leading,spacing:0) { - if source == "Singers" && model.venueSingers.isEmpty { - Text("No singers at this venue. Add a singer or use Manage Venue Singers to include existing singers.").foregroundStyle(.secondary).padding() - } - ForEach(source == "Singers" ? model.venueSingers : model.venues) { entity in - HStack { - Button { - if source == "Singers" { model.selectedSinger = entity.id } else { model.chooseVenue(entity.id) } - } label: { - HStack { - Image(systemName:source == "Singers" ? "person.fill" : "building.2.fill") - Text(entity.name); Spacer() - if entity.id == (source == "Singers" ? model.selectedSinger : model.currentVenue) { - Text(source == "Singers" ? "Selected" : "Current venue").font(.caption).foregroundStyle(.cyan) - Image(systemName:"checkmark.circle.fill").foregroundStyle(.cyan) - } - }.contentShape(Rectangle()) - }.buttonStyle(.plain) - Button("Rename") { renameText = entity.name; editingEntity = entity } - Button("Delete",role:.destructive) { pendingDelete = entity } - }.padding(12) - } - } - } - HStack { - TextField(source == "Singers" ? "Singer name" : "Venue name",text:$name).textFieldStyle(.roundedBorder).onSubmit(addEntity) - Button(source == "Singers" ? "Add Singer" : "Add Venue",action:addEntity).disabled(name.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - }.padding(12) - }.foregroundStyle(.white).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - .sheet(isPresented:$managingRoster) { rosterSheet } - .sheet(item:$editingEntity) { entity in - VStack(alignment:.leading,spacing:16) { - Text("Rename \(source == "Singers" ? "Singer" : "Venue")").font(.headline) - TextField("Name",text:$renameText).textFieldStyle(.roundedBorder) - HStack { Button("Cancel") { editingEntity = nil }; Spacer(); Button("Save") { model.rename(source == "Singers" ? "singers" : "venues",id:entity.id,name:renameText); editingEntity = nil }.disabled(renameText.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) } - }.padding(24).frame(width:360) - } - .confirmationDialog("Delete \(pendingDelete?.name ?? "entry")? Historical plays are kept. Venue memberships and queued entries for it will be removed.",isPresented:Binding(get:{ pendingDelete != nil },set:{ if !$0 { pendingDelete = nil } })) { - Button("Delete",role:.destructive) { if let entity = pendingDelete { model.delete(source == "Singers" ? "singers" : "venues",id:entity.id) }; pendingDelete = nil } - } - } - private var rosterSheet: some View { - VStack(alignment:.leading,spacing:16) { - Text("Singers at \(model.currentVenueName)").font(.title2.bold()) - Text("A singer can belong to any number of venues. Unchecking removes them from this venue only.").foregroundStyle(.secondary) - ScrollView { - VStack(alignment:.leading,spacing:12) { - ForEach(model.singers) { singer in - Toggle(singer.name,isOn:Binding(get:{ model.venueSingers.contains { $0.id == singer.id } },set:{ model.membership(singer:singer.id,included:$0) })) - } - }.frame(maxWidth:.infinity,alignment:.leading) - }.frame(minHeight:120,maxHeight:280) - HStack { - TextField("New singer name",text:$rosterNewName).textFieldStyle(.roundedBorder) - Button("Add") { model.perform { _ = try model.createEntity(.singer,name:rosterNewName); rosterNewName = "" } }.disabled(rosterNewName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - Spacer(); Button("Done") { managingRoster = false }.keyboardShortcut(.defaultAction) - } - }.padding(24).frame(width:460) - } - private var detailPanel: some View { - VStack(alignment:.leading,spacing:9) { - HStack(spacing:10) { - Picker("Current venue",selection:Binding(get:{ model.currentVenue },set:{ model.chooseVenue($0) })) { - Text("Select venue…").tag(nil as Int64?) - ForEach(model.venues) { Text($0.name).tag(Optional($0.id)) } - } - Button { model.creating = .venue } label: { Image(systemName:"plus.circle.fill") }.buttonStyle(.plain).help("Add venue") - Picker("Singer",selection:$model.selectedSinger) { - Text("None").tag(nil as Int64?) - ForEach(model.venueSingers) { Text($0.name).tag(Optional($0.id)) } - } - Button { model.creating = .singer } label: { Image(systemName:"plus.circle.fill") }.buttonStyle(.plain).help("Add singer") - Button("Queue Song") { if let selected { model.enqueue(selected) } }.disabled(selected == nil || model.currentVenue == nil) - } - PlaybackSettings(player:model.player,model:model,selectedSong:selected) - SeekBar(player:model.player) - }.padding(12).frame(maxWidth:.infinity,maxHeight:.infinity) - .background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - @State private var playlistName = "" - @State private var selectedPlaylist: Int64? - private var queuePane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { Text("Queue · \(model.currentVenueName)").font(.headline); Spacer(); Toggle("Auto play next",isOn:$model.autoAdvance).toggleStyle(.checkbox); Button("Play Next") { model.playQueueNext() }.disabled(model.queue.isEmpty) } - ScrollView { - VStack(spacing:0) { - ForEach(Array(model.queue.enumerated()),id:\.element.id) { index,row in - HStack { - Text("\(index+1)").foregroundStyle(.secondary).frame(width:24) - Text(row.singer).frame(width:140,alignment:.leading) - Text(row.title).lineLimit(1); Spacer() - Button { model.moveQueue(row.id,by:-1) } label: { Image(systemName:"arrow.up") }.disabled(index == 0) - Button { model.moveQueue(row.id,by:1) } label: { Image(systemName:"arrow.down") }.disabled(index == model.queue.count-1) - Button("Remove") { model.removeQueue(row.id) } - }.padding(.vertical,8) - } - if model.queue.isEmpty { Text("Choose a venue and singer, select a library song, then click Queue Song.").foregroundStyle(.secondary).padding(.top,30) } - } - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - @State private var historyAllVenues = false - private var displayedHistory: [Performance] { - if historyAllVenues { return (try? model.library?.history(venue:nil,singer:model.selectedSinger)) ?? [] } - return model.history.filter { model.selectedSinger == nil || $0.singer == model.singers.first(where: { $0.id == model.selectedSinger })?.name } - } - private var historyPane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { Text("History · \(historyAllVenues || model.currentVenue == nil ? "All venues" : model.currentVenueName)").font(.headline); Spacer(); Toggle("All venues",isOn:$historyAllVenues).toggleStyle(.checkbox) } - ScrollView { - LazyVStack(alignment:.leading,spacing:12) { - ForEach(displayedHistory) { row in - HStack { Text(row.date).font(.system(.caption,design:.monospaced)); Text(row.singer).frame(width:130,alignment:.leading); Text(row.song); Spacer(); Text(row.venue).foregroundStyle(.secondary) } - } - } - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - private var playlistPane: some View { - VStack(alignment:.leading,spacing:12) { - HStack { - Picker("Playlist",selection:$selectedPlaylist) { Text("Choose…").tag(nil as Int64?); ForEach(model.playlists) { Text($0.name).tag(Optional($0.id)) } } - TextField("New playlist name",text:$playlistName).textFieldStyle(.roundedBorder) - Button("Create") { model.createPlaylist(playlistName); selectedPlaylist = model.playlists.first { $0.name == playlistName.trimmingCharacters(in:.whitespacesAndNewlines) }?.id; playlistName = "" }.disabled(playlistName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - if let selectedPlaylist { - Button("Rename") { model.rename("playlists",id:selectedPlaylist,name:playlistName); playlistName = "" }.disabled(playlistName.trimmingCharacters(in:.whitespacesAndNewlines).isEmpty) - Button("Delete",role:.destructive) { model.delete("playlists",id:selectedPlaylist); self.selectedPlaylist = nil } } - } - ScrollView { - if let selectedPlaylist { - let ids = (try? model.library?.playlistSongIDs(selectedPlaylist)) ?? [] - VStack(alignment:.leading,spacing:10) { - ForEach(ids,id:\.self) { id in - if let song = model.songs.first(where: { $0.id == id }) { - HStack { - Text(song.title); Spacer() - Button("Play") { model.perform { try model.play(song) } } - Button("Queue") { model.enqueue(song.id) }.disabled(model.currentVenue == nil) - Button("Remove") { model.perform { try model.library?.removeFromPlaylist(selectedPlaylist,song:id); try model.refresh() } } - } - } - } - } - } - Text("Add songs using the library row’s context menu.").foregroundStyle(.secondary).padding(.top,20) - } - }.padding(14).frame(maxWidth:.infinity,maxHeight:.infinity).background(Classic.navy).overlay(Rectangle().stroke(Classic.line)) - } - private var footer: some View { - HStack { - Button { importing = true } label: { Image(systemName: "plus").font(.system(size: 20, weight: .bold)).frame(width: 32, height: 24) } - .help("Import audio, MP3+G or ZIP").accessibilityLabel("Import songs") - RepeatButton(player: model.player).padding(.leading, 12) - Spacer() - Text("\(visibleSongs.count) \(visibleSongs.count == 1 ? "Song" : "Songs")").font(.system(size: 14, weight: .medium)) - Spacer() - Button { openWindow(id: "lyrics") } label: { Image(systemName: "rectangle.on.rectangle").frame(width: 32, height: 24) } - .help("Open video window").accessibilityLabel("Open video window") - }.buttonStyle(SilverSquareStyle()) - } - private func playSelected() { - guard let song = selectedSong else { return } - model.perform { try model.play(song) } - } - private func playNext() { - guard !visibleSongs.isEmpty else { return } - let index = visibleSongs.firstIndex { $0.id == selected } ?? -1 - selected = visibleSongs[(index + 1) % visibleSongs.count].id; playSelected() - } - private func addEntity() { - model.perform { - let kind: EntityKind = source == "Singers" ? .singer : .venue - let id = try model.createEntity(kind, name: name) - if kind == .singer { model.selectedSinger = id } else { model.chooseVenue(id) } - name = "" - } - } -} -private struct AddEntitySheet: View { - @ObservedObject var model: AppModel - let kind: EntityKind - let saved: (Int64) -> Void - @Environment(\.dismiss) private var dismiss - @State private var name = "" - @State private var error: String? - @FocusState private var focused: Bool - var body: some View { - VStack(alignment: .leading, spacing: 16) { - Text("New \(kind.title)").font(.title2.bold()) - TextField("\(kind.title) name", text: $name).textFieldStyle(.roundedBorder) - .focused($focused).onSubmit(save) - if let error { Text(error).foregroundStyle(.red).font(.callout) } - HStack { - Spacer() - Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction) - Button("Add \(kind.title)", action: save).keyboardShortcut(.defaultAction) - .disabled(name.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty) - } - }.padding(24).frame(width: 360).onAppear { focused = true } - } - private func save() { - do { let id = try model.createEntity(kind, name: name); saved(id); dismiss() } - catch { self.error = error.localizedDescription } - } -} -private struct TransportView: View { - @ObservedObject var player: Player - @Binding var search: String - let hasSelection: Bool - let play: () -> Void - let next: () -> Void - let display: () -> Void - var body: some View { - HStack(alignment: .top, spacing: 28) { - VStack(spacing: 15) { - HStack(spacing: 7) { - SilverButton(symbol: "backward.fill", label: "Back 10 seconds", size: 35, enabled: player.duration > 0) { player.seek(player.time - 10) } - SilverButton(symbol: player.playing ? "pause.fill" : "play.fill", label: player.playing ? "Pause" : "Play", size: 49, enabled: hasSelection || player.duration > 0) { - if player.duration > 0 { player.toggle() } else { play() } - } - SilverButton(symbol: "stop", label: "Stop", size: 46, enabled: player.duration > 0) { player.stop() } - SilverButton(symbol: "forward.fill", label: "Forward 10 seconds", size: 35, enabled: player.duration > 0) { player.seek(player.time + 10) } - SilverButton(symbol: "forward.end.fill", label: "Play next song", size: 26, enabled: hasSelection, action: next) - } - HStack(spacing: 9) { - Image(systemName: "speaker.fill").font(.system(size: 11)) - Slider(value: $player.volume, in: 0...1).controlSize(.small).tint(.gray).accessibilityLabel("Volume") - Image(systemName: "speaker.wave.3.fill").font(.system(size: 12)) - }.frame(width: 180) - }.frame(width: 220) - VStack(spacing: 0) { - Text(player.duration == 0 ? "Ready!" : player.title).font(.system(size: 15, weight: .medium)).lineLimit(1).padding(.horizontal, 20) - if player.duration > 0 { Text(player.playing ? "Playing" : "Paused").font(.system(size: 10)).foregroundStyle(.white.opacity(0.65)).padding(.top, 4) } - }.frame(maxWidth: .infinity).frame(height: 64) - .background(LinearGradient(colors: [Color(red: 0, green: 0.10, blue: 0.30), Classic.blue], startPoint: .top, endPoint: .bottom), in: Capsule()) - .overlay(Capsule().strokeBorder(LinearGradient(colors: [.black, .white], startPoint: .top, endPoint: .bottom), lineWidth: 1.5)) - .padding(.top, 14) - HStack(spacing: 12) { - TextField("Search", text: $search).textFieldStyle(.plain).font(.system(size: 16)) - .padding(.horizontal, 8).frame(width: 145, height: 28).background(Color(white: 0.07), in: RoundedRectangle(cornerRadius: 5)) - .overlay(RoundedRectangle(cornerRadius: 5).stroke(.white.opacity(0.1))) - SilverButton(symbol: "eye", label: "Open video window", size: 48, action: display) - }.padding(.top, 15) - }.foregroundStyle(.white).frame(height: 96) - } -} -private struct PlaybackSettings: View { - @ObservedObject var player: Player - @ObservedObject var model: AppModel - let selectedSong: Int64? - @State private var personalRating = 0 - var body: some View { - HStack(spacing:10) { - Text("Key") - Picker("Key",selection:$player.pitch) { ForEach(-12..<13) { Text(String(format:"%+d",$0)).tag(Double($0)) } }.labelsHidden().frame(width:70) - Text("Tempo") - Slider(value:$player.tempo,in:0.5...1.5,step:0.05).frame(width:85) - Text(String(format:"%.0f%%",player.tempo*100)).monospacedDigit().frame(width:40) - Text("Rating") - Picker("Singer rating",selection:$personalRating) { ForEach(0..<6) { Text($0 == 0 ? "Unrated" : String(repeating:"★",count:$0)).tag($0) } }.labelsHidden().frame(width:88).help("Singer-specific song rating") - Button("Save for Singer") { - if let song = player.currentSongID ?? selectedSong { model.savePreference(song:song,value:.init(pitch:player.pitch,tempo:player.tempo,rating:personalRating)) } - }.disabled(model.selectedSinger == nil || (player.currentSongID == nil && selectedSong == nil)) - Menu { - Button("Reset key / tempo") { player.pitch = 0; player.tempo = 1 } - ForEach([-1.0,-0.5,0,0.5,1.0],id:\.self) { offset in Button(String(format:"Graphics offset %+.1fs",offset)) { player.graphicsOffset = offset } } - } label: { Image(systemName:"slider.horizontal.3") }.menuStyle(.borderlessButton).frame(width:22).help("Playback settings") - }.font(.system(size:11)) - .onChange(of:model.selectedSinger) { _ in loadRating() } - .onChange(of:player.currentSongID) { _ in loadRating() } - .onChange(of:selectedSong) { _ in loadRating() } - } - private func loadRating() { if let song = player.currentSongID ?? selectedSong { personalRating = model.preference(song).rating } else { personalRating = 0 } } -} -private struct SeekBar: View { - @ObservedObject var player: Player - private func clock(_ seconds: Double) -> String { let n = Int(seconds); return String(format: "%d:%02d", n / 60, n % 60) } - var body: some View { - HStack(spacing: 10) { - Text(clock(player.time)) - Slider(value: Binding(get: { player.time }, set: { player.seek($0) }), in: 0...max(1, player.duration)) - .controlSize(.mini).tint(.gray).disabled(player.duration == 0).accessibilityLabel("Playback position") - Text(clock(player.duration)) - }.font(.system(size: 10, design: .monospaced)).foregroundStyle(.white.opacity(0.65)) - } -} -private struct RepeatButton: View { - @ObservedObject var player: Player - var body: some View { - Button { player.repeating.toggle() } label: { - Image(systemName: "repeat").font(.system(size: 18, weight: .semibold)) - .foregroundStyle(player.repeating ? Color.blue : Color(white: 0.25)).frame(width: 32, height: 24) - }.help(player.repeating ? "Repeat song: on" : "Repeat song: off").accessibilityLabel("Repeat song").accessibilityValue(player.repeating ? "On" : "Off") - } -} diff --git a/backups/before-waveform-20261103-082733/KJamsClone/Player.swift b/backups/before-waveform-20261103-082733/KJamsClone/Player.swift deleted file mode 100644 index ab647b3..0000000 --- a/backups/before-waveform-20261103-082733/KJamsClone/Player.swift +++ /dev/null @@ -1,91 +0,0 @@ -import SwiftUI -import AVFoundation - -/// CDG follows consumed source frames, so tempo adjustment preserves graphics timing. -@MainActor final class Player: ObservableObject { - @Published var image: CGImage? - @Published var playing = false - @Published var time: Double = 0 - @Published var duration: Double = 0 - @Published var title = "Select a song" - @Published var volume: Double = 0.8 { didSet { engine.mainMixerNode.outputVolume = Float(volume) } } - @Published var repeating = false - @Published var pitch: Double = 0 { didSet { effect.pitch = Float(pitch * 100) } } - @Published var tempo: Double = 1 { didSet { effect.rate = Float(tempo) } } - @Published var graphicsOffset: Double = 0 - private(set) var currentSongID: Int64? - var onFinished: (() -> Void)? - private let engine = AVAudioEngine() - private let node = AVAudioPlayerNode() - private let effect = AVAudioUnitTimePitch() - private var file: AVAudioFile? - private var anchor: Double = 0 - private var generation = UUID() - private var cdg = Data() - private var decoder = CDGDecoder() - private var timer: Timer? - init() { engine.attach(node); engine.attach(effect) } - func load(_ song: Song, preference: SongPreference = .init()) throws { - stop() - do { - let loaded = try AVAudioFile(forReading:URL(fileURLWithPath:song.audio)) - let graphics = try song.cdg.map { try Data(contentsOf:URL(fileURLWithPath:$0)) } ?? Data() - guard loaded.length > 0 else { throw LibraryError.message("Audio file is empty") } - engine.connect(node,to:effect,format:loaded.processingFormat) - engine.connect(effect,to:engine.mainMixerNode,format:loaded.processingFormat) - file = loaded; cdg = graphics; decoder = CDGDecoder() - duration = Double(loaded.length)/loaded.processingFormat.sampleRate - title = song.title; currentSongID = song.id - pitch = preference.pitch; tempo = preference.tempo - engine.mainMixerNode.outputVolume = Float(volume) - engine.prepare(); try engine.start() - schedule(at:0,play:true); startTimer(); tick() - } catch { stop(); throw error } - } - private func schedule(at seconds: Double, play: Bool) { - guard let file else { return } - generation = UUID(); let token = generation - node.stop() - let rate = file.processingFormat.sampleRate - let start = min(file.length,max(0,AVAudioFramePosition(seconds*rate))) - anchor = Double(start)/rate; time = anchor - guard start < file.length else { playing = false; render(); return } - node.scheduleSegment(file,startingFrame:start,frameCount:AVAudioFrameCount(min(file.length-start,Int64(UInt32.max))),at:nil,completionCallbackType:.dataPlayedBack) { [weak self] _ in - Task { @MainActor in - guard let self, self.generation == token else { return } - if self.repeating { self.schedule(at:0,play:true) } - else { - self.playing = false; self.time = self.duration; self.render() - self.timer?.invalidate(); self.timer = nil; self.onFinished?() - } - } - } - if play { node.play() }; playing = play; render() - } - private func startTimer() { - timer?.invalidate() - timer = Timer.scheduledTimer(withTimeInterval:1.0/30,repeats:true) { [weak self] _ in Task { @MainActor in self?.tick() } } - } - func toggle() { - guard file != nil else { return } - if playing { tick(); node.pause(); playing = false } - else if time >= duration { schedule(at:0,play:true); startTimer() } - else { node.play(); playing = true; startTimer() } - } - func stop() { - generation = UUID(); timer?.invalidate(); timer = nil; node.stop(); engine.stop() - engine.disconnectNodeOutput(node); engine.disconnectNodeOutput(effect) - file = nil; playing = false; time = 0; anchor = 0; duration = 0; image = nil; currentSongID = nil; title = "Select a song" - } - func seek(_ value: Double) { - guard file != nil, value.isFinite else { return } - schedule(at:min(max(value,0),duration),play:playing); startTimer() - } - private func render() { decoder.render(cdg,at:max(0,time+graphicsOffset)); image = cdg.isEmpty ? nil : decoder.image() } - private func tick() { - if playing, let file, let renderTime = node.lastRenderTime, let playerTime = node.playerTime(forNodeTime:renderTime) { - time = min(duration,max(0,anchor+Double(playerTime.sampleTime)/file.processingFormat.sampleRate)) - } - render() - } -} diff --git a/backups/before-waveform-20261103-082733/KJamsCloneTests/KJamsCloneTests.swift b/backups/before-waveform-20261103-082733/KJamsCloneTests/KJamsCloneTests.swift deleted file mode 100644 index 69948bc..0000000 --- a/backups/before-waveform-20261103-082733/KJamsCloneTests/KJamsCloneTests.swift +++ /dev/null @@ -1,229 +0,0 @@ -import XCTest -@testable import KJamsClone - -final class KJamsCloneTests: XCTestCase { - func packet(_ instruction: UInt8, _ data: [UInt8]) -> [UInt8] { [9,instruction,0,0] + Array((data + Array(repeating: 0,count:16)).prefix(16)) + [0,0,0,0] } - func testPresetTileXORAndInvalidCoordinates() { - var d = CDGDecoder() - d.apply(packet(1,[3,0])); XCTAssertEqual(d.pixels[0],3) - d.apply(packet(6,[0,5,1,1] + Array(repeating:63,count:12))) - XCTAssertEqual(d.pixels[12*300+6],5) - d.apply(packet(38,[0,5,1,1] + Array(repeating:63,count:12))) - XCTAssertEqual(d.pixels[12*300+6],0) - let old = d.pixels; d.apply(packet(6,[1,2,31,63])); XCTAssertEqual(d.pixels,old) - } - func testSeekAndTruncatedPacket() { - var d = CDGDecoder() - let data = Data(packet(1,[2,0]) + packet(1,[7,0]) + [9]) - d.render(data,at:1); XCTAssertEqual(d.pixels[0],7); XCTAssertEqual(d.packetIndex,2) - d.render(data,at:1.0/300); XCTAssertEqual(d.pixels[0],2) - d.render(data,at:0); XCTAssertEqual(d.pixels[0],0) - } - func testPaletteBorderScrollAndImage() { - var d = CDGDecoder() - d.apply(packet(30,[63,63])); XCTAssertEqual(d.palette[0],0xFFFFFFFF) - d.apply(packet(2,[4])); XCTAssertEqual(d.pixels[0],4); XCTAssertEqual(d.pixels[12*300+6],0) - d.apply(packet(20,[3,16,0])); XCTAssertEqual(d.pixels[100*300],3) - d.apply(packet(24,[0,32,0])); XCTAssertEqual(d.pixels[100*300+294],3) - XCTAssertEqual(d.image()?.width,288) - } - func testSQLitePersistenceDedupRatingsAndHistory() throws { - let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at: folder,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:folder) } - let url = folder.appendingPathComponent("test.sqlite") - do { - let db = try Library(url:url) - try db.add(title:"Singer's Song",audio:"/test.mp3",cdg:nil) - try db.add(title:"Duplicate",audio:"/test.mp3",cdg:"/test.cdg") - let song = try XCTUnwrap(db.songs().first) - try db.rate(song.id,5); XCTAssertThrowsError(try db.rate(song.id,6)) - try db.addEntity("singers",name:"O'Neil"); try db.addEntity("venues",name:"Hall") - try db.record(song.id,singer:db.entities("singers").first?.id,venue:db.entities("venues").first?.id) - } - let reopened = try Library(url:url); let songs = try reopened.songs() - XCTAssertEqual(songs.count,1); XCTAssertEqual(songs[0].rating,5); XCTAssertEqual(songs[0].plays,1); XCTAssertEqual(songs[0].cdg,"/test.cdg") - XCTAssertEqual(try reopened.entities("singers").first?.name,"O'Neil") - } - func testPairedImportAndContentDedup() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let audio = root.appendingPathComponent("Test.mp3"), cdg = root.appendingPathComponent("Test.CDG") - try Data([1,2,3]).write(to:audio); try Data(packet(1,[2,0])).write(to:cdg) - let db = try Library(url:root.appendingPathComponent("test.sqlite")) - let importer = Importer(media:root.appendingPathComponent("Media")) - try importer.run([audio],library:db); try importer.run([audio],library:db) - XCTAssertEqual(try db.songs().count,1) - XCTAssertNotNil(try db.songs().first?.cdg) - } - - func testZippedMP3GImportAndUnsafeArchiveRejection() throws { - let folder = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:folder,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:folder) } - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let db = try Library(url:folder.appendingPathComponent("db.sqlite")) - let importer = Importer(media:folder.appendingPathComponent("Media")) - try importer.run([fixtures.appendingPathComponent("Demo.zip")],library:db) - let song = try XCTUnwrap(db.songs().first) - XCTAssertEqual(song.title,"Demo"); XCTAssertNotNil(song.cdg) - XCTAssertTrue(FileManager.default.fileExists(atPath:song.audio)) - XCTAssertThrowsError(try importer.run([fixtures.appendingPathComponent("Unsafe.zip")],library:db)) - } - @MainActor func testMP3PlaybackPauseAndSeek() throws { - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let player = Player() - defer { player.stop() } - try player.load(Song(id:1,title:"Demo",audio:fixtures.appendingPathComponent("Demo.mp3").path,cdg:fixtures.appendingPathComponent("Demo.cdg").path,rating:0,plays:0)) - XCTAssertGreaterThan(player.duration,3.9); XCTAssertTrue(player.playing) - player.toggle(); XCTAssertFalse(player.playing) - player.seek(2); XCTAssertEqual(player.time,2,accuracy:0.05); XCTAssertNotNil(player.image) - player.seek(0.1); XCTAssertEqual(player.time,0.1,accuracy:0.05) - } - @MainActor func testCreateSingerAndVenueThroughAppModel() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - defer { try? FileManager.default.removeItem(at: root) } - let model = AppModel(storageURL: root) - XCTAssertNil(model.error) - let singer = try model.createEntity(.singer, name: " Alex ") - let venue = try model.createEntity(.venue, name: "Town Hall") - XCTAssertEqual(model.singers.first?.name, "Alex") - XCTAssertEqual(model.venues.first?.name, "Town Hall") - XCTAssertEqual(try model.createEntity(.singer, name: "Alex"), singer) - XCTAssertEqual(model.singers.count, 1) - XCTAssertThrowsError(try model.createEntity(.venue, name: " ")) - let reopened = AppModel(storageURL: root) - XCTAssertEqual(reopened.singers.first?.id, singer) - XCTAssertEqual(reopened.venues.first?.id, venue) - } - - @MainActor func testVenuesShareSingersAndRememberSelection() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - defer { try? FileManager.default.removeItem(at:root) } - let model = AppModel(storageURL:root) - let hall = try model.createEntity(.venue,name:"Hall") - let alex = try model.createEntity(.singer,name:"Alex") - let club = try model.createEntity(.venue,name:"Club") - XCTAssertTrue(model.venueSingers.isEmpty) - model.membership(singer:alex,included:true) - XCTAssertEqual(model.venueSingers.map(\.id),[alex]) - model.chooseVenue(hall); XCTAssertEqual(model.venueSingers.map(\.id),[alex]) - model.chooseVenue(club); model.membership(singer:alex,included:false) - XCTAssertTrue(model.venueSingers.isEmpty) - let reopened = AppModel(storageURL:root) - XCTAssertEqual(reopened.currentVenue,club); XCTAssertTrue(reopened.venueSingers.isEmpty) - reopened.chooseVenue(hall); XCTAssertEqual(reopened.venueSingers.map(\.id),[alex]) - XCTAssertEqual(reopened.singers.count,1) - } - func testMigrationAndMembershipRemovalDoesNotReappear() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let url = root.appendingPathComponent("db.sqlite") - var singer: Int64 = 0, venue: Int64 = 0 - do { - let db = try Library(url:url) - try db.add(title:"Song",audio:"/a.mp3",cdg:nil) - try db.addEntity("singers",name:"Alex"); try db.addEntity("venues",name:"Hall") - singer = try XCTUnwrap(db.entities("singers").first?.id); venue = try XCTUnwrap(db.entities("venues").first?.id) - try db.record(XCTUnwrap(db.songs().first?.id),singer:singer,venue:venue) - try db.execute("PRAGMA user_version=1") - } - do { - let migrated = try Library(url:url) - XCTAssertEqual(try migrated.members(of:venue).map(\.id),[singer]) - try migrated.setMembership(singer:singer,venue:venue,included:false) - } - let reopened = try Library(url:url) - XCTAssertTrue(try reopened.members(of:venue).isEmpty) - XCTAssertEqual(try reopened.history(venue:venue).count,1) - } - func testQueuePlaylistsPreferencesAndDeletion() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let db = try Library(url:root.appendingPathComponent("db.sqlite")) - try db.add(title:"First",audio:"/1.mp3",cdg:nil) - try db.add(title:"Second",audio:"/2.mp3",cdg:nil) - let songs = try db.songs() - try db.addEntity("singers",name:"Alex"); try db.addEntity("venues",name:"Hall"); try db.addEntity("venues",name:"Club") - let singer = try XCTUnwrap(db.entities("singers").first?.id) - let hall = try XCTUnwrap(db.entities("venues").first(where: { $0.name == "Hall" })?.id) - let club = try XCTUnwrap(db.entities("venues").first(where: { $0.name == "Club" })?.id) - XCTAssertThrowsError(try db.enqueue(song:songs[0].id,singer:singer,venue:hall)) - try db.setMembership(singer:singer,venue:hall,included:true) - try db.enqueue(song:songs[0].id,singer:singer,venue:hall); try db.enqueue(song:songs[1].id,singer:singer,venue:hall) - XCTAssertTrue(try db.queue(venue:club).isEmpty) - let second = try XCTUnwrap(db.queue(venue:hall).last) - try db.moveQueue(second.id,venue:hall,by:-1) - XCTAssertEqual(try db.queue(venue:hall).first?.songID,songs[1].id) - let preference = SongPreference(pitch:3,tempo:0.85,rating:4) - try db.savePreference(song:songs[0].id,singer:singer,value:preference) - XCTAssertEqual(try db.preference(song:songs[0].id,singer:singer),preference) - XCTAssertThrowsError(try db.savePreference(song:songs[0].id,singer:singer,value:.init(pitch:99))) - try db.addEntity("playlists",name:"Party") - let playlist = try XCTUnwrap(db.entities("playlists").first?.id) - try db.addToPlaylist(playlist,song:songs[0].id); try db.addToPlaylist(playlist,song:songs[0].id) - XCTAssertEqual(try db.playlistSongIDs(playlist),[songs[0].id]) - try db.record(songs[0].id,singer:singer,venue:hall) - try db.rename("singers",id:singer,name:"Alex Jones") - XCTAssertEqual(try db.history(venue:hall).first?.singer,"Alex Jones") - try db.deleteEntity("singers",id:singer) - XCTAssertTrue(try db.queue(venue:hall).isEmpty) - XCTAssertEqual(try db.history(venue:hall).count,1) - try db.selectVenue(hall); try db.deleteEntity("venues",id:hall) - XCTAssertNil(try db.currentVenue()); XCTAssertEqual(try db.history(venue:nil).count,1) - } - @MainActor func testTempoSourceClockPauseAndResume() async throws { - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let player = Player(); defer { player.stop() } - let song = Song(id:1,title:"Demo",audio:fixtures.appendingPathComponent("Demo.mp3").path,cdg:fixtures.appendingPathComponent("Demo.cdg").path,rating:0,plays:0) - try player.load(song,preference:.init(pitch:2,tempo:1.5,rating:3)) - XCTAssertEqual(player.pitch,2); XCTAssertEqual(player.tempo,1.5) - try await Task.sleep(nanoseconds:500_000_000) - XCTAssertGreaterThan(player.time,0.45); XCTAssertLessThan(player.time,1.3) - player.toggle(); let paused = player.time - try await Task.sleep(nanoseconds:100_000_000) - XCTAssertEqual(player.time,paused,accuracy:0.025) - player.seek(1.5); player.toggle() - try await Task.sleep(nanoseconds:200_000_000) - XCTAssertGreaterThan(player.time,1.6); XCTAssertNotNil(player.image) - } - func testNewTestMediaMetadataAndCDGPairImport() throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - try FileManager.default.createDirectory(at:root,withIntermediateDirectories:true) - defer { try? FileManager.default.removeItem(at:root) } - let db = try Library(url:root.appendingPathComponent("db.sqlite")) - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - let importer = Importer(media:root.appendingPathComponent("Media")) - try importer.run([fixtures.appendingPathComponent("TestTrack.cdg")],library:db) - let song = try XCTUnwrap(db.songs().first) - XCTAssertEqual(song.title,"MP3 Plus G Test") - XCTAssertEqual(song.artist,"KJamsClone Test Generator") - XCTAssertNotNil(song.cdg) - let bytes = try Data(contentsOf:fixtures.appendingPathComponent("TestTrack.cdg")) - XCTAssertEqual(bytes.count,20*300*24) - var decoder = CDGDecoder(); decoder.render(bytes,at:2) - XCTAssertTrue(decoder.pixels.contains(1)); XCTAssertTrue(decoder.pixels.contains(2)) - } - @MainActor func testAutomaticVenueQueueAdvancesAndRecordsSinger() async throws { - let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) - defer { try? FileManager.default.removeItem(at:root) } - let model = AppModel(storageURL:root); defer { model.player.stop() } - _ = try model.createEntity(.venue,name:"Test Hall") - _ = try model.createEntity(.singer,name:"Alex") - let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures")) - model.importFiles([fixtures.appendingPathComponent("Demo.zip")]) - let song = try XCTUnwrap(model.songs.first) - model.enqueue(song.id); model.enqueue(song.id); model.playQueueNext() - XCTAssertEqual(model.queue.count,1); XCTAssertEqual(model.history.count,1) - model.player.seek(model.player.duration-0.1) - for _ in 0..<25 { - if model.queue.isEmpty { break } - try await Task.sleep(nanoseconds:100_000_000) - } - XCTAssertNil(model.error); XCTAssertTrue(model.queue.isEmpty) - XCTAssertEqual(model.history.count,2); XCTAssertEqual(model.history.first?.singer,"Alex") - } -} diff --git a/verification/extracted-project.txt b/docs/verification/extracted-project.txt similarity index 100% rename from verification/extracted-project.txt rename to docs/verification/extracted-project.txt diff --git a/verification/showscreen-output.png b/docs/verification/showscreen-output.png similarity index 100% rename from verification/showscreen-output.png rename to docs/verification/showscreen-output.png diff --git a/verification/singer-browser-check.txt b/docs/verification/singer-browser-check.txt similarity index 100% rename from verification/singer-browser-check.txt rename to docs/verification/singer-browser-check.txt diff --git a/verification/test-cdg-ffmpeg.png b/docs/verification/test-cdg-ffmpeg.png similarity index 100% rename from verification/test-cdg-ffmpeg.png rename to docs/verification/test-cdg-ffmpeg.png diff --git a/verification/ui-0.6-library.png b/docs/verification/ui-0.6-library.png similarity index 100% rename from verification/ui-0.6-library.png rename to docs/verification/ui-0.6-library.png diff --git a/verification/ui-0.6-rotation-small.png b/docs/verification/ui-0.6-rotation-small.png similarity index 100% rename from verification/ui-0.6-rotation-small.png rename to docs/verification/ui-0.6-rotation-small.png diff --git a/verification/ui-0.6-rotation.png b/docs/verification/ui-0.6-rotation.png similarity index 100% rename from verification/ui-0.6-rotation.png rename to docs/verification/ui-0.6-rotation.png diff --git a/verification/ui-0.6-settings.png b/docs/verification/ui-0.6-settings.png similarity index 100% rename from verification/ui-0.6-settings.png rename to docs/verification/ui-0.6-settings.png diff --git a/verification/ui-0.6.1-add-songs.png b/docs/verification/ui-0.6.1-add-songs.png similarity index 100% rename from verification/ui-0.6.1-add-songs.png rename to docs/verification/ui-0.6.1-add-songs.png diff --git a/verification/ui-0.6.1-reordered.png b/docs/verification/ui-0.6.1-reordered.png similarity index 100% rename from verification/ui-0.6.1-reordered.png rename to docs/verification/ui-0.6.1-reordered.png diff --git a/verification/ui-0.6.4-waveforms-button.png b/docs/verification/ui-0.6.4-waveforms-button.png similarity index 100% rename from verification/ui-0.6.4-waveforms-button.png rename to docs/verification/ui-0.6.4-waveforms-button.png diff --git a/verification/ui-batch-metadata.png b/docs/verification/ui-batch-metadata.png similarity index 100% rename from verification/ui-batch-metadata.png rename to docs/verification/ui-batch-metadata.png diff --git a/verification/ui-kjmix-pro-global-mixer.png b/docs/verification/ui-kjmix-pro-global-mixer.png similarity index 100% rename from verification/ui-kjmix-pro-global-mixer.png rename to docs/verification/ui-kjmix-pro-global-mixer.png diff --git a/verification/ui-kjmix-pro-locations.png b/docs/verification/ui-kjmix-pro-locations.png similarity index 100% rename from verification/ui-kjmix-pro-locations.png rename to docs/verification/ui-kjmix-pro-locations.png diff --git a/verification/ui-kjmix-pro-minimum.png b/docs/verification/ui-kjmix-pro-minimum.png similarity index 100% rename from verification/ui-kjmix-pro-minimum.png rename to docs/verification/ui-kjmix-pro-minimum.png diff --git a/verification/ui-kjmix-pro-mp4.png b/docs/verification/ui-kjmix-pro-mp4.png similarity index 100% rename from verification/ui-kjmix-pro-mp4.png rename to docs/verification/ui-kjmix-pro-mp4.png diff --git a/verification/ui-kjmix-pro.png b/docs/verification/ui-kjmix-pro.png similarity index 100% rename from verification/ui-kjmix-pro.png rename to docs/verification/ui-kjmix-pro.png diff --git a/verification/ui-metadata.png b/docs/verification/ui-metadata.png similarity index 100% rename from verification/ui-metadata.png rename to docs/verification/ui-metadata.png diff --git a/verification/ui-minimum-size.png b/docs/verification/ui-minimum-size.png similarity index 100% rename from verification/ui-minimum-size.png rename to docs/verification/ui-minimum-size.png diff --git a/verification/ui-monitor-minimum-size.png b/docs/verification/ui-monitor-minimum-size.png similarity index 100% rename from verification/ui-monitor-minimum-size.png rename to docs/verification/ui-monitor-minimum-size.png diff --git a/verification/ui-monitor-video-window.png b/docs/verification/ui-monitor-video-window.png similarity index 100% rename from verification/ui-monitor-video-window.png rename to docs/verification/ui-monitor-video-window.png diff --git a/verification/ui-monitor.png b/docs/verification/ui-monitor.png similarity index 100% rename from verification/ui-monitor.png rename to docs/verification/ui-monitor.png diff --git a/verification/ui-new-singer.png b/docs/verification/ui-new-singer.png similarity index 100% rename from verification/ui-new-singer.png rename to docs/verification/ui-new-singer.png diff --git a/verification/ui-preview.png b/docs/verification/ui-preview.png similarity index 100% rename from verification/ui-preview.png rename to docs/verification/ui-preview.png diff --git a/verification/ui-rotation.png b/docs/verification/ui-rotation.png similarity index 100% rename from verification/ui-rotation.png rename to docs/verification/ui-rotation.png diff --git a/verification/ui-showscreens.png b/docs/verification/ui-showscreens.png similarity index 100% rename from verification/ui-showscreens.png rename to docs/verification/ui-showscreens.png diff --git a/verification/ui-singer-browser.png b/docs/verification/ui-singer-browser.png similarity index 100% rename from verification/ui-singer-browser.png rename to docs/verification/ui-singer-browser.png diff --git a/verification/ui-singer-server.png b/docs/verification/ui-singer-server.png similarity index 100% rename from verification/ui-singer-server.png rename to docs/verification/ui-singer-server.png diff --git a/verification/ui-store-editor.png b/docs/verification/ui-store-editor.png similarity index 100% rename from verification/ui-store-editor.png rename to docs/verification/ui-store-editor.png diff --git a/verification/ui-studio-minimum-size.png b/docs/verification/ui-studio-minimum-size.png similarity index 100% rename from verification/ui-studio-minimum-size.png rename to docs/verification/ui-studio-minimum-size.png diff --git a/verification/ui-studio.png b/docs/verification/ui-studio.png similarity index 100% rename from verification/ui-studio.png rename to docs/verification/ui-studio.png diff --git a/verification/ui-tone-mixer.png b/docs/verification/ui-tone-mixer.png similarity index 100% rename from verification/ui-tone-mixer.png rename to docs/verification/ui-tone-mixer.png diff --git a/verification/ui-tonight-drag-minimum-size.png b/docs/verification/ui-tonight-drag-minimum-size.png similarity index 100% rename from verification/ui-tonight-drag-minimum-size.png rename to docs/verification/ui-tonight-drag-minimum-size.png diff --git a/verification/ui-tonight-drag.png b/docs/verification/ui-tonight-drag.png similarity index 100% rename from verification/ui-tonight-drag.png rename to docs/verification/ui-tonight-drag.png diff --git a/verification/ui-tonight-minimum-size.png b/docs/verification/ui-tonight-minimum-size.png similarity index 100% rename from verification/ui-tonight-minimum-size.png rename to docs/verification/ui-tonight-minimum-size.png diff --git a/verification/ui-tonight.png b/docs/verification/ui-tonight.png similarity index 100% rename from verification/ui-tonight.png rename to docs/verification/ui-tonight.png diff --git a/verification/ui-waveform-minimum-size.png b/docs/verification/ui-waveform-minimum-size.png similarity index 100% rename from verification/ui-waveform-minimum-size.png rename to docs/verification/ui-waveform-minimum-size.png diff --git a/verification/ui-waveform.png b/docs/verification/ui-waveform.png similarity index 100% rename from verification/ui-waveform.png rename to docs/verification/ui-waveform.png diff --git a/verification/xcode-release.log b/verification/xcode-release.log deleted file mode 100644 index ec9af4c..0000000 --- a/verification/xcode-release.log +++ /dev/null @@ -1,297 +0,0 @@ -Command line invocation: - /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project "KJMix Pro.xcodeproj" -scheme "KJMix Pro" -configuration Release -destination platform=macOS -derivedDataPath /Users/markgregory/Developer/Applications/KJamsClone/build-release CODE_SIGNING_ALLOWED=NO build - -Build settings from command line: - CODE_SIGNING_ALLOWED = NO - ---- xcodebuild: WARNING: Using the first of multiple matching destinations: -{ platform:macOS, arch:arm64, id:00006030-000C01641102001C, name:My Mac } -{ platform:macOS, arch:x86_64, id:00006030-000C01641102001C, name:My Mac } -ComputePackagePrebuildTargetDependencyGraph - -Prepare packages - -CreateBuildRequest - -SendProjectDescription - -CreateBuildOperation - -ComputeTargetDependencyGraph -note: Building targets in dependency order -note: Target dependency graph (1 target) - Target 'KJMix Pro' in project 'KJMix Pro' (no dependencies) - -GatherProvisioningInputs - -CreateBuildDescription - -ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -v -E -dM -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -x c -c /dev/null - -ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/usr/bin/actool --version --output-format xml1 - -ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc --version - -ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld -version_details - -Build description signature: 921fe392a05bfa2d854c4c121a720b55 -Build description path: /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/XCBuildData/921fe392a05bfa2d854c4c121a720b55.xcbuilddata -ClangStatCache /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-stat-cache /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk /Users/markgregory/Developer/Applications/KJamsClone/build-release/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache - cd /Users/markgregory/Developer/Applications/KJamsClone/KJMix\ Pro.xcodeproj - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-stat-cache /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -o /Users/markgregory/Developer/Applications/KJamsClone/build-release/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache - -SwiftDriver KJMix\ Pro normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftDriver -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsClone -O @/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro.SwiftFileList -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target x86_64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/ModuleCache.noindex -Xfrontend -serialize-debugging-options -swift-version 5 -I /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release -F /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build-release/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Developer/Applications/KJamsClone/build-release/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-generated-files.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-own-target-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-project-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/include -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/DerivedSources-normal/x86_64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/DerivedSources/x86_64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone-Swift.h -working-directory /Users/markgregory/Developer/Applications/KJamsClone -experimental-emit-module-separately -disable-cmo - -SwiftDriver KJMix\ Pro normal arm64 com.apple.xcode.tools.swift.compiler (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftDriver -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsClone -O @/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro.SwiftFileList -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target arm64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/ModuleCache.noindex -Xfrontend -serialize-debugging-options -swift-version 5 -I /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release -F /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build-release/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Developer/Applications/KJamsClone/build-release/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-generated-files.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-own-target-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-project-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/include -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/DerivedSources-normal/arm64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/DerivedSources/arm64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone-Swift.h -working-directory /Users/markgregory/Developer/Applications/KJamsClone -experimental-emit-module-separately -disable-cmo - -SwiftEmitModule normal arm64 Emitting\ module\ for\ KJamsClone (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftCompile normal arm64 (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - - -SwiftCompile normal arm64 Compiling\ LibraryScanner.swift /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/LibraryScanner.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftCompile normal arm64 /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/LibraryScanner.swift (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftPerFileCompile LibraryScanner.swift - -SwiftCompile normal arm64 Compiling\ KJMixProApp.swift /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/KJMixProApp.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftCompile normal arm64 /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/KJMixProApp.swift (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftPerFileCompile KJMixProApp.swift - -SwiftCompile normal x86_64 Compiling\ Player.swift /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/Player.swift (in target 'KJMix Pro' from project 'KJMix Pro') -/Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/Player.swift:302:35: warning: reference to captured var 'self' in concurrently-executing code; this is an error in the Swift 6 language mode [#SendableClosureCaptures] -300 | guard !Task.isCancelled else { return };let frame = decoded.image(),finished = decoded -301 | await MainActor.run { -302 | guard let self,self.graphicsGeneration == token else { return } - | `- warning: reference to captured var 'self' in concurrently-executing code; this is an error in the Swift 6 language mode [#SendableClosureCaptures] -303 | self.decoder = finished;self.lastGraphicsPacket = target;self.image = frame;self.graphicsTask = nil -304 | } - -[#SendableClosureCaptures]: - -SwiftCompile normal x86_64 /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/Player.swift (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftPerFileCompile Player.swift - -SwiftEmitModule normal x86_64 Emitting\ module\ for\ KJamsClone (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftCompile normal x86_64 (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - - -SwiftCompile normal x86_64 Compiling\ LibraryScanner.swift /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/LibraryScanner.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftCompile normal x86_64 /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/LibraryScanner.swift (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftPerFileCompile LibraryScanner.swift - -SwiftCompile normal x86_64 Compiling\ KJMixProApp.swift /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/KJMixProApp.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftCompile normal x86_64 /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/KJMixProApp.swift (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftPerFileCompile KJMixProApp.swift - -SwiftCompile normal arm64 Compiling\ Player.swift /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/Player.swift (in target 'KJMix Pro' from project 'KJMix Pro') -/Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/Player.swift:302:35: warning: reference to captured var 'self' in concurrently-executing code; this is an error in the Swift 6 language mode [#SendableClosureCaptures] -300 | guard !Task.isCancelled else { return };let frame = decoded.image(),finished = decoded -301 | await MainActor.run { -302 | guard let self,self.graphicsGeneration == token else { return } - | `- warning: reference to captured var 'self' in concurrently-executing code; this is an error in the Swift 6 language mode [#SendableClosureCaptures] -303 | self.decoder = finished;self.lastGraphicsPacket = target;self.image = frame;self.graphicsTask = nil -304 | } - -[#SendableClosureCaptures]: - -SwiftCompile normal arm64 /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/Player.swift (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftPerFileCompile Player.swift - -SwiftDriverJobDiscovery normal x86_64 Compiling LibraryScanner.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftCompile normal x86_64 Compiling\ Metadata.swift /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/Metadata.swift (in target 'KJMix Pro' from project 'KJMix Pro') -/Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/Metadata.swift:97:31: warning: 'metadata' was deprecated in macOS 13.0: Use load(.metadata) instead [#DeprecatedDeclaration] - 95 | exporter.outputURL = temp;exporter.outputFileType = type - 96 | let keys: [AVMetadataKey] = [.commonKeyTitle,.commonKeyArtist,.commonKeyAlbumName,.commonKeyPublisher] - 97 | var items = asset.metadata.filter{!keys.contains($0.commonKey ?? AVMetadataKey(rawValue:""))} - | `- warning: 'metadata' was deprecated in macOS 13.0: Use load(.metadata) instead [#DeprecatedDeclaration] - 98 | for (identifier,value) in [(AVMetadataIdentifier.commonIdentifierTitle,song.title),(.commonIdentifierArtist,song.artist),(.commonIdentifierAlbumName,song.album),(.commonIdentifierPublisher,song.label)] { - 99 | let item = AVMutableMetadataItem();item.identifier = identifier;item.value = value as NSString;items.append(item) - -[#DeprecatedDeclaration]: - -SwiftCompile normal x86_64 /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/Metadata.swift (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftPerFileCompile Metadata.swift - -SwiftCompile normal x86_64 Compiling\ DJWorkspace.swift /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/DJWorkspace.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftCompile normal x86_64 /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/DJWorkspace.swift (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftPerFileCompile DJWorkspace.swift - -SwiftCompile normal x86_64 Compiling\ Hosting.swift /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/Hosting.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftCompile normal x86_64 /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/Hosting.swift (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftPerFileCompile Hosting.swift - -SwiftCompile normal x86_64 Compiling\ SingerServer.swift /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/SingerServer.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftCompile normal x86_64 /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/SingerServer.swift (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftPerFileCompile SingerServer.swift - -SwiftDriverJobDiscovery normal arm64 Compiling LibraryScanner.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftCompile normal arm64 Compiling\ Hosting.swift /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/Hosting.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftCompile normal arm64 /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/Hosting.swift (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftPerFileCompile Hosting.swift - -SwiftCompile normal arm64 Compiling\ SingerServer.swift /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/SingerServer.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftCompile normal arm64 /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/SingerServer.swift (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftPerFileCompile SingerServer.swift - -SwiftCompile normal arm64 Compiling\ DJWorkspace.swift /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/DJWorkspace.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftCompile normal arm64 /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/DJWorkspace.swift (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftPerFileCompile DJWorkspace.swift - -SwiftCompile normal arm64 Compiling\ Metadata.swift /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/Metadata.swift (in target 'KJMix Pro' from project 'KJMix Pro') -/Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/Metadata.swift:97:31: warning: 'metadata' was deprecated in macOS 13.0: Use load(.metadata) instead [#DeprecatedDeclaration] - 95 | exporter.outputURL = temp;exporter.outputFileType = type - 96 | let keys: [AVMetadataKey] = [.commonKeyTitle,.commonKeyArtist,.commonKeyAlbumName,.commonKeyPublisher] - 97 | var items = asset.metadata.filter{!keys.contains($0.commonKey ?? AVMetadataKey(rawValue:""))} - | `- warning: 'metadata' was deprecated in macOS 13.0: Use load(.metadata) instead [#DeprecatedDeclaration] - 98 | for (identifier,value) in [(AVMetadataIdentifier.commonIdentifierTitle,song.title),(.commonIdentifierArtist,song.artist),(.commonIdentifierAlbumName,song.album),(.commonIdentifierPublisher,song.label)] { - 99 | let item = AVMutableMetadataItem();item.identifier = identifier;item.value = value as NSString;items.append(item) - -[#DeprecatedDeclaration]: - -SwiftCompile normal arm64 /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/Metadata.swift (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftPerFileCompile Metadata.swift - -SwiftDriverJobDiscovery normal x86_64 Compiling Player.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftDriverJobDiscovery normal arm64 Compiling Player.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftDriverJobDiscovery normal x86_64 Compiling SingerServer.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftDriverJobDiscovery normal arm64 Compiling Hosting.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftDriverJobDiscovery normal x86_64 Compiling Hosting.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftDriverJobDiscovery normal arm64 Compiling SingerServer.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftDriverJobDiscovery normal x86_64 Compiling Metadata.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftDriverJobDiscovery normal x86_64 Compiling DJWorkspace.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftDriverJobDiscovery normal arm64 Compiling Metadata.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftDriverJobDiscovery normal arm64 Compiling DJWorkspace.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftDriverJobDiscovery normal x86_64 Compiling KJMixProApp.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftDriver\ Compilation KJMix\ Pro normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-Swift-Compilation -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsClone -O @/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro.SwiftFileList -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target x86_64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/ModuleCache.noindex -Xfrontend -serialize-debugging-options -swift-version 5 -I /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release -F /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build-release/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Developer/Applications/KJamsClone/build-release/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-generated-files.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-own-target-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-project-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/include -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/DerivedSources-normal/x86_64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/DerivedSources/x86_64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone-Swift.h -working-directory /Users/markgregory/Developer/Applications/KJamsClone -experimental-emit-module-separately -disable-cmo - -SwiftDriverJobDiscovery normal arm64 Emitting module for KJamsClone (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftDriver\ Compilation\ Requirements KJMix\ Pro normal arm64 com.apple.xcode.tools.swift.compiler (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-Swift-Compilation-Requirements -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsClone -O @/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro.SwiftFileList -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target arm64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/ModuleCache.noindex -Xfrontend -serialize-debugging-options -swift-version 5 -I /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release -F /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build-release/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Developer/Applications/KJamsClone/build-release/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-generated-files.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-own-target-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-project-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/include -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/DerivedSources-normal/arm64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/DerivedSources/arm64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone-Swift.h -working-directory /Users/markgregory/Developer/Applications/KJamsClone -experimental-emit-module-separately -disable-cmo - -SwiftDriverJobDiscovery normal x86_64 Emitting module for KJamsClone (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftDriver\ Compilation\ Requirements KJMix\ Pro normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-Swift-Compilation-Requirements -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsClone -O @/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro.SwiftFileList -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target x86_64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/ModuleCache.noindex -Xfrontend -serialize-debugging-options -swift-version 5 -I /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release -F /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build-release/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Developer/Applications/KJamsClone/build-release/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-generated-files.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-own-target-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-project-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/include -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/DerivedSources-normal/x86_64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/DerivedSources/x86_64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone-Swift.h -working-directory /Users/markgregory/Developer/Applications/KJamsClone -experimental-emit-module-separately -disable-cmo - -Ld /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/Binary/KJMix\ Pro normal x86_64 (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target x86_64-apple-macos13.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -Os -Xlinker -no_warn_duplicate_libraries -L/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/EagerLinkingTBDs/Release -L/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release -F/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/EagerLinkingTBDs/Release -F/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release -filelist /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro.LinkFileList -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -object_path_lto -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro_lto.o -Xlinker -dependency_info -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro_dependency_info.dat -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.swiftmodule -lsqlite3 -o /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/Binary/KJMix\ Pro - -SwiftDriverJobDiscovery normal arm64 Compiling KJMixProApp.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftDriver\ Compilation KJMix\ Pro normal arm64 com.apple.xcode.tools.swift.compiler (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-Swift-Compilation -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsClone -O @/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro.SwiftFileList -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target arm64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/ModuleCache.noindex -Xfrontend -serialize-debugging-options -swift-version 5 -I /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release -F /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build-release/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Developer/Applications/KJamsClone/build-release/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-generated-files.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-own-target-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro-project-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/include -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/DerivedSources-normal/arm64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/DerivedSources/arm64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone-Swift.h -working-directory /Users/markgregory/Developer/Applications/KJamsClone -experimental-emit-module-separately -disable-cmo - -Ld /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/Binary/KJMix\ Pro normal arm64 (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target arm64-apple-macos13.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -Os -Xlinker -no_warn_duplicate_libraries -L/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/EagerLinkingTBDs/Release -L/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release -F/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/EagerLinkingTBDs/Release -F/Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release -filelist /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro.LinkFileList -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -object_path_lto -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro_lto.o -Xlinker -dependency_info -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro_dependency_info.dat -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.swiftmodule -lsqlite3 -o /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/Binary/KJMix\ Pro - -Copy /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJamsClone.swiftmodule/x86_64-apple-macos.swiftmodule /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.swiftmodule (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.swiftmodule /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJamsClone.swiftmodule/x86_64-apple-macos.swiftmodule - -Copy /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJamsClone.swiftmodule/x86_64-apple-macos.abi.json /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.abi.json (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.abi.json /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJamsClone.swiftmodule/x86_64-apple-macos.abi.json - -Copy /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJamsClone.swiftmodule/Project/x86_64-apple-macos.swiftsourceinfo /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.swiftsourceinfo (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.swiftsourceinfo /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJamsClone.swiftmodule/Project/x86_64-apple-macos.swiftsourceinfo - -Copy /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJamsClone.swiftmodule/arm64-apple-macos.abi.json /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.abi.json (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.abi.json /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJamsClone.swiftmodule/arm64-apple-macos.abi.json - -Copy /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJamsClone.swiftmodule/arm64-apple-macos.swiftmodule /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.swiftmodule (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.swiftmodule /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJamsClone.swiftmodule/arm64-apple-macos.swiftmodule - -Copy /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJamsClone.swiftmodule/Project/arm64-apple-macos.swiftsourceinfo /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.swiftsourceinfo (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.swiftsourceinfo /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJamsClone.swiftmodule/Project/arm64-apple-macos.swiftsourceinfo - -CreateUniversalBinary /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJMix\ Pro.app/Contents/MacOS/KJMix\ Pro normal arm64\ x86_64 (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo -create /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/Binary/KJMix\ Pro /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/Binary/KJMix\ Pro -output /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJMix\ Pro.app/Contents/MacOS/KJMix\ Pro - -ExtractAppIntentsMetadata (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/appintentsmetadataprocessor --toolchain-dir /var/run/com.apple.security.cryptexd/mnt/com.apple.MobileAsset.MetalToolchain-v27.2.47.0.Ex1CTN/Metal.xctoolchain --module-name KJamsClone --sdk-root /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk --xcode-version 27B52 --platform-family macOS --deployment-target 13.0 --bundle-identifier com.kjamsclone.app --output /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJMix\ Pro.app/Contents/Resources --target-triple arm64-apple-macos13.0 --target-triple x86_64-apple-macos13.0 --binary-file /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJMix\ Pro.app/Contents/MacOS/KJMix\ Pro --dependency-file /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro_dependency_info.dat --dependency-file /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro_dependency_info.dat --stringsdata-file /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/ExtractedAppShortcutsMetadata.stringsdata --stringsdata-file /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/ExtractedAppShortcutsMetadata.stringsdata --source-file-list /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro.SwiftFileList --source-file-list /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro.SwiftFileList --metadata-file-list /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro.DependencyMetadataFileList --static-metadata-file-list /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/KJMix\ Pro.DependencyStaticMetadataFileList --swift-const-vals-list /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro.SwiftConstValuesFileList --swift-const-vals-list /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro.SwiftConstValuesFileList --compile-time-extraction --deployment-aware-processing --no-app-shortcuts-localization -2026-11-03 13:59:20.100 appintentsmetadataprocessor[7033:153799] Starting App Intents metadata extraction -2026-11-03 13:59:20.101 appintentsmetadataprocessor[7033:153799] warning: Metadata extraction skipped, no AppIntents.framework dependency found - -CopySwiftLibs /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJMix\ Pro.app (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-swiftStdLibTool --copy --verbose --scan-executable /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJMix\ Pro.app/Contents/MacOS/KJMix\ Pro --scan-folder /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJMix\ Pro.app/Contents/Frameworks --scan-folder /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJMix\ Pro.app/Contents/PlugIns --scan-folder /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJMix\ Pro.app/Contents/Library/SystemExtensions --scan-folder /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJMix\ Pro.app/Contents/Extensions --platform macosx --toolchain /var/run/com.apple.security.cryptexd/mnt/com.apple.MobileAsset.MetalToolchain-v27.2.47.0.Ex1CTN/Metal.xctoolchain --toolchain /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain --destination /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJMix\ Pro.app/Contents/Frameworks --strip-bitcode --strip-bitcode-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bitcode_strip --emit-dependency-info /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/SwiftStdLibToolInputDependencies.dep --filter-for-swift-os --back-deploy-swift-span -Ignoring --strip-bitcode because --sign was not passed - -ProcessInfoPlistFile /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJMix\ Pro.app/Contents/Info.plist /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/empty-KJMix\ Pro.plist (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-infoPlistUtility /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/empty-KJMix\ Pro.plist -producttype com.apple.product-type.application -genpkginfo /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJMix\ Pro.app/Contents/PkgInfo -expandbuildsettings -platform macosx -additionalcontentfile /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/KJMix\ Pro.build/Release/KJMix\ Pro.build/assetcatalog_generated_info.plist -o /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJMix\ Pro.app/Contents/Info.plist - -Validate /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJMix\ Pro.app (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-validationUtility /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJMix\ Pro.app -no-validate-extension -infoplist-subpath Contents/Info.plist - -RegisterWithLaunchServices /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJMix\ Pro.app (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-lsregisterurl --record-path /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/XCBuildData/registered-launchservices.txt -- /System/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks/LaunchServices.framework/Versions/Current/Support/lsregister -f -R -trusted /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Products/Release/KJMix\ Pro.app - -PruneExplicitPrecompiledModules /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/ExplicitPrecompiledModules - -PruneExplicitPrecompiledModules /Users/markgregory/Developer/Applications/KJamsClone/build-release/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules - -PruneExplicitPrecompiledModules /Users/markgregory/Developer/Applications/KJamsClone/build-release/SDKExplicitPrecompiledModules - -** BUILD SUCCEEDED ** - diff --git a/verification/xcode-test.log b/verification/xcode-test.log deleted file mode 100644 index 9c32067..0000000 --- a/verification/xcode-test.log +++ /dev/null @@ -1,556 +0,0 @@ -Command line invocation: - /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project "KJMix Pro.xcodeproj" -scheme "KJMix Pro" -configuration Debug -destination platform=macOS -derivedDataPath /Users/markgregory/Developer/Applications/KJamsClone/build CODE_SIGNING_ALLOWED=NO test - -Build settings from command line: - CODE_SIGNING_ALLOWED = NO - ---- xcodebuild: WARNING: Using the first of multiple matching destinations: -{ platform:macOS, arch:arm64, id:00006030-000C01641102001C, name:My Mac } -{ platform:macOS, arch:x86_64, id:00006030-000C01641102001C, name:My Mac } -ComputePackagePrebuildTargetDependencyGraph - -Prepare packages - -CreateBuildRequest - -SendProjectDescription - -CreateBuildOperation - -ComputeTargetDependencyGraph -note: Building targets in dependency order -note: Target dependency graph (2 targets) - Target 'KJMixProTests' in project 'KJMix Pro' - ➜ Explicit dependency on target 'KJMix Pro' in project 'KJMix Pro' - Target 'KJMix Pro' in project 'KJMix Pro' (no dependencies) - -GatherProvisioningInputs - -CreateBuildDescription - -ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc --version - -ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -v -E -dM -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -x c -c /dev/null - -ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/usr/bin/actool --version --output-format xml1 - -ExecuteExternalTool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld -version_details - -Build description signature: d306b18d4ca3c34143e200f5683e27cb -Build description path: /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/XCBuildData/d306b18d4ca3c34143e200f5683e27cb.xcbuilddata -ClangStatCache /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-stat-cache /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk /Users/markgregory/Developer/Applications/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache - cd /Users/markgregory/Developer/Applications/KJamsClone/KJMix\ Pro.xcodeproj - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang-stat-cache /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -o /Users/markgregory/Developer/Applications/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache - -SwiftDriver KJMix\ Pro normal arm64 com.apple.xcode.tools.swift.compiler (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftDriver -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsClone -Onone @/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro.SwiftFileList -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target arm64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Developer/Applications/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -F /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-generated-files.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-own-target-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-project-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/DerivedSources-normal/arm64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/DerivedSources/arm64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone-Swift.h -working-directory /Users/markgregory/Developer/Applications/KJamsClone -experimental-emit-module-separately -disable-cmo - -SwiftDriver KJMix\ Pro normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftDriver -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsClone -Onone @/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro.SwiftFileList -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target x86_64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Developer/Applications/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -F /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-generated-files.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-own-target-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-project-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/DerivedSources-normal/x86_64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/DerivedSources/x86_64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone-Swift.h -working-directory /Users/markgregory/Developer/Applications/KJamsClone -experimental-emit-module-separately -disable-cmo - -ProcessInfoPlistFile /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/Info.plist /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/empty-KJMix\ Pro.plist (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-infoPlistUtility /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/empty-KJMix\ Pro.plist -producttype com.apple.product-type.application -genpkginfo /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/PkgInfo -expandbuildsettings -platform macosx -additionalcontentfile /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/assetcatalog_generated_info.plist -o /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/Info.plist - -SwiftEmitModule normal x86_64 Emitting\ module\ for\ KJamsClone (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftCompile normal x86_64 (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - - -SwiftCompile normal x86_64 Compiling\ KJMixProApp.swift /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/KJMixProApp.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftCompile normal x86_64 /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/KJMixProApp.swift (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftPerFileCompile KJMixProApp.swift - -SwiftCompile normal arm64 Compiling\ KJMixProApp.swift /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/KJMixProApp.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftCompile normal arm64 /Users/markgregory/Developer/Applications/KJamsClone/KJamsClone/KJMixProApp.swift (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftPerFileCompile KJMixProApp.swift - -SwiftEmitModule normal arm64 Emitting\ module\ for\ KJamsClone (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftCompile normal arm64 (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - - -SwiftDriverJobDiscovery normal arm64 Emitting module for KJamsClone (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftDriver\ Compilation\ Requirements KJMix\ Pro normal arm64 com.apple.xcode.tools.swift.compiler (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-Swift-Compilation-Requirements -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsClone -Onone @/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro.SwiftFileList -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target arm64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Developer/Applications/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -F /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-generated-files.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-own-target-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-project-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/DerivedSources-normal/arm64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/DerivedSources/arm64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone-Swift.h -working-directory /Users/markgregory/Developer/Applications/KJamsClone -experimental-emit-module-separately -disable-cmo - -Copy /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/Project/arm64-apple-macos.swiftsourceinfo /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.swiftsourceinfo (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.swiftsourceinfo /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/Project/arm64-apple-macos.swiftsourceinfo - -SwiftDriverJobDiscovery normal x86_64 Emitting module for KJamsClone (in target 'KJMix Pro' from project 'KJMix Pro') - -Copy /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/arm64-apple-macos.swiftmodule /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.swiftmodule (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.swiftmodule /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/arm64-apple-macos.swiftmodule - -Copy /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/arm64-apple-macos.abi.json /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.abi.json (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.abi.json /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/arm64-apple-macos.abi.json - -SwiftDriver\ Compilation\ Requirements KJMix\ Pro normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-Swift-Compilation-Requirements -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsClone -Onone @/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro.SwiftFileList -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target x86_64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Developer/Applications/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -F /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-generated-files.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-own-target-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-project-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/DerivedSources-normal/x86_64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/DerivedSources/x86_64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone-Swift.h -working-directory /Users/markgregory/Developer/Applications/KJamsClone -experimental-emit-module-separately -disable-cmo - -Copy /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/x86_64-apple-macos.swiftmodule /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.swiftmodule (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.swiftmodule /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/x86_64-apple-macos.swiftmodule - -Copy /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/x86_64-apple-macos.abi.json /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.abi.json (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.abi.json /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/x86_64-apple-macos.abi.json - -Copy /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/Project/x86_64-apple-macos.swiftsourceinfo /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.swiftsourceinfo (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.swiftsourceinfo /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJamsClone.swiftmodule/Project/x86_64-apple-macos.swiftsourceinfo - -SwiftDriver KJMixProTests normal arm64 com.apple.xcode.tools.swift.compiler (in target 'KJMixProTests' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftDriver -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJMixProTests -Onone @/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests.SwiftFileList -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins/testing -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target arm64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Developer/Applications/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -Isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -parse-as-library -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-generated-files.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-own-target-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-project-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/DerivedSources-normal/arm64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/DerivedSources/arm64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests-Swift.h -working-directory /Users/markgregory/Developer/Applications/KJamsClone -experimental-emit-module-separately -disable-cmo - -SwiftCompile normal arm64 Compiling\ KJamsCloneTests.swift /Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift (in target 'KJMixProTests' from project 'KJMix Pro') -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:756:73: warning: 'stringValue' was deprecated in macOS 13.0: Use load(.stringValue) instead [#DeprecatedDeclaration] - 754 | let files = try FileManager.default.contentsOfDirectory(at:backup,includingPropertiesForKeys:nil);XCTAssertEqual(files.count,1);XCTAssertEqual(try Data(contentsOf:files[0]),original) - 755 | let metadata = try await AVURLAsset(url:url).load(.commonMetadata) - 756 | XCTAssertEqual(metadata.first{$0.commonKey == .commonKeyTitle}?.stringValue,"Updated ✓") - | `- warning: 'stringValue' was deprecated in macOS 13.0: Use load(.stringValue) instead [#DeprecatedDeclaration] - 757 | var second = song;second.title = "Second";try await FileTagWriter.write(second,backupDirectory:backup) - 758 | XCTAssertEqual(try AudioWaveform.read(url:url,bins:64),before) - -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:824:73: warning: 'stringValue' was deprecated in macOS 13.0: Use load(.stringValue) instead [#DeprecatedDeclaration] - 822 | XCTAssertEqual(tracks.count,1) - 823 | let metadata = try await asset.load(.commonMetadata) - 824 | XCTAssertEqual(metadata.first{$0.commonKey == .commonKeyTitle}?.stringValue,"Tagged Video") - | `- warning: 'stringValue' was deprecated in macOS 13.0: Use load(.stringValue) instead [#DeprecatedDeclaration] - 825 | } - 826 | - -[#DeprecatedDeclaration]: - -SwiftCompile normal arm64 /Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift (in target 'KJMixProTests' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftPerFileCompile KJamsCloneTests.swift - -SwiftEmitModule normal arm64 Emitting\ module\ for\ KJMixProTests (in target 'KJMixProTests' from project 'KJMix Pro') - -SwiftCompile normal arm64 (in target 'KJMixProTests' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - - -SwiftDriverJobDiscovery normal arm64 Emitting module for KJMixProTests (in target 'KJMixProTests' from project 'KJMix Pro') - -SwiftDriver\ Compilation\ Requirements KJMixProTests normal arm64 com.apple.xcode.tools.swift.compiler (in target 'KJMixProTests' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-Swift-Compilation-Requirements -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJMixProTests -Onone @/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests.SwiftFileList -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins/testing -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target arm64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Developer/Applications/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -Isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -parse-as-library -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-generated-files.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-own-target-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-project-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/DerivedSources-normal/arm64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/DerivedSources/arm64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests-Swift.h -working-directory /Users/markgregory/Developer/Applications/KJamsClone -experimental-emit-module-separately -disable-cmo - -SwiftDriver KJMixProTests normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'KJMixProTests' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftDriver -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJMixProTests -Onone @/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests.SwiftFileList -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins/testing -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target x86_64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Developer/Applications/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -Isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -parse-as-library -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-generated-files.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-own-target-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-project-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/DerivedSources-normal/x86_64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/DerivedSources/x86_64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests-Swift.h -working-directory /Users/markgregory/Developer/Applications/KJamsClone -experimental-emit-module-separately -disable-cmo - -Copy /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMixProTests.swiftmodule/arm64-apple-macos.abi.json /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests.abi.json (in target 'KJMixProTests' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests.abi.json /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMixProTests.swiftmodule/arm64-apple-macos.abi.json - -SwiftEmitModule normal x86_64 Emitting\ module\ for\ KJMixProTests (in target 'KJMixProTests' from project 'KJMix Pro') - -SwiftCompile normal x86_64 (in target 'KJMixProTests' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - - -SwiftDriverJobDiscovery normal x86_64 Emitting module for KJMixProTests (in target 'KJMixProTests' from project 'KJMix Pro') - -SwiftDriver\ Compilation\ Requirements KJMixProTests normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'KJMixProTests' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-Swift-Compilation-Requirements -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJMixProTests -Onone @/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests.SwiftFileList -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins/testing -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target x86_64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Developer/Applications/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -Isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -parse-as-library -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-generated-files.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-own-target-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-project-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/DerivedSources-normal/x86_64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/DerivedSources/x86_64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests-Swift.h -working-directory /Users/markgregory/Developer/Applications/KJamsClone -experimental-emit-module-separately -disable-cmo - -Copy /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMixProTests.swiftmodule/x86_64-apple-macos.abi.json /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests.abi.json (in target 'KJMixProTests' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -strip-unsigned-binaries -strip-deterministic -strip-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip -resolve-src-symlinks -rename /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests.abi.json /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMixProTests.swiftmodule/x86_64-apple-macos.abi.json - -SwiftDriverJobDiscovery normal arm64 Compiling KJamsCloneTests.swift (in target 'KJMixProTests' from project 'KJMix Pro') - -SwiftDriver\ Compilation KJMixProTests normal arm64 com.apple.xcode.tools.swift.compiler (in target 'KJMixProTests' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-Swift-Compilation -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJMixProTests -Onone @/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests.SwiftFileList -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins/testing -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target arm64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Developer/Applications/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -Isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -parse-as-library -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-generated-files.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-own-target-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-project-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/DerivedSources-normal/arm64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/DerivedSources/arm64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests-Swift.h -working-directory /Users/markgregory/Developer/Applications/KJamsClone -experimental-emit-module-separately -disable-cmo - -SwiftDriverJobDiscovery normal arm64 Compiling KJMixProApp.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftDriver\ Compilation KJMix\ Pro normal arm64 com.apple.xcode.tools.swift.compiler (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-Swift-Compilation -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsClone -Onone @/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro.SwiftFileList -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target arm64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Developer/Applications/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -F /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-generated-files.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-own-target-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-project-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/DerivedSources-normal/arm64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/DerivedSources/arm64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone-Swift.h -working-directory /Users/markgregory/Developer/Applications/KJamsClone -experimental-emit-module-separately -disable-cmo - -Ld /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/Binary/KJMix\ Pro.debug.dylib normal arm64 (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target arm64-apple-macos13.0 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -Os -Xlinker -no_warn_duplicate_libraries -L/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -L/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -F/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -F/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -filelist /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro.LinkFileList -install_name @rpath/KJMix\ Pro.debug.dylib -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -object_path_lto -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro_lto.o -rdynamic -Xlinker -dependency_info -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro_dependency_info.dat -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJamsClone.swiftmodule -lsqlite3 -Xlinker -alias -Xlinker _main -Xlinker ___debug_main_executable_dylib_entry_point -o /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/Binary/KJMix\ Pro.debug.dylib - -ConstructStubExecutorLinkFileList /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-ExecutorLinkFileList-normal-arm64.txt (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - construct-stub-executor-link-file-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/Binary/KJMix\ Pro.debug.dylib /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/libPreviewsJITStubExecutor_no_swift_entry_point.a /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/libPreviewsJITStubExecutor.a --output /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-ExecutorLinkFileList-normal-arm64.txt -note: Using stub executor library with Swift entry point. (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftDriverJobDiscovery normal x86_64 Compiling KJMixProApp.swift (in target 'KJMix Pro' from project 'KJMix Pro') - -SwiftDriver\ Compilation KJMix\ Pro normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-Swift-Compilation -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJamsClone -Onone @/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro.SwiftFileList -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target x86_64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Developer/Applications/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -F /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-generated-files.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-own-target-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-project-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/DerivedSources-normal/x86_64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/DerivedSources/x86_64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone-Swift.h -working-directory /Users/markgregory/Developer/Applications/KJamsClone -experimental-emit-module-separately -disable-cmo - -Ld /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/Binary/KJMix\ Pro.debug.dylib normal x86_64 (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target x86_64-apple-macos13.0 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -Os -Xlinker -no_warn_duplicate_libraries -L/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -L/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -F/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -F/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -filelist /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro.LinkFileList -install_name @rpath/KJMix\ Pro.debug.dylib -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -object_path_lto -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro_lto.o -rdynamic -Xlinker -dependency_info -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro_dependency_info.dat -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJamsClone.swiftmodule -lsqlite3 -Xlinker -alias -Xlinker _main -Xlinker ___debug_main_executable_dylib_entry_point -o /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/Binary/KJMix\ Pro.debug.dylib - -CreateUniversalBinary /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/MacOS/KJMix\ Pro.debug.dylib normal arm64\ x86_64 (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo -create /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/Binary/KJMix\ Pro.debug.dylib /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/Binary/KJMix\ Pro.debug.dylib -output /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/MacOS/KJMix\ Pro.debug.dylib - -ConstructStubExecutorLinkFileList /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-ExecutorLinkFileList-normal-x86_64.txt (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - construct-stub-executor-link-file-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/Binary/KJMix\ Pro.debug.dylib /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/libPreviewsJITStubExecutor_no_swift_entry_point.a /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/libPreviewsJITStubExecutor.a --output /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-ExecutorLinkFileList-normal-x86_64.txt -note: Using stub executor library with Swift entry point. (in target 'KJMix Pro' from project 'KJMix Pro') - -Ld /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/Binary/KJMix\ Pro normal x86_64 (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target x86_64-apple-macos13.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -Os -Xlinker -no_warn_duplicate_libraries -L/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -F/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -Xlinker -rpath -Xlinker @executable_path -rdynamic -e ___debug_blank_executor_main -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __debug_dylib -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-DebugDylibPath-normal-x86_64.txt -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __debug_instlnm -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-DebugDylibInstallName-normal-x86_64.txt -Xlinker -filelist -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-ExecutorLinkFileList-normal-x86_64.txt /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/Binary/KJMix\ Pro.debug.dylib -o /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/Binary/KJMix\ Pro - -Ld /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/Binary/KJMix\ Pro normal arm64 (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target arm64-apple-macos13.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -Os -Xlinker -no_warn_duplicate_libraries -L/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -F/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -Xlinker -rpath -Xlinker @executable_path -rdynamic -e ___debug_blank_executor_main -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __debug_dylib -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-DebugDylibPath-normal-arm64.txt -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __debug_instlnm -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-DebugDylibInstallName-normal-arm64.txt -Xlinker -filelist -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro-ExecutorLinkFileList-normal-arm64.txt /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/Binary/KJMix\ Pro.debug.dylib -o /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/Binary/KJMix\ Pro - -CreateUniversalBinary /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/MacOS/KJMix\ Pro normal arm64\ x86_64 (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo -create /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/Binary/KJMix\ Pro /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/Binary/KJMix\ Pro -output /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/MacOS/KJMix\ Pro - -CopySwiftLibs /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-swiftStdLibTool --copy --verbose --scan-executable /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/MacOS/KJMix\ Pro.debug.dylib --scan-folder /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/Frameworks --scan-folder /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/PlugIns --scan-folder /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/Library/SystemExtensions --scan-folder /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/Extensions --platform macosx --toolchain /var/run/com.apple.security.cryptexd/mnt/com.apple.MobileAsset.MetalToolchain-v27.2.47.0.Ex1CTN/Metal.xctoolchain --toolchain /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain --destination /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/Frameworks --strip-bitcode --strip-bitcode-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bitcode_strip --emit-dependency-info /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/SwiftStdLibToolInputDependencies.dep --filter-for-swift-os --back-deploy-swift-span -Ignoring --strip-bitcode because --sign was not passed - -ExtractAppIntentsMetadata (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/appintentsmetadataprocessor --toolchain-dir /var/run/com.apple.security.cryptexd/mnt/com.apple.MobileAsset.MetalToolchain-v27.2.47.0.Ex1CTN/Metal.xctoolchain --module-name KJamsClone --sdk-root /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk --xcode-version 27B52 --platform-family macOS --deployment-target 13.0 --bundle-identifier com.kjamsclone.app --output /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/Resources --target-triple arm64-apple-macos13.0 --target-triple x86_64-apple-macos13.0 --binary-file /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/MacOS/KJMix\ Pro --dependency-file /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro_dependency_info.dat --dependency-file /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro_dependency_info.dat --stringsdata-file /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/ExtractedAppShortcutsMetadata.stringsdata --stringsdata-file /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/ExtractedAppShortcutsMetadata.stringsdata --source-file-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro.SwiftFileList --source-file-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro.SwiftFileList --metadata-file-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro.DependencyMetadataFileList --static-metadata-file-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/KJMix\ Pro.DependencyStaticMetadataFileList --swift-const-vals-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/arm64/KJMix\ Pro.SwiftConstValuesFileList --swift-const-vals-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMix\ Pro.build/Objects-normal/x86_64/KJMix\ Pro.SwiftConstValuesFileList --compile-time-extraction --deployment-aware-processing --no-app-shortcuts-localization -2026-11-03 13:58:36.264 appintentsmetadataprocessor[6945:152699] Starting App Intents metadata extraction -2026-11-03 13:58:36.266 appintentsmetadataprocessor[6945:152699] warning: Metadata extraction skipped, no AppIntents.framework dependency found - -ProcessInfoPlistFile /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/PlugIns/KJMixProTests.xctest/Contents/Info.plist /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/empty-KJMixProTests.plist (in target 'KJMixProTests' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-infoPlistUtility /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/empty-KJMixProTests.plist -producttype com.apple.product-type.bundle.unit-test -expandbuildsettings -platform macosx -o /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/PlugIns/KJMixProTests.xctest/Contents/Info.plist - -Ld /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/Binary/KJMixProTests normal arm64 (in target 'KJMixProTests' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target arm64-apple-macos13.0 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -Os -Xlinker -no_warn_duplicate_libraries -L/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -L/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -F/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -filelist /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests.LinkFileList -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @loader_path/../Frameworks -Xlinker -rpath -Xlinker @executable_path/../Frameworks -bundle_loader /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/MacOS/KJMix\ Pro -Xlinker -object_path_lto -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests_lto.o -rdynamic -Xlinker -dependency_info -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests_dependency_info.dat -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests.swiftmodule -lsqlite3 -Xlinker -needed_framework -Xlinker XCTest -framework XCTest -Xlinker -needed-lXCTestSwiftSupport -lXCTestSwiftSupport /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/MacOS/KJMix\ Pro.debug.dylib -o /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/Binary/KJMixProTests -/Users/markgregory/Developer/Applications/KJamsClone/KJMix Pro.xcodeproj: KJMixProTests: ld: warning: building for macOS-13.0, but linking with dylib '@rpath/XCTest.framework/Versions/A/XCTest' which was built for newer version 14.0 -/Users/markgregory/Developer/Applications/KJamsClone/KJMix Pro.xcodeproj: KJMixProTests: ld: warning: building for macOS-13.0, but linking with dylib '@rpath/libXCTestSwiftSupport.dylib' which was built for newer version 14.0 - -SwiftCompile normal x86_64 Compiling\ KJamsCloneTests.swift /Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift (in target 'KJMixProTests' from project 'KJMix Pro') - -SwiftCompile normal x86_64 /Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift (in target 'KJMixProTests' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-SwiftPerFileCompile KJamsCloneTests.swift - -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:756:73: warning: 'stringValue' was deprecated in macOS 13.0: Use load(.stringValue) instead [#DeprecatedDeclaration] - 754 | let files = try FileManager.default.contentsOfDirectory(at:backup,includingPropertiesForKeys:nil);XCTAssertEqual(files.count,1);XCTAssertEqual(try Data(contentsOf:files[0]),original) - 755 | let metadata = try await AVURLAsset(url:url).load(.commonMetadata) - 756 | XCTAssertEqual(metadata.first{$0.commonKey == .commonKeyTitle}?.stringValue,"Updated ✓") - | `- warning: 'stringValue' was deprecated in macOS 13.0: Use load(.stringValue) instead [#DeprecatedDeclaration] - 757 | var second = song;second.title = "Second";try await FileTagWriter.write(second,backupDirectory:backup) - 758 | XCTAssertEqual(try AudioWaveform.read(url:url,bins:64),before) - -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:824:73: warning: 'stringValue' was deprecated in macOS 13.0: Use load(.stringValue) instead [#DeprecatedDeclaration] - 822 | XCTAssertEqual(tracks.count,1) - 823 | let metadata = try await asset.load(.commonMetadata) - 824 | XCTAssertEqual(metadata.first{$0.commonKey == .commonKeyTitle}?.stringValue,"Tagged Video") - | `- warning: 'stringValue' was deprecated in macOS 13.0: Use load(.stringValue) instead [#DeprecatedDeclaration] - 825 | } - 826 | - -[#DeprecatedDeclaration]: -SwiftDriverJobDiscovery normal x86_64 Compiling KJamsCloneTests.swift (in target 'KJMixProTests' from project 'KJMix Pro') - -SwiftDriver\ Compilation KJMixProTests normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'KJMixProTests' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-Swift-Compilation -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -module-name KJMixProTests -Onone @/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests.SwiftFileList -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins/testing -enable-bare-slash-regex -enable-experimental-feature DebugDescriptionMacro -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -target x86_64-apple-macos13.0 -g -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -Xfrontend -serialize-debugging-options -enable-testing -index-store-path /Users/markgregory/Developer/Applications/KJamsClone/build/Index.noindex/DataStore -swift-version 5 -I /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -Isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -parse-as-library -c -j11 -enable-batch-mode -incremental -Xcc -ivfsstatcache -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/SDKStatCaches.noindex/macosx27.2-26B118-9aa026f88bf9ed31cff8761912ac5bd1a7ff82d74745d5ef33555b35c4238456.sdkstatcache -output-file-map /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests-OutputFileMap.json -save-temps -no-color-diagnostics -explicit-module-build -module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules -clang-scanner-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex -sdk-module-cache-path /Users/markgregory/Developer/Applications/KJamsClone/build/SDKExplicitPrecompiledModules -emit-dependencies -emit-module -emit-module-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests.swiftmodule -serialize-diagnostics -dependency-scan-serialize-diagnostics-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests-dependency-scan.dia -validate-clang-modules-once -clang-build-session-file /Users/markgregory/Developer/Applications/KJamsClone/build/ModuleCache.noindex/Session.modulevalidation -Xcc -fmodules-prune-interval\=86400 -Xcc -fmodules-prune-after\=345600 -emit-const-values -const-gather-protocols-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests_const_extract_protocols.json -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-generated-files.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-own-target-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-all-target-headers.hmap -Xcc -iquote -Xcc /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests-project-headers.hmap -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/include -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/DerivedSources-normal/x86_64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/DerivedSources/x86_64 -Xcc -I/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/DerivedSources -emit-objc-header -emit-objc-header-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests-Swift.h -working-directory /Users/markgregory/Developer/Applications/KJamsClone -experimental-emit-module-separately -disable-cmo - -Ld /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/Binary/KJMixProTests normal x86_64 (in target 'KJMixProTests' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target x86_64-apple-macos13.0 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk -Os -Xlinker -no_warn_duplicate_libraries -L/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -L/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/EagerLinkingTBDs/Debug -F/Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug -iframework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -filelist /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests.LinkFileList -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @loader_path/../Frameworks -Xlinker -rpath -Xlinker @executable_path/../Frameworks -bundle_loader /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/MacOS/KJMix\ Pro -Xlinker -object_path_lto -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests_lto.o -rdynamic -Xlinker -dependency_info -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests_dependency_info.dat -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests.swiftmodule -lsqlite3 -Xlinker -needed_framework -Xlinker XCTest -framework XCTest -Xlinker -needed-lXCTestSwiftSupport -lXCTestSwiftSupport /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/MacOS/KJMix\ Pro.debug.dylib -o /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/Binary/KJMixProTests -/Users/markgregory/Developer/Applications/KJamsClone/KJMix Pro.xcodeproj: KJMixProTests: ld: warning: building for macOS-13.0, but linking with dylib '@rpath/XCTest.framework/Versions/A/XCTest' which was built for newer version 14.0 -/Users/markgregory/Developer/Applications/KJamsClone/KJMix Pro.xcodeproj: KJMixProTests: ld: warning: building for macOS-13.0, but linking with dylib '@rpath/libXCTestSwiftSupport.dylib' which was built for newer version 14.0 - -CreateUniversalBinary /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/PlugIns/KJMixProTests.xctest/Contents/MacOS/KJMixProTests normal arm64\ x86_64 (in target 'KJMixProTests' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo -create /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/Binary/KJMixProTests /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/Binary/KJMixProTests -output /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/PlugIns/KJMixProTests.xctest/Contents/MacOS/KJMixProTests - -CopySwiftLibs /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/PlugIns/KJMixProTests.xctest (in target 'KJMixProTests' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-swiftStdLibTool --copy --verbose --scan-executable /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/PlugIns/KJMixProTests.xctest/Contents/MacOS/KJMixProTests --scan-folder /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/PlugIns/KJMixProTests.xctest/Contents/Frameworks --scan-folder /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/PlugIns/KJMixProTests.xctest/Contents/PlugIns --scan-folder /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/PlugIns/KJMixProTests.xctest/Contents/Library/SystemExtensions --scan-folder /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/PlugIns/KJMixProTests.xctest/Contents/Extensions --platform macosx --toolchain /var/run/com.apple.security.cryptexd/mnt/com.apple.MobileAsset.MetalToolchain-v27.2.47.0.Ex1CTN/Metal.xctoolchain --toolchain /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain --destination /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/PlugIns/KJMixProTests.xctest/Contents/Frameworks --strip-bitcode --scan-executable /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/libXCTestSwiftSupport.dylib --strip-bitcode-tool /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bitcode_strip --emit-dependency-info /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/SwiftStdLibToolInputDependencies.dep --filter-for-swift-os --back-deploy-swift-span -Ignoring --strip-bitcode because --sign was not passed - -ExtractAppIntentsMetadata (in target 'KJMixProTests' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/appintentsmetadataprocessor --toolchain-dir /var/run/com.apple.security.cryptexd/mnt/com.apple.MobileAsset.MetalToolchain-v27.2.47.0.Ex1CTN/Metal.xctoolchain --module-name KJMixProTests --sdk-root /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX27.2.sdk --xcode-version 27B52 --platform-family macOS --deployment-target 13.0 --bundle-identifier com.kjamsclone.tests --output /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/PlugIns/KJMixProTests.xctest/Contents/Resources --target-triple arm64-apple-macos13.0 --target-triple x86_64-apple-macos13.0 --binary-file /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app/Contents/PlugIns/KJMixProTests.xctest/Contents/MacOS/KJMixProTests --dependency-file /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests_dependency_info.dat --dependency-file /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests_dependency_info.dat --stringsdata-file /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/ExtractedAppShortcutsMetadata.stringsdata --stringsdata-file /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/ExtractedAppShortcutsMetadata.stringsdata --source-file-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests.SwiftFileList --source-file-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests.SwiftFileList --metadata-file-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests.DependencyMetadataFileList --static-metadata-file-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/KJMixProTests.DependencyStaticMetadataFileList --swift-const-vals-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/arm64/KJMixProTests.SwiftConstValuesFileList --swift-const-vals-list /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/KJMix\ Pro.build/Debug/KJMixProTests.build/Objects-normal/x86_64/KJMixProTests.SwiftConstValuesFileList --compile-time-extraction --deployment-aware-processing --no-app-shortcuts-localization -2026-11-03 13:58:37.359 appintentsmetadataprocessor[6952:152737] Starting App Intents metadata extraction -2026-11-03 13:58:37.361 appintentsmetadataprocessor[6952:152737] warning: Metadata extraction skipped, no AppIntents.framework dependency found - -Validate /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-validationUtility /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app -no-validate-extension -infoplist-subpath Contents/Info.plist - -RegisterWithLaunchServices /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app (in target 'KJMix Pro' from project 'KJMix Pro') - cd /Users/markgregory/Developer/Applications/KJamsClone - builtin-lsregisterurl --record-path /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/XCBuildData/registered-launchservices.txt -- /System/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks/LaunchServices.framework/Versions/Current/Support/lsregister -f -R -trusted /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Products/Debug/KJMix\ Pro.app - -PruneExplicitPrecompiledModules /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/SwiftExplicitPrecompiledModules - -PruneExplicitPrecompiledModules /Users/markgregory/Developer/Applications/KJamsClone/build/Build/Intermediates.noindex/ExplicitPrecompiledModules - -PruneExplicitPrecompiledModules /Users/markgregory/Developer/Applications/KJamsClone/build/SDKExplicitPrecompiledModules - -2026-11-03 13:58:37.964696+0000 KJMix Pro[6954:152857] [Connection] Unable to get remoteObjectProxy, error: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.linkd.autoShortcut" UserInfo={NSDebugDescription=connection to service named com.apple.linkd.autoShortcut} -2026-11-03 13:58:37.964872+0000 KJMix Pro[6954:152857] [Application] Error registering app with AppIntents framework: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.linkd.autoShortcut" UserInfo={NSDebugDescription=connection to service named com.apple.linkd.autoShortcut} -2026-11-03 13:58:38.010189+0000 KJMix Pro[6954:152806] [plugin] AddInstanceForFactory: No factory registered for id F8BB1C28-BAE8-11D6-9C31-00039315CD46 -2026-11-03 13:58:38.037807+0000 KJMix Pro[6954:152806] [logging-persist] cannot open file at line 53094 of [8fa8248e30] -2026-11-03 13:58:38.037823+0000 KJMix Pro[6954:152806] [logging-persist] os_unix.c:53094: (2) open(/private/var/db/DetachedSignatures) - No such file or directory -2026-11-03 13:58:38.125525+0000 KJMix Pro[6954:152806] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/54/8knnwrw15j74z4w2z_3_25q00000gn/T/com.kjamsclone.app.savedState -Test Suite 'All tests' started at 2026-11-03 13:58:38.681. -Test Suite 'KJMixProTests.xctest' started at 2026-11-03 13:58:38.682. -Test Suite 'KJamsCloneTests' started at 2026-11-03 13:58:38.682. -Test Case '-[KJMixProTests.KJamsCloneTests testActualRotationButtonsAddSongReorderAndStart]' started. -2026-11-03 13:58:38.766641+0000 KJMix Pro[6954:152806] [Window] Warning: -[NSWindow makeKeyWindow] called on windowNumber=40c which returned NO from -[NSWindow canBecomeKeyWindow]. -2026-11-03 13:58:39.018789+0000 KJMix Pro[6954:152919] [Connection] Unable to get remoteObjectProxy, error: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.linkd.autoShortcut" UserInfo={NSDebugDescription=connection to service named com.apple.linkd.autoShortcut} -2026-11-03 13:58:39.018905+0000 KJMix Pro[6954:152919] [Connection] Unable to re-register with Process Instance Registry, error: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.linkd.autoShortcut" UserInfo={NSDebugDescription=connection to service named com.apple.linkd.autoShortcut} -2026-11-03 13:58:40.537542+0000 KJMix Pro[6954:152952] [logging] BUG IN CLIENT OF libsqlite3.dylib: database integrity compromised by API violation: vnode unlinked while in use: /private/var/folders/54/8knnwrw15j74z4w2z_3_25q00000gn/T/1055B5C5-B476-4E83-8758-0FA9D4ADB808/Library.sqlite-wal -2026-11-03 13:58:40.537565+0000 KJMix Pro[6954:152952] [logging] invalidated open fd: 25 (0x11) -2026-11-03 13:58:40.537569+0000 KJMix Pro[6954:152954] [logging] BUG IN CLIENT OF libsqlite3.dylib: database integrity compromised by API violation: vnode unlinked while in use: /private/var/folders/54/8knnwrw15j74z4w2z_3_25q00000gn/T/1055B5C5-B476-4E83-8758-0FA9D4ADB808/Library.sqlite-shm -2026-11-03 13:58:40.537581+0000 KJMix Pro[6954:152954] [logging] invalidated open fd: 26 (0x11) -2026-11-03 13:58:40.537815+0000 KJMix Pro[6954:152954] [logging] BUG IN CLIENT OF libsqlite3.dylib: database integrity compromised by API violation: vnode unlinked while in use: /private/var/folders/54/8knnwrw15j74z4w2z_3_25q00000gn/T/1055B5C5-B476-4E83-8758-0FA9D4ADB808/Library.sqlite -2026-11-03 13:58:40.537822+0000 KJMix Pro[6954:152954] [logging] invalidated open fd: 24 (0x11) -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:0: warning: -[KJMixProTests.KJamsCloneTests testActualRotationButtonsAddSongReorderAndStart] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testActualRotationButtonsAddSongReorderAndStart]' passed (1.894 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testActualSingerDisclosurePressAndNavigationRetainExpansion]' started. -2026-11-03 13:58:40.643163+0000 KJMix Pro[6954:152806] [Window] Warning: -[NSWindow makeKeyWindow] called on windowNumber=40d which returned NO from -[NSWindow canBecomeKeyWindow]. -2026-11-03 13:58:41.150784+0000 KJMix Pro[6954:152951] [Connection] Unable to get remoteObjectProxy, error: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.linkd.autoShortcut" UserInfo={NSDebugDescription=connection to service named com.apple.linkd.autoShortcut} -2026-11-03 13:58:41.150817+0000 KJMix Pro[6954:152951] [Connection] Unable to re-register with Process Instance Registry, error: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.linkd.autoShortcut" UserInfo={NSDebugDescription=connection to service named com.apple.linkd.autoShortcut} -2026-11-03 13:58:41.853748+0000 KJMix Pro[6954:152950] [logging] BUG IN CLIENT OF libsqlite3.dylib: database integrity compromised by API violation: vnode unlinked while in use: /private/var/folders/54/8knnwrw15j74z4w2z_3_25q00000gn/T/2ED75CE8-3644-4657-BD58-B6123D4FC5A7/Library.sqlite-wal -2026-11-03 13:58:41.853786+0000 KJMix Pro[6954:152950] [logging] invalidated open fd: 25 (0x11) -2026-11-03 13:58:41.853798+0000 KJMix Pro[6954:152950] [logging] BUG IN CLIENT OF libsqlite3.dylib: database integrity compromised by API violation: vnode unlinked while in use: /private/var/folders/54/8knnwrw15j74z4w2z_3_25q00000gn/T/2ED75CE8-3644-4657-BD58-B6123D4FC5A7/Library.sqlite-shm -2026-11-03 13:58:41.853804+0000 KJMix Pro[6954:152950] [logging] invalidated open fd: 26 (0x11) -2026-11-03 13:58:41.853935+0000 KJMix Pro[6954:152950] [logging] BUG IN CLIENT OF libsqlite3.dylib: database integrity compromised by API violation: vnode unlinked while in use: /private/var/folders/54/8knnwrw15j74z4w2z_3_25q00000gn/T/2ED75CE8-3644-4657-BD58-B6123D4FC5A7/Library.sqlite -2026-11-03 13:58:41.853943+0000 KJMix Pro[6954:152950] [logging] invalidated open fd: 24 (0x11) -Test Case '-[KJMixProTests.KJamsCloneTests testActualSingerDisclosurePressAndNavigationRetainExpansion]' passed (1.294 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testAllStoreProfilesAndCatalogueValidation]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testAllStoreProfilesAndCatalogueValidation]' passed (0.028 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testAutomaticBackgroundHandoffAndManualOverride]' started. -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:947: warning: -[KJMixProTests.KJamsCloneTests testAutomaticBackgroundHandoffAndManualOverride] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testAutomaticBackgroundHandoffAndManualOverride]' passed (1.849 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testAutomaticVenueQueueAdvancesAndRecordsSinger]' started. -2026-11-03 13:58:44.006557+0000 KJMix Pro[6954:152806] [ClientDonation] (+[PPSClientDonation isRegisteredSubsystem:category:]) Permission denied: CoreMedia / CM-ASSETCREATION -:0: warning: -[KJMixProTests.KJamsCloneTests testAutomaticVenueQueueAdvancesAndRecordsSinger] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testAutomaticVenueQueueAdvancesAndRecordsSinger]' passed (0.762 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testBackgroundFadesSaveSettingsAndCancelOnSeekOrSinger]' started. -2026-11-03 13:58:45.165928+0000 KJMix Pro[6954:152954] [Connection] Will NOT re-try to establish the connection -2026-11-03 13:58:45.166155+0000 KJMix Pro[6954:152954] [Connection] Unable to get remoteObjectProxy, error: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.linkd.autoShortcut" UserInfo={NSDebugDescription=connection to service named com.apple.linkd.autoShortcut} -2026-11-03 13:58:45.166281+0000 KJMix Pro[6954:152954] [Connection] Unable to re-register with Process Instance Registry, error: Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.linkd.autoShortcut" UserInfo={NSDebugDescription=connection to service named com.apple.linkd.autoShortcut} -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:1087: warning: -[KJMixProTests.KJamsCloneTests testBackgroundFadesSaveSettingsAndCancelOnSeekOrSinger] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testBackgroundFadesSaveSettingsAndCancelOnSeekOrSinger]' passed (1.706 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testBackgroundSeekRetainsPlaybackStateAndSingerInterlock]' started. -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:1065: warning: -[KJMixProTests.KJamsCloneTests testBackgroundSeekRetainsPlaybackStateAndSingerInterlock] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testBackgroundSeekRetainsPlaybackStateAndSingerInterlock]' passed (0.298 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testBatchMetadataIsAtomicAndPlaylistOrderPersists]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testBatchMetadataIsAtomicAndPlaylistOrderPersists]' passed (0.010 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testBulkTuningCacheSwitchesSingersAndUpdatesWithoutLibraryReload]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testBulkTuningCacheSwitchesSingersAndUpdatesWithoutLibraryReload]' passed (0.035 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testConnectedSingerCreationAndSharedRepertoire]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testConnectedSingerCreationAndSharedRepertoire]' passed (0.067 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testCreateSingerAndVenueThroughAppModel]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testCreateSingerAndVenueThroughAppModel]' passed (0.040 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testDJStopCueHotCuesJogAndLoopKeepTrackLoaded]' started. -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:831: warning: -[KJMixProTests.KJamsCloneTests testDJStopCueHotCuesJogAndLoopKeepTrackLoaded] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testDJStopCueHotCuesJogAndLoopKeepTrackLoaded]' passed (0.579 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testEditableSongDefaultsAndSingerOverridesAreIndependent]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testEditableSongDefaultsAndSingerOverridesAreIndependent]' passed (0.070 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testFadePreservesGlobalMasterAndCancelsForNextSong]' started. -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:739: warning: -[KJMixProTests.KJamsCloneTests testFadePreservesGlobalMasterAndCancelsForNextSong] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testFadePreservesGlobalMasterAndCancelsForNextSong]' passed (0.752 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testFolderScanReferencesAudioAndPreparesReusableWaveform]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testFolderScanReferencesAudioAndPreparesReusableWaveform]' passed (0.183 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testFrequencyBandsDistinguishBassAndTreble]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testFrequencyBandsDistinguishBassAndTreble]' passed (0.004 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testHTTPParserRejectsSmugglingOversizeAndWaitsForBody]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testHTTPParserRejectsSmugglingOversizeAndWaitsForBody]' passed (0.001 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testLowPassAndHighPassFilterActualAudio]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testLowPassAndHighPassFilterActualAudio]' passed (0.031 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testManualBackgroundStopsBeforeSingerAndNeverAutoResumes]' started. -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:854: warning: -[KJMixProTests.KJamsCloneTests testManualBackgroundStopsBeforeSingerAndNeverAutoResumes] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testManualBackgroundStopsBeforeSingerAndNeverAutoResumes]' passed (0.269 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testMetadataEditsPersistAndSurviveReimport]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testMetadataEditsPersistAndSurviveReimport]' passed (0.007 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testMigrationAndMembershipRemovalDoesNotReappear]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testMigrationAndMembershipRemovalDoesNotReappear]' passed (0.012 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testMixerIsGlobalAndPersistsWithoutChangingTrackPreferences]' started. -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:646: warning: -[KJMixProTests.KJamsCloneTests testMixerIsGlobalAndPersistsWithoutChangingTrackPreferences] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testMixerIsGlobalAndPersistsWithoutChangingTrackPreferences]' passed (0.191 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testMP3FileTagWritingBacksUpPreservesAudioAndRejectsBadTags]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testMP3FileTagWritingBacksUpPreservesAudioAndRejectsBadTags]' passed (0.166 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testMP3PlaybackPauseAndSeek]' started. -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:85: warning: -[KJMixProTests.KJamsCloneTests testMP3PlaybackPauseAndSeek] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testMP3PlaybackPauseAndSeek]' passed (0.132 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testMP4ImportWaveformAndPlaybackThroughGlobalMixer]' started. -2026-11-03 13:58:49.160228+0000 KJMix Pro[6954:152952] [player] <<<< FigFilePlayer >>>> signalled err=-12864 at <>:10696 -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:673: warning: -[KJMixProTests.KJamsCloneTests testMP4ImportWaveformAndPlaybackThroughGlobalMixer] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testMP4ImportWaveformAndPlaybackThroughGlobalMixer]' passed (0.259 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testMP4TagExportPreservesVideoAndAudio]' started. -2026-11-03 13:58:49.345692+0000 KJMix Pro[6954:153163] [] (Fig) signalled err=-12785 at <>:1576 -2026-11-03 13:58:49.354600+0000 KJMix Pro[6954:153199] [] <<< FigReportingAgentRef >>> signalled err=-12005 at <>:1605 -2026-11-03 13:58:49.354614+0000 KJMix Pro[6954:153199] [] <<< FigReportingAgentRef >>> signalled err=-12005 at <>:1605 -2026-11-03 13:58:49.354623+0000 KJMix Pro[6954:153199] [] <<< FigPlayerModerator >>> signalled err=-17511 at <>:2110 -2026-11-03 13:58:49.354797+0000 KJMix Pro[6954:153199] [player] <<<< FigAirPlay_Route >>>> signalled err=-12860 at <>:696 -2026-11-03 13:58:49.387135+0000 KJMix Pro[6954:153204] [] <<<< FMDW_UserData >>>> signalled err=-12583 at <>:1072 -2026-11-03 13:58:49.387150+0000 KJMix Pro[6954:153204] [] <<<< FMDW_UserData >>>> signalled err=-12583 at <>:1072 -2026-11-03 13:58:49.387155+0000 KJMix Pro[6954:153204] [] <<<< FMDW_UserData >>>> signalled err=-12583 at <>:1072 -2026-11-03 13:58:49.387585+0000 KJMix Pro[6954:153157] [ClientDonation] (+[PPSClientDonation isRegisteredSubsystem:category:]) Permission denied: CoreMedia / CM-EXPORT -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:819: warning: -[KJMixProTests.KJamsCloneTests testMP4TagExportPreservesVideoAndAudio] : [Internal] Thread running at User-initiated quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testMP4TagExportPreservesVideoAndAudio]' passed (0.110 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testMusicStoreDefinitionsValidateSearchAndPersist]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testMusicStoreDefinitionsValidateSearchAndPersist]' passed (0.006 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testNativeSongDragProviderRoundTrip]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testNativeSongDragProviderRoundTrip]' passed (0.001 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testNaturalFinishAdvancesSingerBeforeBackgroundThenResumesWhenEmpty]' started. -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:978: warning: -[KJMixProTests.KJamsCloneTests testNaturalFinishAdvancesSingerBeforeBackgroundThenResumesWhenEmpty] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testNaturalFinishAdvancesSingerBeforeBackgroundThenResumesWhenEmpty]' passed (1.564 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testNewSingerSongsImmediatelyJoinSmartRotation]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testNewSingerSongsImmediatelyJoinSmartRotation]' passed (0.047 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testNewTestMediaMetadataAndCDGPairImport]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testNewTestMediaMetadataAndCDGPairImport]' passed (0.027 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testOfflineLocationAndDuplicateSourcePreserveLibrary]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testOfflineLocationAndDuplicateSourcePreserveLibrary]' passed (0.074 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testPairedImportAndContentDedup]' started. -2026-11-03 13:58:51.162028+0000 KJMix Pro[6954:153176] [] <<< FFR_Common >>> signalled err=-12873 at <>:4132 -2026-11-03 13:58:51.162160+0000 KJMix Pro[6954:152806] MP3AudioFile.cpp:1565 Problem scanning for packets -2026-11-03 13:58:51.162170+0000 KJMix Pro[6954:152806] MP3AudioFile.cpp:1067 MPEGAudioFile::OpenFromDataSource failed -2026-11-03 13:58:51.162175+0000 KJMix Pro[6954:152806] AudioFileObject.cpp:106 OpenFromDataSource failed -2026-11-03 13:58:51.162178+0000 KJMix Pro[6954:152806] AudioFileObject.cpp:81 Open failed -2026-11-03 13:58:51.162204+0000 KJMix Pro[6954:152806] [avae] AVAEInternal.h:109 [AVAudioFile.mm:305:AVAudioFileImpl: (ExtAudioFileOpenURL((__bridge CFURLRef)fileURL, &_extAudioFile)): error 1685348671 -2026-11-03 13:58:51.162708+0000 KJMix Pro[6954:153176] [] <<< FFR_Common >>> signalled err=-12873 at <>:4132 -2026-11-03 13:58:51.162828+0000 KJMix Pro[6954:152806] MP3AudioFile.cpp:1565 Problem scanning for packets -2026-11-03 13:58:51.162833+0000 KJMix Pro[6954:152806] MP3AudioFile.cpp:1067 MPEGAudioFile::OpenFromDataSource failed -2026-11-03 13:58:51.162836+0000 KJMix Pro[6954:152806] AudioFileObject.cpp:106 OpenFromDataSource failed -2026-11-03 13:58:51.162838+0000 KJMix Pro[6954:152806] AudioFileObject.cpp:81 Open failed -2026-11-03 13:58:51.162861+0000 KJMix Pro[6954:152806] [avae] AVAEInternal.h:109 [AVAudioFile.mm:305:AVAudioFileImpl: (ExtAudioFileOpenURL((__bridge CFURLRef)fileURL, &_extAudioFile)): error 1685348671 -Test Case '-[KJMixProTests.KJamsCloneTests testPairedImportAndContentDedup]' passed (0.008 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testPaletteBorderScrollAndImage]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testPaletteBorderScrollAndImage]' passed (0.032 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testPauseAndUnloadCancelSingerWaitingForBackgroundFade]' started. -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:1125: warning: -[KJMixProTests.KJamsCloneTests testPauseAndUnloadCancelSingerWaitingForBackgroundFade] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testPauseAndUnloadCancelSingerWaitingForBackgroundFade]' passed (0.984 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testPlayerReusesSavedWaveformAndCanForceReanalysis]' started. -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:451: warning: -[KJMixProTests.KJamsCloneTests testPlayerReusesSavedWaveformAndCanForceReanalysis] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testPlayerReusesSavedWaveformAndCanForceReanalysis]' passed (0.354 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testPresetTileXORAndInvalidCoordinates]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testPresetTileXORAndInvalidCoordinates]' passed (0.001 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testQueuePlaylistsPreferencesAndDeletion]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testQueuePlaylistsPreferencesAndDeletion]' passed (0.006 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testQueueRemembersSingerSongWithoutDuplicatingAssignment]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testQueueRemembersSingerSongWithoutDuplicatingAssignment]' passed (0.005 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testRapidCDGJogCannotPublishAnOldSeekFrame]' started. -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:926: warning: -[KJMixProTests.KJamsCloneTests testRapidCDGJogCannotPublishAnOldSeekFrame] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testRapidCDGJogCannotPublishAnOldSeekFrame]' passed (0.504 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testReorderingPlayedTonightDoesNotQueueItAgain]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testReorderingPlayedTonightDoesNotQueueItAgain]' passed (0.040 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testRotationDragTargetsExplicitVenueAndReordersRoster]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testRotationDragTargetsExplicitVenueAndReordersRoster]' passed (0.029 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testRotationSettingsRosterAndPersonalRatingsPersistPerVenue]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testRotationSettingsRosterAndPersonalRatingsPersistPerVenue]' passed (0.048 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testRotationStartPauseResumeStopAndEmptyExplanation]' started. -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:999: warning: -[KJMixProTests.KJamsCloneTests testRotationStartPauseResumeStopAndEmptyExplanation] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testRotationStartPauseResumeStopAndEmptyExplanation]' passed (0.114 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testSeekAndTruncatedPacket]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testSeekAndTruncatedPacket]' passed (0.001 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testSettingsPersistWithoutAutoplayAndPreserveMaster]' started. -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:866: warning: -[KJMixProTests.KJamsCloneTests testSettingsPersistWithoutAutoplayAndPreserveMaster] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testSettingsPersistWithoutAutoplayAndPreserveMaster]' passed (0.533 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testShowScreensPersistRenderPauseSeekAndFinish]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testShowScreensPersistRenderPauseSeekAndFinish]' passed (0.242 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testSingerAPIIsolationRevocationAndPersonalSettings]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testSingerAPIIsolationRevocationAndPersonalSettings]' passed (0.049 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testSingerWaitsForAudibleBackgroundFadeOut]' started. -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:1108: warning: -[KJMixProTests.KJamsCloneTests testSingerWaitsForAudibleBackgroundFadeOut] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testSingerWaitsForAudibleBackgroundFadeOut]' passed (1.261 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testSingerWebServerRealLoopbackHTTP]' started. -2026-11-03 13:58:55.451159+0000 KJMix Pro[6954:152950] [] nw_path_necp_check_for_updates Failed to copy updated result (22) -Test Case '-[KJMixProTests.KJamsCloneTests testSingerWebServerRealLoopbackHTTP]' passed (0.085 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testSmartRotationInterleavesPreservesEmptyAndDepartedCursor]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testSmartRotationInterleavesPreservesEmptyAndDepartedCursor]' passed (0.001 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testSongDropCopiesToTargetSingerAndRejectsWrongContext]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testSongDropCopiesToTargetSingerAndRejectsWrongContext]' passed (0.034 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testSourceZipUsesManagedMediaAndCancellationKeepsCompletedIndex]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testSourceZipUsesManagedMediaAndCancellationKeepsCompletedIndex]' passed (0.317 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testSQLitePersistenceDedupRatingsAndHistory]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testSQLitePersistenceDedupRatingsAndHistory]' passed (0.006 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testStandardMacPasteboardCarriesKJMixSongAndRejectsOtherText]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testStandardMacPasteboardCarriesKJMixSongAndRejectsOtherText]' passed (0.002 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testTargetedMultiTermQuotedExactAndNumericSearch]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testTargetedMultiTermQuotedExactAndNumericSearch]' passed (0.001 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testTempoSourceClockPauseAndResume]' started. -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:193: warning: -[KJMixProTests.KJamsCloneTests testTempoSourceClockPauseAndResume] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testTempoSourceClockPauseAndResume]' passed (0.986 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testToneEQBoostAndBypassProcessActualAudio]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testToneEQBoostAndBypassProcessActualAudio]' passed (0.024 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testTonightDragReorderPersistsAndKeepsOtherSingerSlots]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testTonightDragReorderPersistsAndKeepsOtherSingerSlots]' passed (0.042 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testTonightMigrationAndVenueIsolation]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testTonightMigrationAndVenueIsolation]' passed (0.006 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testTonightPersistsForEachSingerAcrossSwitchPlaybackAndRestart]' started. -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:474: warning: -[KJMixProTests.KJamsCloneTests testTonightPersistsForEachSingerAcrossSwitchPlaybackAndRestart] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testTonightPersistsForEachSingerAcrossSwitchPlaybackAndRestart]' passed (0.111 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testUnifiedRosterDropRoutesSingerAndSongProviders]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testUnifiedRosterDropRoutesSingerAndSongProviders]' passed (0.362 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testVenuesShareSingersAndRememberSelection]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testVenuesShareSingersAndRememberSelection]' passed (0.082 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testVersionThreeMigrationBuildsSingerSongListsFromHistory]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testVersionThreeMigrationBuildsSingerSongListsFromHistory]' passed (0.010 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testVisibleSingerReorderUpdatesManualAndSmartPlansAndPersists]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testVisibleSingerReorderUpdatesManualAndSmartPlansAndPersists]' passed (0.060 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testWaveformAnalysisAndStopClearsTrackData]' started. -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:263: warning: -[KJMixProTests.KJamsCloneTests testWaveformAnalysisAndStopClearsTrackData] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testWaveformAnalysisAndStopClearsTrackData]' passed (0.188 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testWaveformBatchCancellationKeepsCompletedCaches]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testWaveformBatchCancellationKeepsCompletedCaches]' passed (0.088 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testWaveformBatchDeduplicatesReportsMissingMediaAndSkipsSlides]' started. -2026-11-03 13:58:57.844328+0000 KJMix Pro[6954:152806] [avae] AVAEInternal.h:109 [AVAudioFile.mm:305:AVAudioFileImpl: (ExtAudioFileOpenURL((__bridge CFURLRef)fileURL, &_extAudioFile)): error 2003334207 -Test Case '-[KJMixProTests.KJamsCloneTests testWaveformBatchDeduplicatesReportsMissingMediaAndSkipsSlides]' passed (0.063 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testWaveformBatchGeneratesReusesAndForcesFreshAnalysis]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testWaveformBatchGeneratesReusesAndForcesFreshAnalysis]' passed (0.092 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testWaveformCacheRejectsChangedFilesAndCorruption]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testWaveformCacheRejectsChangedFilesAndCorruption]' passed (0.074 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testWaveformRepresentsSilenceAndSignalInTimeOrder]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testWaveformRepresentsSilenceAndSignalInTimeOrder]' passed (0.003 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testWaveformSelectionAndWholeLibraryGenerateWithoutChangingPlayback]' started. -/Users/markgregory/Developer/Applications/KJamsClone/KJamsCloneTests/KJamsCloneTests.swift:1164: warning: -[KJMixProTests.KJamsCloneTests testWaveformSelectionAndWholeLibraryGenerateWithoutChangingPlayback] : [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions -Test Case '-[KJMixProTests.KJamsCloneTests testWaveformSelectionAndWholeLibraryGenerateWithoutChangingPlayback]' passed (0.229 seconds). -Test Case '-[KJMixProTests.KJamsCloneTests testZippedMP3GImportAndUnsafeArchiveRejection]' started. -Test Case '-[KJMixProTests.KJamsCloneTests testZippedMP3GImportAndUnsafeArchiveRejection]' passed (0.291 seconds). -Test Suite 'KJamsCloneTests' passed at 2026-11-03 13:58:58.535. - Executed 73 tests, with 0 failures (0 unexpected) in 19.834 (19.853) seconds -Test Suite 'KJMixProTests.xctest' passed at 2026-11-03 13:58:58.535. - Executed 73 tests, with 0 failures (0 unexpected) in 19.834 (19.854) seconds -Test Suite 'All tests' passed at 2026-11-03 13:58:58.536. - Executed 73 tests, with 0 failures (0 unexpected) in 19.834 (19.855) seconds -2026-11-03 13:59:02.643 xcodebuild[6913:152399] [MT] IDETestOperationsObserverDebug: 25.227 elapsed -- Testing started completed. -2026-11-03 13:59:02.643 xcodebuild[6913:152399] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start -2026-11-03 13:59:02.643 xcodebuild[6913:152399] [MT] IDETestOperationsObserverDebug: 25.227 sec, +25.227 sec -- end - -Test session results, code coverage, and logs: - /Users/markgregory/Developer/Applications/KJamsClone/build/Logs/Test/Test-KJMix Pro-2026.11.03_13-58-27-+0000.xcresult - -** TEST SUCCEEDED ** - -Testing started