diff options
author | brunzelchen <brunzelchen@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-12-21 17:51:42 +0000 |
---|---|---|
committer | brunzelchen <brunzelchen@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-12-21 17:51:42 +0000 |
commit | 3e561cd4fd1eb46590cb70aaf940f7775a855966 (patch) | |
tree | a8e390ab9e5ab7103aa488d05dfd272863c6757a /Game/Code/Classes | |
parent | e32e65d0272f98e47dbbb7c5a0a33566d791e5d4 (diff) | |
download | usdx-3e561cd4fd1eb46590cb70aaf940f7775a855966.tar.gz usdx-3e561cd4fd1eb46590cb70aaf940f7775a855966.tar.xz usdx-3e561cd4fd1eb46590cb70aaf940f7775a855966.zip |
added pitch detection for editor
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/1.0.1 Challenge MOD@2765 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code/Classes')
-rw-r--r-- | Game/Code/Classes/UMain.pas | 24 | ||||
-rw-r--r-- | Game/Code/Classes/UMusic.pas | 8 | ||||
-rw-r--r-- | Game/Code/Classes/URecord.pas | 18 |
3 files changed, 37 insertions, 13 deletions
diff --git a/Game/Code/Classes/UMain.pas b/Game/Code/Classes/UMain.pas index e1205cd8..bc3ac1b0 100644 --- a/Game/Code/Classes/UMain.pas +++ b/Game/Code/Classes/UMain.pas @@ -605,17 +605,17 @@ begin Czesci[P].Czesc[S].Nuta[Pet].Dlugosc > BRange) then
begin
// przesuwanie tonu w odpowiednia game => shifting tone in the corresponding game?
- while (Sound[CP].Ton - Czesci[P].Czesc[S].Nuta[Pet].Ton > 6) do
- Sound[CP].Ton := Sound[CP].Ton - 12;
- while (Sound[CP].Ton - Czesci[P].Czesc[S].Nuta[Pet].Ton < -6) do
- Sound[CP].Ton := Sound[CP].Ton + 12;
+ while (Sound[CP].TonGamy - Czesci[P].Czesc[S].Nuta[Pet].Ton > 6) do
+ Sound[CP].TonGamy := Sound[CP].TonGamy - 12;
+ while (Sound[CP].TonGamy - Czesci[P].Czesc[S].Nuta[Pet].Ton < -6) do
+ Sound[CP].TonGamy := Sound[CP].TonGamy + 12;
// Half size Notes Patch
NoteHit := false;
- AktTon := Sound[CP].Ton;
+ AktTon := Sound[CP].TonGamy;
Range := 2 - Ini.Difficulty;
- if (abs(Czesci[P].Czesc[S].Nuta[Pet].Ton - Sound[CP].Ton) <= Range) or
+ if (abs(Czesci[P].Czesc[S].Nuta[Pet].Ton - Sound[CP].TonGamy) <= Range) or
DEBUG_NOTE_HIT then
begin
AktTon := Czesci[P].Czesc[S].Nuta[Pet].Ton;
@@ -784,17 +784,17 @@ begin Czesci[P].Czesc[S].Nuta[Pet].Dlugosc > BRange) then
begin
// przesuwanie tonu w odpowiednia game
- while (Sound[CP].Ton - Czesci[P].Czesc[S].Nuta[Pet].Ton > 6) do
- Sound[CP].Ton := Sound[CP].Ton - 12;
- while (Sound[CP].Ton - Czesci[P].Czesc[S].Nuta[Pet].Ton < -6) do
- Sound[CP].Ton := Sound[CP].Ton + 12;
+ while (Sound[CP].TonGamy - Czesci[P].Czesc[S].Nuta[Pet].Ton > 6) do
+ Sound[CP].TonGamy := Sound[CP].TonGamy - 12;
+ while (Sound[CP].TonGamy - Czesci[P].Czesc[S].Nuta[Pet].Ton < -6) do
+ Sound[CP].TonGamy := Sound[CP].TonGamy + 12;
// Half size Notes Patch
NoteHit := false;
- AktTon := Sound[CP].Ton;
+ AktTon := Sound[CP].TonGamy;
Range := 2 - Ini.Difficulty;
- if (abs(Czesci[P].Czesc[S].Nuta[Pet].Ton - Sound[CP].Ton) <= Range) or
+ if (abs(Czesci[P].Czesc[S].Nuta[Pet].Ton - Sound[CP].TonGamy) <= Range) or
DEBUG_NOTE_HIT then
begin
AktTon := Czesci[P].Czesc[S].Nuta[Pet].Ton;
diff --git a/Game/Code/Classes/UMusic.pas b/Game/Code/Classes/UMusic.pas index d192927e..1ce421b8 100644 --- a/Game/Code/Classes/UMusic.pas +++ b/Game/Code/Classes/UMusic.pas @@ -60,6 +60,7 @@ type Loaded: boolean;
Loop: boolean;
+ CaptureStarted: boolean;
// DXSound: TDXSound;
// Player: TcmxMp3;
DSP_VocalRemover: HDSP;
@@ -415,6 +416,7 @@ var S: integer;
begin
+ CaptureStarted := false;
if RecordSystem = 1 then begin
SetLength(Sound, 6 {max players});//Ini.Players+1);
for S := 0 to High(Sound) do begin //Ini.Players do begin
@@ -771,6 +773,9 @@ var P1: integer;
P2: integer;
begin
+ if CaptureStarted then
+ Exit;
+
for S := 0 to High(Sound) do
Sound[S].BufferLong[0].Clear;
@@ -785,6 +790,8 @@ begin if (P1 > 0) or (P2 > 0) then
CaptureCard(SC);
end;
+
+ CaptureStarted := true;
end;
procedure TMusic.CaptureStop;
@@ -800,6 +807,7 @@ begin if P2 > PlayersPlay then P2 := 0;
if (P1 > 0) or (P2 > 0) then StopCard(SC);
end;
+ CaptureStarted := false;
end;
//procedure TMusic.CaptureCard(RecordI, SoundNum, PlayerLeft, PlayerRight: byte);
diff --git a/Game/Code/Classes/URecord.pas b/Game/Code/Classes/URecord.pas index 7354d931..57919fe1 100644 --- a/Game/Code/Classes/URecord.pas +++ b/Game/Code/Classes/URecord.pas @@ -27,6 +27,7 @@ type procedure AnalizujBufor; // use to analyze sound from buffers to get new pitch
procedure AnalizujByAutocorrelation; // we call it to analyze sound by checking Autocorrelation
function AnalyzeAutocorrelationFreq(Freq: real): real; // use this to check one frequency by Autocorrelation
+ function GetToneString: string; //from usdx 1.1
end;
TSoundCardInput = record
@@ -61,9 +62,24 @@ var Poz: integer;
Recording: TRecord;
+const
+ // from usdx 1.1
+ ToneStrings: array[0..11] of string = (
+ 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'
+ );
+
implementation
uses UMain, ULog;
+// from usdx 1.1
+function TSound.GetToneString: string;
+begin
+ if (SzczytJest) then
+ Result := ToneStrings[TonGamy] + IntToStr(Ton div 12 + 2)
+ else
+ Result := '-';
+end;
+
procedure TSound.ProcessNewBuffer;
var
S: integer;
@@ -153,7 +169,7 @@ begin if MaxV >= Threshold then begin // found acceptable volume // 0.1
SzczytJest := true;
TonGamy := MaxT mod 12;
- Ton := MaxT mod 12;
+ Ton := MaxT;
end;
// Log.LogAnalyze('--> Weight: ')
|