formStereoRamp(withInitialValue:multiplyingBy:_:increment:results:_:)
Populates two single-precision vectors that contain stereo monotonically incrementing or decrementing values multiplied by two source vectors.
Declaration
static func formStereoRamp<U, V>(withInitialValue initialValue: inout Double, multiplyingBy multiplierOne: U, _ multiplierTwo: U, increment: Double, results resultOne: inout V, _ resultTwo: inout V) where U : AccelerateBuffer, V : AccelerateMutableBuffer, U.Element == Double, V.Element == DoubleParameters
- initialValue:
The initial value of the ramp.
- multiplierOne:
The first input vector that’s multiplied by the ramp function.
- multiplierTwo:
The second input vector that’s multiplied by the ramp function.
- increment:
The increment, or decrement if negative, between each generated element.
- resultOne:
The array to overwrite with the first generated ramp.
- resultTwo:
The array to overwrite with the second generated ramp.
Discussion
Use this function to populate two vectors by multiplying the values in two input vectors with the corresponding values of a ramp.
For example, the following code fills the arrays multiplierOne and multiplierTwo with sine values:
let n = vDSP_Length(1024)
let multiplierOne: [Double] = (0 ..< n).map {
return sin(Double($0) / 20) * 2
}
let multiplierTwo: [Double] = (0 ..< n).map {
return sin(Double($0) / 40)
}The following figure illustrates the values of multiplierOne, as a solid line, and multiplierTwo, as a dashed line:
[Image]
Pass multiplierOne and multiplierTwo as the multiplyingBy parameter of formStereoRamp(withInitialValue:multiplyingBy:_:increment:results:_:):
var start: Double = 0
let step: Double = 0.1
var resultOne = [Double](repeating: 0,
count: Int(n))
var resultTwo = [Double](repeating: 0,
count: Int(n))
vDSP.formStereoRamp(withInitialValue: &start,
multiplyingBy: multiplierOne, multiplierTwo,
increment: step,
results: &resultOne, &resultTwo)On return, the output vectors, results.firstOutput and results.secondOutput, contain ramped-sine waves. The figure below shows the first output as a solid line and the second output as a dashed line:
[Image]