aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code
diff options
context:
space:
mode:
authorbrunzelchen <brunzelchen@b956fd51-792f-4845-bead-9b4dfca2ff2c>2010-02-24 21:26:02 +0000
committerbrunzelchen <brunzelchen@b956fd51-792f-4845-bead-9b4dfca2ff2c>2010-02-24 21:26:02 +0000
commit262e2fd159ad63b7682992864987bb41a7814975 (patch)
treec65ab307e049a67d27bd0407f80ab4ae8ba695a0 /Game/Code
parent8d673db586aa57d95823730458e4973029fdfea7 (diff)
downloadusdx-262e2fd159ad63b7682992864987bb41a7814975.tar.gz
usdx-262e2fd159ad63b7682992864987bb41a7814975.tar.xz
usdx-262e2fd159ad63b7682992864987bb41a7814975.zip
added experimental voice playback after singing
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/1.0.1 Challenge MOD@2154 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code')
-rw-r--r--Game/Code/Classes/ULog.pas5
-rw-r--r--Game/Code/Classes/UMain.pas5
-rw-r--r--Game/Code/Classes/UMusic.pas64
-rw-r--r--Game/Code/Screens/UScreenScore.pas72
-rw-r--r--Game/Code/Screens/UScreenSing.pas15
-rw-r--r--Game/Code/Screens/UScreenTop.pas3
-rw-r--r--Game/Code/UltraStar.dpr2
7 files changed, 150 insertions, 16 deletions
diff --git a/Game/Code/Classes/ULog.pas b/Game/Code/Classes/ULog.pas
index c870a279..ce6d5f07 100644
--- a/Game/Code/Classes/ULog.pas
+++ b/Game/Code/Classes/ULog.pas
@@ -34,7 +34,7 @@ type
procedure CriticalError(Text: string);
// voice
- procedure LogVoice(SoundNr: Integer; Player, Artist, Title, Points: string);
+ function LogVoice(SoundNr: Integer; Player, Artist, Title, Points: string): string;
// compability
procedure LogStatus(Log1, Log2: string);
@@ -172,7 +172,7 @@ begin
end;
end;
-procedure TLog.LogVoice(SoundNr: Integer; Player, Artist, Title, Points: string);
+function TLog.LogVoice(SoundNr: Integer; Player, Artist, Title, Points: string): string;
type
TRiffHeader = record
riff: Array[0..3] OF Char;
@@ -275,6 +275,7 @@ begin
end;
FS.Free;
+ LogVoice := FileName;
end;
procedure TLog.LogStatus(Log1, Log2: string);
diff --git a/Game/Code/Classes/UMain.pas b/Game/Code/Classes/UMain.pas
index 35c84059..795f2241 100644
--- a/Game/Code/Classes/UMain.pas
+++ b/Game/Code/Classes/UMain.pas
@@ -7,6 +7,7 @@ uses SDL, UGraphic, UMusic, URecord, UTime, SysUtils, UDisplay, UIni, ULog, ULyr
type
TPlayer = record
Name: string;
+ VoiceFile: string; //Recorded Voice
Score: real;
ScoreLine: real;
@@ -70,8 +71,8 @@ type
TStats = record
Player: array of TPlayer;
- SongArtist: UTF8String;
- SongTitle: UTF8String;
+ SongArtist: String;
+ SongTitle: String;
end;
TMedleyPlaylist = record
diff --git a/Game/Code/Classes/UMusic.pas b/Game/Code/Classes/UMusic.pas
index 942c8c81..fbd7fb29 100644
--- a/Game/Code/Classes/UMusic.pas
+++ b/Game/Code/Classes/UMusic.pas
@@ -51,6 +51,8 @@ type
BassShuffle: hStream;
BassApplause: hStream;
+ BassVoices: array of hStream;
+
//Custom Sounds
CustomSounds: array of TCustomSoundEntry;
@@ -93,6 +95,12 @@ type
procedure PlayShuffle;
procedure StopShuffle;
procedure PlayApplause;
+
+ function VoicesOpen(Names: array of string): integer;
+ procedure VoicesPlay;
+ procedure VoicesStop;
+ procedure VoicesClose;
+
procedure CaptureStart;
procedure CaptureStop;
procedure CaptureCard(RecordI, PlayerLeft, PlayerRight: byte);
@@ -313,6 +321,7 @@ begin
Exit;
end;
DSP_VocalRemover := 0;
+ SetLength(BassVoices, 0);
Log.BenchmarkEnd(4); Log.LogBenchmark('--> Bass Init', 4);
// config playing buffer
@@ -481,7 +490,7 @@ end;
function TMusic.Open(Name: string): boolean;
begin
Loaded := false;
-
+
if FileExists(Name) then begin
{ MediaPlayer.FileName := Name;
MediaPlayer.Open;}
@@ -948,4 +957,57 @@ begin
Result := (DSP_VocalRemover <> 0);
end;
+
+function TMusic.VoicesOpen(Names: array of string): integer;
+var
+ I: integer;
+ num: integer;
+
+begin
+ SetLength(BassVoices, 0);
+
+ for I := 0 to high(Names) do
+ begin
+ if FileExists(Names[I]) then
+ begin
+ num := high(BassVoices)+1;
+ SetLength(BassVoices, num+1);
+ BassVoices[num] := Bass_StreamCreateFile(false, pchar(Names[I]), 0, 0, 0);
+ DSP_VocalRemover:=0;
+ end;
+ end;
+
+ Result := high(BassVoices)+1;
+end;
+
+procedure TMusic.VoicesPlay;
+var
+ I: integer;
+begin
+ for I := 0 to high(BassVoices) do
+ begin
+ BASS_ChannelPlay(BassVoices[I], True);
+ end;
+end;
+
+procedure TMusic.VoicesStop;
+var
+ I: integer;
+begin
+ for I := 0 to high(BassVoices) do
+ Bass_ChannelStop(BassVoices[I]);
+end;
+
+
+procedure TMusic.VoicesClose;
+var
+ I: integer;
+begin
+ for I := 0 to high(BassVoices) do
+ begin
+ Bass_StreamFree(BassVoices[I]);
+ DSP_VocalRemover:=0;
+ end;
+ SetLength(BassVoices, 0);
+end;
end.
diff --git a/Game/Code/Screens/UScreenScore.pas b/Game/Code/Screens/UScreenScore.pas
index 917e9d04..daeff363 100644
--- a/Game/Code/Screens/UScreenScore.pas
+++ b/Game/Code/Screens/UScreenScore.pas
@@ -53,7 +53,9 @@ type
Animation: real;
Fadeout: boolean;
- ActualRound: integer;
+ ActualRound: integer;
+ Voice: integer;
+
constructor Create; override;
function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override;
procedure onShow; override;
@@ -61,6 +63,7 @@ type
procedure FillPlayer(Item, P: integer);
procedure RefreshTexts;
procedure StartPreview;
+ procedure StartVoice;
end;
implementation
@@ -118,13 +121,21 @@ begin
// Music.StopShuffle;
if ScreenSong.PartyMedley and (ScreenSong.Mode=smChallenge) then
begin
- ScreenSong.SongIndex := -1;
- Music.FadeStop(Ini.PreviewFading);
+ if not (Ini.SavePlayback=1) then
+ begin
+ ScreenSong.SongIndex := -1;
+ Music.FadeStop(Ini.PreviewFading);
+ end else
+ Music.VoicesClose;
+
FadeTo(@ScreenPartyNewRoundM2);
end else if (ScreenSong.Mode <> smMedley) then
FadeTo(@ScreenTop)
else
begin
+ if (Ini.SavePlayback=1) then
+ Music.VoicesClose;
+
FadeTo(@ScreenSong);
end;
Fadeout := true;
@@ -143,7 +154,10 @@ begin
Music.PlayChange;
inc(ActualRound);
RefreshTexts;
- StartPreview;
+ if not (Ini.SavePlayback=1) then
+ StartPreview
+ else
+ StartVoice;
end;
end;
@@ -154,7 +168,10 @@ begin
Music.PlayChange;
dec(ActualRound);
RefreshTexts;
- StartPreview;
+ if not (Ini.SavePlayback=1) then
+ StartPreview
+ else
+ StartVoice;
end;
end;
end;
@@ -356,7 +373,13 @@ begin
LCD.WriteText(2, 'Score: ' + Text[TextTotalScore[1]].Text);
MP3VolumeHandler.changed := false;
- StartPreview;
+ if not (Ini.SavePlayback=1) then
+ StartPreview
+ else
+ begin
+ Voice := -1;
+ StartVoice;
+ end;
end;
function TScreenScore.Draw: boolean;
@@ -581,4 +604,41 @@ begin
end;
end;
+procedure TScreenSCore.StartVoice;
+var
+ changed: boolean;
+ files: array of string;
+ I: integer;
+
+begin
+ //Music.Close;
+ //ScreenSong.SongIndex := -1;
+ changed := false;
+ if (ScreenSong.Mode = smMedley) or ScreenSong.PartyMedley then
+ begin
+ if (ActualRound<Length(PlaylistMedley.Stats)-1) and (Voice <> ActualRound) then
+ begin
+ Voice := ActualRound;
+ changed := true;
+ SetLength(files, PlaylistMedley.NumPlayer);
+ for I := 0 to Length(files) - 1 do
+ files[I] := PlaylistMedley.Stats[Voice].Player[I].VoiceFile;
+ end;
+ end else
+ begin
+ Voice := 0;
+ changed := true;
+ SetLength(files, PlayersPlay);
+ for I := 0 to Length(files) - 1 do
+ files[I] := Player[I].VoiceFile;
+ end;
+
+ if changed then
+ begin
+ Music.VoicesClose;
+ if (Music.VoicesOpen(files)>0) then
+ Music.VoicesPlay;
+ end;
+end;
+
end.
diff --git a/Game/Code/Screens/UScreenSing.pas b/Game/Code/Screens/UScreenSing.pas
index 9bd89339..0469a017 100644
--- a/Game/Code/Screens/UScreenSing.pas
+++ b/Game/Code/Screens/UScreenSing.pas
@@ -814,7 +814,7 @@ end;
procedure TScreenSing.LoadNextSong;
var
- P: integer;
+ P, I: integer;
numNotes: integer;
begin
// load notes
@@ -824,6 +824,10 @@ begin
begin
CatSongs.Selected := PlaylistMedley.Song[PlaylistMedley.CurrentMedleySong-1];
Music.Open(CatSongs.Song[CatSongs.Selected].Path + CatSongs.Song[CatSongs.Selected].Mp3);
+ end else
+ begin
+ for I := 0 to PlayersPlay - 1 do
+ Player[I].VoiceFile := '';
end;
AktSong := CatSongs.Song[CatSongs.Selected];
@@ -1409,13 +1413,14 @@ begin
if Ini.SavePlayback = 1 then begin
Log.BenchmarkStart(0);
+
for I := 0 to PlayersPlay - 1 do
begin
points := IntToStr(Player[I].ScoreTotalI);
while Length(points) < 5 do
points := '0'+points;
-
- Log.LogVoice(I, Ini.Name[I], AktSong.Artist, AktSong.Title, points);
+
+ Player[I].VoiceFile := Log.LogVoice(I, Ini.Name[I], AktSong.Artist, AktSong.Title, points);
end;
Log.BenchmarkEnd(0);
@@ -1433,10 +1438,12 @@ begin
begin
if not FadeOut then
begin
+ for I := 0 to PlayersPlay - 1 do
+ PlaylistMedley.Stats[Length(PlaylistMedley.Stats)-1].Player[I] := Player[I];
+
inc(PlaylistMedley.CurrentMedleySong);
if PlaylistMedley.CurrentMedleySong<=PlaylistMedley.NumMedleySongs then
begin
- //AudioPlayback.PlaySound(SoundLib.Applause);
LoadNextSong;
end else
begin
diff --git a/Game/Code/Screens/UScreenTop.pas b/Game/Code/Screens/UScreenTop.pas
index e74507b9..a7085b36 100644
--- a/Game/Code/Screens/UScreenTop.pas
+++ b/Game/Code/Screens/UScreenTop.pas
@@ -85,6 +85,9 @@ begin
SDLK_BACKSPACE,
SDLK_RETURN:
begin
+ if (Ini.SavePlayback=1) then
+ Music.VoicesClose;
+
if (not Fadeout) then begin
if(ScreenSong.Mode = smNormal) or (ScreenSong.Mode = smMedley) then
FadeTo(@ScreenSong)
diff --git a/Game/Code/UltraStar.dpr b/Game/Code/UltraStar.dpr
index ac5eeb89..fb7d57ff 100644
--- a/Game/Code/UltraStar.dpr
+++ b/Game/Code/UltraStar.dpr
@@ -124,7 +124,7 @@ uses
acinerella in 'lib\acinerella\acinerella.pas';
const
- Version = 'UltraStar Deluxe v1.0.1a Challenge-MOD r7 alpha 2010-02-22';
+ Version = 'UltraStar Deluxe v1.0.1a Challenge-MOD r7 alpha 3 2010-02-24';
var
WndTitle: string;