mardi 3 mars 2015

Convert SIint16 to float on iPhone4

I am developing an app which uses simple pitch perception and it runs fine in the Xcode Simulator. The app loads in the iPhone 4 and I can navigate the app but no output is shown . I have started to debug and find that when I convert Sint16 to float I get an overflow error. I have tried vDSP and a simple loop.


simplified code n=1536



sampleBuffer = (SInt16*) malloc(n);
floatSamples = (float*) malloc(sizeof(float)*n);
// Convert SInt 16 to float
for(int i = 0; i<n; i++) {
floatSamples[i] = (float)samples[i];

}

//vDSP_vflt16(samples,1,floatSamples,1,n);


This results in -0.000000 -0.000000 -0.000000 964957789008661674961361960960.000000 -5629971079108504200413184.000000 -inf 35116851871418647838720.000000 -inf 0.000000 0.000000 0.000000 -1233.760620 288987875649316726325339192557568.000000 -0.000000 -0.000000 -0.000000 -7508525217561044282816045485425426432.000000 -656399043038732589927376093184.000000 0.000000 -0.000053 9470091451011432448.000000 -24555002 similar result from vDSP Everything is fine in the simulator on iPhone 4s all the vDSP calculations work. iPhone is running ios7.1.2 and xCode 6 on MacBook pro. Just looking for a clue really.




Aucun commentaire:

Enregistrer un commentaire