iOS 1.0 RC 1: battery and heat work, version label, web player redraw tweaks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-11-06 08:31:00 -08:00
1 parent 0fc35b13e8
commit c0e33b5e3e
18 files changed
+143 -36

No files matched your search

+13 -4
View File
@@ -201,7 +201,11 @@ final class StemEngine: @unchecked Sendable {
static let ringSeconds = 3
/// Frames each stem must have before (re)starting output.
static let prefill = 8192
/// Mixed audio kept ahead of the speaker. Short while someone's looking, so faders and EQ
/// answer quickly; deep when nobody is, so the engine wakes a few times a second instead of
/// hundreds and the CPU can sleep between bursts.
static let bufferMs = 120
static let backgroundBufferMs = 600
/// Where playback is; position = frame + (now - nanos) while [running].
struct Snapshot {
@@ -446,7 +450,8 @@ final class StemEngine: @unchecked Sendable {
guard let s = session, wantPlay else {
setFlags(false, false)
publish()
idle(100)
// Nothing moves while paused; a command wakes the loop.
idle(2000)
return
}
if let e = s.error() {
@@ -483,9 +488,13 @@ final class StemEngine: @unchecked Sendable {
setFlags(true, false)
guard let tap else { return }
if tap.ring.freeFrames < Self.chunk {
let target = min(trackRate * (AppActivity.isActive ? Self.bufferMs : Self.backgroundBufferMs) / 1000, tap.ring.capacityFrames)
let buffered = tap.ring.availableFrames
if buffered + Self.chunk > target {
publish()
idle(5)
// Sleep until the buffer is half drained, then top it up in one burst.
let ms = Double(buffered - target / 2) * 1000 / Double(max(1, trackRate)) / speed
idle(max(5, Int(ms)))
return
}
let n = mixChunk(s)
@@ -620,7 +629,7 @@ final class StemEngine: @unchecked Sendable {
#if os(iOS)
try? AVAudioSession.sharedInstance().setPreferredSampleRate(Double(rate))
#endif
let t = OutputTap(rate: rate, frames: max(4096, rate * Self.bufferMs / 1000))
let t = OutputTap(rate: rate, frames: max(4096, rate * Self.backgroundBufferMs / 1000))
t.setLatency(Self.outputLatency())
t.speed = speed
guard let fmt = AVAudioFormat(standardFormatWithSampleRate: Double(rate), channels: 2) else {