renamed some stuff
This commit is contained in:
parent
234c26f377
commit
ac69e0c48d
@ -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, -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)
|
||||
}
|
||||
|
@ -4,12 +4,12 @@ import music.Samples
|
||||
import music.Signal
|
||||
import music.WaveformTransformation
|
||||
|
||||
abstract class Generator(val volume: Float, val waveform: WaveformTransformation) {
|
||||
abstract class Generator(private val volume: Float, private val waveform: WaveformTransformation) {
|
||||
|
||||
fun getWave(samples: Samples): Signal {
|
||||
fun get(samples: Samples): Signal {
|
||||
return waveform(generate(samples), volume)
|
||||
}
|
||||
|
||||
abstract fun generate(samples: Samples): Samples
|
||||
protected abstract fun generate(samples: Samples): Samples
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user