Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
ShirasawaSama committed Dec 10, 2023
1 parent 780010b commit 804d993
Show file tree
Hide file tree
Showing 35 changed files with 59 additions and 461 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@ jobs:
- name: Check out git repository
uses: actions/checkout@v3

- name: Set up JDK 19
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: liberica
java-version: 19
java-version: 21

- name: Build
shell: bash
run: |
sed -i "s/0\.0\.0/${{ github.event.release.tag_name }}/" gradle.properties
sed -i "s/--add-exports=java.desktop\/com.apple.eawt.event=ALL-UNNAMED//" release-bin/.vmoptions
mkdir package
./gradlew :daw:shadowJar
./gradlew --stop
./gradlaaew --stop
cp daw/build/libs/daw.jar package/EchoInMirror.jar
cp -R release-bin/. package/
curl https://github.com/EchoInMirror/EIMHost/releases/latest/download/EIMHost-x86.exe -o package/EIMHost-x86.exe -L
Expand Down
3 changes: 1 addition & 2 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization") version "1.9.20"
kotlin("plugin.serialization") version System.getProperty("kotlinVersion")
id("org.jetbrains.compose")
}

Expand All @@ -16,7 +16,6 @@ kotlin {
sourceSets {
named("commonMain") {
dependencies {
compileOnly(project(":time-stretchers"))
api(project(":audio-sources"))
api(project(":audio-processors"))
api(project(":utils"))
Expand Down
2 changes: 1 addition & 1 deletion audio-processors/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization") version "1.9.20"
kotlin("plugin.serialization") version System.getProperty("kotlinVersion")
id("org.jetbrains.compose")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ abstract class AbstractAudioPlayer(

interface AudioPlayerFactory {
val name: String
val isEnabled: Boolean
suspend fun getPlayers(): List<String>
fun create(
name: String, currentPosition: MutableCurrentPosition, processor: AudioProcessor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private val audioProcessorFactoryLogger = KotlinLogging.logger("AudioProcessorFa
@Serializable(with = AudioProcessorFactoryNameSerializer::class)
interface AudioProcessorFactory<T: AudioProcessor> : IDisplayName {
val name: String
val isEnabled: Boolean
val descriptions: Set<AudioProcessorDescription>
suspend fun createAudioProcessor(description: AudioProcessorDescription): T
suspend fun createAudioProcessor(path: Path): T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ class AudioPlayerManagerImpl : AudioPlayerManager {

override fun reload() {
factories.clear()
factories.putAll(ServiceLoader.load(AudioPlayerFactory::class.java).associateBy { it.name })
factories.putAll(ServiceLoader.load(AudioPlayerFactory::class.java).filter { it.isEnabled }.associateBy { it.name })
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AudioProcessorManagerImpl: AudioProcessorManager {

override fun reload() {
factories.clear()
ServiceLoader.load(AudioProcessorFactory::class.java).forEach { factories[it.name] = it }
ServiceLoader.load(AudioProcessorFactory::class.java).filter { it.isEnabled }.forEach { factories[it.name] = it }
}

override suspend fun createAudioProcessor(factory: String, description: AudioProcessorDescription): AudioProcessor {
Expand Down
2 changes: 1 addition & 1 deletion audio-sources/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization") version "1.9.20"
kotlin("plugin.serialization") version System.getProperty("kotlinVersion")
}

kotlin {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("org.jetbrains.compose") apply false
kotlin("multiplatform") version "1.9.20" apply false
kotlin("multiplatform") version System.getProperty("kotlinVersion") apply false
`maven-publish`
}

Expand Down
2 changes: 1 addition & 1 deletion components/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import org.jetbrains.compose.ComposeBuildConfig

plugins {
kotlin("multiplatform")
kotlin("plugin.serialization") version "1.9.20"
kotlin("plugin.serialization") version System.getProperty("kotlinVersion")
id("org.jetbrains.compose")
}

Expand Down
3 changes: 1 addition & 2 deletions daw/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import java.net.URI

plugins {
kotlin("multiplatform")
kotlin("plugin.serialization") version "1.9.20"
kotlin("plugin.serialization") version System.getProperty("kotlinVersion")
id("org.jetbrains.compose")
id("com.github.johnrengelman.shadow") version "8.1.1"
id("java")
Expand Down Expand Up @@ -37,7 +37,6 @@ kotlin {
api(project(":api"))
api(project(":native"))
api(project(":audio-sources"))
api(project(":time-stretchers"))

api(compose.desktop.currentOs) {
exclude("org.jetbrains.compose.material")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
package com.eimsound.daw.dawutils

import androidx.compose.ui.graphics.Color
import java.lang.foreign.Addressable
import java.lang.foreign.Arena
import java.lang.foreign.FunctionDescriptor
import java.lang.foreign.Linker
import java.lang.foreign.MemorySession
import java.lang.foreign.SymbolLookup
import java.lang.foreign.ValueLayout
import kotlin.math.roundToLong

private val session by lazy { MemorySession.openImplicit() }
private val DwmSetWindowAttribute by lazy {
val linker = Linker.nativeLinker()
val kernel = SymbolLookup.libraryLookup("dwmapi.dll", session)
val kernel = SymbolLookup.libraryLookup("dwmapi.dll", Arena.global())
linker.downcallHandle(
kernel.lookup("DwmSetWindowAttribute").orElseThrow(),
kernel.find("DwmSetWindowAttribute").orElseThrow(),
FunctionDescriptor.of(
ValueLayout.JAVA_LONG,
ValueLayout.JAVA_LONG,
Expand All @@ -30,10 +28,10 @@ internal enum class WindowColorType(val value: Int) {
}
internal fun windowsSetWindowColor(handle: Long, color: Color, type: WindowColorType = WindowColorType.CAPTION) = try {
(DwmSetWindowAttribute.invokeExact(handle, type.value,
session.allocate(
Arena.ofAuto().allocate(
ValueLayout.JAVA_LONG,
(color.blue * 255).roundToLong() shl 16 or ((color.green * 255).roundToLong() shl 8) or ((color.red * 255).roundToLong() shl 0)
) as Addressable, 4) as Long) >= 0
), 4) as Long) >= 0
} catch (ignored: Throwable) {
false
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ internal fun EditorControls(clip: TrackClip<AudioClip>) {
}
OutlinedDropdownSelector(
{ c.timeStretcher = it },
timeStretchers, c.timeStretcher.ifEmpty { timeStretchers.first() },
timeStretchers, c.timeStretcher.ifEmpty { timeStretchers.firstOrNull() },
Modifier.height(40.dp).fillMaxWidth(), label = "变速算法"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class EIMAudioProcessorFactory : AudioProcessorFactory<AudioProcessor> {
override val name = EIMAudioProcessorFactoryName
override val displayName = "内置"
override val descriptions = setOf(KarplusStrongSynthesizerDescription)
override val isEnabled = true
private val audioProcessors = descriptions.associateBy { it.name }

override suspend fun createAudioProcessor(description: AudioProcessorDescription): AudioProcessor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class DefaultTrackFactory : TrackFactory<Track> {
override val name = "DefaultTrackFactory"
override val displayName = "默认"
override val descriptions = setOf(DefaultTrackDescription)
override val isEnabled = true

override suspend fun createAudioProcessor(description: AudioProcessorDescription): TrackImpl {
defaultTrackLogger.info { "Creating track ${description.identifier}" }
Expand Down
2 changes: 1 addition & 1 deletion dsp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization") version "1.9.20"
kotlin("plugin.serialization") version System.getProperty("kotlinVersion")
id("org.jetbrains.compose")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.eimsound.dsp.timestretcher
import java.util.ServiceLoader

/**
* @see com.eimsound.dsp.timestretcher.impl.NativeTimeStretcherFactory
* @see com.eimsound.dsp.native.timestretcher.NativeTimeStretcherFactory
*/
interface TimeStretcherFactory {
val timeStretchers: List<String>
Expand Down
6 changes: 4 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
version=0.0.0

jvm.version=19
jvm.version=21
kotlin.code.style=official
kotlin.incremental.useClasspathSnapshot=true
kotlin.version=1.9.20

systemProp.kotlinVersion=1.9.21
kotlin.version=1.9.21
kapt.use.worker.api=true
kapt.incremental.apt=true

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
6 changes: 4 additions & 2 deletions native/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization") version "1.9.20"
kotlin("plugin.serialization") version System.getProperty("kotlinVersion")
id("org.jetbrains.compose")
}

Expand All @@ -24,12 +24,14 @@ kotlin {
}
named("jvmMain") {
dependencies {
compileOnly(project(":dsp"))
implementation(project(":utils"))
implementation(compose.runtime)
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${extra["eim.dependencies.kotlinx.coroutines"]}")
implementation("org.apache.commons:commons-lang3:${extra["eim.dependencies.commons.lang"]}")
implementation("org.slf4j:slf4j-api:${extra["eim.dependencies.slf4j"]}")
implementation("com.github.ShirasawaSama:JavaSharedMemory:0.1.5")
implementation("com.github.ShirasawaSama:JavaSharedMemory:0.2.0")
implementation("com.github.EchoInMirror:EIMTimeStretchers:0.1.1")

compileOnly(compose.material3)
compileOnly(compose.materialIconsExtended)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class JvmAudioPlayer(

class JvmAudioPlayerFactory : AudioPlayerFactory {
override val name = "JVM"
override val isEnabled = true

override suspend fun getPlayers() = AudioSystem.getMixerInfo().mapNotNull {
if (AudioSystem.getMixer(it).sourceLineInfo.any { i -> i is DataLine.Info }) it.name
else null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import java.io.EOFException
import java.nio.ByteBuffer
import java.nio.file.Files
import java.util.*
import kotlin.io.path.Path

private val logger = KotlinLogging.logger { }
class NativeAudioPlayer(
Expand Down Expand Up @@ -202,6 +204,7 @@ class NativeAudioPlayer(
class NativeAudioPlayerFactory : AudioPlayerFactory {
private val execFile get() = System.getProperty("eim.dsp.nativeaudioplayer.file")
override val name = "Native"
override val isEnabled get() = execFile != null && Files.exists(Path(execFile))
override suspend fun getPlayers() = withContext(Dispatchers.IO) {
ProcessBuilder(execFile, "-O", "-A").start().inputStream
.readAllBytes().decodeToString().split("\$EIM\$").filter { it.isNotEmpty() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ class NativeAudioPluginFactoryImpl: NativeAudioPluginFactory {

private fun getNativeHostPath(isX86: Boolean = false) = Paths.get(System.getProperty("eim.dsp.nativeaudioplugins.host" +
(if (isX86) ".x86" else ""))).absolutePathString()

override val isEnabled get() = Path(getNativeHostPath()).exists()
fun getNativeHostPath(description: NativeAudioPluginDescription) =
getNativeHostPath(SystemUtils.IS_OS_WINDOWS && description.isX86)
private fun getNativeHostPath(path: String) = getNativeHostPath(SystemUtils.IS_OS_WINDOWS && File(path).isX86PEFile())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.eimsound.dsp.timestretcher.impl
package com.eimsound.dsp.native.timestretcher

import com.eimsound.dsp.timestretcher.TimeStretcher
import com.eimsound.dsp.timestretcher.TimeStretcherFactory
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.eimsound.dsp.native.timestretcher.NativeTimeStretcherFactory
2 changes: 1 addition & 1 deletion release-bin/.vmoptions
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-Xms128m
-Xmx4G
-Xmx6G
-XX:ReservedCodeCacheSize=512m
-XX:+UseZGC
-XX:SoftRefLRUPolicyMSPerMB=50
Expand Down
7 changes: 7 additions & 0 deletions release-bin/eim-debug.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@echo off

set JAVA_EXE="%~dp0\jre\bin\java.exe"
if not exist "%JAVA_EXE%" set JAVA_EXE=java.exe

echo %JAVA_EXE% -Xms1G -XX:+UseZGC --enable-preview --enable-native-access=ALL-UNNAMED -jar "%~dp0\EchoInMirror.jar" %*
%JAVA_EXE% -Xms1G -XX:+UseZGC --enable-preview --enable-native-access=ALL-UNNAMED -jar "%~dp0\EchoInMirror.jar" %*
9 changes: 9 additions & 0 deletions release-bin/eim-debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

java="jre/bin/java"
if [ ! -f java ]; then
java="java"
fi

echo $java -Xms1G -XX:+UseZGC --enable-preview --enable-native-access=ALL-UNNAMED -jar EchoInMirror.jar "$@"
$java -Xms1G -XX:+UseZGC --enable-preview --enable-native-access=ALL-UNNAMED -jar EchoInMirror.jar "$@"
1 change: 0 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ include(
":components",
":utils",
":audio-sources",
":time-stretchers",
":dsp",
":audio-processors",
":native",
Expand Down
30 changes: 0 additions & 30 deletions time-stretchers/build.gradle.kts

This file was deleted.

This file was deleted.

Loading

0 comments on commit 804d993

Please sign in to comment.