-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added PlaybackFormat type (for gapless playback)
- Loading branch information
1 parent
b10e76d
commit 112a872
Showing
17 changed files
with
186 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+35.3 KB
(100%)
....xcodeproj/project.xcworkspace/xcuserdata/kven.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// | ||
// PlaybackFormat.swift | ||
// Aural | ||
// | ||
// Copyright © 2024 Kartik Venugopal. All rights reserved. | ||
// | ||
// This software is licensed under the MIT software license. | ||
// See the file "LICENSE" in the project root directory for license terms. | ||
// | ||
|
||
import AVFoundation | ||
|
||
struct PlaybackFormat { | ||
|
||
let sampleRate: Double | ||
let channelCount: AVAudioChannelCount | ||
|
||
let layoutTag: AudioChannelLayoutTag? | ||
let channelBitmapRawValue: UInt32? | ||
|
||
init(audioFormat: AVAudioFormat) { | ||
|
||
self.sampleRate = audioFormat.sampleRate | ||
self.channelCount = audioFormat.channelCount | ||
self.layoutTag = audioFormat.channelLayout?.layoutTag | ||
|
||
if self.layoutTag == kAudioChannelLayoutTag_UseChannelBitmap { | ||
self.channelBitmapRawValue = audioFormat.channelLayout?.layout.pointee.mChannelBitmap.rawValue | ||
} else { | ||
self.channelBitmapRawValue = 0 | ||
} | ||
} | ||
|
||
init?(persistentState: PlaybackFormatPersistentState) { | ||
|
||
guard let sampleRate = persistentState.sampleRate, | ||
let channelCount = persistentState.channelCount else {return nil} | ||
|
||
self.sampleRate = sampleRate | ||
self.channelCount = channelCount | ||
|
||
self.layoutTag = persistentState.layoutTag | ||
self.channelBitmapRawValue = persistentState.channelBitmapRawValue | ||
} | ||
} | ||
|
||
extension PlaybackFormat: Hashable { | ||
|
||
static func == (lhs: PlaybackFormat, rhs: PlaybackFormat) -> Bool { | ||
|
||
if lhs.sampleRate != rhs.sampleRate { | ||
return false | ||
} | ||
|
||
if lhs.channelCount != rhs.channelCount { | ||
return false | ||
} | ||
|
||
if lhs.channelCount <= 2 { | ||
return true | ||
} | ||
|
||
// MARK: Channel count > 2 -------------------------------------------------- | ||
|
||
if lhs.layoutTag != rhs.layoutTag { | ||
return false | ||
} | ||
|
||
if lhs.layoutTag == kAudioChannelLayoutTag_UseChannelBitmap { | ||
return lhs.channelBitmapRawValue == rhs.channelBitmapRawValue | ||
|
||
} else { | ||
return true | ||
} | ||
} | ||
|
||
func hash(into hasher: inout Hasher) { | ||
|
||
hasher.combine(sampleRate) | ||
hasher.combine(channelCount) | ||
hasher.combine(layoutTag) | ||
hasher.combine(channelBitmapRawValue) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.