From 49ada15c935658c5d90416e26acfb360f1e7c047 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 3 Jun 2007 19:45:43 +0000 Subject: Added SongPreview Fading Song Preview Max Volume is now 70 % Need Testing because of timing git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@243 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UMusic.pas | 13 +++++++++++++ Game/Code/Screens/UScreenSong.pas | 14 ++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'Game/Code') diff --git a/Game/Code/Classes/UMusic.pas b/Game/Code/Classes/UMusic.pas index 6e997c11..52bae3c9 100644 --- a/Game/Code/Classes/UMusic.pas +++ b/Game/Code/Classes/UMusic.pas @@ -59,6 +59,7 @@ type procedure InitializePlayback; procedure InitializeRecord; procedure SetVolume(Volume: integer); + procedure SetMusicVolume(Volume: Byte); procedure SetLoop(Enabled: boolean); function Open(Name: string): boolean; // true if succeed procedure Rewind; @@ -350,6 +351,16 @@ begin BASS_SetConfig(BASS_CONFIG_GVOL_MUSIC, Volume); end; +procedure TMusic.SetMusicVolume(Volume: Byte); +begin + //Max Volume Prevention + if Volume > 100 then + Volume := 100; + + //Set Volume + BASS_ChannelSetAttributes (Bass, -1, Integer(Volume), -101); +end; + procedure TMusic.SetLoop(Enabled: boolean); begin Loop := Enabled; @@ -364,6 +375,8 @@ begin Bass := Bass_StreamCreateFile(false, pchar(Name), 0, 0, 0); Loaded := true; + //Set Max Volume + SetMusicVolume (100); end; Result := Loaded; diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 3924968f..ae02b2f4 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -1275,6 +1275,8 @@ begin 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); SetScroll; UpdateLCD; end; @@ -1349,18 +1351,25 @@ begin // Log.LogBenchmark('SetScroll4', 5); - // 0.5.0: cover fade + // 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; + + //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; + if (CoverTime > 1) and (CoverTime <= 3.5) then + Music.SetMusicVolume(Round((CoverTime-1)* 20)); + inherited Draw; @@ -1448,7 +1457,8 @@ begin Music.Close; if Music.Open(CatSongs.Song[Interaction].Path + CatSongs.Song[Interaction].Mp3) then begin Music.MoveTo(Music.Length / 4); - Music.Play; + //Song Fading: Not Play Directly + //Music.Play; end; end else -- cgit v1.2.3