]> gitweb.factorcode.org Git - factor.git/commitdiff
Add play-waveform and play-sine to openal.examples
authorJon Harper <jon.harper87@gmail.com>
Sun, 29 Sep 2013 16:58:16 +0000 (18:58 +0200)
committerJon Harper <jon.harper87@gmail.com>
Sun, 29 Sep 2013 16:58:16 +0000 (18:58 +0200)
extra/openal/example/example.factor

index 54ce402957188711ed9c9510362c1de91214654a..9e438a70eff30871f49e5e0b0e605831476556a0 100755 (executable)
@@ -9,6 +9,18 @@ IN: openal.example
     first dup AL_BUFFER  alutCreateBufferHelloWorld set-source-param
     source-play
     1000 milliseconds sleep ;
+
+: play-waveform ( waveshape freq phase duration -- )
+    init-openal
+    [
+        [ 1 gen-sources first dup AL_BUFFER ] 4dip
+        alutCreateBufferWaveform
+        set-source-param
+        source-play
+    ] [ seconds sleep ] bi ;
+
+: play-sine ( freq duration -- )
+  [ ALUT_WAVEFORM_SINE ] 2dip [ 0 ] dip play-waveform ;
   
 : (play-file) ( source -- )
     100 milliseconds sleep