Refactor project structure by removing "common" module

Removed the "common" module and associated configurations from the project. Updated dependencies and file placements to reflect these changes across build and source files. Migrated necessary code from the "common" module to relevant existing modules to maintain functionality.
This commit is contained in:
2024-12-08 14:57:01 +01:00
parent b20b2266ba
commit ee76d4c4a3
10 changed files with 201 additions and 282 deletions

View File

@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<excludedPredefinedLibrary name="vst-chip/build/js/node_modules" />
<excludedPredefinedLibrary name="vst-chip/build/js/packages/vst-chip-audio-worklet-test/node_modules" />
<excludedPredefinedLibrary name="vst-chip/build/js/packages/vst-chip-audio-worklet/node_modules" />
<excludedPredefinedLibrary name="vst-chip/build/js/packages/vst-chip-common-test/node_modules" />
<excludedPredefinedLibrary name="vst-chip/build/js/packages/vst-chip-test/node_modules" />
<excludedPredefinedLibrary name="vst-chip/build/js/packages/vst-chip/node_modules" />
</component>
</project>

View File

@@ -40,15 +40,9 @@ kotlin {
sourceSets { sourceSets {
val commonMain by getting { val commonMain by getting {
dependencies { dependencies {
implementation(project(":common"))
implementation("nl.astraeus:vst-worklet-base:1.0.0-SNAPSHOT") implementation("nl.astraeus:vst-worklet-base:1.0.0-SNAPSHOT")
} }
} }
val jsMain by getting { val jsMain by getting
dependencies {
implementation(project(":common"))
}
}
} }
} }

View File

