Skip to content

Commit 63443b3

Browse files
authored
Fixed error on compilation of SpectrogramFlatView/UIColor+intermediate.swift for macOS (#85)
* Made SpectrogramFlatView unavailable to macOS as it relies on some iOS only stuff. * Added comment on what to to next and how to make class available on macOS
1 parent 6d08971 commit 63443b3

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

Sources/AudioKitUI/Visualizations/SpectrogramFlatView/SpectrogramFlatView.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ Steps involved:
3535
this implementation caches the resulting image.
3636

3737

38+
Suggested next steps on development:
39+
* Layout and draw the slices directly on a Canvas (instead of HStack) and independently move the Canvas left.
40+
* Make class compatible with macOS
41+
- Drawing with Canvas instead of UIGraphicsImageRenderer
42+
(caching of UIImage no longer needed if callback can draw directly on one Canvas)
43+
- CrossPlatformColor from Waveform.swift or Color.Resolved instead of UIColor for gradient lookup
44+
* Add some parameters that can be changed while the spectrogram is running
45+
- Pause so user can have a close look at the analyzed past
46+
- Gain or sensitivity
47+
- Speed of the rolling plot / detail frequency by adjusting fftSize
48+
- Min and max frequency shown
49+
50+
3851
Cause of inefficiency of this implementation
3952
* Each time a new slice arrives from FFTTap, the view gets a complete layout update.
4053
* Rendering of new slices is done on a background thread and involves too many steps
@@ -66,6 +79,8 @@ Steps involved:
6679
import AudioKit
6780
import SwiftUI
6881

82+
#if !os(macOS) || targetEnvironment(macCatalyst)
83+
6984
/// Displays a rolling plot of the frequency spectrum.
7085
///
7186
/// Each slice represents a point in time with the frequencies shown from bottom to top
@@ -145,3 +160,5 @@ struct SpectrogramFlatView_Previews: PreviewProvider {
145160
return SpectrogramFlatView(node: Mixer())
146161
}
147162
}
163+
164+
#endif

Sources/AudioKitUI/Visualizations/SpectrogramFlatView/SpectrogramModel.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright AudioKit. All Rights Reserved. Revision History at http://github.com/AudioKit/AudioKitUI/
22
//
33

4+
#if !os(macOS) || targetEnvironment(macCatalyst)
5+
46
import AudioKit
57
import SwiftUI
68

@@ -168,3 +170,5 @@ class SpectrogramFlatModel: ObservableObject {
168170
}
169171

170172
}
173+
174+
#endif

Sources/AudioKitUI/Visualizations/SpectrogramFlatView/SpectrogramSlice.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright AudioKit. All Rights Reserved. Revision History at http://github.com/AudioKit/AudioKitUI/
22

3+
#if !os(macOS) || targetEnvironment(macCatalyst)
4+
35
import SwiftUI
46

57
/// One slice with frequencies from low frequencies at the bottom up to high frequences.
@@ -286,3 +288,5 @@ struct SpectrogramSlice_Previews: PreviewProvider {
286288
).scaleEffect(x: 1, y: -1)
287289
}
288290
}
291+
292+
#endif

Sources/AudioKitUI/Visualizations/SpectrogramFlatView/UIColor+intermediate.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright AudioKit. All Rights Reserved. Revision History at http://github.com/AudioKit/AudioKitUI/
22

3+
#if !os(macOS) || targetEnvironment(macCatalyst)
4+
35
import Foundation
46
import UIKit
57

@@ -38,3 +40,5 @@ extension Array where Element: UIColor {
3840
}
3941
}
4042
}
43+
44+
#endif

0 commit comments

Comments
 (0)