From 7cdcb7edb2147b5de679f3185515648d0ca0f50a Mon Sep 17 00:00:00 2001 From: jeffshee Date: Sun, 2 Jun 2019 03:44:23 +0900 Subject: [PATCH] Add Boost Function --- .../java/io/github/jeffshee/visualizerdemo/MainActivity.kt | 7 +++++-- .../io/github/jeffshee/visualizer/painters/fft/FftBar.kt | 6 ++++-- .../io/github/jeffshee/visualizer/painters/fft/FftLine.kt | 6 ++++-- .../io/github/jeffshee/visualizer/painters/fft/FftWave.kt | 6 ++++-- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/github/jeffshee/visualizerdemo/MainActivity.kt b/app/src/main/java/io/github/jeffshee/visualizerdemo/MainActivity.kt index 567a476..0373c2a 100644 --- a/app/src/main/java/io/github/jeffshee/visualizerdemo/MainActivity.kt +++ b/app/src/main/java/io/github/jeffshee/visualizerdemo/MainActivity.kt @@ -8,6 +8,9 @@ import android.os.Bundle import android.support.v4.app.ActivityCompat import android.support.v4.content.ContextCompat import android.support.v7.app.AppCompatActivity +import io.github.jeffshee.visualizer.painters.fft.FftBar +import io.github.jeffshee.visualizer.painters.fft.FftWave +import io.github.jeffshee.visualizer.painters.fft.FftWaveRgb import io.github.jeffshee.visualizer.painters.misc.SimpleIcon import io.github.jeffshee.visualizer.utils.Preset import io.github.jeffshee.visualizer.utils.VisualizerHelper @@ -42,8 +45,8 @@ class MainActivity : AppCompatActivity() { helper = VisualizerHelper(0) visual.setPainterList( helper, listOf( - Preset.getPresetWithIcon("cWaveRgbIcon", bitmap) - //Preset.getPresetWithIcon("cIcon", bitmap) + //Preset.getPresetWithIcon("cWaveRgbIcon", bitmap) + Preset.getPresetWithIcon("cIcon", bitmap) ) ) } diff --git a/visualizer/src/main/java/io/github/jeffshee/visualizer/painters/fft/FftBar.kt b/visualizer/src/main/java/io/github/jeffshee/visualizer/painters/fft/FftBar.kt index 0d8d67b..8f5b223 100644 --- a/visualizer/src/main/java/io/github/jeffshee/visualizer/painters/fft/FftBar.kt +++ b/visualizer/src/main/java/io/github/jeffshee/visualizer/painters/fft/FftBar.kt @@ -20,16 +20,18 @@ class FftBar( var yR: Float = 1f, var wR: Float = 1f, var gapX: Float = 0f, - var ampR: Float = 1f + var ampR: Float = 1f, + var enableBoost: Boolean = false ) : Painter() { private var points = Array(0) { GravityModel() } override fun draw(canvas: Canvas, helper: VisualizerHelper) { - val fft = helper.getFftMagnitudeRange(startHz, endHz) + var fft = helper.getFftMagnitudeRange(startHz, endHz) if (isQuiet(fft)) return val width = canvas.width.toFloat() * wR + if(enableBoost) fft = boost(fft) when (mode) { "mirror" -> { diff --git a/visualizer/src/main/java/io/github/jeffshee/visualizer/painters/fft/FftLine.kt b/visualizer/src/main/java/io/github/jeffshee/visualizer/painters/fft/FftLine.kt index 7d625eb..185d0a0 100644 --- a/visualizer/src/main/java/io/github/jeffshee/visualizer/painters/fft/FftLine.kt +++ b/visualizer/src/main/java/io/github/jeffshee/visualizer/painters/fft/FftLine.kt @@ -19,16 +19,18 @@ class FftLine( var xR: Float = 0f, var yR: Float = 1f, var wR: Float = 1f, - var ampR: Float = 1f + var ampR: Float = 1f, + var enableBoost: Boolean = false ) : Painter() { private var points = Array(0) { GravityModel() } override fun draw(canvas: Canvas, helper: VisualizerHelper) { - val fft = helper.getFftMagnitudeRange(startHz, endHz) + var fft = helper.getFftMagnitudeRange(startHz, endHz) if (isQuiet(fft)) return val width = canvas.width.toFloat() * wR + if(enableBoost) fft = boost(fft) when (mode) { "mirror" -> { diff --git a/visualizer/src/main/java/io/github/jeffshee/visualizer/painters/fft/FftWave.kt b/visualizer/src/main/java/io/github/jeffshee/visualizer/painters/fft/FftWave.kt index 11830b8..786e4a8 100644 --- a/visualizer/src/main/java/io/github/jeffshee/visualizer/painters/fft/FftWave.kt +++ b/visualizer/src/main/java/io/github/jeffshee/visualizer/painters/fft/FftWave.kt @@ -20,17 +20,19 @@ class FftWave( var xR: Float = 0f, var yR: Float = 1f, var wR: Float = 1f, - var ampR: Float = 1f + var ampR: Float = 1f, + var enableBoost: Boolean = false ) : Painter() { private val path = Path() private var points = Array(0) { GravityModel() } override fun draw(canvas: Canvas, helper: VisualizerHelper) { - val fft = helper.getFftMagnitudeRange(startHz, endHz) + var fft = helper.getFftMagnitudeRange(startHz, endHz) if (isQuiet(fft)) return val width = canvas.width.toFloat() * wR + if(enableBoost) fft = boost(fft) when (mode) { "mirror" -> {