Start() public method

Restart the computation of a fingerprint with a new audio stream
public Start ( int sample_rate, int num_channels ) : bool
sample_rate int sample rate of the audio stream (in Hz)
num_channels int numbers of channels in the audio stream (1 or 2)
return bool
コード例 #1
0
ファイル: MainForm.cs プロジェクト: gaborp/AcoustID.NET
        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);
                    });
                }
            }
        }
コード例 #2
0
ファイル: AudioEngine.cs プロジェクト: cplaster/RockBox
        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);
                    }
                }
            }
        }
コード例 #3
0
ファイル: TagDialog.xaml.cs プロジェクト: cplaster/RockBox
        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);
                }
            }
        }