diff --git a/RendererUI/ViewModels/MainWindowViewModel.cs b/RendererUI/ViewModels/MainWindowViewModel.cs index 751e37a..1b53875 100644 --- a/RendererUI/ViewModels/MainWindowViewModel.cs +++ b/RendererUI/ViewModels/MainWindowViewModel.cs @@ -56,6 +56,16 @@ public bool UseImaginaryAndRealAverage this.RaisePropertyChanged(); } } + + public bool UsePleaseHelpMe + { + get => _renderer.UsePleaseHelpMe; + set + { + _renderer.UsePleaseHelpMe = value; + this.RaisePropertyChanged(); + } + } [Reactive] public ObservableCollection FFTWindows { get; set; } = new(); [Reactive] public string SelectedFFTWindow { get; set; } @@ -123,9 +133,10 @@ public async Task BrowseForOutputPathAsync() } } - public void RenderSongAsync() + public async Task RenderSongAsync() { ShowDoneText = false; + await Task.Delay(1000); if (!File.Exists(FileToRender) || !Directory.Exists(OutputPath)) { OutputText = "Invalid file or output path"; diff --git a/RendererUI/Views/MainWindow.axaml b/RendererUI/Views/MainWindow.axaml index 2771366..6b150b2 100644 --- a/RendererUI/Views/MainWindow.axaml +++ b/RendererUI/Views/MainWindow.axaml @@ -56,6 +56,8 @@ SelectedItem="{Binding SelectedFFTWindow}"/> + - DecodeSongSums(string path) { var fft = new float[_fftResolution]; - var could = Bass.Init(); - Console.WriteLine("Bass.Init returned " + could); var chan = Bass.CreateStream(path, Flags: BassFlags.Decode | BassFlags.Float | BassFlags.Prescan); Console.WriteLine("Prescan2 complete"); @@ -178,6 +181,34 @@ private float FastDecodeStepAsync(int chan, float[] ffts) FastFourierTransform.FFT(false, (int)Math.Log(_fftResolution, 2.0), ref complexFFTs); + + if (UsePleaseHelpMe) + { + //get avg of real and imaginary parts + //var avg = (ulong)complexFFTs[i]; + var the3CThing = new Complex(); + complexFFTs[0] = new Complex(0, 0); + complexFFTs[1] = new Complex(0, 0); + for (var i = 0; i < complexFFTs.Length; i++) + { + var current = complexFFTs[i]; + var next = new Complex(); + if (i + 1 < complexFFTs.Length) + { + next = complexFFTs[i + 1]; + } + + var sqrt = Complex.Sqrt(current * current + next * next) * 0.0009765625f; + complexFFTs[i] = sqrt; + + if (sqrt.Real <= the3CThing.Real) + { + sqrt = the3CThing; + } + the3CThing = sqrt; + } + } + int fFT512KISS = data; if (fFT512KISS < 1) { @@ -192,7 +223,7 @@ private float FastDecodeStepAsync(int chan, float[] ffts) var avg = (complexFFTs[i].Real + complexFFTs[i].Imaginary) / 2; num += (float)Math.Sqrt(Math.Max(0f, avg)); } - else if (UseImaginaryFFTValues) + else if (UseImaginaryFFTValues && !UsePleaseHelpMe) { num += (float)Math.Sqrt(Math.Max(0f, complexFFTs[i].Imaginary)); }