@@ -4,7 +4,6 @@ package nl.astraeus.vst.chip
import nl.astraeus.vst.ADSR import nl.astraeus.vst.ADSR
import nl.astraeus.vst.AudioWorkletProcessor import nl.astraeus.vst.AudioWorkletProcessor
import nl.astraeus.vst.Note
import nl.astraeus.vst.currentTime import nl.astraeus.vst.currentTime
import nl.astraeus.vst.registerProcessor import nl.astraeus.vst.registerProcessor
import nl.astraeus.vst.sampleRate import nl.astraeus.vst.sampleRate
@@ -21,6 +20,8 @@ import kotlin.math.sin
val POLYPHONICS = 10 val POLYPHONICS = 10
val PI2 = PI * 2 val PI2 = PI * 2
@ExperimentalJsExport
@JsExport
class PlayingNote( class PlayingNote(
val note: Int, val note: Int,
var velocity: Int = 0 var velocity: Int = 0

View File

@@ -0,0 +1,196 @@
package nl.astraeus.vst.chip
import nl.astraeus.vst.chip.Note.entries
import kotlin.math.max
import kotlin.math.min
import kotlin.math.pow
import kotlin.math.round
/**
* User: rnentjes
* Date: 14-11-15
* Time: 11:50
*/
@ExperimentalJsExport
@JsExport
enum class Note(
val sharp: String,
val flat: String
) {
NO01("C--", "C--"),
NO02("C#-", "Db-"),
NO03("D--", "D--"),
NO04("D#-", "Eb-"),
NO05("E--", "E--"),
NO06("F--", "F--"),
NO07("F#-", "Gb-"),
NO08("G--", "G--"),
NO09("G#-", "Ab-"),
NO10("A--", "A--"),
NO11("A#-", "Bb-"),
NO12("B--", "B--"),
C0("C-0", "C-0"),
C0s("C#0", "Db0"),
D0("D-0", "D-0"),
D0s("D#0", "Eb0"),
E0("E-0", "E-0"),
F0("F-0", "F-0"),
F0s("F#0", "Gb0"),
G0("G-0", "G-0"),
G0s("G#0", "Ab0"),
A0("A-0", "A-0"),
A0s("A#0", "Bb0"),
B0("B-0", "B-0"),
C1("C-1", "C-1"),
C1s("C#1", "Db1"),
D1("D-1", "D-1"),
D1s("D#1", "Eb1"),
E1("E-1", "E-1"),
F1("F-1", "F-1"),
F1s("F#1", "Gb1"),
G1("G-1", "G-1"),
G1s("G#1", "Ab1"),
A1("A-1", "A-1"),
A1s("A#1", "Bb1"),
B1("B-1", "B-1"),
C2("C-2", "C-2"),
C2s("C#2", "Db2"),
D2("D-2", "D-2"),
D2s("D#2", "Eb2"),
E2("E-2", "E-2"),
F2("F-2", "F-2"),
F2s("F#2", "Gb2"),
G2("G-2", "G-2"),
G2s("G#2", "Ab2"),
A2("A-2", "A-2"),
A2s("A#2", "Bb2"),
B2("B-2", "B-2"),
C3("C-3", "C-3"),
C3s("C#3", "Db3"),
D3("D-3", "D-3"),
D3s("D#3", "Eb3"),
E3("E-3", "E-3"),
F3("F-3", "F-3"),
F3s("F#3", "Gb3"),
G3("G-3", "G-3"),
G3s("G#3", "Ab3"),
A3("A-3", "A-3"),
A3s("A#3", "Bb3"),
B3("B-3", "B-3"),
C4("C-4", "C-4"),
C4s("C#4", "Db4"),
D4("D-4", "D-4"),
D4s("D#4", "Eb4"),
E4("E-4", "E-4"),
F4("F-4", "F-4"),
F4s("F#4", "Gb4"),
G4("G-4", "G-4"),
G4s("G#4", "Ab4"),
A4("A-4", "A-4"),
A4s("A#4", "Bb4"),
B4("B-4", "B-4"),
C5("C-5", "C-5"),
C5s("C#5", "Db5"),
D5("D-5", "D-5"),
D5s("D#5", "Eb5"),
E5("E-5", "E-5"),
F5("F-5", "F-5"),
F5s("F#5", "Gb5"),
G5("G-5", "G-5"),
G5s("G#5", "Ab5"),
A5("A-5", "A-5"),
A5s("A#5", "Bb5"),
B5("B-5", "B-5"),
C6("C-6", "C-6"),
C6s("C#6", "Db6"),
D6("D-6", "D-6"),
D6s("D#6", "Eb6"),
E6("E-6", "E-6"),
F6("F-6", "F-6"),
F6s("F#6", "Gb6"),
G6("G-6", "G-6"),
G6s("G#6", "Ab6"),
A6("A-6", "A-6"),
A6s("A#6", "Bb6"),
B6("B-6", "B-6"),
C7("C-7", "C-7"),
C7s("C#7", "Db7"),
D7("D-7", "D-7"),
D7s("D#7", "Eb7"),
E7("E-7", "E-7"),
F7("F-7", "F-7"),
F7s("F#7", "Gb7"),
G7("G-7", "G-7"),
G7s("G#7", "Ab7"),
A7("A-7", "A-7"),
A7s("A#7", "Bb7"),
B7("B-7", "B-7"),
C8("C-8", "C-8"),
C8s("C#8", "Db8"),
D8("D-8", "D-8"),
D8s("D#8", "Eb8"),
E8("E-8", "E-8"),
F8("F-8", "F-8"),
F8s("F#8", "Gb8"),
G8("G-8", "G-8"),
G8s("G#8", "Ab8"),
A8("A-8", "A-8"),
A8s("A#8", "Bb8"),
B8("B-8", "B-8"),
C9("C-9", "C-9"),
C9s("C#9", "Db9"),
D9("D-9", "D-9"),
D9s("D#9", "Eb9"),
E9("E-9", "E-9"),
F9("F-9", "F-9"),
F9s("F#9", "Gb9"),
G9("G-9", "G-9"),
// out of midi range
//G9s("G#9","Ab9"),
//A9("A-9","A-9"),
//A9s("A#9","Bb9"),
//B9("B-9","B-9"),
NONE("---", "---"),
UP("^^^", "^^^"),
END("XXX", "XXX"),
;
// 69 = A4.ordinal
val freq: Double = round(440.0 * 2.0.pow((ordinal - 69) / 12.0)) // * 10000.0) / 10000.0
val cycleLength: Double = 1.0 / freq
var sampleDelta: Double = 0.0
fun transpose(semiNotes: Int): Note = if (ordinal >= C0.ordinal && ordinal <= G9.ordinal) {
var result = this.ordinal + semiNotes
result = min(result, G9.ordinal)
result = max(result, C0.ordinal)
fromMidi(result)
} else {
this
}
companion object {
fun fromMidi(midi: Int): Note {
// todo: add check
return entries[midi]
}
fun updateSampleRate(rate: Int) {
println("Setting sample rate to $rate")
for (note in Note.entries) {
note.sampleDelta = (1.0 / rate.toDouble()) / note.cycleLength
}
}
}
}
// freq = 10Hz
// cycleLength = 0.1
// sampleRate = 48000
// sampleDelta = 4800
// (1.0 / freq) * sampleRate

View File

@@ -55,7 +55,6 @@ kotlin {
sourceSets { sourceSets {
val commonMain by getting { val commonMain by getting {
dependencies { dependencies {
implementation(project(":common"))
//base //base
implementation("nl.astraeus:kotlin-css-generator:1.0.10") implementation("nl.astraeus:kotlin-css-generator:1.0.10")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.0") implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.0")

View File

@@ -1,36 +0,0 @@
@file:OptIn(ExperimentalKotlinGradlePluginApi::class)
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
buildscript {
apply(from = "../common.gradle.kts")
}
plugins {
kotlin("multiplatform")
}
kotlin {
js {
compilerOptions {
target.set("es2015")
}
browser()
}
/* @OptIn(ExperimentalWasmDsl::class)
wasmJs {
browser()
mavenPublication {
groupId = group as String
pom { name = "${project.name}-wasm-js" }
}
}*/
jvm()
sourceSets {
val commonMain by getting
val jsMain by getting
val jvmMain by getting
//val wasmJsMain by getting
}
}

View File

@@ -1 +0,0 @@
apply(from = "../settings.common.gradle.kts")

View File

@@ -1,192 +0,0 @@
package nl.astraeus.vst
import kotlin.math.max
import kotlin.math.min
import kotlin.math.pow
import kotlin.math.round
/**
* User: rnentjes
* Date: 14-11-15
* Time: 11:50
*/
enum class Note(
val sharp: String,
val flat: String
) {
NO01("C--","C--"),
NO02("C#-","Db-"),
NO03("D--","D--"),
NO04("D#-","Eb-"),
NO05("E--","E--"),
NO06("F--","F--"),
NO07("F#-","Gb-"),
NO08("G--","G--"),
NO09("G#-","Ab-"),
NO10("A--","A--"),
NO11("A#-","Bb-"),
NO12("B--","B--"),
C0("C-0","C-0"),
C0s("C#0","Db0"),
D0("D-0","D-0"),
D0s("D#0","Eb0"),
E0("E-0","E-0"),
F0("F-0","F-0"),
F0s("F#0","Gb0"),
G0("G-0","G-0"),
G0s("G#0","Ab0"),
A0("A-0","A-0"),
A0s("A#0","Bb0"),
B0("B-0","B-0"),
C1("C-1","C-1"),
C1s("C#1","Db1"),
D1("D-1","D-1"),
D1s("D#1","Eb1"),
E1("E-1","E-1"),
F1("F-1","F-1"),
F1s("F#1","Gb1"),
G1("G-1","G-1"),
G1s("G#1","Ab1"),
A1("A-1","A-1"),
A1s("A#1","Bb1"),
B1("B-1","B-1"),
C2("C-2","C-2"),
C2s("C#2","Db2"),
D2("D-2","D-2"),
D2s("D#2","Eb2"),
E2("E-2","E-2"),
F2("F-2","F-2"),
F2s("F#2","Gb2"),
G2("G-2","G-2"),
G2s("G#2","Ab2"),
A2("A-2","A-2"),
A2s("A#2","Bb2"),
B2("B-2","B-2"),
C3("C-3","C-3"),
C3s("C#3","Db3"),
D3("D-3","D-3"),
D3s("D#3","Eb3"),
E3("E-3","E-3"),
F3("F-3","F-3"),
F3s("F#3","Gb3"),
G3("G-3","G-3"),
G3s("G#3","Ab3"),
A3("A-3","A-3"),
A3s("A#3","Bb3"),
B3("B-3","B-3"),
C4("C-4","C-4"),
C4s("C#4","Db4"),
D4("D-4","D-4"),
D4s("D#4","Eb4"),
E4("E-4","E-4"),
F4("F-4","F-4"),
F4s("F#4","Gb4"),
G4("G-4","G-4"),
G4s("G#4","Ab4"),
A4("A-4","A-4"),
A4s("A#4","Bb4"),
B4("B-4","B-4"),
C5("C-5","C-5"),
C5s("C#5","Db5"),
D5("D-5","D-5"),
D5s("D#5","Eb5"),
E5("E-5","E-5"),
F5("F-5","F-5"),
F5s("F#5","Gb5"),
G5("G-5","G-5"),
G5s("G#5","Ab5"),
A5("A-5","A-5"),
A5s("A#5","Bb5"),
B5("B-5","B-5"),
C6("C-6","C-6"),
C6s("C#6","Db6"),
D6("D-6","D-6"),
D6s("D#6","Eb6"),
E6("E-6","E-6"),
F6("F-6","F-6"),
F6s("F#6","Gb6"),
G6("G-6","G-6"),
G6s("G#6","Ab6"),
A6("A-6","A-6"),
A6s("A#6","Bb6"),
B6("B-6","B-6"),
C7("C-7","C-7"),
C7s("C#7","Db7"),
D7("D-7","D-7"),
D7s("D#7","Eb7"),
E7("E-7","E-7"),
F7("F-7","F-7"),
F7s("F#7","Gb7"),
G7("G-7","G-7"),
G7s("G#7","Ab7"),
A7("A-7","A-7"),
A7s("A#7","Bb7"),
B7("B-7","B-7"),
C8("C-8","C-8"),
C8s("C#8","Db8"),
D8("D-8","D-8"),
D8s("D#8","Eb8"),
E8("E-8","E-8"),
F8("F-8","F-8"),
F8s("F#8","Gb8"),
G8("G-8","G-8"),
G8s("G#8","Ab8"),
A8("A-8","A-8"),
A8s("A#8","Bb8"),
B8("B-8","B-8"),
C9("C-9","C-9"),
C9s("C#9","Db9"),
D9("D-9","D-9"),
D9s("D#9","Eb9"),
E9("E-9","E-9"),
F9("F-9","F-9"),
F9s("F#9","Gb9"),
G9("G-9","G-9"),
// out of midi range
//G9s("G#9","Ab9"),
//A9("A-9","A-9"),
//A9s("A#9","Bb9"),
//B9("B-9","B-9"),
NONE("---", "---"),
UP("^^^","^^^"),
END("XXX","XXX"),
;
// 69 = A4.ordinal
val freq: Double = round(440.0 * 2.0.pow((ordinal - 69)/12.0)) // * 10000.0) / 10000.0
val cycleLength: Double = 1.0 / freq
var sampleDelta: Double = 0.0
fun transpose(semiNotes: Int): Note = if (ordinal >= C0.ordinal && ordinal <= G9.ordinal) {
var result = this.ordinal + semiNotes
result = min(result, G9.ordinal)
result = max(result, C0.ordinal)
fromMidi(result)
} else {
this
}
companion object {
fun fromMidi(midi: Int): Note {
// todo: add check
return entries[midi]
}
fun updateSampleRate(rate: Int) {
println("Setting sample rate to $rate")
for (note in Note.entries) {
note.sampleDelta = (1.0 / rate.toDouble()) / note.cycleLength
}
}
}
}
// freq = 10Hz
// cycleLength = 0.1
// sampleRate = 48000
// sampleDelta = 4800
// (1.0 / freq) * sampleRate

View File

@@ -2,5 +2,4 @@ apply(from = "settings.common.gradle.kts")
rootProject.name = "vst-chip" rootProject.name = "vst-chip"
include(":common")
include(":audio-worklet") include(":audio-worklet")

View File

@@ -1,6 +1,7 @@
package nl.astraeus.vst.chip package nl.astraeus.vst.chip
import nl.astraeus.vst.base.Settings import nl.astraeus.vst.base.Settings
import nl.astraeus.vst.base.db.Database
import nl.astraeus.vst.base.web.UndertowServer import nl.astraeus.vst.base.web.UndertowServer
import nl.astraeus.vst.chip.logger.LogLevel import nl.astraeus.vst.chip.logger.LogLevel
import nl.astraeus.vst.chip.logger.Logger import nl.astraeus.vst.chip.logger.Logger
@@ -15,38 +16,7 @@ fun main() {
Settings.port = 9005 Settings.port = 9005
Settings.jdbcStatsPort = 6005 Settings.jdbcStatsPort = 6005
/* Database.start()
Class.forName("nl.astraeus.jdbc.Driver")
Database.initialize(HikariConfig().apply {
driverClassName = "nl.astraeus.jdbc.Driver"
jdbcUrl = "jdbc:stat:webServerPort=6002:jdbc:sqlite:data/chip.db"
username = "sa"
password = ""
maximumPoolSize = 25
isAutoCommit = false
validate()
})
val sessionHandler = SessionAttachmentHandler(
InMemorySessionManager("vst-session-manager"),
SessionCookieConfig()
)
sessionHandler.setNext(RequestHandler)
val server = Undertow.builder()
.addHttpListener(Settings.port, "localhost")
.setIoThreads(4)
.setHandler(sessionHandler)
.setServerOption(UndertowOptions.SHUTDOWN_TIMEOUT, 1000)
.build()
println("Starting server at port ${Settings.port}...")
server?.start()
*/
UndertowServer.start( UndertowServer.start(
"Vst Chip", "Vst Chip",