Refactor/unify modules files structure

This commit is contained in:
2020-03-20 20:29:25 +01:00
parent 730d3803f0
commit 7bccb28080
50 changed files with 138 additions and 96 deletions

View File

@@ -1,7 +1,8 @@
package io.smnp.ext
package io.smnp.ext.mic
import io.smnp.ext.function.MicLevelFunction
import io.smnp.ext.function.WaitFunction
import io.smnp.ext.provider.NativeModuleProvider
import io.smnp.ext.mic.function.MicLevelFunction
import io.smnp.ext.mic.function.WaitFunction
import org.pf4j.Extension
@Extension

View File

@@ -1,9 +1,9 @@
package io.smnp.ext.function
package io.smnp.ext.mic.function
import io.smnp.callable.function.Function
import io.smnp.callable.function.FunctionDefinitionTool
import io.smnp.callable.signature.Signature.Companion.simple
import io.smnp.ext.mic.TestMicrophoneLevelLoop
import io.smnp.ext.mic.lib.loop.TestMicrophoneLevelLoop
import io.smnp.type.model.Value
class MicLevelFunction : Function("micLevel") {

View File

@@ -1,9 +1,9 @@
package io.smnp.ext.function
package io.smnp.ext.mic.function
import io.smnp.callable.function.Function
import io.smnp.callable.function.FunctionDefinitionTool
import io.smnp.callable.signature.Signature.Companion.simple
import io.smnp.ext.mic.SoundListenerLoop
import io.smnp.ext.mic.lib.loop.SoundListenerLoop
import io.smnp.type.enumeration.DataType.INT
import io.smnp.type.matcher.Matcher.Companion.ofType
import io.smnp.type.model.Value
@@ -11,7 +11,10 @@ import io.smnp.type.model.Value
class WaitFunction : Function("wait") {
override fun define(new: FunctionDefinitionTool) {
new function simple(ofType(INT), ofType(INT)) body { _, (inThreshold, outThreshold) ->
val loop = SoundListenerLoop(inThreshold.value as Int, outThreshold.value as Int)
val loop = SoundListenerLoop(
inThreshold.value as Int,
outThreshold.value as Int
)
loop.run()
Value.void()
}

View File

@@ -1,4 +1,4 @@
package io.smnp.ext.mic
package io.smnp.ext.mic.lib.loop
import io.smnp.error.CustomException
import javax.sound.sampled.AudioFormat

View File

@@ -1,4 +1,4 @@
package io.smnp.ext.mic
package io.smnp.ext.mic.lib.loop
class SoundListenerLoop(private val inThreshold: Int, private val outThreshold: Int) : MicrophoneLevelLoop() {
private var noiseReached = false

View File

@@ -1,4 +1,4 @@
package io.smnp.ext.mic
package io.smnp.ext.mic.lib.loop
import kotlin.math.min