ios: karaoke vocals On/Soft/Off (1.0.6)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8e5ebb70b1
commit
41b8171df2
4 files changed
+55
-21
No files matched your search
@@ -19,6 +19,8 @@ enum Stems {
|
||||
}
|
||||
}
|
||||
|
||||
enum KaraokeVocals: Int, CaseIterable { case On, Soft, Off }
|
||||
|
||||
/// One stem's fader. [level] is the slider position; 0.8 is unity gain.
|
||||
struct StemSetting: Codable, Hashable {
|
||||
static let unity: Float = 0.8
|
||||
@@ -124,7 +126,7 @@ final class PlaybackManager: StemEngineListener, @unchecked Sendable {
|
||||
private(set) var message: AppMessage?
|
||||
/// Mixes saved for single songs (by rating key), put back whenever that song starts.
|
||||
private(set) var songMixes: [String: [String: StemSetting]] = [:]
|
||||
/// Karaoke mode: vocals out on every song, lyrics on Now Playing.
|
||||
/// Karaoke mode: vocals on, soft or out (per settings) on every song, lyrics on Now Playing.
|
||||
private(set) var karaoke = false
|
||||
@ObservationIgnored private var preKaraokeMix: [String: StemSetting]?
|
||||
|
||||
@@ -415,11 +417,25 @@ final class PlaybackManager: StemEngineListener, @unchecked Sendable {
|
||||
|
||||
/// The mix a song starts with: karaoke if that's on, else the song's saved mix, else cleared (or kept, per settings).
|
||||
private func startMix(_ t: Track) -> [String: StemSetting] {
|
||||
if karaoke { return Self.karaokeMix }
|
||||
if karaoke { return karaokeMix }
|
||||
return songMixes[t.ratingKey] ?? (settings.keepStemMix ? mix : [:])
|
||||
}
|
||||
|
||||
private static let karaokeMix = ["vocals": StemSetting(muted: true)]
|
||||
/// How much of the singer is left in karaoke mode. Soft is about -12 dB, a guide under your own voice.
|
||||
private var karaokeMix: [String: StemSetting] {
|
||||
switch karaokeVocals {
|
||||
case .On: return [:]
|
||||
case .Soft: return ["vocals": StemSetting(level: 0.4)]
|
||||
case .Off: return ["vocals": StemSetting(muted: true)]
|
||||
}
|
||||
}
|
||||
|
||||
var karaokeVocals: KaraokeVocals { KaraokeVocals(rawValue: settings.karaokeVocals) ?? .Off }
|
||||
|
||||
func setKaraokeVocals(_ v: KaraokeVocals) {
|
||||
settings.karaokeVocals = v.rawValue
|
||||
if karaoke { applyMix(karaokeMix) }
|
||||
}
|
||||
|
||||
/// Turning it off puts back the song's saved mix, or the one from before, unless the mix was changed meanwhile.
|
||||
func setKaraoke(_ on: Bool) {
|
||||
@@ -427,9 +443,9 @@ final class PlaybackManager: StemEngineListener, @unchecked Sendable {
|
||||
karaoke = on
|
||||
if on {
|
||||
preKaraokeMix = mix
|
||||
applyMix(Self.karaokeMix)
|
||||
applyMix(karaokeMix)
|
||||
} else {
|
||||
if MixPresets.normalized(mix) == Self.karaokeMix { applyMix(songMix ?? preKaraokeMix ?? [:]) }
|
||||
if MixPresets.normalized(mix) == karaokeMix { applyMix(songMix ?? preKaraokeMix ?? [:]) }
|
||||
preKaraokeMix = nil
|
||||
changed()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user