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