From 3e561cd4fd1eb46590cb70aaf940f7775a855966 Mon Sep 17 00:00:00 2001 From: brunzelchen Date: Tue, 21 Dec 2010 17:51:42 +0000 Subject: 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 --- Game/Code/Classes/URecord.pas | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'Game/Code/Classes/URecord.pas') 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: ') -- cgit v1.2.3