broken changes
This commit is contained in:
@@ -88,7 +88,7 @@ import CoreAudio
|
||||
guard let unit = engine.outputNode.audioUnit else { throw LibraryError.message("Audio output unavailable") }
|
||||
let running = engine.isRunning;engine.stop();var value = device
|
||||
let result = AudioUnitSetProperty(unit,kAudioOutputUnitProperty_CurrentDevice,kAudioUnitScope_Global,0,&value,UInt32(MemoryLayout.size(ofValue:value)))
|
||||
guard result == noErr else { throw LibraryError.message("Audio routing failed (\(result))") }
|
||||
guard result == noErr else { if running { try? engine.start() };throw LibraryError.message("Audio routing failed (\(result))") }
|
||||
if running { try engine.start() }
|
||||
}
|
||||
struct GlobalMix: Codable, Equatable {
|
||||
@@ -103,6 +103,7 @@ import CoreAudio
|
||||
}
|
||||
@Published private(set) var waveform = [Float]()
|
||||
@Published private(set) var waveformBands = [WaveformBands]()
|
||||
@Published var inputGain: Double = 0 { didSet { tone.globalGain = Float(min(12,max(-12,inputGain))) } }
|
||||
@Published var lowGain: Double = 0 { didSet { updateTone() } }
|
||||
@Published var midGain: Double = 0 { didSet { updateTone() } }
|
||||
@Published var highGain: Double = 0 { didSet { updateTone() } }
|
||||
@@ -157,9 +158,10 @@ import CoreAudio
|
||||
AudioTone.configure(tone,sampleRate:file?.processingFormat.sampleRate ?? 44100,low:lowGain,mid:midGain,high:highGain,filter:filter,enabled:toneEnabled)
|
||||
saveMix()
|
||||
}
|
||||
func load(_ song: Song, preference: SongPreference = .init()) throws {
|
||||
func load(_ song: Song, preference: SongPreference = .init(), startPlaying: Bool = true) throws {
|
||||
stop()
|
||||
do {
|
||||
guard MediaByteCopy.nonempty(URL(fileURLWithPath:song.audio)) else { throw LibraryError.message("Audio file is empty or unavailable: \(song.title). Reimport the original media to repair the library copy.") }
|
||||
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") }
|
||||
@@ -176,7 +178,7 @@ import CoreAudio
|
||||
metering = true
|
||||
engine.mainMixerNode.outputVolume = Float(volume)
|
||||
engine.prepare(); try engine.start()
|
||||
schedule(at:0,play:true); startTimer(); tick()
|
||||
schedule(at:0,play:startPlaying); startTimer(); tick()
|
||||
if ["mp4","m4v","mov"].contains(URL(fileURLWithPath:song.audio).pathExtension.lowercased()) {
|
||||
let item = AVPlayerItem(url:URL(fileURLWithPath:song.audio))
|
||||
let output = AVPlayerItemVideoOutput(pixelBufferAttributes:[kCVPixelBufferPixelFormatTypeKey as String:kCVPixelFormatType_32BGRA])
|
||||
|
||||
Reference in New Issue
Block a user