injecting a pcm s16be array into novocaine audiomanager

111 Views Asked by At

To @alexbw and friends, First of all thanks for this great piece of code. I have pcm data (signed 16 bit big endian) in a byte array and I want to play it with Novocaine AudioManager setOutputBlock. I understand I first need to convert to a float array. Or is there a faster way? Cheers Philippe

1

There are 1 best solutions below

0
AlexKoren On

Late, but for anyone else reading:

You can use the Accelerate framework here:

float *float_data = malloc(sizeof(float) * numFrames); vDSP_vflt16(my_s16_data, 1, float_data, 1, numFrames); //Scaling [-32768, 32768] to [-1, 1] float scale = 1.0 / (float)INT16_MAX; vDSP_vsmul(float_data, 1, &scale, float_data, 1, numFrames);

And "float_data" will now have the float equivalent.