### Prepare for Interface Builder Source: https://github.com/audiokit/audiokitui/wiki/ADSRView Performs necessary setup to allow the view to be rendered correctly within Interface Builder. This is an override method. ```swift override public func prepareForInterfaceBuilder() ``` -------------------------------- ### receivedMIDISetupChange Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView Notifies that the MIDI setup has changed. ```APIDOC ## receivedMIDISetupChange() ### Description MIDI Setup has changed. ``` -------------------------------- ### File Start Time Property Source: https://github.com/audiokit/audiokitui/wiki/ViewableSegment Specifies the start time of the segment within the original audio file in seconds. This is a required property for any type conforming to ViewableSegment. ```swift var fileStartTime: TimeInterval ``` -------------------------------- ### MIDI Setup Change Notification Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView This method is called when the MIDI setup on the system has been modified. No parameters are required as it signifies a global change. ```swift public func receivedMIDISetupChange() ``` -------------------------------- ### Initialize MockSegment Source: https://github.com/audiokit/audiokitui/wiki/MockSegment Initializes a new MockSegment instance with a file URL, start time, and RMS frames per second. ```swift public init(audioFileURL: URL, playbackStartTime: TimeInterval, rmsFramesPerSecond: Double) throws ``` -------------------------------- ### Playback Start Time Property Source: https://github.com/audiokit/audiokitui/wiki/ViewableSegment Specifies the start time of the segment during playback in seconds. This is a required property for any type conforming to ViewableSegment. ```swift var playbackStartTime: TimeInterval ``` -------------------------------- ### Get Waveform Channels Source: https://github.com/audiokit/audiokitui/wiki/Waveform Read-only property indicating the number of audio channels the waveform is configured to display. ```swift public private(set) var channels: Int = 2 ``` -------------------------------- ### Get multitouch state Source: https://github.com/audiokit/audiokitui/wiki/MultitouchGestureRecognizer Returns the current state of the gesture recognizer. ```swift public var multitouchState: MultitouchState ``` -------------------------------- ### Get Samples Per Pixel Source: https://github.com/audiokit/audiokitui/wiki/Waveform Read-only property indicating the number of audio samples represented per pixel in the waveform display. ```swift public private(set) var samplesPerPixel: Int = 0 ``` -------------------------------- ### FFTView Initializer Source: https://github.com/audiokit/audiokitui/wiki/FFTView Initializes a new FFTView to visualize audio data from a given node. ```APIDOC ## init(_:linearGradient:paddingFraction:includeCaps:validBinCount:barCount:maxAmplitude:minAmplitude:backgroundColor:) ### Description Initializes the FFTView with specific visual parameters for frequency visualization. ### Parameters - **node** (Node) - Required - The audio node to visualize. - **linearGradient** (LinearGradient) - Optional - The gradient used for the bars. - **paddingFraction** (CGFloat) - Optional - The fraction of space used for padding. - **includeCaps** (Bool) - Optional - Whether to include caps on the bars. - **validBinCount** (FFTValidBinCount) - Optional - The number of valid bins to process. - **barCount** (Int) - Optional - The number of bars to display. - **maxAmplitude** (Float) - Optional - The maximum amplitude threshold. - **minAmplitude** (Float) - Optional - The minimum amplitude threshold. - **backgroundColor** (Color) - Optional - The background color of the view. ``` -------------------------------- ### Initialize FFTView Source: https://github.com/audiokit/audiokitui/wiki/FFTView Initializer for configuring the FFT visualization with gradient, amplitude, and bin settings. ```swift public init(_ node: Node, linearGradient: LinearGradient = LinearGradient(gradient: Gradient(colors: [.red, .yellow, .green]), startPoint: .top, endPoint: .center), paddingFraction: CGFloat = 0.2, includeCaps: Bool = true, validBinCount: FFTValidBinCount? = nil, barCount: Int? = nil, maxAmplitude: Float = -10.0, minAmplitude: Float = -150.0, backgroundColor: Color = Color.black) ``` -------------------------------- ### Initialize RawOutputView Source: https://github.com/audiokit/audiokitui/wiki/RawOutputView Initializes RawOutputView with optional audio node and customizable parameters for buffer size, stroke color, normalization, and scale factor. Defaults are provided for convenience. ```swift public init(_ node: Node? = nil, bufferSize: Int = 1024, strokeColor: Binding = .constant(Color.black), isNormalized: Binding = .constant(false), scaleFactor: Binding = .constant(1.0)) ``` -------------------------------- ### NodeOutputView Initializer Source: https://github.com/audiokit/audiokitui/wiki/NodeOutputView Initializes a new NodeOutputView to visualize the output of a specific audio node. ```APIDOC ## init(_:color:backgroundColor:bufferSize:) ### Description Initializes the view with a specific audio node and styling parameters. ### Parameters - **node** (Node) - Required - The audio node to visualize. - **color** (Color) - Optional - The color of the plot line (default: .gray). - **backgroundColor** (Color) - Optional - The background color of the view (default: .clear). - **bufferSize** (Int) - Optional - The size of the audio buffer to process (default: 1024). ``` -------------------------------- ### Get centroid coordinates Source: https://github.com/audiokit/audiokitui/wiki/MultitouchGestureRecognizer Calculates the average location of all current touches. ```swift public var centroid: CGPoint? ``` -------------------------------- ### KeyboardView Initializers Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView Details the various initializers available for KeyboardView, catering to different platforms and configuration needs. ```APIDOC ## Initializers ### `init(frame:)` Initialize the keyboard with default info. **Platform:** macOS, macCatalyst, iOS ```swift public override init(frame: CGRect) ``` ### `init(width:height:firstOctave:octaveCount:polyphonic:)` Initialize the keyboard with specified dimensions and options. **Platform:** macCatalyst, iOS ```swift public init(width: Int, height: Int, firstOctave: Int = 4, octaveCount: Int = 3, polyphonic: Bool = false) ``` ### `init?(coder:)` Initialization within Interface Builder or from Storyboard. **Platform:** macCatalyst, iOS (Interface Builder) **Platform:** macOS (Storyboard) ```swift public required init?(coder aDecoder: NSCoder) ``` ### `init(width:height:firstOctave:octaveCount:polyphonic:)` (macOS) Initialize with all parameters for macOS. **Platform:** macOS #### Parameters - **width** (Int) - Horizontal size - **height** (Int) - Vertical size - **firstOctave** (Int) - Octave of left-most keys (default: 4) - **octaveCount** (Int) - Number of octaves to display (default: 3) - **polyphonic** (Bool) - Should more than one key light up at a time? (default: false) ```swift public init(width: Int, height: Int, firstOctave: Int = 4, octaveCount: Int = 3, polyphonic: Bool = false) ``` ### `init?(coder:)` (macOS) Initialize from Storyboard for macOS. **Platform:** macOS #### Parameters - **aDecoder** (NSCoder) - Decoder ```swift required public init?(coder aDecoder: NSCoder) ``` ``` -------------------------------- ### Initialize AudioFileWaveform Source: https://github.com/audiokit/audiokitui/wiki/AudioFileWaveform Initializer for creating an AudioFileWaveform instance with a URL, RMS samples per window, and color. ```swift public init(url: URL, rmsSamplesPerWindow: Int = 256, color: Color = Color.gray) ``` -------------------------------- ### Get previous centroid coordinates Source: https://github.com/audiokit/audiokitui/wiki/MultitouchGestureRecognizer Calculates the average location of all previous touches. ```swift public var previousCentroid: CGPoint? ``` -------------------------------- ### NodeFFTView Initializers Source: https://github.com/audiokit/audiokitui/wiki/NodeFFTView Information about the available initializers for NodeFFTView. ```APIDOC ## Initializers ### `init(_:)` Initializes a new instance of NodeFFTView with a given Node. #### Parameters - **node** (Node) - The Node to associate with the view. ``` -------------------------------- ### Get Waveform Plots Source: https://github.com/audiokit/audiokitui/wiki/Waveform Provides read-only access to the array of waveform layers managed by the Waveform container. ```swift public private(set) var plots ``` -------------------------------- ### Handle Touch Begin Event Source: https://github.com/audiokit/audiokitui/wiki/MultitouchGestureRecognizerDelegate Optional method called when a touch begins. ```swift @objc optional func multitouchGestureRecognizer(_ gestureRecognizer: MultitouchGestureRecognizer, touchDidBegin touch: UITouch) ``` -------------------------------- ### UI Components Source: https://github.com/audiokit/audiokitui/wiki/Home A list of available UI components for creating audio interfaces. ```APIDOC ## UI Components This section lists the various UI components available in the AudioKit UI library. ### ADSRView A click and draggable view of an ADSR Envelope (Attack, Decay, Sustain, Release). All values are normalized 0->1, so scale them as needed in your callback. ### MIDITrackViewModel Represents the data model for a MIDI track view. ### MultitouchGestureRecognizer A `UIGestureRecognizer` subclass that tracks the state of individual touches. ### FloatPlot A component for plotting floating-point data. ### FragmentBuilder A component for building fragments. ### RollingViewData Data structure for rolling views. ### TableView Displays table values in a graphical format. ### Waveform A container CALayer-based class for multiple CAWaveformLayers. ### WaveformLayer A CAShapeLayer rendering of a mono waveform. Can be updated on any thread. ### WavetableModel Model for wavetable data. ### MultitouchGestureRecognizer.Mode Denotes the way the list of touches is managed. ### MultitouchGestureRecognizer.MultitouchState The current gesture recognizer state, as it pertains to the `sustain` setting. ### MetalFragment Represents a Metal fragment. ### ArcKnob A circular knob UI component. ### Knob A standard knob UI component. ### MIDITrackView MIDI track UI similar to the one found in Digital Audio Workstations (DAWs). ### MusicalDurationStepper A stepper component for adjusting musical durations. ### ParameterEditor A UI component for editing parameters. ### ReverbPresetStepper A stepper component for selecting reverb presets. ### TapCountingDrumPadGrid A grid of drum pads that respond to tap counting. ### TempoDraggableStepper A stepper component for adjusting tempo with drag functionality. ### MultitouchOverlayView An overlay view for handling multitouch gestures. ### AmplitudeView A view for visualizing amplitude. ### AudioFileWaveform A waveform visualization for audio files. ### AudioWaveform A general-purpose audio waveform visualization. ### FFTView A view for displaying Fast Fourier Transform (FFT) data. ### FloatPlotView A view component for plotting floating-point data. ### NodeFFTView A view for displaying FFT data of a node. ### NodeOutputView A view for displaying the output of a node. ### NodeRollingView A rolling view for node data. ### RawOutputView A view for displaying raw output. ### SpectrogramView A view for displaying spectrogram data. ### SpectrumView A view for displaying spectrum data. ### TrackView A view representing a track. ### MockSegment A mock segment for testing or placeholder purposes. ### WavetableArrayView A view for displaying an array of wavetables. ### WavetableView A view for displaying wavetable data. ``` -------------------------------- ### Get Intrinsic Content Size Source: https://github.com/audiokit/audiokitui/wiki/ADSRView Represents the natural size of the view, used for layout calculations. This is an override property. ```swift override public var intrinsicContentSize: CGSize ``` -------------------------------- ### CGRect Initializers Source: https://github.com/audiokit/audiokitui/wiki/CGRect Provides documentation for the various initializers available for CGRect extensions. ```APIDOC ## Initializers on CGRect ### `init(size:)` Initialize with a size. ### Method Initializer ### Parameters #### Path Parameters - **size** (CGSize) - Required - The size to create the CGRect with. ### `init(width:height:)` (CGFloat) Initialize with width and height. ### Method Initializer ### Parameters #### Path Parameters - **width** (CGFloat) - Required - The width of the rectangle. - **height** (CGFloat) - Required - The height of the rectangle. ### `init(width:height:)` (Int) Initialize with width and height. ### Method Initializer ### Parameters #### Path Parameters - **width** (Int) - Required - The width of the rectangle. - **height** (Int) - Required - The height of the rectangle. ``` -------------------------------- ### Initialize MIDITrackView Source: https://github.com/audiokit/audiokitui/wiki/MIDITrackView Initializes a MIDITrackView with a file URL, track number, and dimensions. Requires a binding to a URL for the MIDI file. ```swift public init(fileURL: Binding, trackNumber: Int, trackWidth: CGFloat, trackHeight: CGFloat ) ``` -------------------------------- ### Initialize KeyboardView (macOS) Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView Initializers for the macOS version of the keyboard. ```swift public init(width: Int, height: Int, firstOctave: Int = 4, octaveCount: Int = 3, polyphonic: Bool = false) ``` ```swift required public init?(coder aDecoder: NSCoder) ``` -------------------------------- ### SpectrogramView Struct Definition Source: https://github.com/audiokit/audiokitui/wiki/SpectrogramView Defines the SpectrogramView struct, a custom SwiftUI View. No specific setup is required beyond standard SwiftUI usage. ```swift public struct SpectrogramView: View ``` -------------------------------- ### Initialize MIDITrackViewModel Source: https://github.com/audiokit/audiokitui/wiki/MIDITrackViewModel Standard initializer for creating a new instance of the view model. ```swift public init() ``` -------------------------------- ### TrackView Initializer Source: https://github.com/audiokit/audiokitui/wiki/TrackView Initializes a new TrackView instance to display audio segments. ```APIDOC ## init(segments:rmsFramesPerSecond:pixelsPerRMS:) ### Description Initializes a TrackView with a collection of viewable segments and configuration for RMS visualization. ### Parameters #### Arguments - **segments** ([Segment]) - Required - An array of objects conforming to the ViewableSegment protocol. - **rmsFramesPerSecond** (Double) - Optional - The frame rate for RMS calculation, defaults to 50. - **pixelsPerRMS** (Double) - Optional - The scaling factor for pixels per RMS unit, defaults to 1. ``` -------------------------------- ### Initialize WavetableView Source: https://github.com/audiokit/audiokitui/wiki/WavetableView Initializes a new WavetableView with a DynamicWaveformNode and optional styling parameters. ```swift public init(_ node: DynamicWaveformNode, strokeColor: Color = Color.white, strokeLineWidth: CGFloat = 1.0, fillColor: Color = Color.green.opacity(0.8), backgroundColor: Color = Color.black) ``` -------------------------------- ### Initialize KeyboardView (iOS/macCatalyst) Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView Initializers for the iOS and macCatalyst versions of the keyboard. ```swift public override init(frame: CGRect) ``` ```swift public init(width: Int, height: Int, firstOctave: Int = 4, octaveCount: Int = 3, polyphonic: Bool = false) ``` ```swift public required init?(coder aDecoder: NSCoder) ``` -------------------------------- ### NodeOutputView Initializer Source: https://github.com/audiokit/audiokitui/wiki/NodeOutputView Initializes NodeOutputView with a node, color, background color, and buffer size. Defaults are provided for color, background color, and buffer size. ```swift public init(_ node: Node, color: Color = .gray, backgroundColor: Color = .clear, bufferSize: Int = 1024) ``` -------------------------------- ### Implement noteOn Event Source: https://github.com/audiokit/audiokitui/wiki/KeyboardDelegate Implement this method to handle the event when a MIDI note is turned on. Requires a MIDINoteNumber as input. ```swift func noteOn(note: MIDINoteNumber) ``` -------------------------------- ### Initialize TableView (Non-macOS/Catalyst) Source: https://github.com/audiokit/audiokitui/wiki/TableView Initializes the table view with a Table and a frame, specifically for environments other than macOS or Catalyst. ```swift public init(_ table: Table, frame: CGRect = CGRect(width: 440, height: 150)) ``` -------------------------------- ### ADSRView Initializers Source: https://github.com/audiokit/audiokitui/wiki/ADSRView Provides different ways to initialize the ADSRView, including with a callback, from Interface Builder, or with a specified frame and callback. ```APIDOC ## Initializers ### `init(callback:)` #### Description Initialize the view, usually with a callback. #### Signature ```swift public init(callback: ADSRCallback? = nil) ``` ### `init?(coder:)` (for Interface Builder) #### Description Initialization of the view from within interface builder. #### Signature ```swift public required init?(coder aDecoder: NSCoder) ``` ### `init(frame:callback:)` #### Description Initialize with size and callback. #### Signature ```swift public init(frame: CGRect = CGRect(width: 440, height: 150), callback: @escaping ADSRCallback) ``` #### Parameters - **frame** (`CGRect`) - View size - **callback** (`ADSRCallback`) - Callback to call as values change ### `init?(coder:)` (Unimplemented) #### Description Required, but unimplemented initializer. #### Signature ```swift public required init?(coder aDecoder: NSCoder) ``` #### Parameters - **aDecoder** (`NSCoder`) - Decoder ``` -------------------------------- ### Initialize ArcKnob Source: https://github.com/audiokit/audiokitui/wiki/ArcKnob Initializes the ArcKnob with a binding value, range, title, and color configurations. ```swift public init(value: Binding, range: ClosedRange, title: String, textColor: Color, arcColor: Color) ``` -------------------------------- ### KeyboardWidget Initializer Source: https://github.com/audiokit/audiokitui/wiki/KeyboardWidget Initializes a new KeyboardWidget instance with specific configuration for octaves and polyphony. ```APIDOC ## init(delegate:firstOctave:octaveCount:polyphonicMode:) ### Description Initializes the KeyboardWidget with a delegate and keyboard layout parameters. ### Parameters - **delegate** (KeyboardDelegate?) - Optional - The delegate to handle keyboard events. - **firstOctave** (Int) - Required - The starting octave index. - **octaveCount** (Int) - Required - The total number of octaves to display. - **polyphonicMode** (Bool) - Required - Whether the keyboard supports polyphonic input. ``` -------------------------------- ### NodeRollingView Initialization Source: https://github.com/audiokit/audiokitui/wiki/NodeRollingView Initializes a NodeRollingView with a specified audio node, color, and buffer size. ```APIDOC ## NodeRollingView Initializer ### Description Initializes a `NodeRollingView` with a specified audio node, an optional color, and an optional buffer size. ### Parameters #### Initializer Parameters - **node** (Node) - Required - The audio node to visualize. - **color** (Color) - Optional - The color of the visualization. Defaults to `.gray`. - **bufferSize** (Int) - Optional - The size of the buffer for audio data. Defaults to `1024`. ``` -------------------------------- ### Initialize TableView (macOS/Catalyst) Source: https://github.com/audiokit/audiokitui/wiki/TableView Initializes the table view with a Table and a frame. Use this when targeting macOS or Catalyst environments. ```swift public init(_ table: Table, frame: CGRect = CGRect(x: 0, y: 0, width: 440, height: 150)) ``` -------------------------------- ### Keyboard Configuration and State Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView General configuration properties for keyboard behavior and layout. ```swift open weak var delegate: KeyboardDelegate? ``` ```swift public var polyphonicMode = false ``` ```swift override open var intrinsicContentSize: CGSize ``` -------------------------------- ### Initialize ReverbPresetStepper Source: https://github.com/audiokit/audiokitui/wiki/ReverbPresetStepper Initializer requiring a binding to an AVAudioUnitReverbPreset. ```swift public init(preset: Binding) ``` -------------------------------- ### receivedMIDISystemCommand Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView Receive a MIDI system command. ```APIDOC ## receivedMIDISystemCommand(_:portID:timeStamp:) ### Description Receive a MIDI system command (such as clock, SysEx, etc). ### Parameters - **data** ([MIDIByte]) - Array of integers - **portID** (MIDIUniqueID?) - MIDI Unique Port ID - **timeStamp** (MIDITimeStamp?) - The offset in samples that this event occurs in the buffer ``` -------------------------------- ### Waveform Initializers Source: https://github.com/audiokit/audiokitui/wiki/Waveform Initializes a new Waveform instance with specified parameters for channels, size, and colors. ```APIDOC ## Initializers ### `init(channels:size:waveformColor:backgroundColor:)` Initialize with parameters ```swift public convenience init(channels: Int = 2, size: CGSize? = nil, waveformColor: CGColor? = nil, backgroundColor: CGColor? = nil) ``` #### Parameters - channels: Channel count - size: Rectangular size - waveformColor: Foreground color - backgroundColor: Background color ``` -------------------------------- ### TapCountingDrumPadGrid Initializer Source: https://github.com/audiokit/audiokitui/wiki/TapCountingDrumPadGrid Initializes a TapCountingDrumPadGrid with a list of names, optional rows and columns, and a callback function. The callback is executed when drum pads are tapped. This initializer is available on macOS or Mac Catalyst. ```swift public init(names: [String], rows: Int = 2, cols: Int = 4, callback: @escaping ([Int]) -> Void) ``` -------------------------------- ### Initialize Waveform CALayer Source: https://github.com/audiokit/audiokitui/wiki/Waveform Initializes a Waveform CALayer with specified parameters for channels, size, and colors. Defaults are provided for convenience. ```swift public convenience init(channels: Int = 2, size: CGSize? = nil, waveformColor: CGColor? = nil, backgroundColor: CGColor? = nil) ``` -------------------------------- ### Initialize NodeFFTView Source: https://github.com/audiokit/audiokitui/wiki/NodeFFTView Initializes NodeFFTView with a given Node. ```swift public init(_ node: Node) ``` -------------------------------- ### Load Sequencer File Source: https://github.com/audiokit/audiokitui/wiki/MIDITrackViewModel Loads a MIDI sequencer file from a specified URL. ```swift public func loadSequencerFile(fileURL: URL) ``` -------------------------------- ### SpectrumView Initializer Source: https://github.com/audiokit/audiokitui/wiki/SpectrumView Initializes a SpectrumView with various customization options for appearance and analysis. ```swift public init(_ node: Node, backgroundColor: Color = Color.black, shouldPlotPoints: Bool = false, plotPointColor: Color = Color(red: 0.9, green: 0.9, blue: 0.9, opacity: 0.8), shouldStroke: Bool = true, strokeColor: Color = Color.white, shouldFill: Bool = true, fillColor: Color = Color(red: 0.5, green: 0.5, blue: 0.5, opacity: 0.4), shouldAnalyzeTouch: Bool = true, cursorColor: Color = Color.white, shouldDisplayAxisLabels: Bool = true) ``` -------------------------------- ### Initialize CGRect with CGSize Source: https://github.com/audiokit/audiokitui/wiki/CGRect Use this initializer to create a CGRect instance when you have the size as a CGSize object. Requires the CGSize type. ```swift public init(size: CGSize) ``` -------------------------------- ### Initialize WavetableModel Source: https://github.com/audiokit/audiokitui/wiki/WavetableModel Default initializer for the WavetableModel class. ```swift public init() ``` -------------------------------- ### NodeFFTView Methods Source: https://github.com/audiokit/audiokitui/wiki/NodeFFTView Details the methods for creating and updating the underlying platform-specific views. ```APIDOC ## Methods ### `makeNSView(context:)` Creates the `NSView` for macOS. #### Parameters - **context** (Context) - The context for creating the view. ### `updateNSView(_:context:)` Updates the `NSView` for macOS. #### Parameters - **nsView** (FloatPlot) - The `NSView` to update. - **context** (Context) - The context for updating the view. ### `makeUIView(context:)` Creates the `UIView` for other platforms (iOS, tvOS, watchOS). #### Parameters - **context** (Context) - The context for creating the view. ### `updateUIView(_:context:)` Updates the `UIView` for other platforms (iOS, tvOS, watchOS). #### Parameters - **uiView** (FloatPlot) - The `UIView` to update. - **context** (Context) - The context for updating the view. ``` -------------------------------- ### WavetableView Initializer Source: https://github.com/audiokit/audiokitui/wiki/WavetableView Initializes a new WavetableView instance to display waveform data from a node. ```APIDOC ## Initializer: WavetableView ### Description Initializes a SwiftUI view that visualizes audio data from a DynamicWaveformNode. ### Parameters - **node** (DynamicWaveformNode) - Required - The audio node providing the waveform data. - **strokeColor** (Color) - Optional - The color of the waveform stroke (default: white). - **strokeLineWidth** (CGFloat) - Optional - The width of the waveform stroke (default: 1.0). - **fillColor** (Color) - Optional - The color used to fill the waveform (default: green with 0.8 opacity). - **backgroundColor** (Color) - Optional - The background color of the view (default: black). ### Usage Example ```swift WavetableView(myWaveformNode, strokeColor: .blue, strokeLineWidth: 2.0) ``` ``` -------------------------------- ### Initialize WaveformLayer Source: https://github.com/audiokit/audiokitui/wiki/WaveformLayer Initializes the WaveformLayer with specified parameters for waveform data, size, colors, opacity, and mirroring. Use this to create a new WaveformLayer instance with custom settings. ```swift public convenience init(table: [Float], size: CGSize? = nil, fillColor: CGColor? = nil, strokeColor: CGColor? = nil, backgroundColor: CGColor? = nil, opacity: Float = 1, isMirrored: Bool = false) ``` -------------------------------- ### FloatPlotView Initialization Source: https://github.com/audiokit/audiokitui/wiki/FloatPlotView Initializes a new FloatPlotView with a data callback function. ```APIDOC ## init(dataCallback:) ### Description Initializes the FloatPlotView with a closure that returns an array of floats to be plotted. ### Parameters - **dataCallback** (escaping closure) - Required - A function that returns [Float] to be visualized by the view. ### Request Example FloatPlotView(dataCallback: { return [0.1, 0.5, -0.2] }) ``` -------------------------------- ### WaveformLayer Initialization Source: https://github.com/audiokit/audiokitui/wiki/WaveformLayer Initializes a WaveformLayer with specified parameters for waveform rendering. ```APIDOC ## WaveformLayer Initialization ### Description Initializes a WaveformLayer with specified parameters for waveform rendering. ### Method `init(table:size:fillColor:strokeColor:backgroundColor:opacity:isMirrored:)` ### Parameters #### Initializer Parameters - **table** ([Float]) - Required - Array of floats representing the waveform data. - **size** (CGSize?) - Optional - The size of the layer. - **fillColor** (CGColor?) - Optional - The fill color of the waveform. - **strokeColor** (CGColor?) - Optional - The stroke color of the waveform. - **backgroundColor** (CGColor?) - Optional - The background color of the layer. - **opacity** (Float) - Optional - The opacity of the layer (default is 1). - **isMirrored** (Bool) - Optional - Whether to display the waveform mirrored (default is false). ``` -------------------------------- ### macOS Keyboard Utility and Input Methods Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView Methods for handling note naming and mouse input events on macOS. ```swift public func getNoteName(note: Int) -> String ``` ```swift override public func mouseDown(with event: NSEvent) ``` ```swift override public func mouseUp(with event: NSEvent) ``` ```swift override public func mouseDragged(with event: NSEvent) ``` -------------------------------- ### Platform Specific Methods Source: https://github.com/audiokit/audiokitui/wiki/NodeOutputView Methods for integrating NodeOutputView into SwiftUI views on macOS and iOS. ```APIDOC ## makeNSView(context:) ### Description Creates the FloatPlot view for macOS. ## updateNSView(_:context:) ### Description Updates the existing FloatPlot view on macOS. ## makeUIView(context:) ### Description Creates the FloatPlot view for iOS. ## updateUIView(_:context:) ### Description Updates the existing FloatPlot view on iOS. ``` -------------------------------- ### ADSRView Initializers Source: https://github.com/audiokit/audiokitui/wiki/ADSRView Various initializers for creating an ADSRView instance, including programmatic and Interface Builder support. ```swift public init(callback: ADSRCallback? = nil) ``` ```swift public required init?(coder aDecoder: NSCoder) ``` ```swift public init(frame: CGRect = CGRect(width: 440, height: 150), callback: @escaping ADSRCallback) ``` ```swift public required init?(coder aDecoder: NSCoder) ``` -------------------------------- ### MultitouchOverlayView Methods Source: https://github.com/audiokit/audiokitui/wiki/MultitouchOverlayView Documentation for the methods of MultitouchOverlayView, including `makeUIView` and `updateUIView`. These methods are available on macOS and Mac Catalyst environments. ```APIDOC ## MultitouchOverlayView Methods ### `makeUIView(context:)` #### Description Creates and returns a new `UIView` instance for the `MultitouchOverlayView`. This method is part of the `UIViewRepresentable` protocol and is available on macOS and Mac Catalyst environments. #### Method Signature ```swift public func makeUIView(context: UIViewRepresentableContext) -> MultitouchOverlayView.UIViewType ``` ### `updateUIView(_:context:)` #### Description Updates the existing `UIView` instance with new data or state. This method is part of the `UIViewRepresentable` protocol and is available on macOS and Mac Catalyst environments. #### Method Signature ```swift public func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext) ``` ``` -------------------------------- ### Control MIDI Engine and Playback Source: https://github.com/audiokit/audiokitui/wiki/MIDITrackViewModel Methods for managing the engine state and sequencer playback. ```swift public func startEngine() ``` ```swift public func stopEngine() ``` ```swift public func play() ``` ```swift public func stop() ``` -------------------------------- ### Handle Touches Began Source: https://github.com/audiokit/audiokitui/wiki/ADSRView Processes the initial touch events on the UI element. This method is available for non-macOS environments or Catalyst. ```swift override public func touchesBegan(_ touches: Set, with event: UIEvent?) ``` -------------------------------- ### macOS Keyboard Drawing and Interface Builder Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView Methods for rendering the keyboard and supporting Interface Builder on macOS. ```swift override public func draw(_ dirtyRect: NSRect) ``` ```swift override public func prepareForInterfaceBuilder() ``` -------------------------------- ### MIDITrackViewModel Methods Source: https://github.com/audiokit/audiokitui/wiki/MIDITrackViewModel Methods available for controlling the MIDI engine and sequencer playback. ```APIDOC ## startEngine ### Description Starts the MIDI engine. ### Method func ## stopEngine ### Description Stops the MIDI engine. ### Method func ## play ### Description Starts playback of the MIDI track. ### Method func ## stop ### Description Stops playback of the MIDI track. ### Method func ## loadSequencerFile(fileURL:) ### Description Loads a MIDI sequencer file from the specified URL. ### Method func ### Parameters #### Path Parameters - **fileURL** (URL) - Required - The local file path to the MIDI sequencer file. ``` -------------------------------- ### Initialize ParameterEditor Source: https://github.com/audiokit/audiokitui/wiki/ParameterEditor Initializes a new instance of ParameterEditor with a NodeParameter. ```swift public init(param: NodeParameter) ``` -------------------------------- ### Initialize AudioWaveform with RMS Values Source: https://github.com/audiokit/audiokitui/wiki/AudioWaveform Initializes an AudioWaveform with an array of Float values representing RMS. ```swift public init(rmsVals: [Float]) ``` -------------------------------- ### Configure touch mode Source: https://github.com/audiokit/audiokitui/wiki/MultitouchGestureRecognizer Sets the touch management mode, defaulting to .stack. ```swift public var mode: Mode = .stack ``` -------------------------------- ### Receive program change Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView Handles MIDI program change events. ```swift public func receivedMIDIProgramChange(_ program: MIDIByte, channel: MIDIChannel, portID: MIDIUniqueID?, timeStamp: MIDITimeStamp?) ``` -------------------------------- ### TableView Initialization Source: https://github.com/audiokit/audiokitui/wiki/TableView Initializes a new instance of the TableView component with a specified table and frame. ```APIDOC ## Initializer: init(_:frame:) ### Description Initialize the table view with a specific table and display frame. ### Parameters - **table** (Table) - Required - The table data to visualize. - **frame** (CGRect) - Optional - The display area for the view (default: 440x150). ### Request Example let tableView = TableView(myTable, frame: CGRect(x: 0, y: 0, width: 440, height: 150)) ``` -------------------------------- ### KeyboardWidget View Methods Source: https://github.com/audiokit/audiokitui/wiki/KeyboardWidget Methods for integrating the KeyboardWidget into SwiftUI view hierarchies on different platforms. ```APIDOC ## View Lifecycle Methods ### Description Methods used to create and update the underlying KeyboardView for macOS and other platforms. ### Methods - **makeNSView(context:)** - Creates a KeyboardView for macOS. - **updateNSView(_:context:)** - Updates the existing KeyboardView on macOS. - **makeUIView(context:)** - Creates a KeyboardView for non-macOS platforms. - **updateUIView(_:context:)** - Updates the existing KeyboardView on non-macOS platforms. ``` -------------------------------- ### iOS and macCatalyst View Lifecycle Methods Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView Methods for handling view rendering and touch events on iOS and macCatalyst. ```swift public override func prepareForInterfaceBuilder() ``` ```swift public override func draw(_ rect: CGRect) ``` ```swift public override func touchesBegan(_ touches: Set, with event: UIEvent?) ``` ```swift public override func touchesEnded(_ touches: Set, with event: UIEvent?) ``` ```swift public override func touchesMoved(_ touches: Set, with event: UIEvent?) ``` ```swift public override func touchesCancelled(_ touches: Set?, with event: UIEvent?) ``` -------------------------------- ### Initialize MultitouchOverlayView Source: https://github.com/audiokit/audiokitui/wiki/MultitouchOverlayView Initializes the MultitouchOverlayView with a touch callback. This initializer is restricted to macOS and Mac Catalyst. ```swift public init(callback cb: @escaping TouchCallback) ``` -------------------------------- ### Make UIView for NodeFFTView (!macOS) Source: https://github.com/audiokit/audiokitui/wiki/NodeFFTView Creates a UIView for the NodeFFTView on platforms other than macOS. This method is conditionally compiled. ```swift public func makeUIView(context: Context) -> FloatPlot ``` -------------------------------- ### ArcKnob View Source: https://github.com/audiokit/audiokitui/wiki/ArcKnob Information about the ArcKnob struct and its initializer. ```APIDOC ## ArcKnob ### Description Represents a circular knob interface for controlling values within a specified range. ### Initializers #### `init(value:range:title:textColor:arcColor:)` Initializes an ArcKnob with the specified binding, range, title, and colors. - **value** (Binding) - Required - A binding to the Float value that the knob controls. - **range** (ClosedRange) - Required - The range of values the knob can represent. - **title** (String) - Required - The text title displayed on the knob. - **textColor** (Color) - Required - The color of the title text. - **arcColor** (Color) - Required - The color of the arc representing the current value. ### Properties #### `body` - **body** (some View) - The body of the view, which defines its content and layout. ``` -------------------------------- ### Receive MIDI Note Events Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView Method to handle incoming MIDI note on events. ```swift public func receivedMIDINoteOn(noteNumber: MIDINoteNumber, velocity: MIDIVelocity, channel: MIDIChannel, portID: MIDIUniqueID?, timeStamp: MIDITimeStamp?) ``` -------------------------------- ### macOS Methods Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView Methods specific to the macOS environment. ```APIDOC ## macOS Methods ### `draw(_:)` Draw keyboard. #### Parameters - **dirtyRect** (NSRect) - Rectangle to draw into ```swift override public func draw(_ dirtyRect: NSRect) ``` ### `prepareForInterfaceBuilder()` Story board rendering. ```swift override public func prepareForInterfaceBuilder() ``` ### `getNoteName(note:)` Get note name or spelling. #### Parameters - **note** (Int) - MIDI Note Number as an Integer #### Returns Spelling ```swift public func getNoteName(note: Int) -> String ``` ### `mouseDown(with:)` React to mouse down. #### Parameters - **event** (NSEvent) - Click event ```swift override public func mouseDown(with event: NSEvent) ``` ### `mouseUp(with:)` React to mouse up. #### Parameters - **event** (NSEvent) - Click event ```swift override public func mouseUp(with event: NSEvent) ``` ### `mouseDragged(with:)` React to mouse dragging. #### Parameters - **event** (NSEvent) - Drage event ```swift override public func mouseDragged(with event: NSEvent) ``` ### `receivedMIDINoteOn(noteNumber:velocity:channel:portID:timeStamp:)` Receive the MIDI note on event. ```swift public func receivedMIDINoteOn(noteNumber: MIDINoteNumber, velocity: MIDIVelocity, channel: MIDIChannel, portID: MIDIUniqueID?, timeStamp: MIDITimeStamp?) ``` ``` -------------------------------- ### Protocols Source: https://github.com/audiokit/audiokitui/wiki/Home Protocols used within the AudioKit UI library. ```APIDOC ## Protocols This section details the protocols available in the AudioKit UI library. ### MultitouchGestureRecognizerDelegate An extension of `UIGestureRecognizerDelegate` that allows the delegate to receive messages related to individual touches. The `delegate` property can be set to a class implementing `MultitouchGestureRecognizerDelegate` to receive these messages. ### ViewableSegment A protocol for viewable segments. ``` -------------------------------- ### Initialize CGRect with CGFloat Width and Height Source: https://github.com/audiokit/audiokitui/wiki/CGRect Create a CGRect instance using CGFloat values for width and height. This is a common way to define rectangle dimensions. ```swift public init(width: CGFloat, height: CGFloat) ``` -------------------------------- ### MultitouchState Ready Case Source: https://github.com/audiokit/audiokitui/wiki/MultitouchGestureRecognizer_MultitouchState Indicates that all touches have ended and none are being sustained. This is the initial state. ```swift case ready ``` -------------------------------- ### RawOutputView Struct Source: https://github.com/audiokit/audiokitui/wiki/RawOutputView Represents a view for displaying raw audio output. ```APIDOC ## RawOutputView ### Description A SwiftUI View for visualizing raw audio output data. ### Initializers #### `init(_:bufferSize:strokeColor:isNormalized:scaleFactor:)` Initializes a `RawOutputView` with optional audio node, buffer size, stroke color, normalization, and scale factor. - **node** (`Node?`) - Optional. The audio node to visualize. - **bufferSize** (`Int`) - Optional. The size of the buffer to use for visualization. Defaults to 1024. - **strokeColor** (`Binding`) - Optional. The color of the visualization stroke. Defaults to black. - **isNormalized** (`Binding`) - Optional. Whether the output should be normalized. Defaults to false. - **scaleFactor** (`Binding`) - Optional. The scaling factor for the visualization. Defaults to 1.0. ### Properties #### `body` ```swift var body: some View ``` The body of the view, which defines its content and layout. ``` -------------------------------- ### KeyboardView Class Overview Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView Provides a view that displays a piano keyboard, inheriting from NSView and conforming to MIDIListener. ```APIDOC ## KeyboardView Class ### Description View that displays a piano keyboard. ### Inheritance `MIDIListener`, `NSView`, `UIView` ``` -------------------------------- ### iOS/Mac Catalyst Methods Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView Methods available for iOS and Mac Catalyst environments. ```APIDOC ## iOS/Mac Catalyst Methods ### `prepareForInterfaceBuilder()` Set up the view for rendering in Interface Builder. ```swift public override func prepareForInterfaceBuilder() ``` ### `draw(_:)` Draw the view. ```swift public override func draw(_ rect: CGRect) ``` ### `touchesBegan(_:with:)` Handle new touches. ```swift public override func touchesBegan(_ touches: Set, with event: UIEvent?) ``` ### `touchesEnded(_:with:)` Handle touches completed. ```swift public override func touchesEnded(_ touches: Set, with event: UIEvent?) ``` ### `touchesMoved(_:with:)` Handle moved touches. ```swift public override func touchesMoved(_ touches: Set, with event: UIEvent?) ``` ### `touchesCancelled(_:with:)` Handle stopped touches. ```swift public override func touchesCancelled(_ touches: Set?, with event: UIEvent?) ``` ### `programmaticNoteOn(_:)` Programmatically trigger key press without calling delegate. ```swift public func programmaticNoteOn(_ note: MIDINoteNumber) ``` ### `programmaticNoteOff(_:)` Programmatically remove key press without calling delegate. Note: you can programmatically 'release' a note that has been pressed manually, but in such a case, the delegate.noteOff() will not be called when the finger is removed. ```swift public func programmaticNoteOff(_ note: MIDINoteNumber) ``` ``` -------------------------------- ### MusicalDurationStepper Initializer Source: https://github.com/audiokit/audiokitui/wiki/MusicalDurationStepper Initializes a new MusicalDurationStepper view with a binding to a musical duration and a time value. ```APIDOC ## init(musicalDuration:time:) ### Description Initializes the MusicalDurationStepper view with a binding to a MusicalDuration object and a float representing time. ### Parameters #### Arguments - **musicalDuration** (Binding) - Required - A binding to the musical duration state. - **time** (Float) - Required - The time value associated with the stepper. ### Request Example MusicalDurationStepper(musicalDuration: $myDuration, time: 1.0) ``` -------------------------------- ### receivedMIDISystemCommand Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView Handles incoming MIDI system commands such as clock or SysEx messages. ```APIDOC ## receivedMIDISystemCommand(_:portID:timeStamp:) ### Description Receive a MIDI system command (such as clock, SysEx, etc). ### Parameters - **data** ([MIDIByte]) - Required - Array of integers - **portID** (MIDIUniqueID?) - Optional - MIDI Unique Port ID - **timeStamp** (MIDITimeStamp?) - Optional - The offset in samples that this event occurs in the buffer ``` -------------------------------- ### Receive global aftertouch Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView Handles global MIDI aftertouch events. ```swift public func receivedMIDIAftertouch(_ pressure: MIDIByte, channel: MIDIChannel, portID: MIDIUniqueID?, timeStamp: MIDITimeStamp?) ``` -------------------------------- ### Knob Struct Source: https://github.com/audiokit/audiokitui/wiki/Knob Documentation for the Knob struct, including its inheritance and initializers. ```APIDOC ## Knob ### Description Represents a knob UI component for controlling values. ### Inheritance `View` ### Initializers #### `init(value:range:title:)` Initializes a new Knob. - **value** (Binding) - Required - A binding to the Float value the knob controls. - **range** (ClosedRange) - Required - The range of possible values for the knob. - **title** (String) - Required - The title displayed for the knob. ### Properties #### `body` ```swift public var body: some View ``` The body of the knob view. ``` -------------------------------- ### WavetableArrayView Initializer Source: https://github.com/audiokit/audiokitui/wiki/WavetableArrayView Initializes WavetableArrayView with a DynamicWaveformNode and other customizable parameters. Use this to create a view for displaying and interacting with wavetables. ```swift public init(_ node: DynamicWaveformNode, selectedValue: Binding, realWavetables: [AudioKit.Table], backgroundColor: Color = Color.black, arrayStrokeColor: Color = Color.white.opacity(0.4), selectedStrokeColor: Color = Color.white.opacity(1.0), fillColor: Color = Color.green.opacity(0.7)) ``` -------------------------------- ### Initialize FloatPlotView Source: https://github.com/audiokit/audiokitui/wiki/FloatPlotView Initializes FloatPlotView with a data callback that returns an array of floats. This callback is used to fetch the data to be plotted. ```swift public init(dataCallback: @escaping () -> [Float]) ``` -------------------------------- ### TableView Methods Source: https://github.com/audiokit/audiokitui/wiki/TableView Methods available for rendering the TableView. ```APIDOC ## Method: draw(_:) ### Description Draws the table view within the specified rectangle. ### Parameters - **rect** (CGRect) - Required - The rectangle area to draw the view in. ``` -------------------------------- ### Configure Keyboard Appearance Properties Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView Properties for customizing the visual state of keyboard keys on macOS. ```swift @IBInspectable open var blackKeyOff: NSColor = #colorLiteral(red: 0.000, green: 0.000, blue: 0.000, alpha: 1.000) ``` ```swift @IBInspectable open var keyOnColor: NSColor = #colorLiteral(red: 1.000, green: 0.000, blue: 0.000, alpha: 1.000) ``` ```swift @IBInspectable open var topWhiteKeyOff: NSColor = #colorLiteral(red: 1.000, green: 1.000, blue: 1.000, alpha: 0.000) ``` -------------------------------- ### FloatPlotView Lifecycle Methods Source: https://github.com/audiokit/audiokitui/wiki/FloatPlotView Methods for creating and updating the underlying NSView. ```APIDOC ## makeNSView(context:) ### Description Creates the underlying FloatPlot NSView. ### Parameters - **context** (Context) - Required - The context provided by the SwiftUI system. ## updateNSView(_:context:) ### Description Updates the state of the existing FloatPlot NSView. ### Parameters - **nsView** (FloatPlot) - Required - The view instance to update. - **context** (Context) - Required - The context provided by the SwiftUI system. ``` -------------------------------- ### makeUIView for iOS Source: https://github.com/audiokit/audiokitui/wiki/KeyboardWidget Creates the UIView for the KeyboardWidget on iOS. ```swift public func makeUIView(context: Context) -> KeyboardView ``` -------------------------------- ### MusicalDurationStepper Initializer Source: https://github.com/audiokit/audiokitui/wiki/MusicalDurationStepper Initializes MusicalDurationStepper with a binding to a MusicalDuration and a time value. ```swift public init(musicalDuration: Binding, time: Float) ``` -------------------------------- ### KeyboardWidget Initializer Source: https://github.com/audiokit/audiokitui/wiki/KeyboardWidget Initializes a KeyboardWidget with optional delegate, first octave, octave count, and polyphonic mode. ```swift public init(delegate: KeyboardDelegate? = nil, firstOctave: Int, octaveCount: Int, polyphonicMode: Bool) ``` -------------------------------- ### MultitouchOverlayView Initializer Source: https://github.com/audiokit/audiokitui/wiki/MultitouchOverlayView Initializes a new instance of MultitouchOverlayView with a specified touch callback. This initializer is available on macOS and Mac Catalyst environments. ```APIDOC ## MultitouchOverlayView Initializer ### Description Initializes a new instance of `MultitouchOverlayView` with a specified touch callback. This initializer is available on macOS and Mac Catalyst environments. ### Method Signature ```swift public init(callback cb: @escaping TouchCallback) ``` ``` -------------------------------- ### Fill Waveform with Data Source: https://github.com/audiokit/audiokitui/wiki/Waveform Populates the waveform with new audio data. This method can be safely called from any thread. ```swift public func fill(with data: FloatChannelData) ``` -------------------------------- ### Receive pitch wheel value Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView Handles MIDI pitch wheel value changes. ```swift public func receivedMIDIPitchWheel(_ pitchWheelValue: MIDIWord, channel: MIDIChannel, portID: MIDIUniqueID?, timeStamp: MIDITimeStamp?) ``` -------------------------------- ### Receive MIDI system command Source: https://github.com/audiokit/audiokitui/wiki/KeyboardView Handles MIDI system commands such as clock or SysEx messages. ```swift public func receivedMIDISystemCommand(_ data: [MIDIByte], portID: MIDIUniqueID?, timeStamp: MIDITimeStamp?) ``` -------------------------------- ### ParameterEditor Initializer Source: https://github.com/audiokit/audiokitui/wiki/ParameterEditor Initializes a new ParameterEditor view to control a specific NodeParameter. ```APIDOC ## init(param:) ### Description Initializes the ParameterEditor view with a specific NodeParameter instance. ### Parameters #### Request Body - **param** (NodeParameter) - Required - The parameter to be edited by this view. ### Request Example ```swift ParameterEditor(param: myNodeParameter) ``` ```