Add orx-minim
This commit is contained in:
9
orx-jvm/orx-minim/README.md
Normal file
9
orx-jvm/orx-minim/README.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# orx-minim
|
||||||
|
|
||||||
|
A minimal Minim support library
|
||||||
|
|
||||||
|
## usage
|
||||||
|
|
||||||
|
Add `orx-minim` to `orxFeatures`
|
||||||
|
|
||||||
|
Check the [example](src/demo/kotlin/DemoFFT01.kt)
|
||||||
34
orx-jvm/orx-minim/build.gradle.kts
Normal file
34
orx-jvm/orx-minim/build.gradle.kts
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
sourceSets {
|
||||||
|
val main by getting { }
|
||||||
|
val demo by creating {
|
||||||
|
java {
|
||||||
|
srcDir("src/demo/kotlin")
|
||||||
|
compileClasspath += main.getCompileClasspath()
|
||||||
|
runtimeClasspath += main.getRuntimeClasspath()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val openrndrVersion: String by rootProject.extra
|
||||||
|
val openrndrOS: String by rootProject.extra
|
||||||
|
val slf4jVersion: String by rootProject.extra
|
||||||
|
val kotlinVersion: String by rootProject.extra
|
||||||
|
val demoImplementation by configurations.getting {}
|
||||||
|
val demoRuntimeOnly by configurations.getting {}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api(project(":orx-parameters"))
|
||||||
|
api(project(":orx-jvm:orx-panel"))
|
||||||
|
|
||||||
|
api("net.compartmental.code:minim:2.2.2") {
|
||||||
|
exclude(group = "org.apache.maven.plugins", module = "maven-javadoc-plugin")
|
||||||
|
}
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
|
||||||
|
demoImplementation("org.openrndr:openrndr-application:$openrndrVersion")
|
||||||
|
demoImplementation("org.openrndr:openrndr-extensions:$openrndrVersion")
|
||||||
|
|
||||||
|
demoRuntimeOnly("org.slf4j:slf4j-simple:$slf4jVersion")
|
||||||
|
demoRuntimeOnly("org.openrndr:openrndr-gl3:$openrndrVersion")
|
||||||
|
demoRuntimeOnly("org.openrndr:openrndr-gl3-natives-$openrndrOS:$openrndrVersion")
|
||||||
|
demoImplementation(sourceSets.getByName("main").output)
|
||||||
|
}
|
||||||
31
orx-jvm/orx-minim/src/demo/kotlin/DemoFFT01.kt
Normal file
31
orx-jvm/orx-minim/src/demo/kotlin/DemoFFT01.kt
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import ddf.minim.Minim
|
||||||
|
import ddf.minim.analysis.FFT
|
||||||
|
import ddf.minim.analysis.LanczosWindow
|
||||||
|
|
||||||
|
import org.openrndr.application
|
||||||
|
import org.openrndr.extra.minim.minim
|
||||||
|
import org.openrndr.math.map
|
||||||
|
import kotlin.math.ln
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
application {
|
||||||
|
configure {
|
||||||
|
width = 1280
|
||||||
|
height = 720
|
||||||
|
}
|
||||||
|
|
||||||
|
program {
|
||||||
|
val minim = minim()
|
||||||
|
val lineIn = minim.getLineIn(Minim.MONO, 2048, 48000f)
|
||||||
|
val fft = FFT(lineIn.bufferSize(), lineIn.sampleRate())
|
||||||
|
fft.window(LanczosWindow())
|
||||||
|
extend {
|
||||||
|
fft.forward(lineIn.mix)
|
||||||
|
for (i in 0 until 200) {
|
||||||
|
val bandDB = 20.0 * ln(2.0 * fft.getBand(i) / fft.timeSize())
|
||||||
|
drawer.rectangle(i * 5.0, height / 2.0, 5.0, bandDB.map(0.0, -150.0, 0.0, -height / 8.0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
19
orx-jvm/orx-minim/src/main/kotlin/Minim.kt
Normal file
19
orx-jvm/orx-minim/src/main/kotlin/Minim.kt
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package org.openrndr.extra.minim
|
||||||
|
|
||||||
|
import ddf.minim.Minim
|
||||||
|
import org.openrndr.Program
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
class MinimObject {
|
||||||
|
fun sketchPath(fileName:String) = "./"
|
||||||
|
fun createInput(fileName: String) = File(fileName).inputStream()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Program.minim(): Minim {
|
||||||
|
val minim = Minim(MinimObject())
|
||||||
|
ended.listen {
|
||||||
|
minim.stop()
|
||||||
|
|
||||||
|
}
|
||||||
|
return minim
|
||||||
|
}
|
||||||
@@ -27,6 +27,7 @@ include 'openrndr-demos',
|
|||||||
'orx-kdtree',
|
'orx-kdtree',
|
||||||
'orx-jvm:orx-keyframer',
|
'orx-jvm:orx-keyframer',
|
||||||
'orx-mesh-generators',
|
'orx-mesh-generators',
|
||||||
|
'orx-jvm:orx-minim',
|
||||||
'orx-jvm:orx-kotlin-parser',
|
'orx-jvm:orx-kotlin-parser',
|
||||||
'orx-jvm:orx-midi',
|
'orx-jvm:orx-midi',
|
||||||
'orx-no-clear',
|
'orx-no-clear',
|
||||||
|
|||||||
Reference in New Issue
Block a user