module Sound.Iteratee.Base ( -- * Types -- ** Internal types AudioStreamState (..), WritableAudio (..), AudioMonad, -- *** Functions to work with AudioMonad module Control.Monad.Trans.State, defaultChunkLength, -- ** Audio Format types AudioFormat (..), SupportedBitDepths (..), NumChannels, SampleRate, BitDepth, FrameCount, -- ** File Format Types SupportedFileFormat (..) ) where import Prelude as P import Control.Monad.Trans.State import System.IO -- |Information about the AudioStream data AudioStreamState = WaveState !(Maybe Handle) !(Maybe AudioFormat) !Integer !Integer !Integer -- ^ Handle, format, Total bytes written, data bytes written, data chunklen offset | NoState deriving (Eq, Show) -- | An enumeration of all file types supported for reading and writing. data SupportedFileFormat = Raw | Wave deriving (Show, Enum, Bounded, Eq) -- | Common functions for writing audio data class WritableAudio a where emptyState :: a -> AudioStreamState initState :: a -> Handle -> AudioStreamState supportedBitDepths :: a -> SupportedBitDepths fileType :: a -> SupportedFileFormat -- | Audio monad stack (for writing files) type AudioMonad = StateT AudioStreamState IO -- | Format of audio data data AudioFormat = AudioFormat { numberOfChannels :: NumChannels, -- ^Number of channels in the audio data sampleRate :: SampleRate, -- ^Sample rate of the audio data bitDepth :: BitDepth -- ^Bit depth of the audio data } deriving (Show, Eq) type NumChannels = Integer type SampleRate = Integer type BitDepth = Integer type FrameCount = Integer data SupportedBitDepths = Any | Supported [BitDepth] defaultChunkLength :: Int defaultChunkLength = 8190