From 41d6675bd42130112da67e3475e863ef97dc63ee Mon Sep 17 00:00:00 2001 From: Abe Pazos Date: Mon, 10 Oct 2022 10:45:50 +0000 Subject: [PATCH] [orx-minim] Fix audio file loading, add demo (#280) --- demo-data/sounds/26777__junggle__btn402.mp3 | Bin 0 -> 1462 bytes demo-data/sounds/26777__junggle__btn402.txt | 8 ++++++ .../src/demo/kotlin/DemoPlaySound01.kt | 24 ++++++++++++++++++ orx-jvm/orx-minim/src/main/kotlin/Minim.kt | 3 ++- 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 demo-data/sounds/26777__junggle__btn402.mp3 create mode 100644 demo-data/sounds/26777__junggle__btn402.txt create mode 100644 orx-jvm/orx-minim/src/demo/kotlin/DemoPlaySound01.kt diff --git a/demo-data/sounds/26777__junggle__btn402.mp3 b/demo-data/sounds/26777__junggle__btn402.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..f18599a70a680d3b29a9706bc0979d7180fd8934 GIT binary patch literal 1462 zcmezWJKz8V0|Nu2jtBz-V}@GtZcPUUh6V-(24)5WMizkv27ZPG4I;`XcE~-Mb%(d_ zgU!qG1l0$;mG=)EWK(K6{&T^5!2@&bKkRL4_PDG6-{C?VA7h}n{Qt)WO+1~4ivR!D zn%bc#5V!3A|39B+i3+DKa%Nyq5MXhbeEaRUb_RxPt4-HMm8{!xd77Bk317+l9Vv-( zh0{DgTzaX-u%o7k`?q5Kq?Q>oxilA?sL)>AapA7zs;uj!{Y4e;Bm%e=yz;rruD>+s zYT+#-;pCzR?;Sp6{Qn(vz@R~ZmwDmOWj7*yrmX$GB!OAVC^x({BamD0(8NVOCrd6Q zyWBk^{cjdq%KmGq7K|dF92gil^L8f)c&_-jNJc_}x5hT`*52Iv|NsA&`l^>|8kdwm48YDa%*w&=aq7r#~Qrj^f~nj7KdQ@M0^5h-U=*X?WN=-iepd`LU-(w&YzowLn$AP?CwaLm}Azk6Y47iXU_C85LmdesjrL6OhaRhW9)&&6(XV&0`54v9c49Nuz-0o&rK+If SU~o8%JXe4`bY>WNhyehpb*y;+ literal 0 HcmV?d00001 diff --git a/demo-data/sounds/26777__junggle__btn402.txt b/demo-data/sounds/26777__junggle__btn402.txt new file mode 100644 index 00000000..8f0505fc --- /dev/null +++ b/demo-data/sounds/26777__junggle__btn402.txt @@ -0,0 +1,8 @@ +Sound author +http://jazzy.junggle.net/ + +License +https://creativecommons.org/licenses/by/4.0/ + +Downloaded from +https://freesound.org/s/26777/ diff --git a/orx-jvm/orx-minim/src/demo/kotlin/DemoPlaySound01.kt b/orx-jvm/orx-minim/src/demo/kotlin/DemoPlaySound01.kt new file mode 100644 index 00000000..bb215d7a --- /dev/null +++ b/orx-jvm/orx-minim/src/demo/kotlin/DemoPlaySound01.kt @@ -0,0 +1,24 @@ +import org.openrndr.application +import org.openrndr.extra.minim.minim + +fun main() { + application { + program { + val minim = minim() + val player = minim.loadFile( + "demo-data/sounds/26777__junggle__btn402.mp3" + ) + + // fade gain to -40dB in 15 seconds + player.shiftGain(player.gain, -40f, 15000) + + extend { + if(frameCount % 30 == 0) { + player.rewind() + //player.gain = Random.nextDouble(-20.0, 0.0).toFloat() + player.play() + } + } + } + } +} \ No newline at end of file diff --git a/orx-jvm/orx-minim/src/main/kotlin/Minim.kt b/orx-jvm/orx-minim/src/main/kotlin/Minim.kt index 02f4354e..50dbc5a8 100644 --- a/orx-jvm/orx-minim/src/main/kotlin/Minim.kt +++ b/orx-jvm/orx-minim/src/main/kotlin/Minim.kt @@ -3,10 +3,11 @@ package org.openrndr.extra.minim import ddf.minim.Minim import org.openrndr.Program import java.io.File +import java.io.InputStream class MinimObject { fun sketchPath(fileName:String) = "./" - fun createInput(fileName: String) = File(fileName).inputStream() + fun createInput(fileName: String) = File(fileName).inputStream() as InputStream } fun Program.minim(): Minim {