Inheritance: System.Entity
        /// <summary>
        /// Create a Fingerprint and lookup the Recordings
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        private async Task <List <Recording> > GetRecordings(string file)
        {
            var stream = Bass.BASS_StreamCreateFile(file, 0, 0, BASSFlag.BASS_STREAM_DECODE);
            var chInfo = Bass.BASS_ChannelGetInfo(stream);

            var bufLen = (int)Bass.BASS_ChannelSeconds2Bytes(stream, 120.0);
            var buf    = new short[bufLen];

            var chromaContext = new ChromaContext();

            chromaContext.Start(chInfo.freq, chInfo.chans);

            var length = Bass.BASS_ChannelGetData(stream, buf, bufLen);

            chromaContext.Feed(buf, length / 2);

            chromaContext.Finish();

            var fingerPrint = chromaContext.GetFingerprint();

            Configuration.ClientKey = "mfbgmu2P";
            var lookupSvc = new LookupService();

            var len  = Bass.BASS_ChannelGetLength(stream, BASSMode.BASS_POS_BYTE);
            var time = Bass.BASS_ChannelBytes2Seconds(stream, len);

            Bass.BASS_StreamFree(stream);

            //var result = await lookupSvc.GetAsync(fingerPrint, Convert.ToInt32(time), new[] { "recordingids", "releases", "artists" });
            var trackIds = await lookupSvc.GetAsync(fingerPrint, Convert.ToInt32(time), new[] { "recordingids" });

            var recordings = new List <Recording>();

            foreach (var trackId in trackIds.Results)
            {
                foreach (var rec in trackId.Recordings)
                {
                    System.Threading.Thread.Sleep(400);
                    var recording = await Recording.GetAsync(rec.Id, new[] { "releases", "artists", "media", "discids" });

                    recordings.Add(recording);
                }
            }
            return(recordings);
        }
Beispiel #2
0
 public RecordingTests()
 {
     this.recording = TestHelper.Get<Recording>("recording-get.xml");
 }