-
Notifications
You must be signed in to change notification settings - Fork 194
/
AudioAnalysisContext.swift
44 lines (37 loc) 路 1.08 KB
/
AudioAnalysisContext.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// Copyright 漏 2024 Stream.io Inc. All rights reserved.
//
import AVFoundation
/// An object describing the context of an AudioTrack analysis process
struct AudioAnalysisContext {
/// The URL location of the AudioTrack under analysis
let audioURL: URL
/// The number of samples contained in the AudioTrack
let totalSamples: Int
/// The asset pointing to the AudioTrack
let asset: AVAsset
/// The first audio track available in the asset (if any)
let assetTrack: AVAssetTrack?
init(
audioURL: URL,
totalSamples: Int,
asset: AVAsset,
assetTrack: AVAssetTrack?
) {
self.audioURL = audioURL
self.totalSamples = totalSamples
self.asset = asset
self.assetTrack = assetTrack
}
init(
from loadedAsset: AVAsset,
audioURL: URL
) {
self.init(
audioURL: audioURL,
totalSamples: loadedAsset.totalSamplesOfFirstAudioTrack(),
asset: loadedAsset,
assetTrack: loadedAsset.tracks(withMediaType: .audio).first
)
}
}