M fpsound.pas

AM   OpenAL_NT.pas
M    fpsound_openal.pas


git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2275 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
yangjixian
2012-02-01 01:46:41 +00:00
parent 9f861a7b4c
commit 00857e5d2c
4 changed files with 2402 additions and 10 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
object Form1: TForm1 object Form1: TForm1
Left = 323 Left = 200
Height = 240 Height = 240
Top = 171 Top = 166
Width = 320 Width = 320
Caption = 'Form1' Caption = 'Form1'
ClientHeight = 240 ClientHeight = 240
@ -19,7 +19,7 @@ object Form1: TForm1
end end
object pathEdit: TFileNameEdit object pathEdit: TFileNameEdit
Left = 8 Left = 8
Height = 25 Height = 27
Top = 13 Top = 13
Width = 268 Width = 268
FileName = '/home/felipe/Programas/lazarus-ccr/components/fpsound/testsounds/test.wav' FileName = '/home/felipe/Programas/lazarus-ccr/components/fpsound/testsounds/test.wav'

View File

@ -104,6 +104,7 @@ type
procedure Stop; procedure Stop;
procedure Seek(ANewPos: Double); procedure Seek(ANewPos: Double);
procedure SetSoundPlayer(AKind: TSoundPlayerKind); procedure SetSoundPlayer(AKind: TSoundPlayerKind);
function GetSoundDocPtr: Pointer;
end; end;
var var
@ -285,6 +286,13 @@ begin
FPlayer := GSoundPlayers[AKind]; FPlayer := GSoundPlayers[AKind];
end; end;
function TSoundDocument.GetSoundDocPtr: Pointer;
begin
aStream.Position := 0;
getmem(Result, aStream.Size);
aStream.Read(Result^, aStream.Size);
end;
var var
lReaderIndex: TSoundFormat; lReaderIndex: TSoundFormat;
lPlayerIndex: TSoundPlayerKind; lPlayerIndex: TSoundPlayerKind;

View File

@ -15,7 +15,7 @@ unit fpsound_openal;
interface interface
uses uses
Classes, SysUtils, openal, fpsound; Classes, SysUtils, OpenAL_NT, fpsound;
type type
@ -26,9 +26,9 @@ type
al_device: PALCdevice; al_device: PALCdevice;
al_context: PALCcontext; al_context: PALCcontext;
codec_bs : Longword; codec_bs : Longword;
al_source : ALuint; al_source : TALuint;
al_format : Integer; al_format : Integer;
al_buffers : array[0..0] of ALuint; al_buffers : array[0..0] of TALuint;
al_bufsize : Longword; al_bufsize : Longword;
al_readbuf : Pointer; al_readbuf : Pointer;
al_rate : Longword; al_rate : Longword;
@ -107,15 +107,24 @@ begin
Inc(lBufferWordPtr, 2); Inc(lBufferWordPtr, 2);
end; end;
end; end;
al_readbuf := ASound.GetSoundDocPtr;
end; end;
procedure TOpenALPlayer.Initialize; procedure TOpenALPlayer.Initialize;
var argv: array of PALbyte;
begin begin
if FInitialized then Exit; if FInitialized then Exit;
al_device := alcOpenDevice(nil); IsMultiThread := False;
if not InitOpenAL then
Exception.Create('Initialize OpenAL failed');
{ al_device := alcOpenDevice(nil);
al_context := alcCreateContext(al_device, nil); al_context := alcCreateContext(al_device, nil);
alcMakeContextCurrent(al_context); alcMakeContextCurrent(al_context); }
alutInit(nil, argv);
al_bufcount := 1;
alGenBuffers(al_bufcount, @al_buffers);
alListener3f(AL_POSITION, 0, 0, 0); alListener3f(AL_POSITION, 0, 0, 0);
alListener3f(AL_VELOCITY, 0, 0, 0); alListener3f(AL_VELOCITY, 0, 0, 0);
@ -130,8 +139,6 @@ begin
alSourcei(al_source, AL_LOOPING, AL_FALSE); alSourcei(al_source, AL_LOOPING, AL_FALSE);
// alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); // alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
al_bufcount := 1;
alGenBuffers(al_bufcount, @al_buffers);
FInitialized := True; FInitialized := True;
end; end;