updated
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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<Int64>()
|
||||
@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<Int64>) 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<Int64>()
|
||||
@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<Int64>()
|
||||
@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..<count {
|
||||
let start = bar*player.waveform.count/count,end = max(start+1,(bar+1)*player.waveform.count/count)
|
||||
let level = player.waveform[start..<min(end,player.waveform.count)].max() ?? 0
|
||||
let height = max(0.7,CGFloat(level)*(plotHeight-3)),x = CGFloat(bar)*step
|
||||
let path = Path(CGRect(x:x,y:mid-height/2,width:max(0.7,step-0.7),height:height))
|
||||
context.fill(path,with:.color(bandColor(start).opacity(x <= size.width*progress ? 1 : 0.65)))
|
||||
}
|
||||
let x = size.width*progress
|
||||
var head = Path();head.move(to:CGPoint(x:x,y:top));head.addLine(to:CGPoint(x:x,y:size.height))
|
||||
context.stroke(head,with:.color(.red),lineWidth:1)
|
||||
} else if player.waveformLoading {
|
||||
context.draw(Text("Analysing waveform…").font(.system(size:9)).foregroundColor(.gray),at:CGPoint(x:size.width/2,y:mid))
|
||||
}
|
||||
}.contentShape(Rectangle())
|
||||
.gesture(DragGesture(minimumDistance:0).onEnded { value in
|
||||
guard player.duration > 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<Double>
|
||||
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")
|
||||
}
|
||||
}
|
||||
@@ -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<String> {
|
||||
let s = try statement("PRAGMA table_info(\(table))", []); defer { sqlite3_finalize(s) }
|
||||
var result = Set<String>(); 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
|
||||
}
|
||||
}
|
||||
@@ -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<Void, Never>?
|
||||
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<AudioWaveform.Analysis, Error>
|
||||
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..<frames {
|
||||
let bin = min(bins-1, Int((position+Int64(frame))*Int64(bins)/file.length))
|
||||
var sum: Double = 0
|
||||
for channel in 0..<channels {
|
||||
let sample = Double(data[channel][frame])
|
||||
if sample.isFinite {
|
||||
sum += sample * sample
|
||||
lowState[channel] = lowAlpha*lowState[channel]+(1-lowAlpha)*sample
|
||||
highState[channel] = highAlpha*highState[channel]+(1-highAlpha)*sample
|
||||
let low = lowState[channel], mid = highState[channel]-low, high = sample-highState[channel]
|
||||
lows[bin] += low*low; mids[bin] += mid*mid; highs[bin] += high*high
|
||||
}
|
||||
}
|
||||
energy[bin] += sum / Double(max(channels,1)); counts[bin] += 1
|
||||
}
|
||||
position += Int64(frames)
|
||||
}
|
||||
let rms = zip(energy, counts).map { $1 > 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..<bins).map { i in WaveformBands(low:Float(sqrt(lows[i])),mid:Float(sqrt(mids[i])),high:Float(sqrt(highs[i]))) }
|
||||
return .init(levels:levels,bands:bands)
|
||||
}
|
||||
}
|
||||
|
||||
struct WaveformBands: Sendable {
|
||||
var low: Float
|
||||
var mid: Float
|
||||
var high: Float
|
||||
}
|
||||
/// Four real audio filters; the filter knob is low-pass left, bypass at centre, high-pass right.
|
||||
enum AudioTone {
|
||||
static func configure(_ eq: AVAudioUnitEQ, sampleRate: Double, low: Double, mid: Double, high: Double, filter: Double, enabled: Bool) {
|
||||
eq.bypass = !enabled
|
||||
let frequencies = [160.0,1000.0,6000.0]
|
||||
let types: [AVAudioUnitEQFilterType] = [.lowShelf,.parametric,.highShelf]
|
||||
for i in 0..<3 {
|
||||
let band = eq.bands[i];band.filterType = types[i];band.frequency = Float(min(frequencies[i],sampleRate*0.4))
|
||||
band.bandwidth = 1;band.gain = Float(min(12,max(-12,[low,mid,high][i])));band.bypass = false
|
||||
}
|
||||
let value = min(1,max(-1,filter))
|
||||
let band = eq.bands[3];band.bypass = abs(value) < 0.01;band.bandwidth = 0.7
|
||||
band.filterType = value < 0 ? .lowPass : .highPass
|
||||
let frequency = value < 0 ? 20000*pow(0.004,-value) : 20*pow(400,value)
|
||||
band.frequency = Float(min(sampleRate*0.45,max(20,frequency)))
|
||||
}
|
||||
}
|
||||
/// The audio callback only updates a tiny locked snapshot; UI reads it on the existing clock.
|
||||
final class AudioLevelMeter: @unchecked Sendable {
|
||||
private let lock = NSLock()
|
||||
private var levels: (Float,Float) = (0,0)
|
||||
func consume(_ buffer: AVAudioPCMBuffer) {
|
||||
guard let data = buffer.floatChannelData else { return }
|
||||
let channels = Int(buffer.format.channelCount), frames = Int(buffer.frameLength)
|
||||
var left: Float = 0, right: Float = 0
|
||||
for i in 0..<frames {
|
||||
left = max(left,abs(data[0][i]));right = max(right,abs(data[min(1,channels-1)][i]))
|
||||
}
|
||||
lock.lock();levels = (left,right);lock.unlock()
|
||||
}
|
||||
func snapshot() -> (Float,Float) { lock.lock();defer { lock.unlock() };return levels }
|
||||
func reset() { lock.lock();levels = (0,0);lock.unlock() }
|
||||
}
|
||||
@@ -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..<Int(output.frameLength) { let v = Double(output.floatChannelData![0][i]);energy += v*v;count += 1 } }
|
||||
}
|
||||
return sqrt(energy/Double(max(1,count)))
|
||||
}
|
||||
func testToneEQBoostAndBypassProcessActualAudio() throws {
|
||||
let flat = try toneRMS(frequency:60)
|
||||
let boosted = try toneRMS(frequency:60,low:12)
|
||||
let bypassed = try toneRMS(frequency:60,low:12,enabled:false)
|
||||
XCTAssertGreaterThan(flat,0.01);XCTAssertGreaterThan(boosted,flat*2)
|
||||
XCTAssertEqual(bypassed/flat,1,accuracy:0.05)
|
||||
}
|
||||
func testLowPassAndHighPassFilterActualAudio() throws {
|
||||
let high = try toneRMS(frequency:6000),low = try toneRMS(frequency:60)
|
||||
XCTAssertLessThan(try toneRMS(frequency:6000,filter:-1),high*0.1)
|
||||
XCTAssertLessThan(try toneRMS(frequency:60,filter:1),low*0.1)
|
||||
}
|
||||
func testVersionThreeMigrationBuildsSingerSongListsFromHistory() 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,song: Int64 = 0
|
||||
do {
|
||||
let db = try Library(url:url)
|
||||
try db.addEntity("singers",name:"Alex");try db.add(title:"Song",audio:"/sample.mp3",cdg:nil)
|
||||
singer = try XCTUnwrap(db.entities("singers").first?.id);song = try XCTUnwrap(db.songs().first?.id)
|
||||
try db.record(song,singer:singer,venue:nil)
|
||||
try db.execute("DROP TABLE singer_songs");try db.execute("PRAGMA user_version=3")
|
||||
}
|
||||
let migrated = try Library(url:url)
|
||||
XCTAssertEqual(try migrated.singerSongIDs()[singer],[song])
|
||||
XCTAssertEqual(try migrated.history(venue:nil).count,1)
|
||||
}
|
||||
}
|
||||
@@ -1,311 +0,0 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 56;
|
||||
objects = {
|
||||
AB0000000000000000000001 = {isa = PBXFileReference; lastKnownFileType = folder; path = Fixtures; sourceTree = "<group>";};
|
||||
AB0000000000000000000002 = {isa = PBXBuildFile; fileRef = AB0000000000000000000001;};
|
||||
AB0000000000000000000003 = {isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = (AB0000000000000000000002); runOnlyForDeploymentPostprocessing = 0;};
|
||||
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
000000000000000000000065 /* KJamsCloneApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 000000000000000000000001 /* KJamsCloneApp.swift */; };
|
||||
000000000000000000000066 /* Library.swift in Sources */ = {isa = PBXBuildFile; fileRef = 000000000000000000000002 /* Library.swift */; };
|
||||
000000000000000000000067 /* CDG.swift in Sources */ = {isa = PBXBuildFile; fileRef = 000000000000000000000003 /* CDG.swift */; };
|
||||
000000000000000000000068 /* Importer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 000000000000000000000004 /* Importer.swift */; };
|
||||
000000000000000000000069 /* Player.swift in Sources */ = {isa = PBXBuildFile; fileRef = 000000000000000000000005 /* Player.swift */; };
|
||||
A00000000000000000000004 /* KJamsCloneTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A00000000000000000000003 /* KJamsCloneTests.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
D00000000000000000000003 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F00000000000000000000001 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = D00000000000000000000001;
|
||||
remoteInfo = KJamsClone;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
000000000000000000000001 /* KJamsCloneApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KJamsCloneApp.swift; sourceTree = "<group>"; };
|
||||
000000000000000000000002 /* Library.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Library.swift; sourceTree = "<group>"; };
|
||||
000000000000000000000003 /* CDG.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CDG.swift; sourceTree = "<group>"; };
|
||||
000000000000000000000004 /* Importer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Importer.swift; sourceTree = "<group>"; };
|
||||
000000000000000000000005 /* Player.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Player.swift; sourceTree = "<group>"; };
|
||||
A00000000000000000000001 /* KJamsClone.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; path = KJamsClone.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A00000000000000000000002 /* KJamsCloneTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; path = KJamsCloneTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A00000000000000000000003 /* KJamsCloneTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KJamsCloneTests.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
B00000000000000000000001 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
AB0000000000000000000001 /* Fixtures */,
|
||||
B00000000000000000000002 /* KJamsClone */,
|
||||
B00000000000000000000003 /* KJamsCloneTests */,
|
||||
B00000000000000000000004 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B00000000000000000000002 /* KJamsClone */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
000000000000000000000001 /* KJamsCloneApp.swift */,
|
||||
000000000000000000000002 /* Library.swift */,
|
||||
000000000000000000000003 /* CDG.swift */,
|
||||
000000000000000000000004 /* Importer.swift */,
|
||||
000000000000000000000005 /* Player.swift */,
|
||||
);
|
||||
path = KJamsClone;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B00000000000000000000003 /* KJamsCloneTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A00000000000000000000003 /* KJamsCloneTests.swift */,
|
||||
);
|
||||
path = KJamsCloneTests;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B00000000000000000000004 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A00000000000000000000001 /* KJamsClone.app */,
|
||||
A00000000000000000000002 /* KJamsCloneTests.xctest */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
D00000000000000000000001 /* KJamsClone */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = E00000000000000000000002 /* Build configuration list for PBXNativeTarget "KJamsClone" */;
|
||||
buildPhases = (
|
||||
C00000000000000000000001 /* Sources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = KJamsClone;
|
||||
productName = KJamsClone;
|
||||
productReference = A00000000000000000000001 /* KJamsClone.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
D00000000000000000000002 /* KJamsCloneTests */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = E00000000000000000000003 /* Build configuration list for PBXNativeTarget "KJamsCloneTests" */;
|
||||
buildPhases = (
|
||||
C00000000000000000000002 /* Sources */,
|
||||
AB0000000000000000000003 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
D00000000000000000000004 /* PBXTargetDependency */,
|
||||
);
|
||||
name = KJamsCloneTests;
|
||||
productName = KJamsCloneTests;
|
||||
productReference = A00000000000000000000002 /* KJamsCloneTests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.unit-test";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
F00000000000000000000001 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 1600;
|
||||
};
|
||||
buildConfigurationList = E00000000000000000000001 /* Build configuration list for PBXProject "KJamsClone" */;
|
||||
compatibilityVersion = "Xcode 14.0";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = B00000000000000000000001;
|
||||
productRefGroup = B00000000000000000000004 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
D00000000000000000000001 /* KJamsClone */,
|
||||
D00000000000000000000002 /* KJamsCloneTests */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
C00000000000000000000001 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
000000000000000000000065 /* KJamsCloneApp.swift in Sources */,
|
||||
000000000000000000000066 /* Library.swift in Sources */,
|
||||
000000000000000000000067 /* CDG.swift in Sources */,
|
||||
000000000000000000000068 /* Importer.swift in Sources */,
|
||||
000000000000000000000069 /* Player.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
C00000000000000000000002 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
A00000000000000000000004 /* KJamsCloneTests.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
D00000000000000000000004 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = D00000000000000000000001 /* KJamsClone */;
|
||||
targetProxy = D00000000000000000000003 /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
F10000000000000000000000 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
F10000000000000000000001 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
F20000000000000000000000 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 7;
|
||||
DEVELOPMENT_TEAM = 39R6U3437D;
|
||||
ENABLE_APP_SANDBOX = NO;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
MARKETING_VERSION = 0.3.2;
|
||||
OTHER_LDFLAGS = "-lsqlite3";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.kjamsclone.app;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
F20000000000000000000001 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 7;
|
||||
DEVELOPMENT_TEAM = 39R6U3437D;
|
||||
ENABLE_APP_SANDBOX = NO;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
MARKETING_VERSION = 0.3.2;
|
||||
OTHER_LDFLAGS = "-lsqlite3";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.kjamsclone.app;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
F30000000000000000000000 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
OTHER_LDFLAGS = "-lsqlite3";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.kjamsclone.tests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/KJamsClone.app/Contents/MacOS/KJamsClone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
F30000000000000000000001 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
OTHER_LDFLAGS = "-lsqlite3";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.kjamsclone.tests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/KJamsClone.app/Contents/MacOS/KJamsClone";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
E00000000000000000000001 /* Build configuration list for PBXProject "KJamsClone" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
F10000000000000000000000 /* Debug */,
|
||||
F10000000000000000000001 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
E00000000000000000000002 /* Build configuration list for PBXNativeTarget "KJamsClone" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
F20000000000000000000000 /* Debug */,
|
||||
F20000000000000000000001 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
E00000000000000000000003 /* Build configuration list for PBXNativeTarget "KJamsCloneTests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
F30000000000000000000000 /* Debug */,
|
||||
F30000000000000000000001 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = F00000000000000000000001 /* Project object */;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme LastUpgradeVersion="1600" version="1.3">
|
||||
<BuildAction parallelizeBuildables="YES" buildImplicitDependencies="YES"><BuildActionEntries><BuildActionEntry buildForTesting="YES" buildForRunning="YES" buildForProfiling="YES" buildForArchiving="YES" buildForAnalyzing="YES"><BuildableReference BuildableIdentifier="primary" BlueprintIdentifier="D00000000000000000000001" BuildableName="KJamsClone.app" BlueprintName="KJamsClone" ReferencedContainer="container:KJamsClone.xcodeproj"/></BuildActionEntry></BuildActionEntries></BuildAction>
|
||||
<TestAction buildConfiguration="Debug" selectedDebuggerIdentifier="Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier="Xcode.IDEFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv="YES"><Testables><TestableReference skipped="NO"><BuildableReference BuildableIdentifier="primary" BlueprintIdentifier="D00000000000000000000002" BuildableName="KJamsCloneTests.xctest" BlueprintName="KJamsCloneTests" ReferencedContainer="container:KJamsClone.xcodeproj"/></TestableReference></Testables></TestAction>
|
||||
<LaunchAction buildConfiguration="Debug" selectedDebuggerIdentifier="Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier="Xcode.IDEFoundation.Launcher.LLDB" launchStyle="0" useCustomWorkingDirectory="NO" ignoresPersistentStateOnLaunch="NO" debugDocumentVersioning="YES" debugServiceExtension="internal" allowLocationSimulation="YES"><BuildableProductRunnable runnableDebuggingMode="0"><BuildableReference BuildableIdentifier="primary" BlueprintIdentifier="D00000000000000000000001" BuildableName="KJamsClone.app" BlueprintName="KJamsClone" ReferencedContainer="container:KJamsClone.xcodeproj"/></BuildableProductRunnable></LaunchAction>
|
||||
<ProfileAction buildConfiguration="Release" shouldUseLaunchSchemeArgsEnv="YES" savedToolIdentifier="" useCustomWorkingDirectory="NO" debugDocumentVersioning="YES"/><AnalyzeAction buildConfiguration="Debug"/><ArchiveAction buildConfiguration="Release" revealArchiveInOrganizer="YES"/>
|
||||
</Scheme>
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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<String> {
|
||||
let s = try statement("PRAGMA table_info(\(table))", []); defer { sqlite3_finalize(s) }
|
||||
var result = Set<String>(); 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<Int64>] {
|
||||
let s = try statement("SELECT singer,song FROM singer_songs WHERE favourite=1",[]);defer { sqlite3_finalize(s) }
|
||||
var result = [Int64:Set<Int64>]()
|
||||
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 }
|
||||
}
|
||||
}
|
||||
@@ -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<Void, Never>?
|
||||
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<AudioWaveform.Analysis,Error>
|
||||
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..<frames {
|
||||
let bin = min(bins-1, Int((position+Int64(frame))*Int64(bins)/file.length))
|
||||
var sum: Double = 0
|
||||
for channel in 0..<channels {
|
||||
let sample = Double(data[channel][frame])
|
||||
if sample.isFinite {
|
||||
sum += sample * sample
|
||||
lowState[channel] = lowAlpha*lowState[channel]+(1-lowAlpha)*sample
|
||||
highState[channel] = highAlpha*highState[channel]+(1-highAlpha)*sample
|
||||
let low = lowState[channel], mid = highState[channel]-low, high = sample-highState[channel]
|
||||
lows[bin] += low*low; mids[bin] += mid*mid; highs[bin] += high*high
|
||||
}
|
||||
}
|
||||
energy[bin] += sum / Double(max(channels,1)); counts[bin] += 1
|
||||
}
|
||||
position += Int64(frames)
|
||||
}
|
||||
let rms = zip(energy, counts).map { $1 > 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..<bins).map { i in WaveformBands(low:Float(sqrt(lows[i])),mid:Float(sqrt(mids[i])),high:Float(sqrt(highs[i]))) }
|
||||
return .init(levels:levels,bands:bands)
|
||||
}
|
||||
}
|
||||
|
||||
struct WaveformBands: Codable, Sendable {
|
||||
var low: Float
|
||||
var mid: Float
|
||||
var high: Float
|
||||
}
|
||||
/// Four real audio filters; the filter knob is low-pass left, bypass at centre, high-pass right.
|
||||
enum AudioTone {
|
||||
static func configure(_ eq: AVAudioUnitEQ, sampleRate: Double, low: Double, mid: Double, high: Double, filter: Double, enabled: Bool) {
|
||||
eq.bypass = !enabled
|
||||
let frequencies = [160.0,1000.0,6000.0]
|
||||
let types: [AVAudioUnitEQFilterType] = [.lowShelf,.parametric,.highShelf]
|
||||
for i in 0..<3 {
|
||||
let band = eq.bands[i];band.filterType = types[i];band.frequency = Float(min(frequencies[i],sampleRate*0.4))
|
||||
band.bandwidth = 1;band.gain = Float(min(12,max(-12,[low,mid,high][i])));band.bypass = false
|
||||
}
|
||||
let value = min(1,max(-1,filter))
|
||||
let band = eq.bands[3];band.bypass = abs(value) < 0.01;band.bandwidth = 0.7
|
||||
band.filterType = value < 0 ? .lowPass : .highPass
|
||||
let frequency = value < 0 ? 20000*pow(0.004,-value) : 20*pow(400,value)
|
||||
band.frequency = Float(min(sampleRate*0.45,max(20,frequency)))
|
||||
}
|
||||
}
|
||||
/// The audio callback only updates a tiny locked snapshot; UI reads it on the existing clock.
|
||||
final class AudioLevelMeter: @unchecked Sendable {
|
||||
private let lock = NSLock()
|
||||
private var levels: (Float,Float) = (0,0)
|
||||
func consume(_ buffer: AVAudioPCMBuffer) {
|
||||
guard let data = buffer.floatChannelData else { return }
|
||||
let channels = Int(buffer.format.channelCount), frames = Int(buffer.frameLength)
|
||||
var left: Float = 0, right: Float = 0
|
||||
for i in 0..<frames {
|
||||
left = max(left,abs(data[0][i]));right = max(right,abs(data[min(1,channels-1)][i]))
|
||||
}
|
||||
lock.lock();levels = (left,right);lock.unlock()
|
||||
}
|
||||
func snapshot() -> (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)
|
||||
}
|
||||
}
|
||||
@@ -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 "$@"
|
||||
@@ -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('<h',int(3000*max(0,fade)*math.sin(2*math.pi*freq*t))))
|
||||
out.writeframes(data)
|
||||
ffmpeg=shutil.which('ffmpeg')
|
||||
if not ffmpeg:raise SystemExit('ffmpeg is needed only to regenerate the included MP3 test file')
|
||||
subprocess.run([ffmpeg,'-y','-loglevel','error','-i',str(root/'TestTrack.wav'),'-codec:a','libmp3lame','-q:a','5','-metadata','title=MP3 Plus G Test','-metadata','artist=KJamsClone Test Generator','-metadata','album=Original Test Media',str(root/'TestTrack.mp3')],check=True)
|
||||
with zipfile.ZipFile(root/'TestTrack.zip','w',zipfile.ZIP_DEFLATED) as z:
|
||||
for name in ['TestTrack.mp3','TestTrack.cdg']:z.write(root/name,name)
|
||||
(root/'TEST-MEDIA.txt').write_text('Original synthetic 20-second low-volume tone melody and original test text. No vocals or commercial song. Free to use. Import TestTrack.zip, or keep TestTrack.mp3 and TestTrack.cdg together and import the MP3. CDG has timed white-to-yellow word highlighting. Test pause, seek, tempo and key changes. Demo.* remains the original 4-second regression fixture. Unsafe.zip is a deliberately invalid traversal test fixture, not playable media.\n')
|
||||
print('Created original TestTrack.cdg, TestTrack.mp3, TestTrack.zip and WAV source.')
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
xcodebuild -project KJamsClone.xcodeproj -scheme KJamsClone -configuration Release -destination 'platform=macOS' -derivedDataPath "$PWD/build-release" CODE_SIGNING_ALLOWED=NO build "$@"
|
||||
mkdir -p dist
|
||||
/usr/bin/ditto -c -k --sequesterRsrc --keepParent build-release/Build/Products/Release/KJamsClone.app dist/KJamsClone-unsigned-macOS.zip
|
||||
@@ -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 test "$@"
|
||||
@@ -1,700 +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)
|
||||
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..<count {
|
||||
let start = bar*player.waveform.count/count
|
||||
let end = max(start+1,(bar+1)*player.waveform.count/count)
|
||||
let level = player.waveform[start..<min(end,player.waveform.count)].max() ?? 0
|
||||
let height = max(1,CGFloat(level)*(size.height-2))
|
||||
let x = CGFloat(bar)*step
|
||||
let path = Path(roundedRect:CGRect(x:x,y:mid-height/2,width:max(1,step-1),height:height),cornerRadius:0.6)
|
||||
if x <= size.width*progress {
|
||||
context.fill(path,with:.linearGradient(Gradient(colors:[teal,cyan]),startPoint:.zero,endPoint:CGPoint(x:size.width,y:0)))
|
||||
} else { context.fill(path,with:.color(Color(red:0.22,green:0.34,blue:0.48))) }
|
||||
}
|
||||
let x = size.width*progress
|
||||
var head = Path(); head.move(to:CGPoint(x:x,y:0)); head.addLine(to:CGPoint(x:x,y:size.height))
|
||||
context.stroke(head,with:.color(Color(red:0.72,green:0.98,blue:0.94)),lineWidth:1)
|
||||
} else {
|
||||
var line = Path(); line.move(to:CGPoint(x:0,y:mid)); line.addLine(to:CGPoint(x:size.width,y:mid))
|
||||
context.stroke(line,with:.color(cyan.opacity(0.25)),lineWidth:1)
|
||||
if player.waveformLoading {
|
||||
context.draw(Text("Analysing waveform…").font(.system(size:9)).foregroundColor(.gray),at:CGPoint(x:size.width/2,y:mid))
|
||||
}
|
||||
}
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.gesture(DragGesture(minimumDistance:0).onEnded { value in
|
||||
guard player.duration > 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")
|
||||
}
|
||||
}
|
||||
@@ -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<String> {
|
||||
let s = try statement("PRAGMA table_info(\(table))", []); defer { sqlite3_finalize(s) }
|
||||
var result = Set<String>(); 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)]) }
|
||||
}
|
||||
@@ -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<Void, Never>?
|
||||
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..<frames {
|
||||
let bin = min(bins-1, Int((position+Int64(frame))*Int64(bins)/file.length))
|
||||
var sum: Double = 0
|
||||
for channel in 0..<channels {
|
||||
let sample = Double(data[channel][frame])
|
||||
if sample.isFinite { sum += sample * sample }
|
||||
}
|
||||
energy[bin] += sum / Double(max(channels,1)); counts[bin] += 1
|
||||
}
|
||||
position += Int64(frames)
|
||||
}
|
||||
let rms = zip(energy, counts).map { $1 > 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)) }
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
@@ -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<String> {
|
||||
let s = try statement("PRAGMA table_info(\(table))", []); defer { sqlite3_finalize(s) }
|
||||
var result = Set<String>(); 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<Int64>] {
|
||||
let s = try statement("SELECT singer,song FROM singer_songs WHERE favourite=1",[]);defer { sqlite3_finalize(s) }
|
||||
var result = [Int64:Set<Int64>]()
|
||||
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 }
|
||||
}
|
||||
}
|
||||
@@ -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..<Int(output.frameLength) { let v = Double(output.floatChannelData![0][i]);energy += v*v;count += 1 } }
|
||||
}
|
||||
return sqrt(energy/Double(max(1,count)))
|
||||
}
|
||||
func testToneEQBoostAndBypassProcessActualAudio() throws {
|
||||
let flat = try toneRMS(frequency:60)
|
||||
let boosted = try toneRMS(frequency:60,low:12)
|
||||
let bypassed = try toneRMS(frequency:60,low:12,enabled:false)
|
||||
XCTAssertGreaterThan(flat,0.01);XCTAssertGreaterThan(boosted,flat*2)
|
||||
XCTAssertEqual(bypassed/flat,1,accuracy:0.05)
|
||||
}
|
||||
func testLowPassAndHighPassFilterActualAudio() throws {
|
||||
let high = try toneRMS(frequency:6000),low = try toneRMS(frequency:60)
|
||||
XCTAssertLessThan(try toneRMS(frequency:6000,filter:-1),high*0.1)
|
||||
XCTAssertLessThan(try toneRMS(frequency:60,filter:1),low*0.1)
|
||||
}
|
||||
func testVersionThreeMigrationBuildsSingerSongListsFromHistory() 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,song: Int64 = 0
|
||||
do {
|
||||
let db = try Library(url:url)
|
||||
try db.addEntity("singers",name:"Alex");try db.add(title:"Song",audio:"/sample.mp3",cdg:nil)
|
||||
singer = try XCTUnwrap(db.entities("singers").first?.id);song = try XCTUnwrap(db.songs().first?.id)
|
||||
try db.record(song,singer:singer,venue:nil)
|
||||
try db.execute("DROP TABLE singer_songs");try db.execute("PRAGMA user_version=3")
|
||||
}
|
||||
let migrated = try Library(url:url)
|
||||
XCTAssertEqual(try migrated.singerSongIDs()[singer],[song])
|
||||
XCTAssertEqual(try migrated.history(venue:nil).count,1)
|
||||
}
|
||||
func testMusicStoreDefinitionsValidateSearchAndPersist() 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")
|
||||
let db = try Library(url:url)
|
||||
try db.saveStore(.init(id:0,name:"Example",url:"https://example.com",searchTemplate:"https://example.com/search?q={query}"))
|
||||
let store = try XCTUnwrap(db.stores().first)
|
||||
let destination = try store.destination(query:"ABBA & Queen")
|
||||
XCTAssertEqual(URLComponents(url:destination,resolvingAgainstBaseURL:false)?.queryItems?.first?.value,"ABBA & Queen")
|
||||
XCTAssertThrowsError(try db.saveStore(.init(id:0,name:"Bad",url:"file:///tmp/test",searchTemplate:"")))
|
||||
XCTAssertThrowsError(try db.saveStore(.init(id:0,name:"Bad2",url:"https://example.com",searchTemplate:"https://example.com/search")))
|
||||
XCTAssertEqual(try Library(url:url).stores().first?.name,"Example")
|
||||
try db.saveStore(.init(id:store.id,name:"Renamed",url:"https://example.org",searchTemplate:""))
|
||||
XCTAssertEqual(try db.stores().count,1);XCTAssertEqual(try db.stores().first?.name,"Renamed")
|
||||
try db.deleteStore(store.id);XCTAssertTrue(try db.stores().isEmpty)
|
||||
}
|
||||
@MainActor func testEditableSongDefaultsAndSingerOverridesAreIndependent() throws {
|
||||
let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
|
||||
defer { try? FileManager.default.removeItem(at:root) }
|
||||
let model = AppModel(storageURL:root)
|
||||
let db = try XCTUnwrap(model.library)
|
||||
try db.add(title:"Song",audio:"/a.mp3",cdg:nil,duration:123.5);try model.refresh()
|
||||
let song = try XCTUnwrap(model.songs.first?.id)
|
||||
model.updateTuning(song,pitch:2,tempo:1.1)
|
||||
XCTAssertEqual(try db.defaultPreference(song:song).pitch,2)
|
||||
let venue = try model.createEntity(.venue,name:"Hall")
|
||||
let singer = try model.createSinger(name:"Alex",venue:venue,songs:[song])
|
||||
XCTAssertEqual(model.preference(song).tempo,1.1)
|
||||
model.updateTuning(song,pitch:-3,tempo:0.9)
|
||||
XCTAssertEqual(try db.preference(song:song,singer:singer).pitch,-3)
|
||||
XCTAssertEqual(try db.defaultPreference(song:song).pitch,2)
|
||||
model.setFavourite(song,singer:singer,included:true)
|
||||
XCTAssertTrue(model.favourites[singer]?.contains(song) == true)
|
||||
let reopened = AppModel(storageURL:root)
|
||||
XCTAssertEqual(reopened.songs.first?.duration,123.5)
|
||||
XCTAssertTrue(reopened.favourites[singer]?.contains(song) == true)
|
||||
XCTAssertEqual(try XCTUnwrap(reopened.library).preference(song:song,singer:singer).tempo,0.9)
|
||||
}
|
||||
func testMetadataEditsPersistAndSurviveReimport() 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("audio.mp3"),url = root.appendingPathComponent("db.sqlite")
|
||||
let bytes = Data([1,2,3]);try bytes.write(to:audio)
|
||||
let db = try Library(url:url)
|
||||
try db.add(title:"Old",audio:audio.path,cdg:nil,artist:"Old artist")
|
||||
let id = try XCTUnwrap(db.songs().first?.id)
|
||||
try db.updateMetadata(song:id,title:" New Title ",artist:"New artist",album:"New album",label:"New label",rating:5)
|
||||
XCTAssertThrowsError(try db.updateMetadata(song:id,title:" ",artist:"",album:"",label:"",rating:0))
|
||||
try db.add(title:"Original tag",audio:audio.path,cdg:nil,artist:"Original artist",album:"Original album",label:"Original label")
|
||||
let saved = try XCTUnwrap(Library(url:url).songs().first)
|
||||
XCTAssertEqual(saved.title,"New Title");XCTAssertEqual(saved.artist,"New artist")
|
||||
XCTAssertEqual(saved.album,"New album");XCTAssertEqual(saved.label,"New label");XCTAssertEqual(saved.rating,5)
|
||||
XCTAssertEqual(try Data(contentsOf:audio),bytes)
|
||||
}
|
||||
func testWaveformCacheRejectsChangedFilesAndCorruption() 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 source = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures/Demo.mp3"))
|
||||
let audio = root.appendingPathComponent("demo.mp3"),cache = root.appendingPathComponent("Waveforms")
|
||||
try FileManager.default.copyItem(at:source,to:audio)
|
||||
let analysis = try AudioWaveform.analyse(url:audio)
|
||||
try WaveformCache.save(analysis,audio:audio,directory:cache)
|
||||
XCTAssertEqual(try WaveformCache.load(audio:audio,directory:cache).levels,analysis.levels)
|
||||
let first = try WaveformCache.location(audio:audio,directory:cache)
|
||||
try FileManager.default.setAttributes([.modificationDate:Date(timeIntervalSince1970:123456)],ofItemAtPath:audio.path)
|
||||
XCTAssertNotEqual(first,try WaveformCache.location(audio:audio,directory:cache))
|
||||
XCTAssertThrowsError(try WaveformCache.load(audio:audio,directory:cache))
|
||||
try WaveformCache.save(analysis,audio:audio,directory:cache)
|
||||
try Data([0,1,2]).write(to:WaveformCache.location(audio:audio,directory:cache))
|
||||
XCTAssertThrowsError(try WaveformCache.load(audio:audio,directory:cache))
|
||||
}
|
||||
@MainActor func testPlayerReusesSavedWaveformAndCanForceReanalysis() async throws {
|
||||
let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
|
||||
defer { try? FileManager.default.removeItem(at:root) }
|
||||
let audio = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures/Demo.mp3"))
|
||||
let player = Player(waveformCacheDirectory:root);player.volume = 0;defer { player.stop() }
|
||||
let song = Song(id:1,title:"Demo",audio:audio.path,cdg:nil,rating:0,plays:0)
|
||||
try player.load(song);player.toggle()
|
||||
for _ in 0..<100 { if !player.waveformLoading { break };try await Task.sleep(nanoseconds:20_000_000) }
|
||||
XCTAssertTrue(player.waveformSaved);XCTAssertFalse(player.waveformFromCache)
|
||||
let first = player.waveform
|
||||
player.stop();try player.load(song);player.toggle()
|
||||
for _ in 0..<100 { if !player.waveformLoading { break };try await Task.sleep(nanoseconds:20_000_000) }
|
||||
XCTAssertTrue(player.waveformFromCache);XCTAssertEqual(player.waveform,first)
|
||||
player.reanalyseWaveform()
|
||||
for _ in 0..<100 { if !player.waveformLoading { break };try await Task.sleep(nanoseconds:20_000_000) }
|
||||
XCTAssertFalse(player.waveformFromCache);XCTAssertTrue(player.waveformSaved);XCTAssertEqual(player.waveform,first)
|
||||
}
|
||||
@MainActor func testTonightPersistsForEachSingerAcrossSwitchPlaybackAndRestart() throws {
|
||||
let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
|
||||
defer { try? FileManager.default.removeItem(at:root) }
|
||||
let model = AppModel(storageURL:root);model.autoAdvance = false;defer { model.player.stop() }
|
||||
let hall = try model.createEntity(.venue,name:"Hall")
|
||||
let alex = try model.createEntity(.singer,name:"Alex"),bob = try model.createEntity(.singer,name:"Bob")
|
||||
let fixtures = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures"))
|
||||
try model.library?.add(title:"A",audio:fixtures.appendingPathComponent("Demo.mp3").path,cdg:nil)
|
||||
try model.library?.add(title:"B",audio:fixtures.appendingPathComponent("TestTrack.mp3").path,cdg:nil)
|
||||
try model.refresh()
|
||||
let a = try XCTUnwrap(model.songs.first(where:{ $0.title == "A" })?.id),b = try XCTUnwrap(model.songs.first(where:{ $0.title == "B" })?.id)
|
||||
model.selectedSinger = bob;model.addToTonight(a,singer:alex)
|
||||
model.addToTonight(b)
|
||||
model.selectedSinger = alex;XCTAssertEqual(model.tonightSongs(for:alex).map(\.id),[a])
|
||||
model.selectedSinger = bob;XCTAssertEqual(model.tonightSongs(for:bob).map(\.id),[b])
|
||||
model.addToTonight(b);XCTAssertEqual(model.queue.count,2)
|
||||
model.player.volume = 0;model.playQueueNext();model.player.stop()
|
||||
XCTAssertEqual(model.queue.count,1)
|
||||
XCTAssertEqual(model.tonightSongs(for:alex).map(\.id),[a])
|
||||
let reopened = AppModel(storageURL:root)
|
||||
XCTAssertEqual(reopened.currentVenue,hall)
|
||||
XCTAssertEqual(reopened.tonightSongs(for:alex).map(\.id),[a]);XCTAssertEqual(reopened.tonightSongs(for:bob).map(\.id),[b])
|
||||
reopened.removeFromTonight(a,singer:alex)
|
||||
XCTAssertTrue(reopened.tonightSongs(for:alex).isEmpty);XCTAssertEqual(reopened.tonightSongs(for:bob).map(\.id),[b])
|
||||
XCTAssertEqual(reopened.songs(for:alex).map(\.id),[a])
|
||||
}
|
||||
func testTonightMigrationAndVenueIsolation() 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,hall: Int64 = 0,club: Int64 = 0,song: Int64 = 0
|
||||
do {
|
||||
let db = try Library(url:url)
|
||||
try db.addEntity("singers",name:"Alex");try db.addEntity("venues",name:"Hall");try db.addEntity("venues",name:"Club")
|
||||
singer = try XCTUnwrap(db.entities("singers").first?.id)
|
||||
hall = try XCTUnwrap(db.entities("venues").first(where:{ $0.name == "Hall" })?.id);club = try XCTUnwrap(db.entities("venues").first(where:{ $0.name == "Club" })?.id)
|
||||
try db.setMembership(singer:singer,venue:hall,included:true);try db.setMembership(singer:singer,venue:club,included:true)
|
||||
try db.add(title:"Song",audio:"/a.mp3",cdg:nil);song = try XCTUnwrap(db.songs().first?.id)
|
||||
try db.enqueue(song:song,singer:singer,venue:hall)
|
||||
try db.execute("DROP TABLE singer_tonight");try db.execute("PRAGMA user_version=6")
|
||||
}
|
||||
let db = try Library(url:url)
|
||||
XCTAssertEqual(try db.tonightSongIDs(venue:hall)[singer],[song]);XCTAssertTrue(try db.tonightSongIDs(venue:club).isEmpty)
|
||||
let entry = try XCTUnwrap(db.queue(venue:hall).first);try db.removeQueue(entry.id)
|
||||
XCTAssertEqual(try Library(url:url).tonightSongIDs(venue:hall)[singer],[song])
|
||||
try db.setMembership(singer:singer,venue:hall,included:false)
|
||||
XCTAssertTrue(try db.tonightSongIDs(venue:hall).isEmpty)
|
||||
}
|
||||
}
|
||||
@@ -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<String> {
|
||||
let s = try statement("PRAGMA table_info(\(table))", []); defer { sqlite3_finalize(s) }
|
||||
var result = Set<String>(); 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<Int64>] {
|
||||
let s = try statement("SELECT singer,song FROM singer_songs WHERE favourite=1",[]);defer { sqlite3_finalize(s) }
|
||||
var result = [Int64:Set<Int64>]()
|
||||
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") }
|
||||
}
|
||||
}
|
||||
@@ -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..<Int(output.frameLength) { let v = Double(output.floatChannelData![0][i]);energy += v*v;count += 1 } }
|
||||
}
|
||||
return sqrt(energy/Double(max(1,count)))
|
||||
}
|
||||
func testToneEQBoostAndBypassProcessActualAudio() throws {
|
||||
let flat = try toneRMS(frequency:60)
|
||||
let boosted = try toneRMS(frequency:60,low:12)
|
||||
let bypassed = try toneRMS(frequency:60,low:12,enabled:false)
|
||||
XCTAssertGreaterThan(flat,0.01);XCTAssertGreaterThan(boosted,flat*2)
|
||||
XCTAssertEqual(bypassed/flat,1,accuracy:0.05)
|
||||
}
|
||||
func testLowPassAndHighPassFilterActualAudio() throws {
|
||||
let high = try toneRMS(frequency:6000),low = try toneRMS(frequency:60)
|
||||
XCTAssertLessThan(try toneRMS(frequency:6000,filter:-1),high*0.1)
|
||||
XCTAssertLessThan(try toneRMS(frequency:60,filter:1),low*0.1)
|
||||
}
|
||||
func testVersionThreeMigrationBuildsSingerSongListsFromHistory() 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,song: Int64 = 0
|
||||
do {
|
||||
let db = try Library(url:url)
|
||||
try db.addEntity("singers",name:"Alex");try db.add(title:"Song",audio:"/sample.mp3",cdg:nil)
|
||||
singer = try XCTUnwrap(db.entities("singers").first?.id);song = try XCTUnwrap(db.songs().first?.id)
|
||||
try db.record(song,singer:singer,venue:nil)
|
||||
try db.execute("DROP TABLE singer_songs");try db.execute("PRAGMA user_version=3")
|
||||
}
|
||||
let migrated = try Library(url:url)
|
||||
XCTAssertEqual(try migrated.singerSongIDs()[singer],[song])
|
||||
XCTAssertEqual(try migrated.history(venue:nil).count,1)
|
||||
}
|
||||
func testMusicStoreDefinitionsValidateSearchAndPersist() 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")
|
||||
let db = try Library(url:url)
|
||||
try db.saveStore(.init(id:0,name:"Example",url:"https://example.com",searchTemplate:"https://example.com/search?q={query}"))
|
||||
let store = try XCTUnwrap(db.stores().first)
|
||||
let destination = try store.destination(query:"ABBA & Queen")
|
||||
XCTAssertEqual(URLComponents(url:destination,resolvingAgainstBaseURL:false)?.queryItems?.first?.value,"ABBA & Queen")
|
||||
XCTAssertThrowsError(try db.saveStore(.init(id:0,name:"Bad",url:"file:///tmp/test",searchTemplate:"")))
|
||||
XCTAssertThrowsError(try db.saveStore(.init(id:0,name:"Bad2",url:"https://example.com",searchTemplate:"https://example.com/search")))
|
||||
XCTAssertEqual(try Library(url:url).stores().first?.name,"Example")
|
||||
try db.saveStore(.init(id:store.id,name:"Renamed",url:"https://example.org",searchTemplate:""))
|
||||
XCTAssertEqual(try db.stores().count,1);XCTAssertEqual(try db.stores().first?.name,"Renamed")
|
||||
try db.deleteStore(store.id);XCTAssertTrue(try db.stores().isEmpty)
|
||||
}
|
||||
@MainActor func testEditableSongDefaultsAndSingerOverridesAreIndependent() throws {
|
||||
let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
|
||||
defer { try? FileManager.default.removeItem(at:root) }
|
||||
let model = AppModel(storageURL:root)
|
||||
let db = try XCTUnwrap(model.library)
|
||||
try db.add(title:"Song",audio:"/a.mp3",cdg:nil,duration:123.5);try model.refresh()
|
||||
let song = try XCTUnwrap(model.songs.first?.id)
|
||||
model.updateTuning(song,pitch:2,tempo:1.1)
|
||||
XCTAssertEqual(try db.defaultPreference(song:song).pitch,2)
|
||||
let venue = try model.createEntity(.venue,name:"Hall")
|
||||
let singer = try model.createSinger(name:"Alex",venue:venue,songs:[song])
|
||||
XCTAssertEqual(model.preference(song).tempo,1.1)
|
||||
model.updateTuning(song,pitch:-3,tempo:0.9)
|
||||
XCTAssertEqual(try db.preference(song:song,singer:singer).pitch,-3)
|
||||
XCTAssertEqual(try db.defaultPreference(song:song).pitch,2)
|
||||
model.setFavourite(song,singer:singer,included:true)
|
||||
XCTAssertTrue(model.favourites[singer]?.contains(song) == true)
|
||||
let reopened = AppModel(storageURL:root)
|
||||
XCTAssertEqual(reopened.songs.first?.duration,123.5)
|
||||
XCTAssertTrue(reopened.favourites[singer]?.contains(song) == true)
|
||||
XCTAssertEqual(try XCTUnwrap(reopened.library).preference(song:song,singer:singer).tempo,0.9)
|
||||
}
|
||||
func testMetadataEditsPersistAndSurviveReimport() 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("audio.mp3"),url = root.appendingPathComponent("db.sqlite")
|
||||
let bytes = Data([1,2,3]);try bytes.write(to:audio)
|
||||
let db = try Library(url:url)
|
||||
try db.add(title:"Old",audio:audio.path,cdg:nil,artist:"Old artist")
|
||||
let id = try XCTUnwrap(db.songs().first?.id)
|
||||
try db.updateMetadata(song:id,title:" New Title ",artist:"New artist",album:"New album",label:"New label",rating:5)
|
||||
XCTAssertThrowsError(try db.updateMetadata(song:id,title:" ",artist:"",album:"",label:"",rating:0))
|
||||
try db.add(title:"Original tag",audio:audio.path,cdg:nil,artist:"Original artist",album:"Original album",label:"Original label")
|
||||
let saved = try XCTUnwrap(Library(url:url).songs().first)
|
||||
XCTAssertEqual(saved.title,"New Title");XCTAssertEqual(saved.artist,"New artist")
|
||||
XCTAssertEqual(saved.album,"New album");XCTAssertEqual(saved.label,"New label");XCTAssertEqual(saved.rating,5)
|
||||
XCTAssertEqual(try Data(contentsOf:audio),bytes)
|
||||
}
|
||||
func testWaveformCacheRejectsChangedFilesAndCorruption() 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 source = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures/Demo.mp3"))
|
||||
let audio = root.appendingPathComponent("demo.mp3"),cache = root.appendingPathComponent("Waveforms")
|
||||
try FileManager.default.copyItem(at:source,to:audio)
|
||||
let analysis = try AudioWaveform.analyse(url:audio)
|
||||
try WaveformCache.save(analysis,audio:audio,directory:cache)
|
||||
XCTAssertEqual(try WaveformCache.load(audio:audio,directory:cache).levels,analysis.levels)
|
||||
let first = try WaveformCache.location(audio:audio,directory:cache)
|
||||
try FileManager.default.setAttributes([.modificationDate:Date(timeIntervalSince1970:123456)],ofItemAtPath:audio.path)
|
||||
XCTAssertNotEqual(first,try WaveformCache.location(audio:audio,directory:cache))
|
||||
XCTAssertThrowsError(try WaveformCache.load(audio:audio,directory:cache))
|
||||
try WaveformCache.save(analysis,audio:audio,directory:cache)
|
||||
try Data([0,1,2]).write(to:WaveformCache.location(audio:audio,directory:cache))
|
||||
XCTAssertThrowsError(try WaveformCache.load(audio:audio,directory:cache))
|
||||
}
|
||||
@MainActor func testPlayerReusesSavedWaveformAndCanForceReanalysis() async throws {
|
||||
let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
|
||||
defer { try? FileManager.default.removeItem(at:root) }
|
||||
let audio = try XCTUnwrap(Bundle(for:Self.self).resourceURL?.appendingPathComponent("Fixtures/Demo.mp3"))
|
||||
let player = Player(waveformCacheDirectory:root);player.volume = 0;defer { player.stop() }
|
||||
let song = Song(id:1,title:"Demo",audio:audio.path,cdg:nil,rating:0,plays:0)
|
||||
try player.load(song);player.toggle()
|
||||
for _ in 0..<100 { if !player.waveformLoading { break };try await Task.sleep(nanoseconds:20_000_000) }
|
||||
XCTAssertTrue(player.waveformSaved);XCTAssertFalse(player.waveformFromCache)
|
||||
let first = player.waveform
|
||||
player.stop();try player.load(song);player.toggle()
|
||||
for _ in 0..<100 { if !player.waveformLoading { break };try await Task.sleep(nanoseconds:20_000_000) }
|
||||
XCTAssertTrue(player.waveformFromCache);XCTAssertEqual(player.waveform,first)
|
||||
player.reanalyseWaveform()
|
||||
for _ in 0..<100 { if !player.waveformLoading { break };try await Task.sleep(nanoseconds:20_000_000) }
|
||||
XCTAssertFalse(player.waveformFromCache);XCTAssertTrue(player.waveformSaved);XCTAssertEqual(player.waveform,first)
|
||||
}
|
||||
}
|
||||
@@ -1,311 +0,0 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 56;
|
||||
objects = {
|
||||
AB0000000000000000000001 = {isa = PBXFileReference; lastKnownFileType = folder; path = Fixtures; sourceTree = "<group>";};
|
||||
AB0000000000000000000002 = {isa = PBXBuildFile; fileRef = AB0000000000000000000001;};
|
||||
AB0000000000000000000003 = {isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = (AB0000000000000000000002); runOnlyForDeploymentPostprocessing = 0;};
|
||||
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
000000000000000000000065 /* KJamsCloneApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 000000000000000000000001 /* KJamsCloneApp.swift */; };
|
||||
000000000000000000000066 /* Library.swift in Sources */ = {isa = PBXBuildFile; fileRef = 000000000000000000000002 /* Library.swift */; };
|
||||
000000000000000000000067 /* CDG.swift in Sources */ = {isa = PBXBuildFile; fileRef = 000000000000000000000003 /* CDG.swift */; };
|
||||
000000000000000000000068 /* Importer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 000000000000000000000004 /* Importer.swift */; };
|
||||
000000000000000000000069 /* Player.swift in Sources */ = {isa = PBXBuildFile; fileRef = 000000000000000000000005 /* Player.swift */; };
|
||||
A00000000000000000000004 /* KJamsCloneTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A00000000000000000000003 /* KJamsCloneTests.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
D00000000000000000000003 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = F00000000000000000000001 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = D00000000000000000000001;
|
||||
remoteInfo = KJamsClone;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
000000000000000000000001 /* KJamsCloneApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KJamsCloneApp.swift; sourceTree = "<group>"; };
|
||||
000000000000000000000002 /* Library.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Library.swift; sourceTree = "<group>"; };
|
||||
000000000000000000000003 /* CDG.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CDG.swift; sourceTree = "<group>"; };
|
||||
000000000000000000000004 /* Importer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Importer.swift; sourceTree = "<group>"; };
|
||||
000000000000000000000005 /* Player.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Player.swift; sourceTree = "<group>"; };
|
||||
A00000000000000000000001 /* KJamsClone.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; path = KJamsClone.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A00000000000000000000002 /* KJamsCloneTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; path = KJamsCloneTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
A00000000000000000000003 /* KJamsCloneTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KJamsCloneTests.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
B00000000000000000000001 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
AB0000000000000000000001 /* Fixtures */,
|
||||
B00000000000000000000002 /* KJamsClone */,
|
||||
B00000000000000000000003 /* KJamsCloneTests */,
|
||||
B00000000000000000000004 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B00000000000000000000002 /* KJamsClone */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
000000000000000000000001 /* KJamsCloneApp.swift */,
|
||||
000000000000000000000002 /* Library.swift */,
|
||||
000000000000000000000003 /* CDG.swift */,
|
||||
000000000000000000000004 /* Importer.swift */,
|
||||
000000000000000000000005 /* Player.swift */,
|
||||
);
|
||||
path = KJamsClone;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B00000000000000000000003 /* KJamsCloneTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A00000000000000000000003 /* KJamsCloneTests.swift */,
|
||||
);
|
||||
path = KJamsCloneTests;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B00000000000000000000004 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A00000000000000000000001 /* KJamsClone.app */,
|
||||
A00000000000000000000002 /* KJamsCloneTests.xctest */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
D00000000000000000000001 /* KJamsClone */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = E00000000000000000000002 /* Build configuration list for PBXNativeTarget "KJamsClone" */;
|
||||
buildPhases = (
|
||||
C00000000000000000000001 /* Sources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = KJamsClone;
|
||||
productName = KJamsClone;
|
||||
productReference = A00000000000000000000001 /* KJamsClone.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
D00000000000000000000002 /* KJamsCloneTests */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = E00000000000000000000003 /* Build configuration list for PBXNativeTarget "KJamsCloneTests" */;
|
||||
buildPhases = (
|
||||
C00000000000000000000002 /* Sources */,
|
||||
AB0000000000000000000003 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
D00000000000000000000004 /* PBXTargetDependency */,
|
||||
);
|
||||
name = KJamsCloneTests;
|
||||
productName = KJamsCloneTests;
|
||||
productReference = A00000000000000000000002 /* KJamsCloneTests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.unit-test";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
F00000000000000000000001 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 1600;
|
||||
};
|
||||
buildConfigurationList = E00000000000000000000001 /* Build configuration list for PBXProject "KJamsClone" */;
|
||||
compatibilityVersion = "Xcode 14.0";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = B00000000000000000000001;
|
||||
productRefGroup = B00000000000000000000004 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
D00000000000000000000001 /* KJamsClone */,
|
||||
D00000000000000000000002 /* KJamsCloneTests */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
C00000000000000000000001 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
000000000000000000000065 /* KJamsCloneApp.swift in Sources */,
|
||||
000000000000000000000066 /* Library.swift in Sources */,
|
||||
000000000000000000000067 /* CDG.swift in Sources */,
|
||||
000000000000000000000068 /* Importer.swift in Sources */,
|
||||
000000000000000000000069 /* Player.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
C00000000000000000000002 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
A00000000000000000000004 /* KJamsCloneTests.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
D00000000000000000000004 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = D00000000000000000000001 /* KJamsClone */;
|
||||
targetProxy = D00000000000000000000003 /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
F10000000000000000000000 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
F10000000000000000000001 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
F20000000000000000000000 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_TEAM = 39R6U3437D;
|
||||
ENABLE_APP_SANDBOX = NO;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
MARKETING_VERSION = 0.1.0;
|
||||
OTHER_LDFLAGS = "-lsqlite3";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.kjamsclone.app;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
F20000000000000000000001 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_TEAM = 39R6U3437D;
|
||||
ENABLE_APP_SANDBOX = NO;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.music";
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
MARKETING_VERSION = 0.1.0;
|
||||
OTHER_LDFLAGS = "-lsqlite3";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.kjamsclone.app;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
F30000000000000000000000 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
OTHER_LDFLAGS = "-lsqlite3";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.kjamsclone.tests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/KJamsClone.app/Contents/MacOS/KJamsClone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
F30000000000000000000001 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BUNDLE_LOADER = "$(TEST_HOST)";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
OTHER_LDFLAGS = "-lsqlite3";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.kjamsclone.tests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/KJamsClone.app/Contents/MacOS/KJamsClone";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
E00000000000000000000001 /* Build configuration list for PBXProject "KJamsClone" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
F10000000000000000000000 /* Debug */,
|
||||
F10000000000000000000001 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
E00000000000000000000002 /* Build configuration list for PBXNativeTarget "KJamsClone" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
F20000000000000000000000 /* Debug */,
|
||||
F20000000000000000000001 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
E00000000000000000000003 /* Build configuration list for PBXNativeTarget "KJamsCloneTests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
F30000000000000000000000 /* Debug */,
|
||||
F30000000000000000000001 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = F00000000000000000000001 /* Project object */;
|
||||
}
|
||||
@@ -1,59 +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 audio in 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
|
||||
}
|
||||
let asset = AVURLAsset(url: audio)
|
||||
let metadata = asset.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))
|
||||
}
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
@@ -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<String> {
|
||||
let s = try statement("PRAGMA table_info(\(table))", []); defer { sqlite3_finalize(s) }
|
||||
var result = Set<String>(); 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)]) }
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
|
Before Width: | Height: | Size: 222 KiB |
@@ -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")
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 216 KiB After Width: | Height: | Size: 216 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 285 KiB After Width: | Height: | Size: 285 KiB |
|
Before Width: | Height: | Size: 272 KiB After Width: | Height: | Size: 272 KiB |
|
Before Width: | Height: | Size: 316 KiB After Width: | Height: | Size: 316 KiB |
|
Before Width: | Height: | Size: 322 KiB After Width: | Height: | Size: 322 KiB |
|
Before Width: | Height: | Size: 287 KiB After Width: | Height: | Size: 287 KiB |
|
Before Width: | Height: | Size: 284 KiB After Width: | Height: | Size: 284 KiB |
|
Before Width: | Height: | Size: 284 KiB After Width: | Height: | Size: 284 KiB |
|
Before Width: | Height: | Size: 121 KiB After Width: | Height: | Size: 121 KiB |
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 245 KiB After Width: | Height: | Size: 245 KiB |
|
Before Width: | Height: | Size: 352 KiB After Width: | Height: | Size: 352 KiB |
|
Before Width: | Height: | Size: 310 KiB After Width: | Height: | Size: 310 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 250 KiB After Width: | Height: | Size: 250 KiB |
|
Before Width: | Height: | Size: 256 KiB After Width: | Height: | Size: 256 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 290 KiB After Width: | Height: | Size: 290 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 281 KiB After Width: | Height: | Size: 281 KiB |
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 122 KiB |
|
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 114 KiB |
|
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 114 KiB |
|
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 266 KiB After Width: | Height: | Size: 266 KiB |
|
Before Width: | Height: | Size: 332 KiB After Width: | Height: | Size: 332 KiB |
|
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 296 KiB After Width: | Height: | Size: 296 KiB |
|
Before Width: | Height: | Size: 354 KiB After Width: | Height: | Size: 354 KiB |
|
Before Width: | Height: | Size: 270 KiB After Width: | Height: | Size: 270 KiB |
|
Before Width: | Height: | Size: 329 KiB After Width: | Height: | Size: 329 KiB |
|
Before Width: | Height: | Size: 294 KiB After Width: | Height: | Size: 294 KiB |
|
Before Width: | Height: | Size: 348 KiB After Width: | Height: | Size: 348 KiB |
@@ -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]: <https://docs.swift.org/compiler/documentation/diagnostics/sendable-closure-captures>
|
||||
|
||||
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]: <https://docs.swift.org/compiler/documentation/diagnostics/sendable-closure-captures>
|
||||
|
||||
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]: <https://docs.swift.org/compiler/documentation/diagnostics/deprecated-declaration>
|
||||
|
||||
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]: <https://docs.swift.org/compiler/documentation/diagnostics/deprecated-declaration>
|
||||
|
||||
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 **
|
||||
|
||||
@@ -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]: <https://docs.swift.org/compiler/documentation/diagnostics/deprecated-declaration>
|
||||
|
||||
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]: <https://docs.swift.org/compiler/documentation/diagnostics/deprecated-declaration>
|
||||
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 <CFUUID 0x7b04c313e0> 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 <NSWindow: 0x7b06dcd680> 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 <NSWindow: 0x7b0842d400> 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
|
||||
<unknown>: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
|
||||