aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2007-06-06 20:24:29 +0000
committerwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2007-06-06 20:24:29 +0000
commitd08356e3b64d8738ff9672229c1bbe963b58337c (patch)
treef801d0bb58e2c120933e098abcbe0ceaeb9e559b
parent4c5b6c460f3729fa2db0590e6f133a786a486ed8 (diff)
downloadusdx-d08356e3b64d8738ff9672229c1bbe963b58337c.tar.gz
usdx-d08356e3b64d8738ff9672229c1bbe963b58337c.tar.xz
usdx-d08356e3b64d8738ff9672229c1bbe963b58337c.zip
Fixed some Bugs in Song Fading
Added Ini Values to change the Fading and the Preview Volume git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@245 b956fd51-792f-4845-bead-9b4dfca2ff2c
-rw-r--r--Game/Code/Classes/UIni.pas26
-rw-r--r--Game/Code/Classes/UMusic.pas6
-rw-r--r--Game/Code/Screens/UScreenSong.pas103
3 files changed, 97 insertions, 38 deletions
diff --git a/Game/Code/Classes/UIni.pas b/Game/Code/Classes/UIni.pas
index c92a7a50..528966b3 100644
--- a/Game/Code/Classes/UIni.pas
+++ b/Game/Code/Classes/UIni.pas
@@ -38,7 +38,10 @@ type
BeatClick: integer;
SavePlayback: integer;
Threshold: integer;
- //TwoPlayerMode: integer;
+
+ //Song Preview
+ PreviewVolume: integer;
+ PreviewFading: integer;
// Lyrics
LyricsFont: integer;
@@ -130,7 +133,10 @@ const
IBeatClick: array[0..1] of string = ('Off', 'On');
ISavePlayback: array[0..1] of string = ('Off', 'On');
IThreshold: array[0..3] of string = ('5%', '10%', '15%', '20%');
- //ITwoPlayerMode: array[0..2] of string = ('Stereo', '2 Cards', 'Advanced');
+ //Song Preview
+ IPreviewVolume: array[0..10] of string = ('Off', '10%', '20%', '30%', '40%', '50%', '60%', '70%', '80%', '90%', '100%');
+ IPreviewFading: array[0..5] of string = ('Off', '1 Sec', '2 Secs', '3 Secs', '4 Secs', '5 Secs');
+
ILyricsFont: array[0..2] of string = ('Plain', 'OLine1', 'OLine2');
ILyricsEffect: array[0..3] of string = ('Simple', 'Zoom', 'Slide', 'Ball');
@@ -316,6 +322,15 @@ begin
for Pet := 0 to High(IThreshold) do
if Tekst = IThreshold[Pet] then Ini.Threshold := Pet;
+ //Song Preview
+ Tekst := IniFile.ReadString('Sound', 'PreviewVolume', IPreviewVolume[7]);
+ for Pet := 0 to High(IPreviewVolume) do
+ if Tekst = IPreviewVolume[Pet] then Ini.PreviewVolume := Pet;
+
+ Tekst := IniFile.ReadString('Sound', 'PreviewFading', IPreviewFading[1]);
+ for Pet := 0 to High(IPreviewFading) do
+ if Tekst = IPreviewFading[Pet] then Ini.PreviewFading := Pet;
+
// Lyrics Font
Tekst := IniFile.ReadString('Lyrics', 'LyricsFont', ILyricsFont[1]);
for Pet := 0 to High(ILyricsFont) do
@@ -582,6 +597,13 @@ begin
Tekst := IThreshold[Ini.Threshold];
IniFile.WriteString('Sound', 'Threshold', Tekst);
+ // Song Preview
+ Tekst := IPreviewVolume[Ini.PreviewVolume];
+ IniFile.WriteString('Sound', 'PreviewVolume', Tekst);
+
+ Tekst := IPreviewFading[Ini.PreviewFading];
+ IniFile.WriteString('Sound', 'PreviewFading', Tekst);
+
// SavePlayback
Tekst := ISavePlayback[Ini.SavePlayback];
IniFile.WriteString('Sound', 'SavePlayback', Tekst);
diff --git a/Game/Code/Classes/UMusic.pas b/Game/Code/Classes/UMusic.pas
index 52bae3c9..3fcd2a21 100644
--- a/Game/Code/Classes/UMusic.pas
+++ b/Game/Code/Classes/UMusic.pas
@@ -59,7 +59,7 @@ type
procedure InitializePlayback;
procedure InitializeRecord;
procedure SetVolume(Volume: integer);
- procedure SetMusicVolume(Volume: Byte);
+ procedure SetMusicVolume(Volume: integer);
procedure SetLoop(Enabled: boolean);
function Open(Name: string): boolean; // true if succeed
procedure Rewind;
@@ -351,14 +351,14 @@ begin
BASS_SetConfig(BASS_CONFIG_GVOL_MUSIC, Volume);
end;
-procedure TMusic.SetMusicVolume(Volume: Byte);
+procedure TMusic.SetMusicVolume(Volume: Integer);
begin
//Max Volume Prevention
if Volume > 100 then
Volume := 100;
//Set Volume
- BASS_ChannelSetAttributes (Bass, -1, Integer(Volume), -101);
+ BASS_ChannelSetAttributes (Bass, -1, Volume, -101);
end;
procedure TMusic.SetLoop(Enabled: boolean);
diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas
index ae02b2f4..ee05c11c 100644
--- a/Game/Code/Screens/UScreenSong.pas
+++ b/Game/Code/Screens/UScreenSong.pas
@@ -1271,12 +1271,21 @@ begin
if Length(CatSongs.Song) > 0 then begin
- Music.SetLoop(false);
- Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3);
- Music.MoveTo(Music.Length / 4);
- Music.Play;
- //Music Fade (Start not with max Volume)
- Music.SetMusicVolume(70);
+ //Load Music only when Song Preview is activated
+ if (Ini.PreviewVolume <> 0) then
+ begin
+ Music.SetLoop(false);
+ Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3);
+ Music.MoveTo(Music.Length / 4);
+ Music.Play;
+
+ //Set Preview Volume
+ Music.SetMusicVolume (Ini.PreviewVolume * 10);
+ {//if Music Fade is activated, Set Volume to 0 %
+ if (Ini.PreviewFading <> 0) then
+ Music.SetMusicVolume(0);}
+ end;
+
SetScroll;
UpdateLCD;
end;
@@ -1312,6 +1321,10 @@ end;
procedure TScreenSong.onHide;
begin
+ //When Music Fading is activated, Turn Music to 100 %
+ If (Ini.PreviewVolume <> 100) or (Ini.PreviewFading <> 0) then
+ Music.SetMusicVolume(100);
+
//When hide then Stop Music (For Party Mode Popup on Exit)
if (Display.NextScreen <> @ScreenSing) and (Display.NextScreen <> @ScreenSingModi) and (Music <> nil) then
Music.Stop;
@@ -1350,25 +1363,42 @@ begin
// Log.BenchmarkEnd(5);
// Log.LogBenchmark('SetScroll4', 5);
+ //Fading Functions, Only if Covertime is under 5 Seconds
+ If (CoverTime < 5) then
+ begin
+ // 0.5.0: cover fade
+ if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then begin
+ // load new texture
+ Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false);
+ Button[Interaction].Texture.Alpha := 1;
+ Button[Interaction].Texture2 := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false);
+ Button[Interaction].Texture2.Alpha := 1;
+ end;
- // 0.5.0: cover fade and Song Fade
- if (CoverTime < 1) and (CoverTime + TimeSkip >= 1) then begin
- // load new texture
- Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false);
- Button[Interaction].Texture.Alpha := 1;
- Button[Interaction].Texture2 := Texture.GetTexture(Button[Interaction].Texture.Name, 'Plain', false);
- Button[Interaction].Texture2.Alpha := 1;
+ //Song Fade
+ if (CatSongs.VisibleSongs > 0) AND (Ini.PreviewVolume <> 0) AND (Not CatSongs.Song[Interaction].Main) AND (Ini.PreviewFading <> 0) then
+ begin
+ //Start Song Fade after a little Time, to prevent Song to be Played on Scrolling
+ if (CoverTime < 0.2) and (CoverTime + TimeSkip >= 0.2) then
+ Music.Play;
- //Play Song
- Music.SetMusicVolume(20);
- Music.Play;
- end;
- CoverTime := CoverTime + TimeSkip;
- Button[Interaction].Texture2.Alpha := (CoverTime - 1) * 1.5;
- if Button[Interaction].Texture2.Alpha > 1 then Button[Interaction].Texture2.Alpha := 1;
+ //Update Song Volume
+ if (CoverTime < Ini.PreviewFading) then
+ Music.SetMusicVolume(Round (CoverTime * Ini.PreviewVolume / Ini.PreviewFading * 10))
+ else
+ Music.SetMusicVolume(Ini.PreviewVolume * 10);
+
+ end;
- if (CoverTime > 1) and (CoverTime <= 3.5) then
- Music.SetMusicVolume(Round((CoverTime-1)* 20));
+
+ //Update Fading Time
+ CoverTime := CoverTime + TimeSkip;
+
+ //Update Fading Texture
+ Button[Interaction].Texture2.Alpha := (CoverTime - 1) * 1.5;
+ if Button[Interaction].Texture2.Alpha > 1 then Button[Interaction].Texture2.Alpha := 1;
+
+ end;
inherited Draw;
@@ -1452,17 +1482,24 @@ end;
//Procedure Change current played Preview
procedure TScreenSong.ChangeMusic;
begin
- if (NOT CatSongs.Song[Interaction].Main) AND(CatSongs.VisibleSongs > 0) then
- begin
- Music.Close;
- if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin
- Music.MoveTo(Music.Length / 4);
- //Song Fading: Not Play Directly
- //Music.Play;
- end;
- end
- else
- Music.Stop;
+ //When Music Preview is avtivated -> then Change Music
+ if (Ini.PreviewVolume <> 0) then
+ begin
+ if (NOT CatSongs.Song[Interaction].Main) AND(CatSongs.VisibleSongs > 0) then
+ begin
+ Music.Close;
+ if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin
+ Music.MoveTo(Music.Length / 4);
+ //If Song Fading is activated then don't Play directly, and Set Volume to Null, else Play normal
+ if (Ini.PreviewVolume <> 0) then
+ Music.SetMusicVolume(0)
+ else
+ Music.Play;
+ end;
+ end
+ else
+ Music.Stop;
+ end;
end;
procedure TScreenSong.SkipTo(Target: Cardinal); // 0.5.0