Last active
March 21, 2017 17:50
-
-
Save wighawag/769a17f8df820c43b7bb to your computer and use it in GitHub Desktop.
Kha White Noise
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 kha.System; | |
import kha.Scheduler; | |
class Main{ | |
public static function main(){ | |
System.init({ | |
title: "dsp", | |
width: 800, | |
height: 600, | |
}, initialized); | |
} | |
static function initialized() { | |
kha.audio2.Audio.audioCallback = dsp; | |
} | |
static function dsp(numSamplesToWrite : Int, buffer : kha.audio2.Buffer){ | |
for (i in 0...numSamplesToWrite) { | |
buffer.data.set(buffer.writeLocation, Math.random() * 2 - 1); | |
buffer.writeLocation += 1; | |
if (buffer.writeLocation >= buffer.size) { | |
buffer.writeLocation = 0; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment