Skip to content

Instantly share code, notes, and snippets.

@01010111
Created August 21, 2018 19:20
Show Gist options
  • Save 01010111/db8fbe9e000ed183c29a19e493ae59b8 to your computer and use it in GitHub Desktop.
Save 01010111/db8fbe9e000ed183c29a19e493ae59b8 to your computer and use it in GitHub Desktop.
Lime + OpenAL + wonky sounds
package zsynth;
import lime.utils.Float32Array;
import lime.media.openal.*;
using Math;
class ZSynth
{
public function new()
{
var device = ALC.openDevice();
var context = ALC.createContext(device);
ALC.makeContextCurrent(context);
ALC.processContext(context);
var data = new Float32Array(44100);
for (i in 0...44100) data[i] = (i / (44100 / 1760) * 2 * Math.PI).sin() * 256 - 128;
var buffer = AL.createBuffer();
AL.bufferData(buffer, AL.FORMAT_MONO8, data, 44100, 44100);
var source = AL.createSource ();
AL.sourcei (source, AL.BUFFER, buffer);
AL.sourcePlay(source);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment