2
내가 스위프트 3 구문에 다음 코드로 변환하기 위해 노력하고있어
fileprivate func generateTone(_ buffer: AudioQueueBufferRef) {
if noteAmplitude == 0 {
memset(buffer.pointee.mAudioData, 0, Int(buffer.pointee.mAudioDataBytesCapacity))
} else {
let count: Int = Int(buffer.pointee.mAudioDataBytesCapacity)/MemoryLayout<Float32>.size
var x: Double = 0
var y: Double = 0
let audioData = UnsafeMutablePointer<Float32>(buffer.pointee.mAudioData)
for frame in 0..<count {
x = noteFrame * noteFrequency/kSampleRate
y = sin (x * 2.0 * M_PI) * noteAmplitude
audioData[frame] = Float32(y)
noteAmplitude -= noteDecay
if noteAmplitude < 0.0 {
noteAmplitude = 0
}
noteFrame += 1
}
}
buffer.pointee.mAudioDataByteSize = buffer.pointee.mAudioDataBytesCapacity
}
내가와 붙어있어 :
let audioData = UnsafeMutablePointer<Float32>(buffer.pointee.mAudioData)
엑스 코드는 불평 :
형식이 'UnsafeMutablePointer'인 의 초기화 프로그램을 '(UnsafeMutableRawPointer)'형식의 인수 목록과 함께 호출 할 수 없습니다.
이 프로젝트는 here
에서 사용할 수있는 모든 도움은 매우 극명하게 될 것이다 :
예, 지금은 매우 간단합니다. Martin 고마워! –