This file contains 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-----|-----------------| |
This file contains 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
docker rm -f $(docker container ls -q -a) | |
docker volume rm $(docker volume ls -q) | |
docker rmi $(docker images -q) |
This file contains 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
val df1 = fftData("fft-triangular", freqCutOff = 10 to 3800) | |
lets_plot(df1) {x = "time"; y = "freq"; fill = "value"} + | |
ggsize(1000, 600) + | |
geom_tile() + | |
scale_fill_gradient(low = "light_green", high = "red") | |
val df2 = fftData("fft-hamming", freqCutOff = 10 to 3800) | |
lets_plot(df2) {x = "time"; y = "freq"; fill = "value"} + | |
ggsize(1000, 600) + | |
geom_tile() + |
This file contains 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
fun fftData(table: String, freqCutOff: Pair<Int, Int>): Map<String, List<Any>> { | |
val k = Klaxon() | |
val server = "http://localhost:6800" | |
// 1. read and deserializae the data | |
val data = URL("$server/table/$table/last?interval=10s").openStream().reader().readLines() | |
.map { k.parse<Result>(it)!! } | |
// 2. Calculate the time value to shift values to 0 by x-axis | |
val timeShift = data.asSequence().map { it.value.time }.min() ?: 0 |
This file contains 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
data class FftSample( | |
val index: Long, | |
val binCount: Int, | |
val samplesCount: Int, | |
val sampleRate: Float, | |
val magnitude: List<Double>, | |
val phase: List<Double>, | |
val frequency: List<Double>, | |
val time: Long | |
) |
This file contains 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
%use klaxon | |
%use lets-plot | |
import java.net.* | |
import jetbrains.letsPlot.scale.* |
This file contains 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
val overseer = LocalDistributedOverseer( | |
listOf(triangularFft, hammingFft), | |
threadsCount = 2, | |
partitionsCount = 2 | |
) | |
val errors = overseer.eval(44100.0f) | |
.map { it.get().exception } | |
.filterNotNull() | |
.toList() |
This file contains 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
//Specify the parameters of future calculations: | |
val windowSize = 801 | |
val stepSize = 256 | |
val fftSize = 1024 | |
// Define a signal, windowed sum of sinusoids: | |
val signal = (880.sine() + 440.sine() + 220.sine()) | |
.window(windowSize, stepSize) | |
// The first FFT applying the triangular window function: |
This file contains 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
%use lets-plot | |
@file:Repository("https://dl.bintray.com/wavebeans/wavebeans") | |
@file:DependsOn("io.wavebeans:lib:0.0.3") | |
@file:DependsOn("io.wavebeans:exe:0.0.3") | |
@file:DependsOn("io.wavebeans:http:0.0.3") | |
import io.wavebeans.lib.* | |
import io.wavebeans.lib.io.* | |
import io.wavebeans.lib.math.* |
This file contains 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
val o = (880.sine() + 440.sine() + 220.sine()) | |
.trim(1000, MILLISECONDS) | |
val values = o.asSequence(44100.0f) | |
.drop(500) | |
.take(400) | |
.map { it.asDouble() } | |
.toList() | |
val values2 = o.asSequence(44100.0f) |
NewerOlder