Safe Haskell  None 

Language  Haskell2010 
A highlevel functional interface for manipulating streams of audio.
 data AudioSource m a = AudioSource {}
 type Seconds = Double
 type Frames = Int
 type Rate = Double
 type Channels = Int
 data Duration
 silent :: (Monad m, Num a, Storable a) => Duration > Rate > Channels > AudioSource m a
 sine :: (Monad m, Floating a, Storable a) => a > Duration > Rate > AudioSource m a
 concatenate :: Monad m => AudioSource m a > AudioSource m a > AudioSource m a
 mix :: (Monad m, Num a, Storable a) => AudioSource m a > AudioSource m a > AudioSource m a
 merge :: (Monad m, Num a, Storable a) => AudioSource m a > AudioSource m a > AudioSource m a
 splitChannels :: (Monad m, Storable a) => AudioSource m a > [AudioSource m a]
 padStart :: (Monad m, Num a, Storable a) => Duration > AudioSource m a > AudioSource m a
 padEnd :: (Monad m, Num a, Storable a) => Duration > AudioSource m a > AudioSource m a
 takeStart :: (Monad m, Storable a) => Duration > AudioSource m a > AudioSource m a
 takeEnd :: (Monad m, Storable a) => Duration > AudioSource m a > AudioSource m a
 dropStart :: (Monad m, Storable a) => Duration > AudioSource m a > AudioSource m a
 dropEnd :: (Monad m, Storable a) => Duration > AudioSource m a > AudioSource m a
 fadeIn :: (Monad m, Ord a, Fractional a, Storable a) => AudioSource m a > AudioSource m a
 fadeOut :: (Monad m, Ord a, Fractional a, Storable a) => AudioSource m a > AudioSource m a
 mapSamples :: (Monad m, Storable a, Storable b) => (a > b) > AudioSource m a > AudioSource m b
 gain :: (Monad m, Num a, Storable a) => a > AudioSource m a > AudioSource m a
 vectorFrames :: Storable a => Vector a > Channels > Frames
 framesToSeconds :: Frames > Rate > Seconds
 secondsToFrames :: Seconds > Rate > Frames
 chunkSize :: Frames
 deinterleave :: Storable a => Channels > Vector a > [Vector a]
 interleave :: Storable a => [Vector a] > Vector a
 integralSample :: (RealFrac a, Integral b, Bounded b) => a > b
 fractionalSample :: (Integral a, Bounded a, Fractional b) => a > b
 reorganize :: (Monad m, Storable a) => Frames > AudioSource m a > AudioSource m a
Types
data AudioSource m a Source
An abstraction of a stream of audio. Inside is a Conduit Source
which
loads or generates smallish chunks of audio on demand. m
is the Monad
used by the Source
to produce audio. a
is the type of audio samples,
contained in storable vectors (and thus should be Storable
).
Both (signed) Integral
and Fractional
sample types are supported.
AudioSource  

Used for functions that accept durations in either real time or audio frames.
Generating audio
silent :: (Monad m, Num a, Storable a) => Duration > Rate > Channels > AudioSource m a Source
Generates a stream of silence with the given parameters.
sine :: (Monad m, Floating a, Storable a) => a > Duration > Rate > AudioSource m a Source
Generates a mono sine wave with the given frequency.
Combining audio
concatenate :: Monad m => AudioSource m a > AudioSource m a > AudioSource m a Source
Connects the end of the first audio source to the beginning of the second. The two sources must have the same sample rate and channel count.
mix :: (Monad m, Num a, Storable a) => AudioSource m a > AudioSource m a > AudioSource m a Source
Mixes two audio streams together by adding them samplewise. The two streams must have the same sample rate and channel count. It is recommended to only mix floatingpoint sample types. If you mix integral types and the result goes outside of the type's range, the result will not be a normal "clipping" effect, but will instead overflow, producing glitchy audio.
merge :: (Monad m, Num a, Storable a) => AudioSource m a > AudioSource m a > AudioSource m a Source
Combines the channels of two audio streams into a single source with all the channels. The two streams must have the same sample rate, but can have any number of channels.
splitChannels :: (Monad m, Storable a) => AudioSource m a > [AudioSource m a] Source
Splits an audio stream into several, each providing a single channel of the original stream.
Editing audio
padStart :: (Monad m, Num a, Storable a) => Duration > AudioSource m a > AudioSource m a Source
Adds silence to the start of the audio stream.
padEnd :: (Monad m, Num a, Storable a) => Duration > AudioSource m a > AudioSource m a Source
Adds silence to the end of the audio stream.
takeStart :: (Monad m, Storable a) => Duration > AudioSource m a > AudioSource m a Source
Takes no more than the given duration of audio from the start of the stream.
takeEnd :: (Monad m, Storable a) => Duration > AudioSource m a > AudioSource m a Source
Takes no more than the given duration of audio from the end of the stream.
This function relies on the frames
value stored with the stream.
dropStart :: (Monad m, Storable a) => Duration > AudioSource m a > AudioSource m a Source
Drops the given duration of audio from the start of the stream.
dropEnd :: (Monad m, Storable a) => Duration > AudioSource m a > AudioSource m a Source
Drops the given duration of audio from the end of the stream.
This function relies on the frames
value stored with the stream.
fadeIn :: (Monad m, Ord a, Fractional a, Storable a) => AudioSource m a > AudioSource m a Source
Fades the audio from start (silent) to end (original volume).
This function relies on the frames
value stored with the stream.
fadeOut :: (Monad m, Ord a, Fractional a, Storable a) => AudioSource m a > AudioSource m a Source
Fades the audio from start (original volume) to end (silent).
This function relies on the frames
value stored with the stream.
mapSamples :: (Monad m, Storable a, Storable b) => (a > b) > AudioSource m a > AudioSource m b Source
Applies a function to every sample in the audio stream.
gain :: (Monad m, Num a, Storable a) => a > AudioSource m a > AudioSource m a Source
Multiplies all the audio samples by the given scaling factor.
It is best to use this function on floatingpoint sample types,
for the same reasons that apply to mix
.
Utility functions
vectorFrames :: Storable a => Vector a > Channels > Frames Source
Divides the vector length by the channel count to calculate the number of audio frames.
framesToSeconds :: Frames > Rate > Seconds Source
Uses the sample rate to convert frames to seconds.
secondsToFrames :: Seconds > Rate > Frames Source
Uses the sample rate to convert seconds to frames, rounding if necessary.
deinterleave :: Storable a => Channels > Vector a > [Vector a] Source
Given a vector with interleaved samples, like [L0, R0, L1, R1, ...]
,
converts it into [[L0, L1, ...], [R0, R1, ...]]
.
interleave :: Storable a => [Vector a] > Vector a Source
Opposite of deinterleave
.
All the input vectors should have the same length.
integralSample :: (RealFrac a, Integral b, Bounded b) => a > b Source
Converts fractional samples in the range [1, 1]
to integral samples
in a two'scomplement type. Fractional samples beyond that range are clamped.
fractionalSample :: (Integral a, Bounded a, Fractional b) => a > b Source
Converts integral samples in a two'scomplement type to fractional
samples in the range [1, 1]
.
reorganize :: (Monad m, Storable a) => Frames > AudioSource m a > AudioSource m a Source
Modifies the source so that it outputs vectors of a consistent length in frames. The last vector from the new source may be less than the given length.