public AcoustIDCSCore(CSCore.IWaveSource waveSource) { _waveSource = waveSource; if (_waveSource.WaveFormat.BitsPerSample != 16) { throw new ArgumentOutOfRangeException(nameof(waveSource), "Expected 16 bit audio"); } }
public void Extract(CSCore.IWaveSource audioSource, Song s) { _currentTask = "Analysing Song"; List <Onset> onsets; if (SongAnalysed(s.SongBase.InternalName)) { onsets = LoadOnsets(GetOnsetFilePath(s.SongBase.InternalName)); } else { onsets = _onsetDetector.Detect(audioSource.ToSampleSource()); SaveOnsets(GetOnsetFilePath(s.SongBase.InternalName), onsets); } OnsetTimes = onsets.Select(o => o.OnsetTime).ToList(); Onsets = onsets; ApplyCorrection(OnsetTimes, _correction); //force garbage collection GC.Collect(2, GCCollectionMode.Forced, true); //audioSource.Position = 0; //AcoustID.ChromaContext cm = new AcoustID.ChromaContext(); //AcoustIDCSCore decoder = new AcoustIDCSCore(audioSource); //cm.Start(audioSource.WaveFormat.SampleRate, audioSource.WaveFormat.Channels); //decoder.Decode(cm.Consumer, 60); //cm.Finish(); //var f = cm.GetFingerprint(); //Debug.WriteLine(f); //AcoustID.Configuration.ClientKey = "3jSfGwVIGZ"; //AcoustID.Web.LookupService lService = new AcoustID.Web.LookupService(); //var duration = audioSource.GetLength().TotalSeconds; //var lookupTask = lService.GetAsync(f, (int)duration, new string[] { "recordings", "compress" }); //lookupTask.ContinueWith(t => //{ // var resp = t.Result; // foreach (var res in resp.Results) // { // Debug.WriteLine($"Score: {res.Score}, ID: {res.Id}"); // foreach (var rec in res.Recordings) // { // Debug.WriteLine($"{rec.Artists.First().Name} - {rec.Title}"); // } // } //}); //decoder.Dispose(); }
private void LoadAudioFeatures(CSCore.IWaveSource audioSource, float correction, IProgress <string> progress, Song s) { var options = DetectorOptions.Default; options.MinimumTimeDelta = 7.5f; options.ActivationThreshold = (float)SceneManager.GameSettings["OnsetActivationThreshold"]; options.AdaptiveWhitening = (bool)SceneManager.GameSettings["OnsetAdaptiveWhitening"]; options.Online = (bool)SceneManager.GameSettings["OnsetOnline"]; options.SlicePaddingLength = (float)SceneManager.GameSettings["OnsetSlicePaddingLength"]; options.SliceLength = (float)SceneManager.GameSettings["OnsetSliceLength"]; _audioFeatures = new AudioFeatures(options, SceneManager.Directories["ProcessedSongs"].FullName, correction + (float)_easeInTime, progress); progress.Report("Extracting audio features"); _audioFeatures.Extract(audioSource, s); }