|
|
|
@ -2,21 +2,19 @@ package music
|
|
|
|
|
|
|
|
|
|
import music.Filter.Filters
|
|
|
|
|
import music.Params.SAMPLES
|
|
|
|
|
import music.generators.Generator
|
|
|
|
|
import music.generators.ToneGenerator
|
|
|
|
|
import javax.sound.sampled.AudioFormat;
|
|
|
|
|
import javax.sound.sampled.AudioSystem;
|
|
|
|
|
import javax.sound.sampled.DataLine;
|
|
|
|
|
import javax.sound.sampled.SourceDataLine;
|
|
|
|
|
import javax.sound.sampled.AudioFormat
|
|
|
|
|
import javax.sound.sampled.AudioSystem
|
|
|
|
|
import javax.sound.sampled.DataLine
|
|
|
|
|
import javax.sound.sampled.SourceDataLine
|
|
|
|
|
|
|
|
|
|
object Params {
|
|
|
|
|
val SAMPLES = 44100;
|
|
|
|
|
const val SAMPLES = 44100
|
|
|
|
|
const val PI = kotlin.math.PI.toFloat()
|
|
|
|
|
val CORES = Runtime.getRuntime().availableProcessors()
|
|
|
|
|
val PI = kotlin.math.PI.toFloat()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun main(args: Array<String>) {
|
|
|
|
|
fun main() {
|
|
|
|
|
|
|
|
|
|
val format = AudioFormat(SAMPLES.toFloat(), 16, 1, true, false)
|
|
|
|
|
val info = DataLine.Info( SourceDataLine::class.java, format)
|
|
|
|
@ -25,15 +23,9 @@ fun main(args: Array<String>) {
|
|
|
|
|
line.open(format)
|
|
|
|
|
line.start()
|
|
|
|
|
|
|
|
|
|
for (i in 0..12) {
|
|
|
|
|
|
|
|
|
|
val gen = ToneGenerator(.2f, i, WaveformTransformations::sine)
|
|
|
|
|
|
|
|
|
|
val gen = ToneGenerator(.2f, -24, WaveformTransformations::sawtooth)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val signal = Filters.ease(gen.getWave(Samples(1)))
|
|
|
|
|
val signal = Filters.ease(gen.get(Samples(2)))
|
|
|
|
|
|
|
|
|
|
line.write(signal.toBytes(), 0, signal.size * 2)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|