0

I'm making a function call in my Obj-C++ which returns a C++ float vector:

vector<float> mixedFrames = song.getMixedFrames();

These frames are for audio playback and CoreAudio expects them inside a Float32 array which was defined like this:

Float32 *buffer = (Float32 *)ioData->mBuffers[channel].mData;

My question is which is the fastest way to copy mixedFrames to buffer. Should I just loop through mixedFrames and copy every value to buffer or is there a faster way which would take less memory?

4

1 回答 1

1

内存布局相同,因此可能根本不需要复制;你可以简单地使用mixedFrames.data( ).

如果您出于某种原因确实需要制作副本,您可以简单地使用memcpyor std::copy

于 2012-08-05T21:10:30.603 回答