If you use AVAudioPCMBuffer in swift to write a value to the buffer and sound a sine wave
http://www.tmroyal.com/playing-sounds-in-swift-audioengine.html
It was made by referring to .
I'd like to write this as objective-C, but I'm having a hard time because I don't know how to send a message when I write a value on the buffer.
Here's the swift from the previous site.
for vari=0;i<Int(buffer.frameLength);i+=Int(n_channels){
varval=sinf (441.0*Float(i)*2*Float(M_PI)/sr)
buffer.floatChannelData.memory[i] = val * 0.5
}
When I try to write this in objective-C, buffer.floatChannelData appears as a complement, but memory[i] does not appear as a complement.
Definitely,
buffer.floatChannelData.memory[i]=val;
I thought I could write in , but how should I write it?
I look forward to your kind cooperation.
swift objective-c avfoundation
From the AVAudioPCMBuffer, floatChannelData
is declared as UnsafePointer<UnsafeMutablePointer<Float>>
, but it means potter
.
Swift cannot handle pointers directly, so it is accessed through memory
, but is rewritten using an indirect operator as follows:
*buffer.floatChannelData[i]=val;
Rather than Objective-C, you will need to know more about C language pointers.
568 Who developed the "avformat-59.dll" that comes with FFmpeg?
891 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
568 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
610 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.