<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ShazamKit",
  "identifier" : "/documentation/ShazamKit/SHSignature/slices(from:duration:stride:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "ShazamKit"
    ],
    "preciseIdentifier" : "s:So11SHSignatureC9ShazamKitE6slices4from8duration6strideAbCE6SlicesVSd_S2dSgtKF"
  },
  "title" : "slices(from:duration:stride:)"
}
-->

# slices(from:duration:stride:)

Returns a sequence of signatures of the specified duration from a starting value, stepping by the stride.

```
func slices(from start: TimeInterval, duration: TimeInterval, stride: TimeInterval? = nil) throws -> SHSignature.Slices
```

## 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.

## Return Value

A sequence from `start` of `duration` length. Each value in the sequence is
separated by `stride`.

## Discussion

When you recognize audio with [`match(_:)`](/documentation/ShazamKit/SHSession/match(_:)),  signature duration should be
between [`minimumQuerySignatureDuration`](/documentation/ShazamKit/SHCatalog/minimumQuerySignatureDuration) and
[`maximumQuerySignatureDuration`](/documentation/ShazamKit/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
[`matchStreamingBuffer(_:at:)`](/documentation/ShazamKit/SHSession/matchStreamingBuffer(_:at:)),
which automatically generates and matches signatures from audio buffers.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)