From 4e4e55b6e62a225d7f70a8aa9342e91881decbc8 Mon Sep 17 00:00:00 2001 From: tobigun Date: Fri, 11 Jan 2008 13:42:57 +0000 Subject: Updated to the new audio-interface git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@785 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UAudioPlayback_Bass.pas | 86 +++++++++++++++++++++++++------ 1 file changed, 70 insertions(+), 16 deletions(-) (limited to 'Game/Code/Classes') diff --git a/Game/Code/Classes/UAudioPlayback_Bass.pas b/Game/Code/Classes/UAudioPlayback_Bass.pas index ee6b1ef9..87ff183d 100644 --- a/Game/Code/Classes/UAudioPlayback_Bass.pas +++ b/Game/Code/Classes/UAudioPlayback_Bass.pas @@ -31,18 +31,21 @@ uses UThemes; type - TMPModes = (mpNotReady, mpStopped, mpPlaying, mpRecording, mpSeeking, - mpPaused, mpOpen); - -const - ModeStr: array[TMPModes] of string = ('Not ready', 'Stopped', 'Playing', 'Recording', 'Seeking', 'Paused', 'Open'); - -type - TBassOutputStream = class(TAudioOutputStream) - Handle: HSTREAM; - - constructor Create(); overload; - constructor Create(stream: HSTREAM); overload; + TBassOutputStream = class(TAudioPlaybackStream) + private + Handle: HSTREAM; + public + constructor Create(); overload; + constructor Create(stream: HSTREAM); overload; + + procedure Play(); override; + procedure Pause(); override; + procedure Stop(); override; + procedure Close(); override; + function GetLoop(): boolean; override; + procedure SetLoop(Enabled: boolean); override; + function GetLength(): real; override; + function GetStatus(): TStreamStatus; override; end; type @@ -128,6 +131,61 @@ begin Handle := stream; end; +procedure TBassOutputStream.Play(); +begin + BASS_ChannelPlay(Handle, True); +end; + +procedure TBassOutputStream.Pause(); +begin + //if (Loaded) then + BASS_ChannelPause(Handle); +end; + +procedure TBassOutputStream.Stop(); +begin + BASS_ChannelStop(Handle); +end; + +procedure TBassOutputStream.Close(); +begin + Bass_StreamFree(Handle); +end; + +function TBassOutputStream.GetLoop(): boolean; +begin + // TODO + result := false; +end; + +procedure TBassOutputStream.SetLoop(Enabled: boolean); +begin + // TODO +end; + +function TBassOutputStream.GetLength(): real; +var + bytes: integer; +begin + bytes := BASS_ChannelGetLength(Handle); + Result := BASS_ChannelBytes2Seconds(Handle, bytes); +end; + +function TBassOutputStream.GetStatus(): TStreamStatus; +var + state: DWORD; +begin + state := BASS_ChannelIsActive(Handle); + case state of + BASS_ACTIVE_PLAYING: + result := sPlaying; + BASS_ACTIVE_PAUSED: + result := sPaused; + else + result := sStopped; + end; +end; + function TAudioPlayback_Bass.GetName: String; begin @@ -267,8 +325,6 @@ function TAudioPlayback_Bass.Length: real; var bytes: integer; begin - Result := 60; - bytes := BASS_ChannelGetLength(MusicStream); Result := BASS_ChannelBytes2Seconds(MusicStream, bytes); end; @@ -277,8 +333,6 @@ function TAudioPlayback_Bass.getPosition: real; var bytes: integer; begin - Result := 0; - bytes := BASS_ChannelGetPosition(MusicStream); Result := BASS_ChannelBytes2Seconds(MusicStream, bytes); end; -- cgit v1.2.3