unit mTSound;
..
TSound =
class
constructor create;
//destructor destroy; override;
private
schuss1, schuss2, schuss3 : HSTREAM;
explosion1, explosion2, explosion3 : HSTREAM;
schuss_path, explosion_path :
string;
procedure play_schuss;
procedure play_explosion;
public
procedure playfile( pname :
string);
end;
..
constructor TSound.create;
begin
if not BASS_Init(1, 44100, 0, 0,
nil)
then //HANDLE kannte derbei mir nicht, habs auf 0 gesetzt. Ist das der Fehler?
begin
showmessage('
Bass.dll konnte nicht initialisiert werden!');
exit;
end;
schuss_path := '
/sounds/laserbeamz.wav';
explosion_path := '
/sounds/bomb.wav';
schuss1 := BASS_StreamCreateFile(False, pchar(schuss_path),0, 0,BASS_SAMPLE_SOFTWARE
{$IFDEF UNICODE} or BASS_UNICODE
{$ENDIF});
...
explosion1 := BASS_StreamCreateFile(False, pchar(explosion_path),0, 0,BASS_SAMPLE_SOFTWARE
{$IFDEF UNICODE} or BASS_UNICODE
{$ENDIF});
..
end;
procedure TSound.playfile ( pname :
string );
begin
if pname = '
explosion'
then play_explosion
else if pname = '
schuss'
then play_schuss;
end;
procedure TSound.play_explosion;
begin
if (BASS_ChannelIsActive(explosion1) = 0)
then
BASS_ChannelPlay(explosion1, False)
//Wird afgerufen
else
if (BASS_ChannelIsActive(explosion2) = 0)
then
BASS_ChannelPlay(explosion2, False)
else
...
end;
procedure TSound.play_schuss;
begin
...
end;