diff --git a/src/Spectrogram/Settings.cs b/src/Spectrogram/Settings.cs index 3ec35f1..d36f137 100644 --- a/src/Spectrogram/Settings.cs +++ b/src/Spectrogram/Settings.cs @@ -6,7 +6,7 @@ namespace Spectrogram { class Settings { - public readonly int SampleRate; + public readonly double SampleRate; // vertical information public readonly int FftSize; @@ -29,7 +29,7 @@ class Settings public readonly double StepOverlapFrac; public readonly double StepOverlapSec; - public Settings(int sampleRate, int fftSize, int stepSize, double minFreq, double maxFreq, int offsetHz) + public Settings(double sampleRate, int fftSize, int stepSize, double minFreq, double maxFreq, int offsetHz) { static bool IsPowerOfTwo(int x) => ((x & (x - 1)) == 0) && (x > 0); @@ -45,7 +45,7 @@ public Settings(int sampleRate, int fftSize, int stepSize, double minFreq, doubl // vertical minFreq = Math.Max(minFreq, 0); FreqNyquist = sampleRate / 2; - HzPerPixel = (double)sampleRate / fftSize; + HzPerPixel = sampleRate / fftSize; PxPerHz = (double)fftSize / sampleRate; FftIndex1 = (minFreq == 0) ? 0 : (int)(minFreq / HzPerPixel); FftIndex2 = (maxFreq >= FreqNyquist) ? fftSize / 2 : (int)(maxFreq / HzPerPixel); diff --git a/src/Spectrogram/SpectrogramGenerator.cs b/src/Spectrogram/SpectrogramGenerator.cs index edb85b4..d022564 100644 --- a/src/Spectrogram/SpectrogramGenerator.cs +++ b/src/Spectrogram/SpectrogramGenerator.cs @@ -56,7 +56,7 @@ public class SpectrogramGenerator /// /// Number of samples per second /// - public int SampleRate { get => Settings.SampleRate; } + public double SampleRate { get => Settings.SampleRate; } /// /// Number of samples to step forward after each FFT is processed. @@ -218,7 +218,7 @@ public List GetMelFFTs(int melBinCount) var fftsMel = new List(); foreach (var fft in FFTs) - fftsMel.Add(FftSharp.Mel.Scale(fft, SampleRate, melBinCount)); + fftsMel.Add(FftSharp.Mel.Scale(fft, (int)SampleRate, melBinCount)); return fftsMel; }