Created
August 21, 2018 19:20
-
-
Save 01010111/db8fbe9e000ed183c29a19e493ae59b8 to your computer and use it in GitHub Desktop.
Lime + OpenAL + wonky sounds
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 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