Creating visuals with Music Understanding analysis results
At a glance
| Item | Summary |
|---|---|
| Purpose | Create a multiplatform app that presents analysis results from the Music Understanding framework. |
| App architecture | A Swift sample with the source-visible chain MusicUnderstandingLab → ContentView → SongAnalysisDocument → AssetPlayer → MusicUnderstanding APIs. |
| Main patterns | Actor-isolated state |
| Project style | 22 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries. |
Project structure
Source bundle/
└── MusicUnderstandingLab/
└── MusicUnderstandingLab/
├── MusicUnderstandingLab.swift
└── Views/
├── LoudnessView.swift
├── StructureRoundedBarView.swift
├── VisualizationView.swift
├── ContentView.swift
├── InstrumentActivityView.swift
├── InstrumentRangesView.swift
├── KeyView.swift
├── PaceView.swift
├── PlayheadView.swift
├── RhythmView.swift
└── SongSelectionView.swift
Structure observations
- Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
- Primary languages: Swift.
- The verified tree contains 4 project/configuration file(s) and 39 source declaration(s).
Overall architecture
flowchart LR
N1["MusicUnderstandingLab"]
N2["ContentView"]
N3["SongAnalysisDocument"]
N4["AssetPlayer"]
N5["MusicUnderstanding APIs"]
N1 --> N2
N2 --> N3
N3 --> N4
N4 --> N5
Reference code
MusicUnderstandingLab/MusicUnderstandingLab/MusicUnderstandingLab.swift:10 — architecture anchor
@main
struct MusicUnderstandingLab: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}Interpretation
The arrows summarize the source-visible entry, role-named types or folders, and framework direction; when nodes come from structural folders, the sequence is a high-level interpretation rather than proof that every adjacent node calls the next. Ownership is claimed only where the next section cites a stored property or assignment. The diagram is intentionally limited to the dominant path into Music Understanding.
Ownership and state
classDiagram
LoudnessView *-- CGFloat : contentSpacing
LoudnessView *-- CGFloat : statsSpacing
LoudnessView *-- CGFloat : chartSpacing
LoudnessView *-- Float : loudnessMin
Ownership evidence
MusicUnderstandingLab/MusicUnderstandingLab/Views/LoudnessView.swift:14 — stored dependency or nearest verified ownership anchor
private enum Constants {
static let contentSpacing: CGFloat = 12
// ...
}| Owner | Object or state | Relationship | Mutation authority |
|---|---|---|---|
LoudnessView |
CGFloat (contentSpacing) |
owns value state | Initialized by the owner; the binding is immutable |
LoudnessView |
CGFloat (statsSpacing) |
owns value state | Initialized by the owner; the binding is immutable |
LoudnessView |
CGFloat (chartSpacing) |
owns value state | Initialized by the owner; the binding is immutable |
LoudnessView |
Float (loudnessMin) |
owns value state | Initialized by the owner; the binding is immutable |
Composition arrows indicate a source-visible construction expression or locally owned value state; aggregation means the owner stores or receives a dependency without proving exclusive lifetime ownership.
Class and protocol design
MusicUnderstandingLab/MusicUnderstandingLab/Views/LoudnessView.swift:11 — representative type boundary
struct LoudnessView: View {
// ...
}| Type | Responsibility | Depends on or conforms to |
|---|---|---|
LoudnessView |
User-interface presentation and input forwarding | View |
StructureRoundedBarView |
User-interface presentation and input forwarding | View |
VisualizationView |
User-interface presentation and input forwarding | View |
ContentView |
User-interface presentation and input forwarding | View |
InstrumentActivityView |
User-interface presentation and input forwarding | View |
InstrumentRangesView |
User-interface presentation and input forwarding | View |
KeyView |
User-interface presentation and input forwarding | View |
PaceView |
User-interface presentation and input forwarding | View |
PlayheadView |
User-interface presentation and input forwarding | View |
RhythmView |
User-interface presentation and input forwarding | View |
No local protocol conformance is claimed as protocol-oriented design; external framework conformances are listed only as dependencies.
Access control
| Symbol | Access | Verified effect | Likely rationale |
|---|---|---|---|
result (MusicUnderstandingLab/MusicUnderstandingLab/App/AssetAnalyzer.swift:19) |
private(set) |
Read access follows the declaration; writes remain in the private scope. | Inference: allow observation while reserving invariant-changing writes for the owner. |
isAnalyzing (MusicUnderstandingLab/MusicUnderstandingLab/App/AssetAnalyzer.swift:22) |
private(set) |
Read access follows the declaration; writes remain in the private scope. | Inference: allow observation while reserving invariant-changing writes for the owner. |
isPlaying (MusicUnderstandingLab/MusicUnderstandingLab/App/AssetPlayer.swift:18) |
private(set) |
Read access follows the declaration; writes remain in the private scope. | Inference: allow observation while reserving invariant-changing writes for the owner. |
currentTime (MusicUnderstandingLab/MusicUnderstandingLab/App/AssetPlayer.swift:21) |
private(set) |
Read access follows the declaration; writes remain in the private scope. | Inference: allow observation while reserving invariant-changing writes for the owner. |
Reference code
MusicUnderstandingLab/MusicUnderstandingLab/App/AssetAnalyzer.swift:19 — representative boundary
private(set) var result: MusicUnderstandingSession.SessionResult?
/// Protects against duplicate calls to `analyze()`
private(set) var isAnalyzing = false
/// The asset's filename without extension, suitable for display.
var displayName: String {
// ...
}Swift declarations without a modifier are internal; explicit private, fileprivate, private(set), public, or open entries above are interpreted by language semantics. Objective-C/C samples instead rely on header and implementation boundaries, which are not equivalent to Swift lexical privacy.
Logic ownership and placement
| Logic | Owning type or file | Placement rationale |
|---|---|---|
| Owns document data or lifecycle behavior | SongAnalysisDocument |
The source’s Document suffix makes this role explicit. |
| Owns media or timeline playback | AssetPlayer |
The source’s Player suffix makes this role explicit. |
| User-interface presentation and input forwarding | ContentView, InstrumentActivityView, InstrumentRangesView, KeyView |
The source’s View suffix makes this role explicit. |
Design patterns
| Pattern | Source evidence | Purpose or tradeoff |
|---|---|---|
| Actor-isolated state | MusicUnderstandingLab/MusicUnderstandingLab/App/AssetAnalyzer.swift:12 |
Actor annotations make the concurrency ownership boundary explicit. |
Naming conventions
- Types: Document: SongAnalysisDocument; Player: AssetPlayer; View: ContentView, InstrumentActivityView, InstrumentRangesView, KeyView, LoudnessView.
- Protocols: no local protocol declaration in the scanned source.
- Methods:
statsRow,statItem,stopAccessingSecurityScopedResource. - Files:
MusicUnderstandingLab/MusicUnderstandingLab/MusicUnderstandingLab.swift,MusicUnderstandingLab/MusicUnderstandingLab/Views/LoudnessView.swift,MusicUnderstandingLab/MusicUnderstandingLab/Views/StructureRoundedBarView.swift,MusicUnderstandingLab/MusicUnderstandingLab/Views/VisualizationView.swift,MusicUnderstandingLab/MusicUnderstandingLab/Views/ContentView.swift,MusicUnderstandingLab/MusicUnderstandingLab/Views/InstrumentActivityView.swift.
Architecture takeaways
MusicUnderstandingLabis the main source-visible entry or composition anchor for this sample.- Framework work reaches SwiftUI, MusicUnderstanding, CoreMedia, AVFoundation through a deliberately small high-level chain; the detailed API graph remains inside the cited implementation files.
- Stored-property evidence identifies lifecycle collaboration; it does not by itself prove exclusive object ownership.
- Access-control conclusions separate verified language visibility from the likely design rationale.
- The source does not justify labeling the design protocol-oriented.
Source map
| Source file | Relevant symbols |
|---|---|
MusicUnderstandingLab/MusicUnderstandingLab/MusicUnderstandingLab.swift |
MusicUnderstandingLab |
MusicUnderstandingLab/MusicUnderstandingLab/Views/LoudnessView.swift |
LoudnessView, Constants, ChartSection |
MusicUnderstandingLab/MusicUnderstandingLab/Views/StructureRoundedBarView.swift |
Constants, StructureRoundedBarView, SegmentBar |
MusicUnderstandingLab/MusicUnderstandingLab/Views/VisualizationView.swift |
VisualizationView, Constants, AnalysisTiles |
MusicUnderstandingLab/MusicUnderstandingLab/Views/ContentView.swift |
ContentView, Constants |
MusicUnderstandingLab/MusicUnderstandingLab/Views/InstrumentActivityView.swift |
InstrumentActivityView, Constants |
MusicUnderstandingLab/MusicUnderstandingLab/Views/InstrumentRangesView.swift |
InstrumentRangesView, Constants |
MusicUnderstandingLab/MusicUnderstandingLab/Views/KeyView.swift |
KeyView, Constants |
MusicUnderstandingLab/MusicUnderstandingLab/Views/PaceView.swift |
PaceView, Constants |
MusicUnderstandingLab/MusicUnderstandingLab/Views/PlayheadView.swift |
PlayheadView, Constants |