Skip to content

Commit

Permalink
Fixed error on compilation of SpectrogramFlatView/UIColor+intermediat…
Browse files Browse the repository at this point in the history
…e.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
  • Loading branch information
mahal authored Mar 20, 2024
1 parent 6d08971 commit 63443b3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ Steps involved:
this implementation caches the resulting image.
Suggested next steps on development:
* Layout and draw the slices directly on a Canvas (instead of HStack) and independently move the Canvas left.
* Make class compatible with macOS
- Drawing with Canvas instead of UIGraphicsImageRenderer
(caching of UIImage no longer needed if callback can draw directly on one Canvas)
- CrossPlatformColor from Waveform.swift or Color.Resolved instead of UIColor for gradient lookup
* Add some parameters that can be changed while the spectrogram is running
- Pause so user can have a close look at the analyzed past
- Gain or sensitivity
- Speed of the rolling plot / detail frequency by adjusting fftSize
- Min and max frequency shown
Cause of inefficiency of this implementation
* Each time a new slice arrives from FFTTap, the view gets a complete layout update.
* Rendering of new slices is done on a background thread and involves too many steps
Expand Down Expand Up @@ -66,6 +79,8 @@ Steps involved:
import AudioKit
import SwiftUI

#if !os(macOS) || targetEnvironment(macCatalyst)

/// Displays a rolling plot of the frequency spectrum.
///
/// Each slice represents a point in time with the frequencies shown from bottom to top
Expand Down Expand Up @@ -145,3 +160,5 @@ struct SpectrogramFlatView_Previews: PreviewProvider {
return SpectrogramFlatView(node: Mixer())
}
}

#endif
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright AudioKit. All Rights Reserved. Revision History at http://github.com/AudioKit/AudioKitUI/
//

#if !os(macOS) || targetEnvironment(macCatalyst)

import AudioKit
import SwiftUI

Expand Down Expand Up @@ -168,3 +170,5 @@ class SpectrogramFlatModel: ObservableObject {
}

}

#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright AudioKit. All Rights Reserved. Revision History at http://github.com/AudioKit/AudioKitUI/

#if !os(macOS) || targetEnvironment(macCatalyst)

import SwiftUI

/// One slice with frequencies from low frequencies at the bottom up to high frequences.
Expand Down Expand Up @@ -286,3 +288,5 @@ struct SpectrogramSlice_Previews: PreviewProvider {
).scaleEffect(x: 1, y: -1)
}
}

#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright AudioKit. All Rights Reserved. Revision History at http://github.com/AudioKit/AudioKitUI/

#if !os(macOS) || targetEnvironment(macCatalyst)

import Foundation
import UIKit

Expand Down Expand Up @@ -38,3 +40,5 @@ extension Array where Element: UIColor {
}
}
}

#endif

0 comments on commit 63443b3

Please sign in to comment.