コード例 #1
0
        public async Task <byte[]> makeBrstm(BrstmOptions options, string url)
        {
            byte[]          data;
            YoutubeService  yt   = new YoutubeService();
            YoutubeMetadata ytmd = await yt.GetMetadata(url);

            MemoryStream ms = new MemoryStream(await yt.DownloadAudio(HttpUtility.UrlDecode(url)));

            data = TrimWavFile(ms, TimeSpan.FromSeconds(options.start), TimeSpan.FromSeconds(options.end));
            data = raiseVolume(data, options.decibelIncrease);
            if (options.finalLap)
            {
                data = adjustSpeed(data, options.speedFactor);
            }
            data = adjustChannels(data, options.courseInfo.channelCount);
            return(convertToBrstm(data));
        }
コード例 #2
0
        public async Task <IActionResult> makeBrstm(string url, string courseAbbreviation, int start, int end, double speedFactor, int decibelIncrease, bool finalLap)
        {
            byte[]       data;
            CourseInfo   courseInfo = new CourseInfo(courseAbbreviation);
            BrstmOptions options    = new BrstmOptions
            {
                courseInfo      = courseInfo,
                start           = start,
                end             = end,
                speedFactor     = speedFactor,
                decibelIncrease = decibelIncrease,
                finalLap        = finalLap
            };

            data = await _brstmService.makeBrstm(options, url);

            string filename = courseInfo.fileName + '_';
            string norf     = options.finalLap ? "f" : "n";

            filename += courseInfo.allCaps ? norf.ToUpper() : norf;
            filename += ".brstm";
            return(File(data, "application/octet-stream", filename));
        }