Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Spectrogram/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Spectrogram
{
class Settings
{
public readonly int SampleRate;
public readonly double SampleRate;

// vertical information
public readonly int FftSize;
Expand All @@ -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);

Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/Spectrogram/SpectrogramGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class SpectrogramGenerator
/// <summary>
/// Number of samples per second
/// </summary>
public int SampleRate { get => Settings.SampleRate; }
public double SampleRate { get => Settings.SampleRate; }

/// <summary>
/// Number of samples to step forward after each FFT is processed.
Expand Down Expand Up @@ -218,7 +218,7 @@ public List<double[]> GetMelFFTs(int melBinCount)

var fftsMel = new List<double[]>();
foreach (var fft in FFTs)
fftsMel.Add(FftSharp.Mel.Scale(fft, SampleRate, melBinCount));
fftsMel.Add(FftSharp.Mel.Scale(fft, (int)SampleRate, melBinCount));

return fftsMel;
}
Expand Down
Loading