downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

openal_buffer_create> <使用方法
[edit] Last updated: Mon, 01 Nov 2010

view this page in

CVII. OpenAL 音声バインディング

導入

プラットフォームに依存しない音声バインディングです。 OpenAL ライブラリを必要とします。

インストール手順

この PECL 拡張 モジュールは PHP にバンドルされていません。

この PECL 拡張モジュールをインストールする方法は、 マニュアルの PECL 拡張モジュールのインストール という章にあります。 新規リリース・ダウンロード・ソースファイル・管理者情報・CHANGELOG といった関連する情報については、次の場所にあります。 http://pecl.php.net/package/openal.

この PECL 拡張モジュール の DLL PHP ダウンロード ページ または http://snaps.php.net/ からダウンロードできます。

実行時設定

設定ディレクティブは定義されていません。

リソース型

この拡張モジュールでは、 Open AL(Device) - openal_device_open() が返すもの、 Open AL(Context) - openal_context_create() が返すもの、 Open AL(Buffer) - openal_buffer_create() が返すもの および Open AL(Source) - openal_source_create() が返すものの 4 種類のリソース型が定義されています。

定義済み定数

以下の定数が定義されています。 この関数の拡張モジュールが PHP 組み込みでコンパイルされているか、 実行時に動的にロードされている場合のみ使用可能です。

ALC_FREQUENCY (integer)

コンテキスト属性

ALC_REFRESH (integer)

コンテキスト属性

ALC_SYNC (integer)

コンテキスト属性

AL_FREQUENCY (integer)

バッファ設定

AL_BITS (integer)

バッファ設定

AL_CHANNELS (integer)

バッファ設定

AL_SIZE (integer)

バッファ設定

AL_BUFFER (integer)

ソース/リスナー 設定 (Integer)

AL_SOURCE_RELATIVE (integer)

ソース/リスナー 設定 (Integer)

AL_SOURCE_STATE (integer)

ソース/リスナー 設定 (Integer)

AL_PITCH (integer)

ソース/リスナー 設定 (Float)

AL_GAIN (integer)

ソース/リスナー 設定 (Float)

AL_MIN_GAIN (integer)

ソース/リスナー 設定 (Float)

AL_MAX_GAIN (integer)

ソース/リスナー 設定 (Float)

AL_MAX_DISTANCE (integer)

ソース/リスナー 設定 (Float)

AL_ROLLOFF_FACTOR (integer)

ソース/リスナー 設定 (Float)

AL_CONE_OUTER_GAIN (integer)

ソース/リスナー 設定 (Float)

AL_CONE_INNER_ANGLE (integer)

ソース/リスナー 設定 (Float)

AL_CONE_OUTER_ANGLE (integer)

ソース/リスナー 設定 (Float)

AL_REFERENCE_DISTANCE (integer)

ソース/リスナー 設定 (Float)

AL_POSITION (integer)

ソース/リスナー 設定 (Float Vector)

AL_VELOCITY (integer)

ソース/リスナー 設定 (Float Vector)

AL_DIRECTION (integer)

ソース/リスナー 設定 (Float Vector)

AL_ORIENTATION (integer)

ソース/リスナー 設定 (Float Vector)

AL_FORMAT_MONO8 (integer)

PCM フォーマット

AL_FORMAT_MONO16 (integer)

PCM フォーマット

AL_FORMAT_STEREO8 (integer)

PCM フォーマット

AL_FORMAT_STEREO16 (integer)

PCM フォーマット

AL_INITIAL (integer)

ソースの状態

AL_PLAYING (integer)

ソースの状態

AL_PAUSED (integer)

ソースの状態

AL_STOPPED (integer)

ソースの状態

AL_LOOPING (integer)

ソースの状態

AL_TRUE (integer)

OpenAL が理解する boolean 値

AL_FALSE (integer)

OpenAL が理解する boolean 値

目次
openal_buffer_create --  OpenAL バッファを生成する
openal_buffer_data --  バッファのデータを読み込む
openal_buffer_destroy --  OpenAL バッファを削除する
openal_buffer_get --  OpenAL バッファのプロパティを取得する
openal_buffer_loadwav --  .wav ファイルをバッファに読み込む
openal_context_create --  音声処理コンテキストを作成する
openal_context_current --  指定したコンテキストを現在のコンテキストにする
openal_context_destroy --  コンテキストを削除する
openal_context_process --  指定したコンテキストを処理する
openal_context_suspend --  指定したコンテキストをサスペンドする
openal_device_close --  OpenAL デバイスを閉じる
openal_device_open --  OpenAL 音声レイヤを初期化する
openal_listener_get --  リスナーのプロパティを取得する
openal_listener_set --  リスナーのプロパティを設定する
openal_source_create --  ソースリソースを生成する
openal_source_destroy --  ソースリソースを削除する
openal_source_get --  OpenAL ソースのプロパティを取得する
openal_source_pause --  ソースを一時停止する
openal_source_play --  ソースの再生を開始する
openal_source_rewind --  ソースを巻き戻す
openal_source_set --  ソースのプロパティを設定する
openal_source_stop --  ソースの再生を停止する
openal_stream --  ソースのストリーム再生を開始する


openal_buffer_create> <使用方法
[edit] Last updated: Mon, 01 Nov 2010
 
add a note add a note User Contributed Notes OpenAL 音声バインディング
Tjeerd 02-Feb-2007 08:37
OpenAL aims to provide a standardized API for something called '3D' sound, just like OpenGL does for '3D' video rendering.

The fun part of OpenAL is that it does all the DSP for you, so you don't need to know a lot about audio. Since OpenAL comes from Creative Labs, it supports hardware rendering of audio with most if not all SoundBlaster audio controllers. They come with chips from EMU-systems and are specifically designed to mix down multichannel audio with DSP effects like reverb and chorus, which could consume a lot CPU speed.

The downside of OpenAL is that (at this time of writing) it is focus on games only. It doesn't do MIDI at all, it doesn't record anything, it doesn't work like a synthesizer. The only thing you can do with OpenAL is play sounds in a simulated 3D environment.
It probably doesn't work on the web.

To use OpenAL you need to read the documentation about OpenAL.

Note concerning audio users: there's no such thing as '3D' audio with speakers. Technically, when people have only two ears, they really can't distinguish sound from above or below, even in front or from behind. To achieve this people merely hear volume, the brightness of sound and the phase difference. One should be able to hear more '3D' sound with only two quality-class speakers than with a consumer class 5.1-set.
cweiske at cweiske dot de 06-Sep-2006 01:31
I made a PHP-Gtk2 OpenAL demo which allows you to define as many sound sources as you like and position them relative to the listener by drag and drop: http://gnope.org/p/Tools_OpenALdemo
cweiske at cweiske dot de 21-Jul-2006 11:29
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));
?>

 
show source | credits | sitemap | contact | advertising | mirror sites