]> gitweb.factorcode.org Git - factor.git/blob - extra/audio/audio.factor
factor: trim using lists
[factor.git] / extra / audio / audio.factor
1 ! Copyright (C) 2010 Joe Groff.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien arrays combinators math openal ;
4 IN: audio
5
6 TUPLE: audio
7     { channels integer }
8     { sample-bits integer }
9     { sample-rate integer }
10     { size integer }
11     { data c-ptr } ;
12
13 C: <audio> audio
14
15 ERROR: format-unsupported-by-openal audio ;
16
17 : openal-format ( audio -- format )
18     dup [ channels>> ] [ sample-bits>> ] bi 2array {
19         { { 1  8 } [ drop AL_FORMAT_MONO8    ] }
20         { { 1 16 } [ drop AL_FORMAT_MONO16   ] }
21         { { 2  8 } [ drop AL_FORMAT_STEREO8  ] }
22         { { 2 16 } [ drop AL_FORMAT_STEREO16 ] }
23         [ drop format-unsupported-by-openal ]
24     } case ;