diff options
author | brunzelchen <brunzelchen@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-06-25 18:17:57 +0000 |
---|---|---|
committer | brunzelchen <brunzelchen@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-06-25 18:17:57 +0000 |
commit | 73667c7058d5d9b6d006ebfc8ebfea6435e6abf9 (patch) | |
tree | af845c7099b66411f869b5f7046d4ba880d03d8f /Game/Code/Classes | |
parent | 4c34cb5e200a4cdcdfaba52789e7d9a23a84dab6 (diff) | |
download | usdx-73667c7058d5d9b6d006ebfc8ebfea6435e6abf9.tar.gz usdx-73667c7058d5d9b6d006ebfc8ebfea6435e6abf9.tar.xz usdx-73667c7058d5d9b6d006ebfc8ebfea6435e6abf9.zip |
- do not shuffle, if music no music loaded
- scan more data on mp3 files (BASS_CONFIG_VERIFY)
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/1.0.1 Challenge MOD@2560 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code/Classes')
-rw-r--r-- | Game/Code/Classes/UMusic.pas | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/Game/Code/Classes/UMusic.pas b/Game/Code/Classes/UMusic.pas index a5355bbe..6af444c8 100644 --- a/Game/Code/Classes/UMusic.pas +++ b/Game/Code/Classes/UMusic.pas @@ -82,6 +82,7 @@ type procedure Stop;
procedure Close;
function Finished: boolean;
+ function isOpen: boolean;
function Length: real;
function Position: real;
procedure PlayStart;
@@ -357,11 +358,13 @@ begin Loop := false;
fHWND := Classes.AllocateHWND( nil);
- if BASS_Init(1, 44100, 0, fHWND, nil) = false then + if BASS_Init(-1, 44100, 0, fHWND, nil) = false then begin
Application.MessageBox ('Could not initialize BASS', 'Error');
Exit;
end;
+
+ BASS_SetConfig(BASS_CONFIG_VERIFY, high(WORD));
DSP_VocalRemover := 0;
SetLength(BassVoices, 0);
Log.BenchmarkEnd(4); Log.LogBenchmark('--> Bass Init', 4);
@@ -499,7 +502,7 @@ end; procedure TMusic.Fade(InitVolume, TargetVolume: Integer; FadeTime: real);
var
- time: dword;
+ time: DWORD;
begin
//Max Volume Prevention
if TargetVolume > 100 then
@@ -514,7 +517,7 @@ end; procedure TMusic.FadeStop(FadeTime: real);
var
- time: dword;
+ time: DWORD;
begin
time := round(FadeTime*1000);
BASS_ChannelSlideAttribute(Bass, BASS_ATTRIB_VOL, -1, time); //fade out and stop
@@ -526,15 +529,26 @@ begin end;
function TMusic.Open(Name: string): boolean;
+var
+ errorCode: integer;
begin
Loaded := false;
- if FileExists(Name) then begin
+ if FileExists(Name) then
+ begin
{ MediaPlayer.FileName := Name;
MediaPlayer.Open;}
- Bass := Bass_StreamCreateFile(false, pchar(Name), 0, 0, 0);
- Loaded := true;
+ Bass := Bass_StreamCreateFile(false, PChar(Name), 0, 0, 0);
+ if (Bass>0) then
+ Loaded := true
+ else
+ begin
+ Loaded := false;
+ errorCode := BASS_ErrorGetCode();
+ Log.LogError('Error (' + IntToStr(errorCode) + ') on open File: ' + Name);
+ end;
+
DSP_VocalRemover:=0;
//Set Max Volume
//SetMusicVolume (100);
@@ -555,7 +569,7 @@ end; procedure TMusic.MoveTo(Time: real);
var
- bytes: integer;
+ bytes: QWORD;
begin
// if Loaded then begin
// MediaPlayer.StartPos := Round(Time);
@@ -599,7 +613,7 @@ end; function TMusic.Length: real;
var
- bytes: integer;
+ bytes: QWORD;
begin
//Result := 60;
@@ -615,13 +629,18 @@ end; function TMusic.Position: real;
var
- bytes: integer;
+ bytes: QWORD;
begin
//Result := 0;//MediaPlayer.Position / 1000;
bytes := BASS_ChannelGetPosition(BASS, BASS_POS_BYTE);
Result := BASS_ChannelBytes2Seconds(BASS, bytes);
end;
+function TMusic.isOpen: boolean;
+begin
+ Result := Loaded;
+end;
+
function TMusic.Finished: boolean;
begin
Result := false;
|