This association on line 5 does not contribute to the success of the app. But I honestly do not understand what happens at that moment.
Overloads for ÜnsafeMutablePointer exist with partially matching parameter list: (RawPointer).
But what does it mean? Thanks
override func buffer(withCsound cs: CsoundObj) -> Data {
let length = Int(AKSettings.shared().numberOfChannels) *
Int(AKSettings.shared().samplesPerControlPeriod) * 4
let num = length / 4
let floats = UnsafeMutablePointer<Float>(malloc(length))
/* The phase and amplitude are different for each line to get a nice
* gimmick. */
let phase = (self.amplifier + 0.8) / 1.8
for i in 0 ... num - 1 {
/* The amplitude is placed within the for-loop because it can fade
* to a slightly different value during one plot refresh. */
let amplitude = self.amplifier * self.amplitude
/* It is incredibly important that `time` and `phase` aren't
* multiplied with the frequency or else it will bump at each
* frequency change. */
var t = (time + Double(i) / Double(num) * self.frequency + phase)
floats[i] = Float(sin(t * 2 * 3.14))
/* It is multiplied with a "regular" 0.5 Hz sine to get both ends
* to fade out nicely. It's sort of a simplistic window function. */
t = Double(i) / Double(num)
floats[i] *= Float(sin(t * 1 * 3.14) * amplitude)
floats[i] *= 1 - pow(1 - Float(i) / Float(num), 2.0)
time += self.frequency / 44100 / 2
/* Fade smoothly to the next frequency and amplitude. */
self.frequency += (nextFrequency - self.frequency) / 44100.0 / 4.0
self.amplitude += (nextAmplitude - self.amplitude) / 44100.0 / 2.0
}
/* We keep the time between 0 and 1 to make sure it never overflows /
* loses the necessary precision. */
time = fmod(time, 1.0)
return Data(bytesNoCopy: UnsafeMutablePointer<UInt8>(floats), count: length, deallocator: .free)
}