Skip to content

Instantly share code, notes, and snippets.

@wighawag
Last active March 21, 2017 17:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wighawag/769a17f8df820c43b7bb to your computer and use it in GitHub Desktop.
Save wighawag/769a17f8df820c43b7bb to your computer and use it in GitHub Desktop.
Kha White Noise
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