Created
January 29, 2022 21:26
-
-
Save asubb/8fb0284e24c500d3ef21c2f96e6e57e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.wavebeans.daw.SineVoice | |
import io.wavebeans.daw.Standard6StringTuning | |
import io.wavebeans.daw.synthesize | |
import io.wavebeans.daw.tab | |
import io.wavebeans.execution.SingleThreadedOverseer | |
import io.wavebeans.lib.io.toMono24bitWav | |
val stream = | |
""" | |
e|-------5-7-----7-|-8-----8-2-----2-|-0---------0-----|-----------------| | |
B|-----5-----5-----|---5-------3-----|---1---1-----1---|-0-1-1-----------| | |
G|---5---------5---|-----5-------2---|-----2---------2-|-0-2-2---2-------| | |
D|-7-------6-------|-5-------4-------|-3---------------|-----------------| | |
A|-----------------|-----------------|-----------------|-2-0-0---0---8-7-| | |
E|-----------------|-----------------|-----------------|-----------------| | |
e|---------7-----7-|-8-----8-2-----2-|-0---------0-----|-----------------| | |
B|-------5---5-----|---5-------3-----|---1---1-----1---|-0-1-1-----------| | |
G|-----5-------5---|-----5-------2---|-----2---------2-|-0-2-2-----------| | |
D|---7-----6-------|-5-------4-------|-3---------------|-----------------| | |
A|-0---------------|-----------------|-----------------|-2-0-0-------0-2-| | |
E|-----------------|-----------------|-----------------|-----------------| | |
e|-------0-2-----2-|-0-----0----------|---------3-----3-|-3-2-2-2---------| | |
B|-----------3-----|---1-----0-1------|-1-----1---0-----|-----3-3---------| | |
G|-----0-------2---|-----2-------2----|---0---------0---|-----2-2---------| | |
D|---2-----0-------|-3----------------|-----2-----------|-0---0-0---------| | |
A|-3---------------|---------0----0-2-|-3---------------|-------------0-2-| | |
E|-----------------|------------------|---------3-------|-----------------| | |
e|---------2-----2-|-0-----0----------|---------------2-|-0-0-0-----------| | |
B|-------1---3-----|---1-----0-1------|-------1-----3---|-1-1-1-----------| | |
G|-----0-------2---|-----2-------2----|-----0-----2-----|-2-2-2-----------| | |
D|---2-----0-------|-3----------------|---2-----0-------|-3-3-3-----------| | |
A|-3---------------|---------0----0-2-|-3---------------|-----------------| | |
E|-----------------|------------------|-----------------|-----------------| | |
""".trimIndent().tab(Standard6StringTuning, 80.0f, Pair(1, 8), Pair(4, 4)) | |
.synthesize( | |
mapOf( | |
"e" to SineVoice(), | |
"B" to SineVoice(), | |
"G" to SineVoice(), | |
"D" to SineVoice(), | |
"A" to SineVoice(), | |
"E" to SineVoice(), | |
) | |
) | |
.toMono24bitWav("file:///users/asubb/tmp/guitar.wav") | |
val outputs = listOf(stream) | |
val sampleRate = 44100.0f | |
SingleThreadedOverseer(outputs).use { overseer -> | |
val results = overseer.eval(sampleRate).map { it.get() } | |
if (!results.all { it.finished }) { | |
println("Execution failed.") | |
results.mapNotNull { it.exception } | |
.forEach { it.printStackTrace(System.err) } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment