fpsound: Now it makes some kind of noise

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2269 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat 2012-01-25 14:43:21 +00:00
parent bc0894fe7a
commit 669d73702f

View File

@ -25,10 +25,9 @@ type
TOpenALPlayer = class(TSoundPlayer) TOpenALPlayer = class(TSoundPlayer)
private private
source : TStream; al_device: PALCdevice;
al_context: PALCcontext;
codec_bs : Longword; codec_bs : Longword;
OPCSoundWasInitialized: Boolean;
OPCSoundStreamIsLoaded: Boolean;
al_source : ALuint; al_source : ALuint;
al_format : Integer; al_format : Integer;
al_buffers : array[0..al_bufcount-1] of ALuint; al_buffers : array[0..al_bufcount-1] of ALuint;
@ -100,14 +99,23 @@ end;
procedure TOpenALPlayer.Initialize; procedure TOpenALPlayer.Initialize;
begin begin
// alutInit(0, NULL); al_device := alcOpenDevice(nil);
al_context := alcCreateContext(al_device, nil);
alcMakeContextCurrent(al_context);
{ alListenerfv(AL_POSITION,listenerPos); alListener3f(AL_POSITION, 0, 0, 0);
alListenerfv(AL_VELOCITY,listenerVel); alListener3f(AL_VELOCITY, 0, 0, 0);
alListenerfv(AL_ORIENTATION,listenerOri);} alListener3f(AL_ORIENTATION, 0, 0, -1);
alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
alGenSources(1, @al_source); alGenSources(1, @al_source);
alSourcef(al_source, AL_PITCH, 1);
alSourcef(al_source, AL_GAIN, 1);
alSource3f(al_source, AL_POSITION, 0, 0, 0);
alSource3f(al_source, AL_VELOCITY, 0, 0, 0);
alSourcei(al_source, AL_LOOPING, AL_FALSE);
// alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
alGenBuffers(al_bufcount, @al_buffers); alGenBuffers(al_bufcount, @al_buffers);
end; end;
@ -117,15 +125,6 @@ begin
alDeleteSources(1, @al_source); alDeleteSources(1, @al_source);
alDeleteBuffers(al_bufcount, @al_buffers); alDeleteBuffers(al_bufcount, @al_buffers);
if al_readbuf <> nil then FreeMem(al_readbuf); if al_readbuf <> nil then FreeMem(al_readbuf);
// wave.fStream := nil;
// source := nil;
// finalize codec
// wave.Free;
// close file
// source.Free;
end; end;
procedure TOpenALPlayer.Play(ASound: TSoundDocument); procedure TOpenALPlayer.Play(ASound: TSoundDocument);
@ -134,15 +133,6 @@ var
queued : Integer; queued : Integer;
done : Boolean; done : Boolean;
lKeyElement: TSoundKeyElement; lKeyElement: TSoundKeyElement;
//
{ buffer : Cardinal;
sourcepos: array [0..2] of Single=(0.0, 0.0, 0.0);
sourcevel: array [0..2] of Single=(0.0, 0.0, 0.0);
listenerpos: array [0..2] of Single=(0.0, 0.0, 0.0);
listenervel: array [0..2] of Single=(0.0, 0.0, 0.0);
listenerori: array [0..5] of Single=(0.0, 0.0, -1.0, 0.0, 1.0, 0.0);
Context: PALCcontext;
Device: PALCdevice; }
begin begin
Initialize(); Initialize();
@ -158,7 +148,7 @@ begin
for i := 0 to al_bufcount - 1 do for i := 0 to al_bufcount - 1 do
begin begin
// Fill the buffer // Fill the buffer
AlFillBuffer(ASound, lKeyElement); alFillBuffer(ASound, lKeyElement);
alBufferData(al_buffers[i], al_format, al_readbuf, al_bufsize, al_rate); alBufferData(al_buffers[i], al_format, al_readbuf, al_bufsize, al_rate);
alSourceQueueBuffers(al_source, 1, @al_buffers[i]); alSourceQueueBuffers(al_source, 1, @al_buffers[i]);
@ -168,7 +158,7 @@ begin
alSourcei(al_source, AL_LOOPING, AL_FALSE); alSourcei(al_source, AL_LOOPING, AL_FALSE);
alSourcePlay(al_source); alSourcePlay(al_source);
done:=False; {done:=False;
queued:=0; queued:=0;
repeat repeat
if alProcess(ASound, lKeyElement) then if alProcess(ASound, lKeyElement) then
@ -177,7 +167,7 @@ begin
done:=queued=0; done:=queued=0;
end; end;
Sleep(al_polltime); Sleep(al_polltime);
until done; until done;}
{ {
AlSourceStop(source); AlSourceStop(source);