Change root package
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package com.bartlomiejpluta.smnp.ext.mic
|
||||
|
||||
import com.bartlomiejpluta.smnp.ext.mic.function.MicLevelFunction
|
||||
import com.bartlomiejpluta.smnp.ext.mic.function.WaitFunction
|
||||
import com.bartlomiejpluta.smnp.ext.provider.NativeModuleProvider
|
||||
import org.pf4j.Extension
|
||||
|
||||
@Extension
|
||||
class MicrophoneModule : NativeModuleProvider("smnp.audio.mic") {
|
||||
override fun functions() = listOf(WaitFunction(), MicLevelFunction())
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.bartlomiejpluta.smnp.ext.mic.function
|
||||
|
||||
import com.bartlomiejpluta.smnp.callable.function.Function
|
||||
import com.bartlomiejpluta.smnp.callable.function.FunctionDefinitionTool
|
||||
import com.bartlomiejpluta.smnp.callable.signature.Signature.Companion.simple
|
||||
import com.bartlomiejpluta.smnp.ext.mic.lib.loop.TestMicrophoneLevelLoop
|
||||
import com.bartlomiejpluta.smnp.type.model.Value
|
||||
|
||||
class MicLevelFunction : Function("micLevel") {
|
||||
override fun define(new: FunctionDefinitionTool) {
|
||||
new function simple() body { _, _ ->
|
||||
val printer = TestMicrophoneLevelLoop()
|
||||
printer.run()
|
||||
Value.void()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.bartlomiejpluta.smnp.ext.mic.function
|
||||
|
||||
import com.bartlomiejpluta.smnp.callable.function.Function
|
||||
import com.bartlomiejpluta.smnp.callable.function.FunctionDefinitionTool
|
||||
import com.bartlomiejpluta.smnp.callable.signature.Signature.Companion.simple
|
||||
import com.bartlomiejpluta.smnp.ext.mic.lib.loop.SoundListenerLoop
|
||||
import com.bartlomiejpluta.smnp.type.enumeration.DataType.INT
|
||||
import com.bartlomiejpluta.smnp.type.matcher.Matcher.Companion.ofType
|
||||
import com.bartlomiejpluta.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
|
||||
)
|
||||
loop.run()
|
||||
Value.void()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.smnp.ext.mic.lib.loop
|
||||
package com.bartlomiejpluta.smnp.ext.mic.lib.loop
|
||||
|
||||
import io.smnp.error.CustomException
|
||||
import com.bartlomiejpluta.smnp.error.CustomException
|
||||
import javax.sound.sampled.AudioFormat
|
||||
import javax.sound.sampled.AudioSystem
|
||||
import javax.sound.sampled.DataLine
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.smnp.ext.mic.lib.loop
|
||||
package com.bartlomiejpluta.smnp.ext.mic.lib.loop
|
||||
|
||||
class SoundListenerLoop(private val inThreshold: Int, private val outThreshold: Int) : MicrophoneLevelLoop() {
|
||||
private var noiseReached = false
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.smnp.ext.mic.lib.loop
|
||||
package com.bartlomiejpluta.smnp.ext.mic.lib.loop
|
||||
|
||||
import kotlin.math.min
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package io.smnp.ext.mic
|
||||
|
||||
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
|
||||
class MicrophoneModule : NativeModuleProvider("smnp.audio.mic") {
|
||||
override fun functions() = listOf(WaitFunction(), MicLevelFunction())
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
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.lib.loop.TestMicrophoneLevelLoop
|
||||
import io.smnp.type.model.Value
|
||||
|
||||
class MicLevelFunction : Function("micLevel") {
|
||||
override fun define(new: FunctionDefinitionTool) {
|
||||
new function simple() body { _, _ ->
|
||||
val printer = TestMicrophoneLevelLoop()
|
||||
printer.run()
|
||||
Value.void()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
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.lib.loop.SoundListenerLoop
|
||||
import io.smnp.type.enumeration.DataType.INT
|
||||
import io.smnp.type.matcher.Matcher.Companion.ofType
|
||||
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
|
||||
)
|
||||
loop.run()
|
||||
Value.void()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user