static Configuration() { ClientKey = String.Empty; UserAgent = "AcoustID.NET/" + ChromaContext.GetVersion(); Proxy = null; }
private void ProcessFile(string file) { if (File.Exists(file)) { if (decoder.Ready) { //btnOpen.Enabled = false; btnFingerPrint.Enabled = false; btnRequest.Enabled = false; Task.Factory.StartNew(() => { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); ChromaContext context = new ChromaContext(); context.Start(decoder.SampleRate, decoder.Channels); decoder.Decode(context.Consumer, 120); context.Finish(); stopwatch.Stop(); ProcessFileCallback(context.GetFingerprint(), stopwatch.ElapsedMilliseconds); }); } } }
internal static void Fingerprint(Database.Song row) { NAudioDecoder decoder = new NAudioDecoder(); string filename = row.Path + "\\" + row.Filename; if (System.IO.File.Exists(filename)) { decoder.Load(filename); string duration; int bits = decoder.SourceBitDepth; int channels = decoder.SourceChannels; if (decoder.Ready) { duration = decoder.Duration.ToString(); ChromaContext context = new ChromaContext(); context.Start(decoder.SampleRate, decoder.Channels); decoder.Decode(context.Consumer, 120); context.Finish(); // Release audio file handle. decoder.Dispose(); if (String.IsNullOrEmpty(AcoustID.Configuration.ApiKey)) { // TODO: display a prompt for api key. AcoustID.Configuration.ApiKey = "8XaBELgH"; } LookupService service = new LookupService(); List<Recording> recs = new List<Recording>(); List<LookupResult> results = service.Get(context.GetFingerprint(), decoder.Duration, new string[] { "recordings", "compress" }); foreach (LookupResult res in results) { foreach (Recording rec in res.Recordings) { recs.Add(rec); } } string _lastFmQueryAddress = RockBox.Properties.Resources.LastFmQueryAddress + "?"; string _lastFmApiKey = RockBox.Properties.Resources.LastFmApiKey; LastFmApi.Session s = new LastFmApi.Session(_lastFmApiKey, _lastFmQueryAddress); if (recs.Count > 0) { Recording li = recs[0]; string artist = ""; string title = ""; if (li.Artists.Count > 0) { artist = li.Artists[0].Name; } if (li.Title != null) { title = li.Title; } // we kinda have to do it this way because last.fm returns slightly different schema // depending on what data it has (Tags being a name value pair as opposed to a list of pairs, for example) try { LastFmApi.Query.Track.GetInfo q = new LastFmApi.Query.Track.GetInfo(artist, title); LastFmApi.DataTypes.Track.RootObject o = q.Get(s); ProcessTrack(o, row); Console.WriteLine("Processing " + row.Filename); } catch (Exception e) { LastFmApi.Query.Track2.GetInfo q = new LastFmApi.Query.Track2.GetInfo(artist, title); LastFmApi.DataTypes.Track2.RootObject o = q.Get(s); ProcessTrack2(o, row); Console.WriteLine("Processing " + row.Filename); } } else { Console.WriteLine("Couldn't find a recording for " + row.Filename); } } } }
private void doFingerprint(object sender, RoutedEventArgs e) { if (File.Exists(txtFile.Text)) { if (decoder.Ready) { //btnOpen.Enabled = false; btnFingerprint.IsEnabled = false; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); ChromaContext context = new ChromaContext(); context.Start(decoder.SampleRate, decoder.Channels); decoder.Decode(context.Consumer, 120); context.Finish(); stopwatch.Stop(); ProcessFileCallback(context.GetFingerprint(), stopwatch.ElapsedMilliseconds); } } }