public double[] test2000A(string filenavn) { filename = filenavn; // FileSystemAccess _fileSystem = new FileSystemAccess(); //_filePathFig = filename.Substring(filename.Length - 4,filename.Length-1); int længde = filename.Length - 4; _filePathFig = filename.Substring(0, længde) + ".png"; _filePathtxt = filename.Substring(0, længde) + ".txt"; _filePathwav = filename.Substring(0, længde) + ".wav"; (double[] audio, int sampleRate) = ReadWAV(_filePathwav); // int fftSize1 = 16384; int targetWidthPx = 300; int fftSize1 = (int)MathF.Pow(2, 5); int stepSize1 = 80; //int stepSize1 = audio.Length / targetWidthPx; var sg = new SpectrogramGenerator(sampleRate, fftSize: fftSize1, stepSize: stepSize1, maxFreq: 1000); sg.Add(audio); double[] testData = TakeSum(sg.GetFFTs()); sg.SaveImage(_filePathFig, intensity: 8, dB: true, roll: true); line = line.Replace(',', '.'); return(testData); }
public void Test_AGC_normWindow() { // strategy here is to create a weighted moving window mean and normalize to that string wavFilePath = "../../../../../data/qrss-10min.wav"; (double[] audio, int sampleRate) = AudioFile.ReadWAV(wavFilePath); int fftSize = 8192; var spec = new SpectrogramGenerator(sampleRate, fftSize, stepSize: 2000, maxFreq: 3000); spec.Add(audio); var ffts = spec.GetFFTs(); for (int i = 0; i < ffts.Count; i++) { ffts[i] = SubtractMovingWindowFloor(ffts[i]); } spec.SaveImage("qrss-agc-norm-window.png", intensity: 3); }
public void Test_AGC_normToNoiseFloor() { // strategy here is to normalize to the magnitude of the quietest 20% of frequencies string wavFilePath = "../../../../../data/qrss-10min.wav"; (double[] audio, int sampleRate) = AudioFile.ReadWAV(wavFilePath); int fftSize = 8192; var spec = new SpectrogramGenerator(sampleRate, fftSize, stepSize: 2000, maxFreq: 3000); spec.Add(audio); var ffts = spec.GetFFTs(); double normalIntensity = 2; for (int i = 0; i < ffts.Count; i++) { double[] sorted = new double[ffts[i].Length]; ffts[i].CopyTo(sorted, 0); Array.Sort(sorted); double percentile = 0.25; int percentileIndex = (int)(percentile * ffts[0].Length); double floorValue = sorted[percentileIndex]; for (int y = 0; y < ffts[i].Length; y++) { ffts[i][y] = ffts[i][y] / floorValue * normalIntensity; } Console.WriteLine(floorValue); } spec.SaveImage("qrss-agc-norm-floor.png", intensity: 3); }