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 kotlin.math.max | |
| import kotlin.random.Random | |
| fun compressHash(hexV: String, digits: String = "0123456789abcdefghijklmnopqrstuvwxyz"): String { | |
| val hexDigits = "0123456789abcdef" | |
| val zero = hexDigits.first() | |
| fun dropLeadingZeros(hexV: String): String { | |
| var v = hexV |
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
| FROM jupyter/base-notebook | |
| USER root | |
| # Install OpenJDK-8 | |
| RUN apt-get update && \ | |
| apt-get install -y openjdk-8-jdk && \ | |
| apt-get install -y ant && \ | |
| apt-get clean; |
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
| %use lets-plot | |
| @file:Repository("https://dl.bintray.com/wavebeans/wavebeans") | |
| @file:DependsOn("io.wavebeans:lib:0.0.3") | |
| import io.wavebeans.lib.* | |
| import io.wavebeans.lib.io.* | |
| import io.wavebeans.lib.math.* | |
| import io.wavebeans.lib.stream.* | |
| import io.wavebeans.lib.stream.fft.* |
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
| 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) |
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
| %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 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
| //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 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
| 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 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
| %use klaxon | |
| %use lets-plot | |
| import java.net.* | |
| import jetbrains.letsPlot.scale.* |
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
| 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 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
| 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 |
OlderNewer