Re: Why won't Xcode won't let me use the Accelerate framework in my project?
Re: Why won't Xcode won't let me use the Accelerate framework in my project?
- Subject: Re: Why won't Xcode won't let me use the Accelerate framework in my project?
- From: Steve Christensen <email@hidden>
- Date: Tue, 05 Jul 2016 15:08:07 -0700
> On Jul 5, 2016, at 1:53 PM, Patrick J. Collins <email@hidden> wrote:
>
>> Is your code C++? If so, that’s the error you’d get if one of your parameters were the wrong type.
>
> Ahhh.. wow.. ok, yeah my buffers are of type int16_t... How can I
> use this vDSP_vsmul with that type? If I cast as float:
>
> vDSP_vsmul((float *)buffer, 1, &gain, (float *)buffer, 1, frames);
>
> It ends up sounding like trash...
>
> Really, I just am trying to do:
>
> for (int i = 0; i < frames; i++) {
> buffer[i] *= gain;
> }
>
> Is there a way to do this with vDSP_vsmul?
I'm not an expert on this, but from a peek at the docs it looks like the Accelerate framework's vector multiplication functions only work on floats and doubles, so just casting the buffer type isn't going to change the fact that you're passing in an array of int16_t values. I see there are some conversion functions, so perhaps you just need to do a bit more work?
float floatBuffer[frames];
vDSP_vflt16(buffer, 1, floatBuffer, 1, frames);
vDSP_vsmul(floatBuffer, 1, &gain, floatBuffer, 1, frames);
vDSP_vfix16(floatBuffer, 1, buffer, 1, frames);
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden