# AKOperation

``open class AKOperation : AKComputedParameter``

An AKOperation is a computed parameter that can be passed to other operations in the same operation node

• ``` description ```

Redefining description to return the operation string

#### Declaration

Swift

``open var description: String { get }``
• ``` leftInput ```

Left input to any stereo operation

#### Declaration

Swift

``open static var leftInput: AKOperation``
• ``` rightInput ```

Right input to any stereo operation

#### Declaration

Swift

``open static var rightInput: AKOperation``
• ``` trigger ```

Dummy trigger

#### Declaration

Swift

``open static var trigger: AKOperation``
• ``` parameters ```

An= array of 14 parameters which may be sent to operations

#### Declaration

Swift

``open static var parameters: [AKOperation]``
• ``` toMono() ```

Convert the operation to a mono operation

#### Declaration

Swift

``open func toMono() -> AKOperation``
• ``` abs() ```

Performs absolute value on the operation

#### Declaration

Swift

``open func abs() -> AKOperation``
• ``` floor() ```

Performs floor calculation on the operation

#### Declaration

Swift

``open func floor() -> AKOperation``
• ``` fract() ```

Returns the fractional part of the operation (as opposed to the integer part)

#### Declaration

Swift

``open func fract() -> AKOperation``
• ``` log() ```

Performs natural logarithm on the operation

#### Declaration

Swift

``open func log() -> AKOperation``
• ``` log10() ```

Performs Base 10 logarithm on the operation

#### Declaration

Swift

``open func log10() -> AKOperation``
• ``` round() ```

Rounds the operation to the nearest integer

#### Declaration

Swift

``open func round() -> AKOperation``
• ``` midiNoteToFrequency() ```

Returns a frequency for a given MIDI note number

#### Declaration

Swift

``open func midiNoteToFrequency() -> AKOperation``
• ``` init(_:) ```

Initialize the operation as a constant value

#### Declaration

Swift

``public init(_ value: Double)``

#### Parameters

 ``` value ``` Constant value as an operation
• ``` init(_:) ```

Initialize the operation with a Sporth string

#### Declaration

Swift

``public init(_ operationString: String)``

