From 0a23c10d336fed06345f14d23e8c87d96cda4868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Przemys=C5=82aw=20Pluta?= Date: Mon, 6 Apr 2020 17:32:50 +0200 Subject: [PATCH] Improve evaluation of wave level basing on log2 of velocity --- .../src/main/kotlin/io/smnp/ext/synth/lib/wave/WaveCompiler.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/synth/src/main/kotlin/io/smnp/ext/synth/lib/wave/WaveCompiler.kt b/modules/synth/src/main/kotlin/io/smnp/ext/synth/lib/wave/WaveCompiler.kt index e3f1ca1..a0fe275 100644 --- a/modules/synth/src/main/kotlin/io/smnp/ext/synth/lib/wave/WaveCompiler.kt +++ b/modules/synth/src/main/kotlin/io/smnp/ext/synth/lib/wave/WaveCompiler.kt @@ -8,6 +8,7 @@ import io.smnp.type.enumeration.DataType import io.smnp.type.matcher.Matcher import io.smnp.type.model.Value import io.smnp.util.config.ConfigMapSchema +import kotlin.math.log import kotlin.math.pow 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 }.toTypedArray()) - return parameters.envelope.apply(wave) * parameters.velocity.toDouble() + return parameters.envelope.apply(wave) * log(parameters.velocity.toDouble() + 1.0, 2.0) } } \ No newline at end of file