]> gitweb.factorcode.org Git - factor.git/blob - extra/audio/audio.factor
Merge branch 'master' into irc
[factor.git] / extra / audio / audio.factor
1 USING: accessors alien arrays combinators kernel math openal ;
2 IN: audio
3
4 TUPLE: audio
5     { channels integer }
6     { sample-bits integer }
7     { sample-rate integer }
8     { size integer }
9     { data c-ptr } ;
10
11 C: <audio> audio
12
13 ERROR: format-unsupported-by-openal audio ;
14
15 : openal-format ( audio -- format )
16     dup [ channels>> ] [ sample-bits>> ] bi 2array {
17         { { 1  8 } [ drop AL_FORMAT_MONO8    ] }
18         { { 1 16 } [ drop AL_FORMAT_MONO16   ] }
19         { { 2  8 } [ drop AL_FORMAT_STEREO8  ] }
20         { { 2 16 } [ drop AL_FORMAT_STEREO16 ] }
21         [ drop format-unsupported-by-openal ]
22     } case ;
23