Skip to content

Instantly share code, notes, and snippets.

@lewislepton
Forked from wighawag/Main.hx
Last active March 21, 2017 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lewislepton/e6dc5623d8696f7b315eef34f0faf654 to your computer and use it in GitHub Desktop.
Save lewislepton/e6dc5623d8696f7b315eef34f0faf654 to your computer and use it in GitHub Desktop.
Kha White Noise
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