3

I have an array of 8-bit values which I have received from a microprocessor.
I am looking to turn those values into a wav file using PHP.

I found some examples, like this or this, that work in Java and C# but they all seem to leverage existing classes. Does anyone know of a PHP library that can do this? If not, can someone explain how to create a wav file in PHP?

Community
  • 1
  • 1
BannerMatt
  • 43
  • 5
  • All you need to do is write the RIFF headers. I haven't seen a class in PHP to do this, but it should be pretty easy to do. Wikipedia actually shows a bit of what should be in that header. http://en.wikipedia.org/wiki/WAV#RIFF_WAVE – Brad May 14 '13 at 03:01

1 Answers1

1

You can use pack function, but first you must discover what values used: signed or unsigned

function pack_array($v,$a) {
 return call_user_func_array(pack,array_merge(array($v),(array)$a));
}

$wav = pack_array('c*', $array); // 'C*' for unsigned
sectus
  • 15,605
  • 5
  • 55
  • 97