#### Parameters

 ``` operationString ``` Valid Sporth string (proceed with caution
• ``` init(module:setup:inputs:) ```

Initialize the operation

#### Declaration

Swift

``public init(module: String, setup: String = "", inputs: AKParameter...)``

#### Parameters

 ``` module ``` Sporth unit generator ``` setup ``` Any setup Sporth code that this operation may require ``` inputs ``` All the parameters of the operation
• ``` brownianNoise(amplitude:) ```

Brownian noise generator

#### Declaration

Swift

``public static func brownianNoise(amplitude: AKParameter = 1.0) -> AKOperation``

#### Parameters

 ``` amplitude ``` Overall level. (Default: 1.0, Minimum: 0, Maximum: 1.0)
• ``` pinkNoise(amplitude:) ```

Faust-based pink noise generator

#### Declaration

Swift

``public static func pinkNoise(amplitude: AKParameter = 1.0) -> AKOperation``

#### Parameters

 ``` amplitude ``` Overall level. (Default: 1.0, Minimum: 0, Maximum: 1.0)
• ``` whiteNoise(amplitude:) ```

White noise generator

#### Declaration

Swift

``public static func whiteNoise(amplitude: AKParameter = 1.0) -> AKOperation``

#### Parameters

 ``` amplitude ``` Overall level. (Default: 1.0, Minimum: 0.0, Maximum: 10.0)
• ``` fmOscillator(baseFrequency:carrierMultiplier:modulatingMultiplier:modulationIndex:amplitude:) ```

Classic FM Synthesis audio generation.

#### Declaration

Swift

``````public static func fmOscillator(
baseFrequency: AKParameter = 440,
carrierMultiplier: AKParameter = 1.0,
modulatingMultiplier: AKParameter = 1.0,
modulationIndex: AKParameter = 1.0,
amplitude: AKParameter = 0.5
) -> AKOperation``````

#### Parameters

 ``` baseFrequency ``` In cycles per second, or Hz, this is the common denominator for the carrier and modulating frequencies. (Default: 440, Minimum: 0.0, Maximum: 20000.0) ``` carrierMultiplier ``` This multiplied by the baseFrequency gives the carrier frequency. (Default: 1.0, Minimum: 0.0, Maximum: 1000.0) ``` modulatingMultiplier ``` This multiplied by the baseFrequency gives the modulating frequency. (Default: 1.0, Minimum: 0.0, Maximum: 1000.0) ``` modulationIndex ``` This multiplied by the modulating frequency gives the modulation amplitude. (Default: 1.0, Minimum: 0.0, Maximum: 1000.0) ``` amplitude ``` Output Amplitude. (Default: 0.5, Minimum: 0.0, Maximum: 10.0)
• ``` morphingOscillator(frequency:amplitude:index:) ```

Morphing Oscillator

#### Declaration

Swift

``````public static func morphingOscillator(
frequency: AKParameter = 440,
amplitude: AKParameter = 1,
index: AKParameter = 0
) -> AKOperation``````

#### Parameters

 ``` frequency ``` Frequency in cycles per second (Default: 440) ``` amplitude ``` Amplitude of the output (Default: 1) ``` index ``` Index of waveform 0.0 - 3.0 where 0 = sine, 1 = square, 2 = sawtooth, 3 = reversed sawtooth
• ``` phasor(frequency:phase:) ```

Produces a normalized sawtooth wave between the values of 0 and 1. Phasors are often used when building table-lookup oscillators.

#### Declaration

Swift

``````public static func phasor(
frequency: AKParameter = 1,
phase: Double = 0
) -> AKOperation``````

#### Parameters

 ``` frequency ``` Frequency in cycles per second, or Hz. (Default: 1.0, Minimum: 0.0, Maximum: 1000.0) ``` phase ``` Initial phase (Default: 0)
• ``` sawtooth(frequency:amplitude:phase:) ```

Simple sawtooth oscillator, not-band limited, can be used for LFO or wave, but sawtoothWave is probably better for audio.

#### Declaration

Swift

``````public static func sawtooth(
frequency: AKParameter = 440,
amplitude: AKParameter = 0.5,
phase: AKParameter = 0
) -> AKOperation``````

#### Parameters

 ``` frequency ``` In cycles per second, or Hz. (Default: 440, Minimum: 0.0, Maximum: 20000.0) ``` amplitude ``` Output Amplitude. (Default: 0.5, Minimum: 0.0, Maximum: 1.0)
• ``` reverseSawtooth(frequency:amplitude:phase:) ```

Simple reverse sawtooth oscillator, not-band limited, can be used for LFO or wave.

#### Declaration

Swift

``````public static func reverseSawtooth(
frequency: AKParameter = 440,
amplitude: AKParameter = 0.5,
phase: AKParameter = 0
) -> AKOperation``````

#### Parameters

 ``` frequency ``` In cycles per second, or Hz. (Default: 440, Minimum: 0.0, Maximum: 20000.0) ``` amplitude ``` Output Amplitude. (Default: 0.5, Minimum: 0.0, Maximum: 1.0)
• ``` sawtoothWave(frequency:amplitude:) ```

Bandlimited sawtooth oscillator This is a bandlimited sawtooth oscillator ported from the sawtooth function from the Faust programming language.

#### Declaration

Swift

``````public static func sawtoothWave(
frequency: AKParameter = 440,
amplitude: AKParameter = 0.5
) -> AKOperation``````

#### Parameters

 ``` frequency ``` In cycles per second, or Hz. (Default: 440, Minimum: 0.0, Maximum: 20000.0) ``` amplitude ``` Output Amplitude. (Default: 0.5, Minimum: 0.0, Maximum: 1.0)
• ``` sineWave(frequency:amplitude:) ```

Standard Sine Wave

#### Declaration

Swift

``````public static func sineWave(
frequency: AKParameter = 440,
amplitude: AKParameter = 1
) -> AKOperation``````

#### Parameters

 ``` frequency ``` Frequency in cycles per second (Default: 440) ``` amplitude ``` Amplitude of the output (Default: 1)
• ``` square(frequency:amplitude:phase:) ```

Simple square oscillator, not-band limited, can be used for LFO or wave, but squareWave is probably better for audio.

#### Declaration

Swift

``````public static func square(
frequency: AKParameter = 440,
amplitude: AKParameter = 0.5,
phase: AKParameter = 0
) -> AKOperation``````

#### Parameters

 ``` frequency ``` In cycles per second, or Hz. (Default: 440, Minimum: 0.0, Maximum: 20000.0) ``` amplitude ``` Output Amplitude. (Default: 0.5, Minimum: 0.0, Maximum: 1.0)
• ``` squareWave(frequency:amplitude:pulseWidth:) ```

This is a bandlimited square oscillator ported from the square function from the Faust programming language.

#### Declaration

Swift

``````public static func squareWave(
frequency: AKParameter = 440,
amplitude: AKParameter = 1.0,
pulseWidth: AKParameter = 0.5
) -> AKOperation``````

#### Parameters

 ``` frequency ``` In cycles per second, or Hz. (Default: 440, Minimum: 0, Maximum: 20000) ``` amplitude ``` Output amplitude (Default: 1.0, Minimum: 0, Maximum: 10) ``` pulseWidth ``` Duty cycle width. (Default: 0.5, Minimum: 0, Maximum: 1)
• ``` triangle(frequency:amplitude:phase:) ```

Simple triangle oscillator, not-band limited, can be used for LFO or wave, but triangleWave is probably better for audio.

#### Declaration

Swift

``````public static func triangle(
frequency: AKParameter = 440,
amplitude: AKParameter = 0.5,
phase: AKParameter = 0
) -> AKOperation``````

#### Parameters

 ``` frequency ``` In cycles per second, or Hz. (Default: 440, Minimum: 0.0, Maximum: 20000.0) ``` amplitude ``` Output Amplitude. (Default: 0.5, Minimum: 0.0, Maximum: 1.0)
• ``` triangleWave(frequency:amplitude:) ```

This is a bandlimited triangle oscillator ported from the triangle function from the Faust programming language.

#### Declaration

Swift

``````public static func triangleWave(
frequency: AKParameter = 440,
amplitude: AKParameter = 0.5
) -> AKOperation``````

#### Parameters

 ``` frequency ``` In cycles per second, or Hz. (Default: 440, Minimum: 0.0, Maximum: 20000.0) ``` amplitude ``` Output Amplitude. (Default: 0.5, Minimum: 0.0, Maximum: 1.0)
• ``` pluckedString(trigger:frequency:amplitude:lowestFrequency:) ```

Karplus-Strong plucked string instrument.

#### Declaration

Swift

``````public static func pluckedString(
trigger: AKOperation,
frequency: AKParameter = 110,
amplitude: AKParameter = 0.5,
lowestFrequency: Double = 110
) -> AKOperation``````

#### Parameters

 ``` trigger ``` Triggering operation ``` frequency ``` Variable frequency. Values less than the lowest frequency will be doubled until it is greater than that. (Default: 110, Minimum: 0, Maximum: 22000) ``` amplitude ``` Amplitude (Default: 0.5, Minimum: 0, Maximum: 1) ``` lowestFrequency ``` Sets the initial frequency. This frequency is used to allocate all the buffers needed for the delay. This should be the lowest frequency you plan on using. (Default: 110)
• ``` vocalTract(frequency:tonguePosition:tongueDiameter:tenseness:nasality:) ```

Karplus-Strong plucked string instrument.

#### Declaration

Swift

``````public static func vocalTract(
frequency: AKParameter = 160.0,
tonguePosition: AKParameter = 0.5,
tongueDiameter: AKParameter = 1.0,
tenseness: AKParameter = 0.6,
nasality: AKParameter = 0.0) -> AKOperation``````

#### Parameters

 ``` frequency ``` Glottal frequency. ``` tonguePosition ``` Tongue position (0-1) ``` tongueDiameter ``` Tongue diameter (0-1) ``` tenseness ``` Vocal tenseness. 0 = all breath. 1=fully saturated. ``` nasality ``` Sets the velum size. Larger values of this creates more nasally sounds.
• ``` jitter(amplitude:minimumFrequency:maximumFrequency:) ```

A signal with random fluctuations This is useful for emulating jitter found in analogue equipment.

#### Declaration

Swift

``````public static func jitter(
amplitude: AKParameter = 0.5,
minimumFrequency: AKParameter = 0.5,
maximumFrequency: AKParameter = 4
) -> AKOperation``````

#### Parameters

 ``` amplitude ``` The amplitude of the line. Will produce values in the range of (+/-)amp. (Default: 0.5) ``` minimumFrequency ``` The minimum frequency of change in Hz. (Default: 0.5) ``` maximumFrequency ``` The maximum frequency of change in Hz. (Default: 4)
• ``` randomNumberPulse(minimum:maximum:updateFrequency:) ```

Loosely based off of the Csound opcode randomh. The design is equivalent to scaled noise sent through a classic sample and hold module.

#### Declaration

Swift

``````public static func randomNumberPulse(
minimum: AKParameter = 0,
maximum: AKParameter = 1,
updateFrequency: AKParameter = 10
) -> AKOperation``````

#### Parameters

 ``` minimum ``` Minimum value to use. (Default: 0) ``` maximum ``` Maximum value to use. (Default: 1) ``` updateFrequency ``` Frequency of randomization (in Hz) (Default: 10)
• ``` randomVertexPulse(minimum:maximum:updateFrequency:) ```

Line segments with vertices at random points

#### Declaration

Swift

``````public static func randomVertexPulse(
minimum: AKParameter = 0,
maximum: AKParameter = 1,
updateFrequency: AKParameter = 3
) -> AKOperation``````

#### Parameters

 ``` minimum ``` Minimum value (Default: 0) ``` maximum ``` Maximum value (Default: 1) ``` updateFrequency ``` Frequency to change values. (Default: 3)
• ``` plus(_:) ```

#### Declaration

Swift

``public func plus(_ parameter: AKParameter) -> AKOperation``

#### Parameters

 ``` parameter ``` The amount to add
• ``` offsetBy(_:) ```

#### Declaration

Swift

``public func offsetBy(_ parameter: AKParameter) -> AKOperation``

#### Parameters

 ``` parameter ``` The amount to offset by
• ``` count(maximum:looping:) ```

Keep track of the number of times a trigger has fired

#### Declaration

Swift

``public func count(maximum: AKParameter = 1_000_000, looping: Bool = true) -> AKOperation``

#### Parameters

 ``` maximum ``` Largest value to hold before looping or being pinned to this value ``` looping ``` If set to true, when the maximum is reaching, the count goes back to zero, otherwise it stays at the maximum
• ``` dividedBy(_:) ```

Division of parameters

#### Declaration

Swift

``public func dividedBy(_ denominator: AKParameter) -> AKOperation``

#### Parameters

 ``` denominator ``` The amount to divide
• ``` increment(on:by:minimum:maximum:) ```

Increment a signal by a default value of 1

#### Declaration

Swift

``````public func increment(on trigger: AKParameter,
by step: AKParameter = 1.0,
minimum: AKParameter = 0.0,
maximum: AKParameter = 1_000_000) -> AKOperation``````

#### Parameters

 ``` on ``` When to increment ``` by ``` Increment amount (Default: 1) ``` minimum ``` Increment amount (Default: 1) ``` maximum ``` Increment amount (Default: 1)
• ``` times(_:) ```

Multiplication of parameters

#### Declaration

Swift

``public func times(_ parameter: AKParameter) -> AKOperation``

#### Parameters

 ``` parameter ``` The amount to multiply
• ``` scaledBy(_:) ```

Offsetting by way of multiplication

#### Declaration

Swift

``public func scaledBy(_ parameter: AKParameter) -> AKOperation``

#### Parameters

 ``` parameter ``` The amount to scale by
• ``` save(parameterIndex:) ```

Save a value into the parameters array for using outside of the operation

#### Declaration

Swift

``public func save(parameterIndex: Int) -> AKOperation``

#### Parameters

 ``` parameterIndex ``` Location in the parameters array to save this value
• ``` scale(minimum:maximum:) ```

This scales from -1 to 1 to a range defined by a minimum and maximum point in the input and output domain.

#### Declaration

Swift

``````public func scale(
minimum: AKParameter = 0,
maximum: AKParameter = 1
) -> AKOperation``````

#### Parameters

 ``` minimum ``` Minimum value to scale to. (Default: 0) ``` maximum ``` Maximum value to scale to. (Default: 1)
• ``` lineSegment(trigger:start:end:duration:) ```

Line Segment to change values over time

#### Declaration

Swift

``````public static func lineSegment(
trigger: AKOperation,
start: AKParameter,
end: AKParameter,
duration: AKParameter
) -> AKOperation``````

#### Parameters

 ``` start ``` Starting value ``` end ``` Ending value ``` duration ``` Length of time
• ``` exponentialSegment(trigger:start:end:duration:) ```

Exponential Segment to change values over time

#### Declaration

Swift

``````public static func exponentialSegment(
trigger: AKOperation,
start: AKParameter,
end: AKParameter,
duration: AKParameter
) -> AKOperation``````

#### Parameters

 ``` start ``` Starting value ``` end ``` Ending value ``` duration ``` Length of time
• ``` minus(_:) ```

Subtraction of parameters

#### Declaration

Swift

``public func minus(_ subtrahend: AKParameter) -> AKOperation``

#### Parameters

 ``` subtrahend ``` The amount to subtract
• ``` gatedADSREnvelope(gate:attack:decay:sustain:release:) ```

Gate based linear AHD envelope generator

#### Declaration

Swift

``````public func gatedADSREnvelope(
gate: AKParameter,
attack: AKParameter = 0.1,
decay: AKParameter = 0.0,
sustain: AKParameter = 1,
release: AKParameter = 0.2
) -> AKOperation``````

#### Parameters

 ``` gate ``` 1 for on and 0 for off ``` attack ``` Attack duration, in seconds. (Default: 0.1) ``` hold ``` Hold duration, in seconds. (Default: 0.3) ``` release ``` Release duration, in seconds. (Default: 0.2)
• ``` metronome(frequency:) ```

Metro produces a series of 1-sample ticks at a regular rate. Typically, this is used alongside trigger-driven modules.

#### Declaration

Swift

``public static func metronome(frequency: AKParameter = 2.0) -> AKOperation``

#### Parameters

 ``` frequency ``` The frequency to repeat. (Default: 2.0)
• ``` periodicTrigger(period:) ```

Produce a set of triggers spaced apart by time.

#### Declaration

Swift

``public static func periodicTrigger(period: AKParameter = 1.0) -> AKOperation``

#### Parameters

 ``` period ``` Time between triggers (in seconds). Updates at the start of each trigger. (Default: 1.0)
• ``` portamento(halfDuration:) ```

Portamento-style control signal smoothing Useful for smoothing out low-resolution signals and applying glissando to filters.

#### Declaration

Swift

``public func portamento(halfDuration: AKParameter = 0.02) -> AKOperation``

#### Parameters

 ``` input ``` Input audio signal ``` halfDuration ``` Duration which the curve will traverse half the distance towards the new value, then half as much again, etc., theoretically never reaching its asymptote. (Default: 0.02)
• ``` triggeredWithEnvelope(trigger:attack:hold:release:) ```

Trigger based linear AHD envelope generator

#### Declaration

Swift

``````public func triggeredWithEnvelope(
trigger: AKParameter,
attack: AKParameter = 0.1,
hold: AKParameter = 0.3,
release: AKParameter = 0.2
) -> AKOperation``````

#### Parameters

 ``` trigger ``` A triggering operation such as a metronome ``` attack ``` Attack duration, in seconds. (Default: 0.1) ``` hold ``` Hold duration, in seconds. (Default: 0.3) ``` release ``` Release duration, in seconds. (Default: 0.2)