diff --git a/examples/ggwave-to-file/ggwave-to-file.php b/examples/ggwave-to-file/ggwave-to-file.php new file mode 100644 index 0000000..7140236 --- /dev/null +++ b/examples/ggwave-to-file/ggwave-to-file.php @@ -0,0 +1,46 @@ + array("pipe", "r"), + 1 => array("pipe", "w"), + 2 => array("pipe", "w"), +); + +$process = proc_open($cmd, $descriptorspec, $pipes); + +if (is_resource($process)) { + $message = $_GET['m']; + + fwrite($pipes[0], $message); + fclose($pipes[0]); + + $result = stream_get_contents($pipes[1]); + fclose($pipes[1]); + + $log = stream_get_contents($pipes[2]); + fclose($pipes[2]); + + $return_value = proc_close($process); + + if (strlen($result) == 0) { + header('Content-type: text/plain'); + echo $log; + } else { + header('Content-Disposition: attachment; filename="output.wav"'); + header("Content-Transfer-Encoding: binary"); + header("Content-Type: audio/wav"); + + echo $result; + } +} + +?>