Multimedia Programming/ja
│
Deutsch (de) │
English (en) │
日本語 (ja) │
한국어 (ko) │
русский (ru) │
中文(中国大陆) (zh_CN) │
動画の再生
再生用アプリケーションを起動させる
コマンドラインとパラメータを知っていれば、以下のように TProcessUTF8 を使って再生用アプリを起動させられます。
uses
Classes, ..., LCLProc, UTF8Process;
...
implementation
procedure TMainForm.Button1Click(Sender: TObject);
var
Player: TProcessUTF8;
begin
Player:=TProcessUTF8.Create(nil);
try
Player.CommandLine:=PathToPlayer+' '+ParametersAndMediaFile;
Player.Execute;
finally
Player.Free;
end;
end;
こちらは Linux 上で起動させる具体例です。動画再生アプリ mplayer を使用します。
uses
Classes, ..., FileUtil, LCLProc, UTF8Process;
...
implementation
procedure TMainForm.Button1Click(Sender: TObject);
var
Player: TProcessUTF8;
Filename: String;
PlayerPath: String;
PlayerParams: String;
begin
Filename:='/home/username/video.mpg';
PlayerPath:=FindDefaultExecutablePath('mplayer');
PlayerParams:='"'+Filename+'"';
Player:=TProcessUTF8.Create(nil);
try
Player.CommandLine:=PlayerPath+' '+PlayerParams;
Player.Execute;
finally
Player.Free;
end;
end;
VFW - Video for Windows
Capturing and playing video streams from TV cards and webcams under Windows the VFW API can be used with SysRec.
MPlayer(Linux gtk2/X 用)
mplayer はオープンソースでフリーな動画プレイヤーです。この mplayer を埋め込んだ LCL コントロールがあります。これを使えば、動画プレイヤーを構築してアプリケーションで動画を再生させることができます。以下よりダウンロードできます。
svn co https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/components/mplayer mplayer
音の再生
Windows 限定:Windows API を使用する
wav ファイルなどであれば以下のように Windows API を使って再生できます。
...
uses MMSystem;
...
sndPlaySound('C:\sounds\test.wav', snd_Async or snd_NoDefault);
パスやファイル名に非 ASCII 文字が含まれていても正常に動作させるには以下のようにします。
sndPlaySound(pchar(UTF8ToSys('C:\sounds\test.wav')), snd_Async or snd_NoDefault);
当然ながら、これはクロスプラットフォームではありません。
オーディオコンポーネントスィートを使用する
オーディオコンポーネントスィートに関するページをお読みください。
OpenAL ライブラリを使用する
Delphi 用のチュートリアルでしたら、こちら [1] にあります。
Free Pascal comes with a unit for accessing OpenAL located in fpc/packages/openal as well as usage examples
BASS
BASS ライブラリは http://www.un4seen.com/ および http://www.un4seen.com/forum/?topic=8682.0 よりダウンロードできます。
There is a DJ application, for Windows, Linux and Mac OSX, written with Lazarus and using Bass lib: https://sites.google.com/site/fiensprototyping/
Audiere ライブラリ
Has bindings for Delphi, but they don't work with FPC:
- http://www.casteng.com/whypascal.shtml
- http://www.afterwarp.net/resources/soundlib
- http://code.google.com/p/audiere-bind-delphi/
Audorra ライブラリ
Lazarus で問題なく動作します。
http://sourceforge.net/projects/audorra/
OMEGA Engine
The OMEGA Engine is a full game engine in single Omega.dll file which is just 50kb. It can successfully play FLAC,OGG,MP3,MP2,AMR and WMA files. It searches and uses installed audio codecs from the system.
http://sourceforge.net/projects/omega-engine/files/
このプロジェクトは現在活動していませんが、とても簡単に使えるライブラリです。
Media_Play('Music.mp3', TRUE);
PortAudio
PortAudio はさまざまな言語にバインディングされている、クロスプラットフォームでオープンソースな録音・再生ライブラリです。このライブラリはサウンドデバイスにアクセスするためのものなので、ファイルの読み込み部分等は作成する必要があるでしょう。
フォーラムユーザ FredvS 氏が PortAudio ライブラリを動的読み込みできる Pascal ユニット [2] を書いています。(訳注:静的読み込み用のヘッダユニットは PortAudio の Links ページより入手できます。)
SDL + SDL_mixer
基本となる SDL ライブラリにあるサウンドシステムは、とても簡素なものです。一般には、より扱いやすい多くのサウンド API が実装されている SDL mixer を併せて使用します。
FMOD
ソースは公開されていません。非商用ソフトウェアにはフリーで使うことができますが、商用ソフトウェアではライセンス料金を払う必要があります。
Squall sound
Squall sound は FPC で正常に動作しません。また、立体音響と EAX の音響効果が使えますが、MP3、OGG、WAV フォーマットしかサポートしていません。
http://www.afterwarp.net/resources/soundlib
FPSound
FPSound is a new library being developed in the mold of fpspreadsheet and fpvectorial: it has independent modules to read, write and play sound files and also an intermediary representation for editing. See FPSound
UOS (United OpenLib of Sound)
UOS : United OpenLib of Sound. UOS unifies the best open-source audio libraries.
UOS で以下のことができます。
- mp3、ogg、wav、flac などのオーディオファイルを再生できます。
- データは 16、32 ビット、浮動小数 32 ビットで取り扱えます。
- 再生できるすべてのオーディオ形式で保存できます。
- 簡単なデジタル信号処理(音量、フィルタ処理)が行えます。
- 入出力をマルチチャンネルで行えます。
UOS はオーディオライブラリに PortAudio、SndFile、mpg123 を使用しています。
パッケージには以下のものが含まれています。
- 使い方のサンプル
- Linux 32/64、Windows 32/64、Mac OSX 32 用のバイナリライブラリ
http://sites.google.com/site/fiensprototyping/U_OS_Test.tar.gz