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,9 +1,10 @@
package io.smnp.ext
package io.smnp.ext.synth
import io.smnp.environment.Environment
import io.smnp.ext.function.SynthFunction
import io.smnp.ext.function.WaveFunction
import io.smnp.ext.synth.Synthesizer
import io.smnp.ext.provider.HybridModuleProvider
import io.smnp.ext.synth.function.SynthFunction
import io.smnp.ext.synth.function.WaveFunction
import io.smnp.ext.synth.lib.synthesizer.Synthesizer
import org.pf4j.Extension
@Extension

View File

@@ -1,12 +1,12 @@
package io.smnp.ext.function
package io.smnp.ext.synth.function
import io.smnp.callable.function.Function
import io.smnp.callable.function.FunctionDefinitionTool
import io.smnp.callable.signature.Signature
import io.smnp.callable.signature.Signature.Companion.simple
import io.smnp.ext.synth.Synthesizer
import io.smnp.ext.synth.Wave
import io.smnp.ext.synth.WaveCompiler
import io.smnp.ext.synth.lib.synthesizer.Synthesizer
import io.smnp.ext.synth.lib.wave.Wave
import io.smnp.ext.synth.lib.wave.WaveCompiler
import io.smnp.type.enumeration.DataType
import io.smnp.type.enumeration.DataType.INT
import io.smnp.type.matcher.Matcher
@@ -26,14 +26,20 @@ class SynthFunction : Function("synth") {
listOf(DataType.NOTE, INT, DataType.STRING),
Matcher.mapOfMatchers(Matcher.ofType(DataType.STRING), Matcher.anyType())
) body { _, (config, vararg) ->
val compiler = WaveCompiler(config, Synthesizer.SAMPLING_RATE)
val compiler = WaveCompiler(
config,
Synthesizer.SAMPLING_RATE
)
val wave = compiler.compileLines(vararg.unwrapCollections() as List<List<Value>>)
Synthesizer.synth(wave)
Value.void()
}
new function Signature.vararg(listOf(DataType.NOTE, INT, DataType.STRING)) body { _, (vararg) ->
val compiler = WaveCompiler(Value.map(emptyMap()), Synthesizer.SAMPLING_RATE)
val compiler = WaveCompiler(
Value.map(emptyMap()),
Synthesizer.SAMPLING_RATE
)
val wave = compiler.compileLines(vararg.unwrapCollections() as List<List<Value>>)
Synthesizer.synth(wave)
Value.void()

View File

@@ -1,10 +1,10 @@
package io.smnp.ext.function
package io.smnp.ext.synth.function
import io.smnp.callable.function.Function
import io.smnp.callable.function.FunctionDefinitionTool
import io.smnp.callable.signature.Signature
import io.smnp.ext.synth.Synthesizer
import io.smnp.ext.synth.WaveCompiler
import io.smnp.ext.synth.lib.synthesizer.Synthesizer
import io.smnp.ext.synth.lib.wave.WaveCompiler
import io.smnp.type.enumeration.DataType.*
import io.smnp.type.matcher.Matcher.Companion.anyType
import io.smnp.type.matcher.Matcher.Companion.listOf
@@ -27,7 +27,8 @@ class WaveFunction : Function("wave") {
}
new function Signature.vararg(listOf(NOTE, INT, STRING)) body { _, (vararg) ->
val compiler = WaveCompiler(Value.map(emptyMap()), Synthesizer.SAMPLING_RATE)
val compiler =
WaveCompiler(Value.map(emptyMap()), Synthesizer.SAMPLING_RATE)
val wave = compiler.compileLines(vararg.unwrapCollections() as List<List<Value>>)

View File

@@ -1,4 +1,4 @@
package io.smnp.ext.synth
package io.smnp.ext.synth.lib.envelope
class AdsrEnvelope(private val p1: Double, private val p2: Double, private val p3: Double, private val s: Double) : Envelope() {

View File

@@ -1,4 +1,4 @@
package io.smnp.ext.synth
package io.smnp.ext.synth.lib.envelope
import io.smnp.type.enumeration.DataType.FLOAT
import io.smnp.type.matcher.Matcher.Companion.ofType

View File

@@ -1,4 +1,4 @@
package io.smnp.ext.synth
package io.smnp.ext.synth.lib.envelope
class ConstantEnvelope : Envelope() {
override fun name() = "Constant"

View File

@@ -1,4 +1,4 @@
package io.smnp.ext.synth
package io.smnp.ext.synth.lib.envelope
import io.smnp.type.model.Value

View File

@@ -1,5 +1,6 @@
package io.smnp.ext.synth
package io.smnp.ext.synth.lib.envelope
import io.smnp.ext.synth.lib.wave.Wave
import org.knowm.xchart.QuickChart
import org.knowm.xchart.SwingWrapper

View File

@@ -1,4 +1,4 @@
package io.smnp.ext.synth
package io.smnp.ext.synth.lib.envelope
import io.smnp.error.CustomException
import io.smnp.type.enumeration.DataType

View File

@@ -1,5 +1,6 @@
package io.smnp.ext.synth
package io.smnp.ext.synth.lib.synthesizer
import io.smnp.ext.synth.lib.wave.Wave
import javax.sound.sampled.AudioFormat
import javax.sound.sampled.AudioSystem
import javax.sound.sampled.SourceDataLine

View File

@@ -1,4 +1,4 @@
package io.smnp.ext.synth
package io.smnp.ext.synth.lib.wave
import org.knowm.xchart.QuickChart
import org.knowm.xchart.SwingWrapper

View File

@@ -1,8 +1,10 @@
package io.smnp.ext.synth
package io.smnp.ext.synth.lib.wave
import io.smnp.data.entity.Note
import io.smnp.data.enumeration.Pitch
import io.smnp.error.CustomException
import io.smnp.ext.synth.lib.envelope.Envelope
import io.smnp.ext.synth.lib.envelope.EnvelopeFactory
import io.smnp.math.Fraction
import io.smnp.type.enumeration.DataType
import io.smnp.type.matcher.Matcher