I want to create a sine tone generator with the Accelerate framework. I'd like my generator to have an attack/release setting (i.e., an amplitude envelope).
I understand how to create a vector full of sine values. What I don't know is how to apply an amplitude envelope to my vector data.
I know I could create a ramped vector using vDSP_vgen to create a linear volume envelope vector and multiply my sine vector by my envelope vector. This seems wasteful, though, because I'm dealing with many data points and creating an intermediate vector just to store the amplitude envelope is quite wasteful of memory in my environment.
What's the best way to work with an amplitude envelope with the Accelerate framework?
You don't have to use only vector functions to create or operate on vectors. Vector functions are useful if they exist and are faster. I would benchmark the sequence of vector operations against creating your sine with envelope using calls to your envelope() * sinf() for each vector element, and see which is faster on your iOS test devices.
If you have enough memory to keep long intermediate vectors around and reuse them (for instance reuse envelopes), this may provide performance boosts to subsequent iterations. The is a typical memory use versus performance Ytrade-off.