-
-
Save lewislepton/e6dc5623d8696f7b315eef34f0faf654 to your computer and use it in GitHub Desktop.
Kha White Noise
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
package; | |
import kha.Framebuffer; | |
import kha.Color; | |
import kha.Assets; | |
import kha.audio2.Audio; | |
import kha.audio2.Buffer; | |
class Project { | |
public function new() { | |
Audio.audioCallback = DSP; | |
} | |
public function update():Void { | |
} | |
public function render(framebuffer:Framebuffer):Void { | |
var graphics = framebuffer.g2; | |
graphics.begin(); | |
graphics.end(); | |
} | |
public function DSP(samples:Int, buffer:Buffer){ | |
for (i in 0 ... samples) { | |
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