removed unwanted bar
This commit is contained in:
@@ -309,6 +309,7 @@ import CoreAudio
|
||||
if let timer { RunLoop.main.add(timer,forMode:.common) }
|
||||
}
|
||||
func toggle() {
|
||||
endScrubbing()
|
||||
if slideImage != nil {
|
||||
if playing { tick();slideAnchor = time;playing = false } else { if time >= duration { time = 0;slideAnchor = 0 };slideStart = ProcessInfo.processInfo.systemUptime;playing = true;startTimer() };return
|
||||
}
|
||||
@@ -318,6 +319,7 @@ import CoreAudio
|
||||
else { startNodePlayback(); playing = true; startTimer() }
|
||||
}
|
||||
func stop() {
|
||||
endScrubbing()
|
||||
cancelPendingPlayback()
|
||||
graphicsGeneration = UUID();graphicsTask?.cancel();graphicsTask = nil;checkpointTask?.cancel();checkpointTask = nil;checkpoints = [:];lastGraphicsPacket = -1
|
||||
cuePosition = 0;hotCues = [nil,nil,nil,nil];clearLoop()
|
||||
@@ -331,6 +333,35 @@ import CoreAudio
|
||||
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"
|
||||
}
|
||||
var audibleScrubbing = false
|
||||
private var scrubPreviewTask: Task<Void,Never>?
|
||||
private var scrubPreviewActive = false
|
||||
/// Preview short grains through the deck's normal EQ, fader and output route.
|
||||
/// Keep transport paused so scrubbing cannot start Automix or change sync state.
|
||||
func scrub(to value: Double) {
|
||||
guard audibleScrubbing,!playing,let file,value.isFinite else { seek(value);return }
|
||||
scrubPreviewTask?.cancel()
|
||||
seek(value)
|
||||
guard time < duration,engine.isRunning else { return }
|
||||
generation = UUID();let token = generation
|
||||
node.stop()
|
||||
let rate = file.processingFormat.sampleRate
|
||||
let start = AVAudioFramePosition(time*rate)
|
||||
let count = AVAudioFrameCount(min(file.length-start,Int64(rate*0.1)))
|
||||
guard count > 0 else { return }
|
||||
node.scheduleSegment(file,startingFrame:start,frameCount:count,at:nil)
|
||||
scrubPreviewActive = true;node.play()
|
||||
scrubPreviewTask = Task { @MainActor [weak self] in
|
||||
do { try await Task.sleep(nanoseconds:100_000_000) } catch { return }
|
||||
guard let self,self.generation == token else { return }
|
||||
self.endScrubbing()
|
||||
}
|
||||
}
|
||||
func endScrubbing() {
|
||||
scrubPreviewTask?.cancel();scrubPreviewTask = nil
|
||||
guard scrubPreviewActive else { return };scrubPreviewActive = false
|
||||
if !playing { schedule(at:time,play:false) }
|
||||
}
|
||||
func seek(_ value: Double) {
|
||||
guard value.isFinite else { return }
|
||||
invalidateGraphics()
|
||||
|
||||
Reference in New Issue
Block a user