diff options
author | jaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2007-09-18 13:19:20 +0000 |
---|---|---|
committer | jaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2007-09-18 13:19:20 +0000 |
commit | 433a1b7339e2bf96f3b0bb4c98b8c799c6540027 (patch) | |
tree | a448ca19c45319152f3d9a33f53a419c59908ede /Game/Code/Classes | |
parent | 067444c467e9f3e4dca07ecf10818023140c2873 (diff) | |
download | usdx-433a1b7339e2bf96f3b0bb4c98b8c799c6540027.tar.gz usdx-433a1b7339e2bf96f3b0bb4c98b8c799c6540027.tar.xz usdx-433a1b7339e2bf96f3b0bb4c98b8c799c6540027.zip |
changes in order to compile in lazarus...
minor tidy ups and removal of big old comment blocks..
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@394 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code/Classes')
-rw-r--r-- | Game/Code/Classes/UDLLManager.pas | 9 | ||||
-rw-r--r-- | Game/Code/Classes/UDataBase.pas | 5 | ||||
-rw-r--r-- | Game/Code/Classes/UDraw.pas | 10 | ||||
-rw-r--r-- | Game/Code/Classes/UGraphic.pas | 76 | ||||
-rw-r--r-- | Game/Code/Classes/UIni.pas | 7 | ||||
-rw-r--r-- | Game/Code/Classes/ULanguage.pas | 5 | ||||
-rw-r--r-- | Game/Code/Classes/ULight.pas | 28 | ||||
-rw-r--r-- | Game/Code/Classes/UMain.pas | 5 | ||||
-rw-r--r-- | Game/Code/Classes/UParty.pas | 5 | ||||
-rw-r--r-- | Game/Code/Classes/UPlaylist.pas | 5 | ||||
-rw-r--r-- | Game/Code/Classes/URecord.pas | 117 | ||||
-rw-r--r-- | Game/Code/Classes/USkins.pas | 5 | ||||
-rw-r--r-- | Game/Code/Classes/UTexture.pas | 5 | ||||
-rw-r--r-- | Game/Code/Classes/UVideo.pas | 27 |
14 files changed, 226 insertions, 83 deletions
diff --git a/Game/Code/Classes/UDLLManager.pas b/Game/Code/Classes/UDLLManager.pas index 4b8838b9..0d328c37 100644 --- a/Game/Code/Classes/UDLLManager.pas +++ b/Game/Code/Classes/UDLLManager.pas @@ -1,7 +1,14 @@ unit UDLLManager;
+{$IFDEF FPC}
+ {$MODE DELPHI}
+{$ENDIF}
+
+
interface
-uses ModiSDK, UFiles;
+
+uses ModiSDK,
+ UFiles;
type
TDLLMan = class
diff --git a/Game/Code/Classes/UDataBase.pas b/Game/Code/Classes/UDataBase.pas index b8b41bc1..009d0d63 100644 --- a/Game/Code/Classes/UDataBase.pas +++ b/Game/Code/Classes/UDataBase.pas @@ -2,6 +2,11 @@ unit UDataBase; interface
+{$IFDEF FPC}
+ {$MODE DELPHI}
+{$ENDIF}
+
+
uses USongs, SQLiteTable3;
//--------------------
diff --git a/Game/Code/Classes/UDraw.pas b/Game/Code/Classes/UDraw.pas index 94617583..cbfafbe6 100644 --- a/Game/Code/Classes/UDraw.pas +++ b/Game/Code/Classes/UDraw.pas @@ -1,7 +1,15 @@ unit UDraw;
interface
-uses UThemes, ModiSDK, UGraphicClasses, dialogs;
+
+{$IFDEF FPC}
+ {$MODE DELPHI}
+{$ENDIF}
+
+uses UThemes,
+ ModiSDK,
+ UGraphicClasses;
+ // dialogs;
procedure SingDraw;
procedure SingModiDraw (PlayerInfo: TPlayerInfo);
diff --git a/Game/Code/Classes/UGraphic.pas b/Game/Code/Classes/UGraphic.pas index 0c022b8f..eb7dde8e 100644 --- a/Game/Code/Classes/UGraphic.pas +++ b/Game/Code/Classes/UGraphic.pas @@ -1,16 +1,59 @@ unit UGraphic;
interface
+
+{$IFDEF FPC}
+ {$MODE DELPHI}
+{$ENDIF}
+
uses
- SDL, OpenGL12, UTexture, TextGL, ULog, SysUtils, ULyrics, UScreenLoading,
- UScreenWelcome, UScreenMain, UScreenName, UScreenLevel, UScreenOptions, UScreenOptionsGame,
- UScreenOptionsGraphics, UScreenOptionsSound, UScreenOptionsLyrics, UScreenOptionsThemes, UScreenOptionsRecord, UScreenOptionsAdvanced,
- UScreenSong, UScreenSing, UScreenScore, UScreenTop5, UScreenEditSub,
- UScreenEdit, UScreenEditConvert, UScreenEditHeader, UScreenOpen, UThemes, USkins, UScreenSongMenu, UScreenSongJumpto,
- {Party Screens} UScreenSingModi, UScreenPartyNewRound, UScreenPartyScore, UScreenPartyOptions, UScreenPartyWin, UScreenPartyPlayer,
- {Stats Screens} UScreenStatMain, UScreenStatDetail,
- {CreditsScreen} UScreenCredits,
- {Popup for errors, etc.} UScreenPopup;
+ SDL,
+ OpenGL12,
+ UTexture,
+ TextGL,
+ ULog,
+ SysUtils,
+ ULyrics,
+ UScreenLoading,
+ UScreenWelcome,
+ UScreenMain,
+ UScreenName,
+ UScreenLevel,
+ UScreenOptions,
+ UScreenOptionsGame,
+ UScreenOptionsGraphics,
+ UScreenOptionsSound,
+ UScreenOptionsLyrics,
+ UScreenOptionsThemes,
+ UScreenOptionsRecord,
+ UScreenOptionsAdvanced,
+ UScreenSong,
+ UScreenSing,
+ UScreenScore,
+ UScreenTop5,
+ UScreenEditSub,
+ UScreenEdit,
+ UScreenEditConvert,
+ UScreenEditHeader,
+ UScreenOpen,
+ UThemes,
+ USkins,
+ UScreenSongMenu,
+ UScreenSongJumpto,
+ {Party Screens}
+ UScreenSingModi,
+ UScreenPartyNewRound,
+ UScreenPartyScore,
+ UScreenPartyOptions,
+ UScreenPartyWin,
+ UScreenPartyPlayer,
+ {Stats Screens}
+ UScreenStatMain,
+ UScreenStatDetail,
+ {CreditsScreen}
+ UScreenCredits,
+ {Popup for errors, etc.}
+ UScreenPopup;
type
TRecR = record
@@ -188,9 +231,20 @@ function LoadingThreadFunction: integer; implementation
-uses UMain, UIni, UDisplay, UCommandLine, Graphics, Classes, Windows;
+
+uses UMain,
+ UIni,
+ UDisplay,
+ UCommandLine,
+ {$IFNDEF FPC}
+ Graphics,
+ {$ENDIF}
+ Classes,
+ Windows;
procedure LoadTextures;
+
+
var
P: integer;
R, G, B: real;
@@ -253,7 +307,7 @@ end; procedure Initialize3D (Title: string);
var
- Icon: TIcon;
+// Icon: TIcon;
Res: TResourceStream;
ISurface: PSDL_Surface;
Pixel: PByteArray;
diff --git a/Game/Code/Classes/UIni.pas b/Game/Code/Classes/UIni.pas index 67649a51..cd5c3716 100644 --- a/Game/Code/Classes/UIni.pas +++ b/Game/Code/Classes/UIni.pas @@ -1,6 +1,11 @@ unit UIni;
interface
+
+{$IFDEF FPC}
+ {$MODE DELPHI}
+{$ENDIF}
+
uses IniFiles, ULog, SysUtils;
type
@@ -768,4 +773,4 @@ begin end;
end;
-end.
\ No newline at end of file +end.
diff --git a/Game/Code/Classes/ULanguage.pas b/Game/Code/Classes/ULanguage.pas index 5deed1f7..f693694b 100644 --- a/Game/Code/Classes/ULanguage.pas +++ b/Game/Code/Classes/ULanguage.pas @@ -2,6 +2,11 @@ unit ULanguage; interface
+{$IFDEF FPC}
+ {$MODE DELPHI}
+{$ENDIF}
+
+
type
TLanguageEntry = record
ID: string;
diff --git a/Game/Code/Classes/ULight.pas b/Game/Code/Classes/ULight.pas index b9c7af9e..74681a85 100644 --- a/Game/Code/Classes/ULight.pas +++ b/Game/Code/Classes/ULight.pas @@ -36,6 +36,32 @@ uses zlportio,
{$ENDIF}
UTime;
+
+{$IFDEF FPC}
+ function GetTime: TDateTime;
+ {$IFDEF MSWINDOWS}
+ var
+ SystemTime: TSystemTime;
+ begin
+ GetLocalTime(SystemTime);
+ with SystemTime do
+ Result := EncodeTime(wHour, wMinute, wSecond, wMilliSeconds);
+ end;
+ {$ENDIF}
+ {$IFDEF LINUX}
+ var
+ T: TTime_T;
+ TV: TTimeVal;
+ UT: TUnixTime;
+ begin
+ gettimeofday(TV, nil);
+ T := TV.tv_sec;
+ localtime_r(@T, UT);
+ Result := EncodeTime(UT.tm_hour, UT.tm_min, UT.tm_sec, TV.tv_usec div 1000);
+ end;
+ {$ENDIF}
+{$ENDIF}
+
constructor TLight.Create;
begin
@@ -44,7 +70,7 @@ end; procedure TLight.Enable;
begin
- Enabled := true;
+ Enabled := true;
LastTime := GetTime;
end;
diff --git a/Game/Code/Classes/UMain.pas b/Game/Code/Classes/UMain.pas index e89b4785..646724df 100644 --- a/Game/Code/Classes/UMain.pas +++ b/Game/Code/Classes/UMain.pas @@ -1,6 +1,11 @@ unit UMain;
interface
+
+{$IFDEF FPC}
+ {$MODE Delphi}
+{$ENDIF}
+
{$I switches.inc}
uses SDL, UGraphic, UMusic, URecord, UTime, SysUtils, UDisplay, UIni, ULog, ULyrics, UScreenSing,
diff --git a/Game/Code/Classes/UParty.pas b/Game/Code/Classes/UParty.pas index 7bf3dd1b..9be0df3e 100644 --- a/Game/Code/Classes/UParty.pas +++ b/Game/Code/Classes/UParty.pas @@ -2,6 +2,11 @@ unit UParty; interface
+{$IFDEF FPC}
+ {$MODE DELPHI}
+{$ENDIF}
+
+
uses ModiSDK;
type
diff --git a/Game/Code/Classes/UPlaylist.pas b/Game/Code/Classes/UPlaylist.pas index 1e517ef7..3f89ffed 100644 --- a/Game/Code/Classes/UPlaylist.pas +++ b/Game/Code/Classes/UPlaylist.pas @@ -2,6 +2,11 @@ unit UPlaylist; interface
+{$IFDEF FPC}
+ {$MODE DELPHI}
+{$ENDIF}
+
+
type
TPlaylistItem = record
Artist: String;
diff --git a/Game/Code/Classes/URecord.pas b/Game/Code/Classes/URecord.pas index 6ce83c0a..03c87a35 100644 --- a/Game/Code/Classes/URecord.pas +++ b/Game/Code/Classes/URecord.pas @@ -1,7 +1,13 @@ unit URecord;
interface
-uses Classes, Math, SysUtils, {DXSounds, Wave, }UMusic, UIni, BASS;
+
+uses Classes,
+ Math,
+ SysUtils,
+ UMusic,
+ UIni,
+ BASS;
type
TSound = class
@@ -11,8 +17,6 @@ type Num: integer;
n: integer; // length of Signal to analyze
-// Spectrum: array[1..8192] of single; // sound buffer from above as FFT
-// Spektogram: array[0..100] of TSpekt; // FFT(t)
// pitch detection
SzczytJest: boolean; // czy jest szczyt
@@ -63,7 +67,7 @@ var Recording: TRecord;
implementation
-uses UMain, ULog;
+uses UMain;
procedure TSound.ProcessNewBuffer;
var
@@ -87,7 +91,8 @@ begin BufferNew.ReadBuffer(BufferArray[1+n-L], 2*L);
// process BufferLong
- if Ini.SavePlayback = 1 then begin
+ if Ini.SavePlayback = 1 then
+ begin
BufferNew.Seek(0, soBeginning);
BufferLong[0].CopyFrom(BufferNew, BufferNew.Size);
end;
@@ -110,32 +115,29 @@ var S: integer; // Signal
Threshold: real; // threshold
begin
-// Log.LogAnalyze('[Analyze by Autocorrelation]');
SzczytJest := false;
// find maximum volume of first 1024 words of signal
MaxV := 0;
- for S := 1 to 1024 do begin // 0.5.2: fix. was from 0 to 1023
-// Log.LogDebug('1');
-// Log.LogDebug(IntTostr(S));
+ for S := 1 to 1024 do // 0.5.2: fix. was from 0 to 1023
+ begin
V := Abs(BufferArray[S]) / $10000;
-// Log.LogDebug('2');
-// Log.LogDebug(IntTostr(S) + ': ' + FloatToStr(V) + ', MaxV='+floattostr(maxv)+', buf='+inttostr(length(BufferArray)));
- if V > MaxV then MaxV := V;
-// Log.LogDebug('3');
-// Log.LogDebug(IntTostr(S) + ': ' + FloatToStr(V) + ', MaxV='+floattostr(maxv)+', buf='+inttostr(length(BufferArray)));
- end;
+ if V > MaxV then
+ MaxV := V;
+ end;
// prepare to analyze
MaxW := 0;
// analyze all 12 halftones
- for T := 0 to 35 do begin // to 11, then 23, now 35 (for Whitney and my high voice)
+ for T := 0 to 35 do // to 11, then 23, now 35 (for Whitney and my high voice)
+ begin
F := 130.81*Power(1.05946309436, T)/2; // let's analyze below 130.81
Wages[T] := AnalyzeAutocorrelationFreq(F);
- if Wages[T] > MaxW then begin // this frequency has better wage
+ if Wages[T] > MaxW then
+ begin // this frequency has better wage
MaxW := Wages[T];
MaxT := T;
end;
@@ -149,20 +151,13 @@ begin 3: Threshold := 0.2;
end;
- //Log.LogDebug('Sound -> AnalyzeByAutocorrelation: MaxV='+floattostr(maxv)+', Threshold='+floattostr(threshold));
- if MaxV >= Threshold then begin // found acceptable volume // 0.1
+ if MaxV >= Threshold then
+ begin // found acceptable volume // 0.1
SzczytJest := true;
TonGamy := MaxT mod 12;
Ton := MaxT mod 12;
end;
-// Log.LogAnalyze('--> Weight: ')
-// Log.LogAnalyze('--> Selected: ' + BoolToStr(SzczytJest, true) +
-// ', TonGamy: ' + IntToStr(Ton) +
-// ', MaxV: ' + FloatToStr(MaxV));
-// Log.LogAnalyze('');
-
-
end;
function TSound.AnalyzeAutocorrelationFreq(Freq: real): real; // result medium difference
@@ -175,25 +170,14 @@ var begin
// we use Signal as source
Count := 0;
- Il := 0;
- Src := 1;
- Move := Round(44100/Freq);
- Dst := Src + Move;
-
- // ver 1 - sample 1 and compare n-times
-{ while (Src <= Move) do begin // process by moving Src by one
- while (Dst < n) do begin // process up to n (4KB) of Signal
- Count := Count + Abs(Signal[Src] - Signal[Dst]) / $10000;
- Inc(Dst, Move);
- Inc(Il);
- end;
-
- Inc(Src);
- Dst := Src + Move;
- end;}
+ Il := 0;
+ Src := 1;
+ Move := Round(44100/Freq);
+ Dst := Src + Move;
// ver 2 - compare in vertical
- while (Dst < n) do begin // process up to n (4KB) of Signal
+ while (Dst < n) do
+ begin // process up to n (4KB) of Signal
Count := Count + Abs(BufferArray[Src] - BufferArray[Dst]) / $10000;
Inc(Src);
Inc(Dst);
@@ -208,8 +192,6 @@ var L: integer;
S: integer;
PB: pbytearray;
- PW: pwordarray;
- SI: smallintarray;
PSI: psmallintarray;
I: integer;
Skip: integer;
@@ -217,8 +199,6 @@ var P2: integer;
Boost: byte;
begin
-// Log.LogDebug('Record -> GetMicrophone: len='+inttstr(len));
-
// set boost
case Ini.MicBoost of
0: Boost := 1;
@@ -230,7 +210,8 @@ begin // boost buffer
L := Len div 2; // number of samples
PSI := Buffer;
- for S := 0 to L-1 do begin
+ for S := 0 to L-1 do
+ begin
I := PSI^[S] * Boost;
if I > 32767 then I := 32767; // 0.5.0: limit
if I < -32768 then I := -32768; // 0.5.0: limit
@@ -241,37 +222,36 @@ begin P1 := (user and 255) - 1;
P2 := (user div 256) - 1;
-// Log.LogDebug('Record -> GetMicrophone: P1='+inttostr(p1)+', P2='+inttostr(p2));
// 2 players USB mic, left channel
- if P1 >= 0 then begin
- L := Len div 4; // number of samples
+ if P1 >= 0 then
+ begin
+ L := Len div 4; // number of samples
PB := Buffer;
-// Log.LogDebug('Record -> GetMicrophone -> Sound[P1].BufferNew.Clear');
+
Sound[P1].BufferNew.Clear; // 0.5.2: problem on exiting
- for S := 1 to L do begin
+ for S := 1 to L do
+ begin
Sound[P1].BufferNew.Write(PB[(S-1)*4], 2);
end;
Sound[P1].ProcessNewBuffer;
end;
// 2 players USB mic, right channel
-// if Ini.Debug = 0 then Skip := 2
-// else Skip := 0;
Skip := 2;
- if P2 >= 0 then begin
+ if P2 >= 0 then
+ begin
L := Len div 4; // number of samples
PB := Buffer;
Sound[P2].BufferNew.Clear;
- for S := 1 to L do begin
+ for S := 1 to L do
+ begin
Sound[P2].BufferNew.Write(PB[Skip + (S-1)*4], 2);
end;
Sound[P2].ProcessNewBuffer;
end;
-// Log.LogDebug('Record -> GetMicrophone -> Finish');
-
Result := true;
end;
@@ -283,6 +263,7 @@ var InputName: PChar;
Flags: integer;
No: integer;
+
function isDuplicate(Desc: String): Boolean;
var
I: Integer;
@@ -306,15 +287,17 @@ begin SC := 0;
Descr := BASS_RecordGetDeviceDescription(SC);
- while (Descr <> '') do begin
+ while (Descr <> '') do
+ begin
//If there is another SoundCard with the Same ID, Search an available Name
if (IsDuplicate(Descr)) then
begin
No:= 1; //Count of SoundCards with same Name
Repeat
- Inc(No)
+ Inc(No)
Until not IsDuplicate(Descr + ' (' + InttoStr(No) + ')');
+
//Set Description
Descr := Descr + ' (' + InttoStr(No) + ')';
end;
@@ -333,12 +316,12 @@ begin SoundCard[SC].Input[SCI].Name := InputName;
// process each input
- while (InputName <> nil) do begin
+ while (InputName <> nil) do
+ begin
Flags := BASS_RecordGetInput(SCI);
- if (SCI >= 1) {AND (Flags AND BASS_INPUT_OFF = 0)} then begin
-
+ if (SCI >= 1) {AND (Flags AND BASS_INPUT_OFF = 0)} then
+ begin
SetLength(SoundCard[SC].Input, SCI+1);
-
SoundCard[SC].Input[SCI].Name := InputName;
end;
@@ -346,18 +329,18 @@ begin if ((Flags and BASS_INPUT_TYPE_MIC) = 1) then
SoundCard[SC].MicInput := SCI;
-
Inc(SCI);
InputName := BASS_RecordGetInputName(SCI);
end;
-
BASS_RecordFree;
Inc(SC);
Descr := BASS_RecordGetDeviceDescription(SC);
end; // while
end;
+
+
end.
diff --git a/Game/Code/Classes/USkins.pas b/Game/Code/Classes/USkins.pas index 3bcd9357..a5f618ff 100644 --- a/Game/Code/Classes/USkins.pas +++ b/Game/Code/Classes/USkins.pas @@ -1,5 +1,10 @@ unit USkins;
+{$IFDEF FPC}
+ {$MODE DELPHI}
+{$ENDIF}
+
+
interface
type
diff --git a/Game/Code/Classes/UTexture.pas b/Game/Code/Classes/UTexture.pas index f79f66d6..d1ca0917 100644 --- a/Game/Code/Classes/UTexture.pas +++ b/Game/Code/Classes/UTexture.pas @@ -1,5 +1,10 @@ unit UTexture;
+{$IFDEF FPC}
+ {$MODE DELPHI}
+{$ENDIF}
+
+
// Plain (alpha = 1)
// Transparent
// Transparent Range
diff --git a/Game/Code/Classes/UVideo.pas b/Game/Code/Classes/UVideo.pas index 8e2fc446..c97057ac 100644 --- a/Game/Code/Classes/UVideo.pas +++ b/Game/Code/Classes/UVideo.pas @@ -5,6 +5,10 @@ # based on 'An ffmpeg and SDL Tutorial' (http://www.dranger.com/ffmpeg/) #
#############################################################################}
+{$IFDEF FPC}
+ {$MODE DELPHI}
+{$ENDIF}
+
//{$define DebugDisplay} // uncomment if u want to see the debug stuff
{$define DebugFrames}
{$define Info}
@@ -13,7 +17,20 @@ unit UVideo;
interface
-uses SDL, UGraphicClasses, textgl, avcodec, avformat, avutil, math, OpenGL12, SysUtils, UIni, dialogs;
+
+uses SDL,
+ UGraphicClasses,
+ textgl,
+ avcodec,
+ avformat,
+ avutil,
+ math,
+ OpenGL12,
+ SysUtils,
+ {$ifdef DebugDisplay}
+ dialogs,
+ {$ENDIF}
+ UIni;
procedure Init;
procedure FFmpegOpenFile(FileName: pAnsiChar);
@@ -64,6 +81,7 @@ begin errnum:=av_open_input_file(VideoFormatContext, FileName, Nil, 0, Nil);
if(errnum <> 0)
then begin
+{$ifdef DebugDisplay}
case errnum of
AVERROR_UNKNOWN: showmessage('failed to open file '+Filename+#13#10+'AVERROR_UNKNOWN');
AVERROR_IO: showmessage('failed to open file '+Filename+#13#10+'AVERROR_IO');
@@ -74,6 +92,7 @@ begin AVERROR_NOTSUPP: showmessage('failed to open file '+Filename+#13#10+'AVERROR_NOTSUPP');
else showmessage('failed to open file '+Filename+#13#10+'Error number: '+inttostr(Errnum));
end;
+{$ENDIF}
Exit;
end
else begin
@@ -90,7 +109,9 @@ begin VideoCodecContext:=VideoFormatContext^.streams[VideoStreamIndex]^.codec;
VideoCodec:=avcodec_find_decoder(VideoCodecContext^.codec_id);
end else begin
+{$ifdef DebugDisplay}
showmessage('found no video stream');
+{$ENDIF}
av_close_input_file(VideoFormatContext);
Exit;
end;
@@ -98,7 +119,9 @@ begin begin
errnum:=avcodec_open(VideoCodecContext, VideoCodec);
end else begin
+{$ifdef DebugDisplay}
showmessage('no matching codec found');
+{$ENDIF}
avcodec_close(VideoCodecContext);
av_close_input_file(VideoFormatContext);
Exit;
@@ -125,7 +148,9 @@ begin if myBuffer <> Nil then errnum:=avpicture_fill(PAVPicture(AVFrameRGB), myBuffer, PIX_FMT_RGB24,
VideoCodecContext^.width, VideoCodecContext^.height)
else begin
+{$ifdef DebugDisplay}
showmessage('failed to allocate video buffer');
+{$endif}
av_free(AVFrameRGB);
av_free(AVFrame);
avcodec_close(VideoCodecContext);
|