Skip to content

Commit

Permalink
[FIX/#28] bpm 계산 공식 함수화
Browse files Browse the repository at this point in the history
  • Loading branch information
Marchbreeze committed Jul 31, 2024
1 parent 3421071 commit fbb3d99
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class RhythmFragment : BaseFragment<FragmentRhythmBinding>(R.layout.fragment_rhy
ivRhythmBg.setImageResource(getResource("img_rhythm_bg_$color", DRAWABLE))
lottieRhythmBg.apply {
setAnimation(getResource("stempo_rhythm_$color", RAW))
speed = viewModel.bpm / 120.00000000000F
speed = viewModel.bpm / FLOAT_120
playAnimation()
}
}
Expand Down Expand Up @@ -237,5 +237,7 @@ class RhythmFragment : BaseFragment<FragmentRhythmBinding>(R.layout.fragment_rhy
private const val COLOR = "color"
private const val DRAWABLE = "drawable"
private const val RAW = "raw"

private const val FLOAT_120 = 120.00000000000000000000F
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ constructor(
private fun initRhythmLevelFromDataStore() {
val currentLevel = userRepository.getBpmLevel()
filename = "stempo_level_$currentLevel"
bpm = 40 + currentLevel * 10
bpm = setBpm(currentLevel)
_rhythmLevel.value = currentLevel
tempRhythmLevel.value = currentLevel
}
Expand All @@ -67,8 +67,8 @@ constructor(
fun setRhythmLevel() {
isSubmitted = true
filename = "stempo_level_" + tempRhythmLevel.value.toString()
bpm = 40 + (tempRhythmLevel.value?.times(10) ?: 10)
_rhythmLevel.value = tempRhythmLevel.value ?: -1
bpm = setBpm(tempRhythmLevel.value ?: 1)
_rhythmLevel.value = tempRhythmLevel.value ?: 1
userRepository.setBpmLevel(rhythmLevel.value)
}

Expand Down Expand Up @@ -111,6 +111,8 @@ constructor(
}
}

fun setBpm(level: Int) = 40 + level * 10

companion object {
const val LEVEL_UNDEFINED = -1
}
Expand Down

0 comments on commit fbb3d99

Please sign in to comment.