I'm guessing that you have to swap every other byte as Windows is the
other-endian...

I don't really know for sure though...

You could just use:

exec("/path/to/sox $infile $outfile", $results, $errorcode);
echo implode("<BR>\n", $results);
if ($errorcode){
    echo "OS Error $errorcode.  Usually path/permission.  man errno<BR>\n";
}

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
----- Original Message -----
From: Jason Mercer <[EMAIL PROTECTED]>
Newsgroups: php.general
To: <[EMAIL PROTECTED]>
Sent: Tuesday, August 28, 2001 9:13 PM
Subject: perl-esque data parsing for hex post variables


> I can't get the php to convert audio data to nicely formed binary wav
> format. For instance, in perl you simply do a
>
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>
> and you're done with it.
>
> In php, there are two problems:
>
> 1. no existence of a handy builtin hex2bin() function (though many have
been
> written, such as
>
> function hex2bin($hex_str)
>
>
> for ($i = 0; $i < strlen($hex_str); $i += 2)
>
>
> $bin_str .= chr(hexdec(substr($hex_str, $i, 2)));
>
> }
>
> return $bin_str;
>
> }
>
> which seems to get the case done,
>
> 2. But the real problem is that doing a straight hex2bin conversion is not
> what that beautiful little perl script does. The part that confuses me is
> the hash oriented piece /%([a-fA-F0-9][a-fA-F0-9])/ -- what exactly is it
> doing? Is it just stepping through the string two characters at a time and
> comparing them? Or is it doing something more ambitious and arcane that
I'm
> not really grasping. I tried to emulate it with the following php
> workaround, but come up short...
>
> for ($i = 0; $i < strlen($hex_str); $i += 2)
>
>
> $newdata =.
> preg_replace("/[a-fA-F0-9][a-fA-F0-9]/",pack("C",hexdec(substr($hex_str,
$i,
> 2))),$hex_str);
>
> }
>
> Any help?
>
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to