Skip to content

Commit

Permalink
Fix some division by zero errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Danand committed Mar 26, 2024
1 parent d128472 commit e5fed04
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ class SignalProcessorSensors(

var frequencyMax = this.frequenciesMax[index]

if (weirdEffectDivider == 0) {
weirdEffectDivider = 1
}

if ((sensorValue * 10000.0f).toInt() % weirdEffectDivider == 0) {
frequencyMax += (this.frequenciesMax.random() * tanh(time))
}
Expand Down Expand Up @@ -175,7 +179,21 @@ class SignalProcessorSensors(
sampleValueTotal = max(sampleValueTotal, sampleValueSynth)
}

if ((this.sensorsState.value.light % (this.sensorsState.value.magneticZ * 10.0f)).toInt() % settingsState.rhythmSeedB.value == 0) {
var magneticMultiplied = this.sensorsState.value.magneticZ * 10.0f

if (magneticMultiplied == 0.0f) {
magneticMultiplied = 1.0f
}

val magicNumberLightMagnetic = (this.sensorsState.value.light % magneticMultiplied).toInt()

var rhythmSeedB = settingsState.rhythmSeedB.value

if (rhythmSeedB == 0) {
rhythmSeedB = 1
}

if (magicNumberLightMagnetic % rhythmSeedB == 0) {
val sampleValueRandom = Random.nextFloat() * amplitudeMax
sampleValueTotal = max(sampleValueTotal, sampleValueRandom)
}
Expand Down

0 comments on commit e5fed04

Please sign in to comment.