How to get PCM data use SoundStream

hi guys
I want to create a small interactive installation
like push to talk machine
I have Arduino with 2 servo motor can make 3D printer mouth open and close by microphone via serial port
right now
I need mouth can talk
user can talk to iOS app send PCM data to Arduino Yún, and make mouth move and talk(if it’s possible)

my problem is
I know Arduino can play PCM data(wav2c) like
and OF can use soundStream and audioIn function get input data
but it’s float, not like PCM Audio Example(wav2c)
can anybody help me

and I also
need: talk -> mouth move in realtime
not: talk -> save -> send -> move
is it possible??
or have better solution?

Thank you!!

Do you mean you want to convert the data you get from audioIn() to the format of the wav2c’s data in sounddata.h? You’d just be doing a bit of math to convert it from float to unsigned char. The range of the samples in audioIn() is -1 to 1. The range you want to output to is 0 to 255. So:

unsigned char convertedSample = ((floatSample + 1) * 0.5) * 255.0;

or you could use ofMap:

unsigned char convertedSample = ofMap(floatSample, -1, 1, 0, 255);

super thank you!!!
it’s works
next step I’ll try send wav2c’s data to Arduino play in realtime
yesterday I also found Processing version

I think it’s same way!
Thank you again!