Files
Lyrebird/Sources/Lyrebird/Buffers/WavFileError.swift
T
josh 844dc4d9cd v2.1.0 release: Swift 6.4 modernization
Typed throws across the closed-error-set APIs (OSC, MIDI, engine add/schedule,
bus/config/parameter, and the WAV/RF64/Spectral file codecs — source-compatible
narrowing, new .ioFailure cases), plus internal hardening: NSLock-guarded
scheduling/MIDI state moved to Mutex<State>, and the Spectral/FFT scratch owners
moved to a ~Copyable RTScratchBuffer RAII buffer. No API or behavioral change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-24 19:54:59 -07:00

31 lines
1.3 KiB
Swift

// WavFileError.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import Foundation
/// Errors thrown by the portable WAV reader/writer.
public enum WavFileError: Error, Equatable {
/// The destination file could not be created.
case cannotCreate(URL)
/// The source file could not be opened for reading.
case cannotOpen(URL)
/// The file is not a RIFF/WAVE container (bad magic).
case notWave
/// The file's `fmt ` chunk describes an encoding the portable codec does not
/// handle (only int16 / int24 / float32 PCM are supported; use the
/// `AudioToolbox` path on Apple for compressed or exotic formats).
case unsupportedFormat(formatTag: UInt16, bitsPerSample: UInt16)
/// The file ended before the header or declared data could be read. Also
/// covers a `fmt ` chunk too short to hold the fields it must declare.
case truncated
/// A plain WAV cannot describe more than 4 GB — its RIFF and `data` sizes
/// are 32-bit. Writing past that needs RF64/W64 instead.
case fileTooLarge(bytes: Int)
/// An underlying file-system operation (`FileHandle` read / seek / write)
/// failed. Associated value is the system error's description.
case ioFailure(String)
}