diff --git a/OsuDataDistributeRestful.csproj b/OsuDataDistributeRestful.csproj index 896cc4f..27f4b51 100644 --- a/OsuDataDistributeRestful.csproj +++ b/OsuDataDistributeRestful.csproj @@ -81,6 +81,7 @@ + diff --git a/Server/Api/OrtdpApis.cs b/Server/Api/OrtdpApis.cs index ea1adfa..7af1fb7 100644 --- a/Server/Api/OrtdpApis.cs +++ b/Server/Api/OrtdpApis.cs @@ -79,7 +79,7 @@ public ActionResult GetAudioFile() if (File.Exists(filename)) { - var fs = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read); + var fs = OpenFile(filename); return new ActionResult(fs) { @@ -99,7 +99,7 @@ public ActionResult GetBackgroundFile() if (File.Exists(filename)) { - var fs = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read); + var fs = OpenFile(filename); string ext = Path.GetExtension(filename); return new ActionResult(fs) @@ -120,7 +120,7 @@ public ActionResult GetVideoFile() if (File.Exists(filename)) { - var fs = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read); + var fs = OpenFile(filename); string ext = Path.GetExtension(filename); return new ActionResult(fs) @@ -180,6 +180,11 @@ public object GetPlayingTime() #region tools + private Stream OpenFile(string filename) + { + return new MemoryStream(File.ReadAllBytes(filename)); + } + private object MakeProvideDatas(ProvideDataMask mask, Func selector) { bool isTourney = ortdp.TourneyListenerManagersCount != 0; diff --git a/Server/Api/RtppdApis.cs b/Server/Api/RtppdApis.cs index 9a1ae90..a62cdf1 100644 --- a/Server/Api/RtppdApis.cs +++ b/Server/Api/RtppdApis.cs @@ -109,7 +109,7 @@ public object GetPPFormat() [Route("/hitCountFormat")] public object GetHitCountFormat() - => new {format = StringFormatter.GetHitCountFormatter().Format}; + => new {format = StringFormatter.GetHitCountFormatter().Format }; [Route("/formated/pp")] public object GetFormatedPP() diff --git a/app.config b/app.config new file mode 100644 index 0000000..195db1f --- /dev/null +++ b/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/html/visualizer-wave.html b/html/visualizer-wave.html new file mode 100644 index 0000000..c2bf1b6 --- /dev/null +++ b/html/visualizer-wave.html @@ -0,0 +1,198 @@ + + + + + + + Visualizer + + + + + + + + +
+ +
+ + + diff --git a/html/visualizer.html b/html/visualizer.html index 15332d6..ddaba7d 100644 --- a/html/visualizer.html +++ b/html/visualizer.html @@ -105,8 +105,8 @@ restart_audio(buf, time, 1.0); } } - if (Math.abs(timer - time) > 0.5) - restart_audio(current_audio_buffer, time, mods.timeRate); + if (Math.abs(timer - time) > 0.2) + restart_audio(current_audio_buffer, time+0.1, mods.timeRate); if (last_mods.timeRate != mods.timeRate) restart_audio(current_audio_buffer, time, mods.timeRate); @@ -123,7 +123,7 @@ canvas.height = window.innerHeight; var ctx = canvas.getContext("2d"); - analyser.fftSize = 512; + analyser.fftSize = 2048; var bufferLength = analyser.frequencyBinCount; console.log(bufferLength); @@ -133,7 +133,7 @@ var WIDTH = canvas.width; var HEIGHT = canvas.height; - var barWidth = (WIDTH / bufferLength) * 2.5; + var barWidth = (WIDTH / bufferLength) * 2.5 * 4; var barHeight; var x = 0; @@ -146,8 +146,13 @@ ctx.fillStyle = "#000"; ctx.fillRect(0, 0, WIDTH, HEIGHT); - for (let i = 0; i < bufferLength; i++) { - let val = dataArray[i] / 255.0; + for (let i = 0; i < bufferLength; i+=4) { + let val = 0 + + for(let j=0;j<4;j++){ + val += dataArray[i+j] / 255.0; + } + val /= 4; barHeight = val * val * val; let r = 128 + Math.round((128 * (i / bufferLength))); @@ -161,7 +166,7 @@ ctx.fillRect(x, HEIGHT - barHeight, barWidth, barHeight); - x += barWidth + 1; + x += barWidth; } requestAnimationFrame(renderFrame);