HSoundFile-0.2.2: Audio file reading/writingSource codeContentsIndex
Sound.Base
Contents
Basic Audio data types
SoundFile types and classes
Error handling
Functions
SoundFile functions
AudioSig functions
Description
Datatypes and functions useful for all SoundFile datatypes.
Synopsis
type SampleRate = Integer
type BitDepth = Integer
type SoundData = Double
type SoundFrame = [SoundData]
type FrameCount = Integer
data AudioSig
data SndFileInfo = SndFileInfo {
numChannels :: Int
sr :: SampleRate
bitDepth :: BitDepth
}
data SndFileType
= AIFF
| WavePCM
| OtherSoundFile String
| Internal
data SoundFile = SoundFile SndFileInfo AudioSig
class SndFileCls a where
getSfInfo :: Monad m => a -> AudioMonad m SndFileInfo
getSfType :: a -> SndFileType
getAudioData :: Monad m => a -> AudioMonad m AudioSig
fromSndFileCls :: Monad m => a -> AudioMonad m SoundFile
getAudioLength :: Monad m => a -> AudioMonad m FrameCount
data AudioError
= NoFormatError
| UnknownFileTypeError
| InvalidBitDepthError BitDepth [BitDepth]
| OtherError String
type AudioMonad m = ErrorT AudioError m
lengthInFrames :: AudioSig -> FrameCount
audioData :: AudioSig -> [SoundFrame]
makeFrames :: Int -> [SoundData] -> [SoundFrame]
interleave :: [[SoundData]] -> [SoundFrame]
makeAudioSignal :: FrameCount -> [SoundFrame] -> AudioSig
appendASig :: AudioSig -> AudioSig -> AudioSig
concatASig :: [AudioSig] -> AudioSig
Basic Audio data types
type SampleRate = IntegerSource
The samplerate value, in samples per second.
type BitDepth = IntegerSource
The bit depth, or word length, of audio data.
type SoundData = DoubleSource
A single sample of audio data. Represented normalized to [-1,1]
type SoundFrame = [SoundData]Source
One frame of audio data, i.e. the sample value for each channel in the data.
type FrameCount = IntegerSource
A position in a data stream, or a length, in frame values.
data AudioSig Source
An audio data stream. This has both the raw audio data (as a list of SoundFrame), and the total length, in frames.
show/hide Instances
SoundFile types and classes
data SndFileInfo Source
Basic information about the audio data: number of channels, samplerate, and bit depth.
Constructors
SndFileInfo
numChannels :: Int
sr :: SampleRate
bitDepth :: BitDepth
show/hide Instances
data SndFileType Source
The type of the SndFileCls Internal is a special type used for the SndFile class.
Constructors
AIFF
WavePCM
OtherSoundFile String
Internal
show/hide Instances
data SoundFile Source
A generic datatype for SoundFile data.
Constructors
SoundFile SndFileInfo AudioSig
show/hide Instances
class SndFileCls a whereSource
The basic class datatypes that represent soundfiles should support.
Methods
getSfInfo :: Monad m => a -> AudioMonad m SndFileInfoSource
get a SndFileInfo with data for the current SoundFile
getSfType :: a -> SndFileTypeSource
get the type of the underlying instance
getAudioData :: Monad m => a -> AudioMonad m AudioSigSource
Get the AudioSig from the SndFileCls instance.
fromSndFileCls :: Monad m => a -> AudioMonad m SoundFileSource
convert a SndFileCls instance to the SoundFile type.
getAudioLength :: Monad m => a -> AudioMonad m FrameCountSource
Get the length of audio data, in frames.
show/hide Instances
Error handling
data AudioError Source
Constructors
NoFormatErrorAudio format information not found in file
UnknownFileTypeErrorFile is not in a recognized file format
InvalidBitDepthError BitDepth [BitDepth]Specified bit depth is not supported
OtherError Stringunspecified error.
show/hide Instances
type AudioMonad m = ErrorT AudioError mSource
Monad to support error handling.
Functions
SoundFile functions
lengthInFrames :: AudioSig -> FrameCountSource
length of the audio data.
audioData :: AudioSig -> [SoundFrame]Source
The audio data.
makeFrames :: Int -> [SoundData] -> [SoundFrame]Source
Convert an interleaved [SoundData] (e.g., [l1, r1, l2, r2,...]) to [SoundFrame]
interleave :: [[SoundData]] -> [SoundFrame]Source
Interleave a [[SoundData]] to [SoundFrame], e.g. [[l1,l2,l3], [r1,r2,r3]] -> [[l1,r1], [l2,r2], [l3, r3]]
AudioSig functions
makeAudioSignal :: FrameCount -> [SoundFrame] -> AudioSigSource
appendASig :: AudioSig -> AudioSig -> AudioSigSource
concatASig :: [AudioSig] -> AudioSigSource
Produced by Haddock version 2.6.0