<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MusicUnderstanding",
  "identifier" : "/documentation/MusicUnderstanding/MusicUnderstandingSession",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Music Understanding"
    ],
    "preciseIdentifier" : "s:18MusicUnderstanding0aB7SessionC"
  },
  "title" : "MusicUnderstandingSession"
}
-->

# MusicUnderstandingSession

An object that performs music analysis on an audio source and provides the results.

```
actor MusicUnderstandingSession
```

## Topics

### Creating a session

[`convenience init<Provider>(audioProvider: Provider)`](/documentation/MusicUnderstanding/MusicUnderstandingSession/init(audioProvider:))

Creates a music understanding session that accepts streaming audio buffers.

[`convenience init(asset: any AVAsset & Sendable) async throws`](/documentation/MusicUnderstanding/MusicUnderstandingSession/init(asset:))

Creates a music understanding session from an audio asset.

### Performing an analysis

[`func analyze() async throws -> MusicUnderstandingSession.SessionResult`](/documentation/MusicUnderstanding/MusicUnderstandingSession/analyze())

Performs all available analyses on the session’s audio source.

[`func analyze(for: Set<AnalysisType>) async throws -> MusicUnderstandingSession.SessionResult`](/documentation/MusicUnderstanding/MusicUnderstandingSession/analyze(for:))

Performs the specified analyses on the session’s audio source.

### Getting analysis results

[`struct SessionResult`](/documentation/MusicUnderstanding/MusicUnderstandingSession/SessionResult)

The aggregated results for all analysis types that a music understanding session performs.

[`var loudnessResults: some Sendable & AsyncSequence<LoudnessResult, any Error>`](/documentation/MusicUnderstanding/MusicUnderstandingSession/loudnessResults)

An async sequence that yields loudness analysis results as they become available.

[`struct RangedValue`](/documentation/MusicUnderstanding/MusicUnderstandingSession/RangedValue)

A structure that pairs a value over a time range.

[`struct TimedValue`](/documentation/MusicUnderstanding/MusicUnderstandingSession/TimedValue)

A structure that pairs a value with a time.

### Cancelling a session

[`func cancel() async`](/documentation/MusicUnderstanding/MusicUnderstandingSession/cancel())

Cancels any ongoing analysis.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`Actor`](/documentation/Swift/Actor)

---

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)