private AudioMetadata GetAudioMetadata(string audioFilePath) { var audioData = AudioSampleReader.ReadMonoSamples(audioFilePath, out var sampleRate); var beatDetectorResult = beatDetector.DetectBeats(audioData, sampleRate); return(new AudioMetadata { SampleRate = sampleRate, Length = TimeSpan.FromSeconds(audioData.Count / (double)sampleRate), BeatDetectorResult = beatDetectorResult }); }
public void ApplyModel() { var songFilePath = @"C:\Users\Jan\Music\Dimitri Vegas - Ocarina.mp3"; var sut = new BeatDetector(); var signal = AudioSampleReader.ReadMonoSamples(songFilePath, out var sampleRate); var beatDetectorResult = sut.DetectBeats(signal, sampleRate); Console.WriteLine($@"BPM: {beatDetectorResult.BeatsPerMinute:F0}"); foreach (var beat in beatDetectorResult.DetectedBeats) { Console.WriteLine($@"{beat.SampleIndex};{beat.Strength}"); } }