One Logo Pool Ball
ShazamKit · IOS API REFERENCE

SHSignature

class · iOS 15.0+ · SDK 27.1

class SHSignature

Members (4)

init · iOS 15.0+

init

TypeScript
static init(dataRepresentation: ArrayBuffer): SHSignature
Swift declaration
init(dataRepresentation: Data) throws
get · iOS 15.0+

dataRepresentation

TypeScript
get dataRepresentation(): ArrayBuffer
Swift declaration
var dataRepresentation: Data { get }
get · iOS 15.0+

duration

TypeScript
get duration(): number
Swift declaration
var duration: TimeInterval { get }
method · iOS 18.0+

slices

TypeScript
slices(start: number, duration: number, stride?: (number) | null): SHSignature_Slices
Swift declaration
func slices(from start: TimeInterval, duration: TimeInterval, stride: TimeInterval? = nil) throws -> SHSignature.Slices

Returns a sequence of signatures of the specified duration from a starting value, stepping by the stride. - Parameters: - start: The starting value to use for the sequence. - duration: The desired duration of each sliced signature. - stride: The amount to step by for each slice. Must be a non-zero positive value. - Returns: A sequence from `start` of `duration` length. Each value in the sequence is separated by `stride`. When you recognize audio with ``SHSession/match(_:)``, signature duration should be between ``SHCatalog/minimumQuerySignatureDuration`` and ``SHCatalog/maximumQuerySignatureDuration``. Use this method to slice signatures longer than the maximum duration. Slicing allows you to test specific parts of the audio. If you know certain parts of an audio are clearer or more likely to have recognizable content, prioritize matching those slices. The code below creates slices from a signature and uses the first three slices to find a match: ```swift let signature = try await SHSignatureGenerator.signature(from: audioAsset) let slices = try signature.slices(from: 2.0, duration: 10.0, stride: 5.0) // Use the first 3 slices to find a match. for try await slice in slices.prefix(3) { session.match(slice) } ``` You can use AsyncSequence operators like <doc://com.apple.documentation/documentation/swift/asyncsequence/prefix(_:)> or <doc://com.apple.documentation/documentation/swift/asyncsequence/first(where:)> to choose which slices are processed. The `stride` parameter controls overlap between slices. A smaller stride creates more slices with greater overlap, which increases the number of matching requests. Larger strides create fewer slices, however there are fewer matching requests. For continuous matching as audio becomes available, use ``SHSession/matchStreamingBuffer(_:at:)``, which automatically generates and matches signatures from audio buffers.

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

SHSignature.init()

inherited init: cannot prove legal (class declares 1 custom initializer)

All ShazamKit types →