Improve evaluation of wave level basing on log2 of velocity
This commit is contained in:
@@ -8,6 +8,7 @@ import io.smnp.type.enumeration.DataType
|
|||||||
import io.smnp.type.matcher.Matcher
|
import io.smnp.type.matcher.Matcher
|
||||||
import io.smnp.type.model.Value
|
import io.smnp.type.model.Value
|
||||||
import io.smnp.util.config.ConfigMapSchema
|
import io.smnp.util.config.ConfigMapSchema
|
||||||
|
import kotlin.math.log
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
|
|
||||||
class WaveCompiler(config: Value, private val samplingRate: Double) {
|
class WaveCompiler(config: Value, private val samplingRate: Double) {
|
||||||
@@ -77,6 +78,6 @@ class WaveCompiler(config: Value, private val samplingRate: Double) {
|
|||||||
Wave.sine(frequency * (overtone + 1), duration, samplingRate) * ratio
|
Wave.sine(frequency * (overtone + 1), duration, samplingRate) * ratio
|
||||||
}.toTypedArray())
|
}.toTypedArray())
|
||||||
|
|
||||||
return parameters.envelope.apply(wave) * parameters.velocity.toDouble()
|
return parameters.envelope.apply(wave) * log(parameters.velocity.toDouble() + 1.0, 2.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user