ios - high performance buffers in objective-c -
i'm wondering applicable kind of buffer implementation audio data in objective-c. i'm working audio data on iphone, direct data manipulation/dsp of audio data while recording or playing, performance matters. iphone development since months now. i'm dealing c-arrays of element type sint16 or float32, i'm looking better.
afaik, performance of pointer-iterated c-arrays unbeatable in objective-c environment. however, pointer arithmetic , c-arrays error prone. have make sure not access arrays out of bounds. not runtime error if do. , have make sure manually alloc , dealloc arrays correctly.
thus, i'm looking alternatives. high performance alternatives there? there in objective-c similar c++ style std::vector?
with similar mean:
- good performance
- iteratable pointer-/iterator-based loop
- no overhead of boxing/unboxing basic data types float32 or sint16 objective-c objects (btw, what's correct word 'basic data types' in objective-c?)
- bounds-checking
- possibility copy/read/write chunks of other lists or arrays , out of searched-for list implementation
- memory management included
i've searched , read quite bit , of course nsdata , nsmutablearray among mentioned solutions. don't double processing cost because of overhead boxing/unboxing of basic data types? code looks outright ugly simple 'set'-operation becoming dinosaur named replaceobjectatindex:withobject: isn't of concern, still subtly makes me think class not made me.
the containers provided in foundation framework have little offer audio processing, being on whole rather heavy-weight, nor providing extrinsic iterators.
furthermore, none of audio apis in ios or macosx interact buffers of samples objective-c - based, or take parameters of foundation framework containers.
most likely, want make use of accelerate framework dsp operations, , apis work on arrays of floats or int16s.
whilst of apis c-style, c++ , stl obvious weapon of choice requirements, , interworks cleanly rest of application in guise of objective-c++. stl compiles down code efficient hand-crafted c.
to memory-manage buffers, perhaps use std::array - if want bounds checking or std::shared_ptr or std::unique_ptr custom deleter if you're not worried.
places iterator expected - instance algorithm functions in <algorithm> - can take pointers basic types - such sample buffers.
Comments
Post a Comment