note 68309 added to ref.openal
| From: | cweiske at cweiske dot de | Date: | Fri, 21 Jul 2006 18:29:11 +0000 |
| Subject: | note 68309 added to ref.openal | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115021@lists.php.net to get a copy of this message | ||
Playing a wav file:
<?php
function printok($b) {
echo $b ? " ok\n" : " error\n";
}
echo "Opening device";
$device = openal_device_open();
printok($device);
echo "Creating context";
$context = openal_context_create($device);
printok($context);
echo "Making context the current";
printok(openal_context_current($context));
//where we are
//echo "Setting listener position";
//printok(openal_listener_set(AL_POSITION, array(0, 0, 0)));
//echo "Setting listener orientation";
//printok(openal_listener_set(AL_ORIENTATION, array(0=>0,1 => 1, 2=>0, 3=> 0, 4=>4,
5=>5)));
echo "Creating buffer";
$buffer = openal_buffer_create();
echo "Loading wav";
printok(openal_buffer_loadwav($buffer, '/data/shared/vmware/newmessage.wav'));
echo "buffer stats\n";
echo " Frequency: " . openal_buffer_get($buffer, AL_FREQUENCY) . "\n";
echo " Bits : " . openal_buffer_get($buffer, AL_BITS) . "\n";
echo " Channels : " . openal_buffer_get($buffer, AL_CHANNELS) . "\n";
echo " Size : " . openal_buffer_get($buffer, AL_SIZE) . "\n";
echo "Creating source";
$source = openal_source_create();
echo "Setting source buffer";
printok(openal_source_set($source, AL_BUFFER, $buffer));
//echo "Setting source position";
//printok(openal_source_set($source, AL_POSITION, array(1, 0, 0)));
echo "Playing source";
printok(openal_source_play($source));
echo "sleeping\n";
//sleep(1);
//we wait 300msecs beause the sound
// has no time to be played otherwise
//since playing sound is done concurrently
// to the script
usleep(300000);
echo "Destroying source";
printok(openal_source_destroy($source));
echo "Destroying buffer";
printok(openal_buffer_destroy($buffer));
echo "Destroying context";
printok(openal_context_destroy($context));
echo "Closing device";
printok(openal_device_close($device));
?>
----
Server IP: 66.163.161.117
Probable Submitter: 84.185.147.16
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/ref.openal.php
Edit -- http://master.php.net/note/edit/68309
Del: integrated -- http://master.php.net/note/delete/68309/integrated
Del: useless -- http://master.php.net/note/delete/68309/useless
Del: bad code -- http://master.php.net/note/delete/68309/bad+code
Del: spam -- http://master.php.net/note/delete/68309/spam
Del: non-english -- http://master.php.net/note/delete/68309/non-english
Del: in docs -- http://master.php.net/note/delete/68309/in+docs
Del: other reasons-- http://master.php.net/note/delete/68309
Reject -- http://master.php.net/note/reject/68309
Search -- http://master.php.net/manage/user-notes.php