Ejemplo n.º 1
0
        public R <SongAnalyzerResult, LocalStr> Run(CancellationToken cancellationToken)
        {
            Log.Info("Started analysis for \"{0}\"", Source.AudioResource.ResourceTitle);
            Stopwatch timer = new Stopwatch();

            timer.Start();

            var resource = ResourceResolver.Load(Source.AudioResource);

            if (!resource.Ok)
            {
                return(resource.Error);
            }
            var res          = resource.Value;
            var restoredLink = ResourceResolver.RestoreLink(res.BaseData);

            if (!restoredLink.Ok)
            {
                return(restoredLink.Error);
            }

            Log.Debug("Song resolve took {0}ms", timer.ElapsedMilliseconds);

            if (!(Source.AudioResource.Gain.HasValue || Source.AudioResource.AudioType != "youtube"))
            {
                timer.Restart();

                var gain = FfmpegProducer.VolumeDetect(res.PlayUri, cancellationToken);
                res.BaseData = res.BaseData.WithGain(gain);
                Log.Debug("Song volume detect took {0}ms", timer.ElapsedMilliseconds);
            }

            return(new SongAnalyzerResult {
                Resource = res,
                RestoredLink = restoredLink
            });
        }
Ejemplo n.º 2
0
 public int RunVolumeDetection(string url, CancellationToken token)
 {
     return(FfmpegProducer.VolumeDetect(url, token));
 }