File: Audio.hsc

package info (click to toggle)
haskell-sdl 0.6.4-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 376 kB
  • ctags: 3
  • sloc: haskell: 200; ansic: 18; makefile: 13
file content (54 lines) | stat: -rw-r--r-- 1,584 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "SDL.h"
#ifdef main
#undef main
#endif
-----------------------------------------------------------------------------
-- |
-- Module      :  Graphics.UI.SDL.Audio
-- Copyright   :  (c) David Himmelstrup 2005
-- License     :  BSD-like
--
-- Maintainer  :  lemmih@gmail.com
-- Stability   :  provisional
-- Portability :  portable
--
-----------------------------------------------------------------------------
module Graphics.UI.SDL.Audio
    ( AudioFormat (..)
    , fromAudioFormat
    , toAudioFormat
    ) where

import Data.Word (Word16)

data AudioFormat
    = AudioU8
    | AudioS8
    | AudioU16LSB
    | AudioS16LSB
    | AudioU16MSB
    | AudioS16MSB
    | AudioU16Sys
    | AudioS16Sys
      deriving (Show,Eq,Ord,Enum)

fromAudioFormat :: AudioFormat -> Word16
fromAudioFormat AudioU8 = #{const AUDIO_U8}
fromAudioFormat AudioS8 = #{const AUDIO_S8}
fromAudioFormat AudioU16LSB = #{const AUDIO_U16LSB}
fromAudioFormat AudioS16LSB = #{const AUDIO_S16LSB}
fromAudioFormat AudioU16MSB = #{const AUDIO_U16MSB}
fromAudioFormat AudioS16MSB = #{const AUDIO_S16MSB}
fromAudioFormat AudioU16Sys = #{const AUDIO_U16SYS}
fromAudioFormat AudioS16Sys = #{const AUDIO_S16SYS}

toAudioFormat :: Word16 -> AudioFormat
toAudioFormat #{const AUDIO_U8} = AudioU8
toAudioFormat #{const AUDIO_S8} = AudioS8
toAudioFormat #{const AUDIO_U16LSB} = AudioU16LSB
toAudioFormat #{const AUDIO_S16LSB} = AudioS16LSB
toAudioFormat #{const AUDIO_U16MSB} = AudioU16MSB
toAudioFormat #{const AUDIO_S16MSB} = AudioS16MSB
toAudioFormat _ = error "Graphics.UI.SDL.Audio.toAudioFormat: bad argument"