Safe Haskell | Safe-Inferred |
---|
Functions to read and write audio files. This should be able to read all formats supported by libsndfile.
Synopsis
- check :: forall rate chan. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) => Proxy rate -> Proxy chan -> IO.FilePath -> IO.IO (Maybe String)
- checkA :: forall m rate chan. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) => Proxy (Audio.Audio m rate chan) -> IO.FilePath -> IO.IO (Maybe String)
- getInfo :: IO.FilePath -> IO.IO (Maybe Info)
- duration :: IO.FilePath -> IO.IO (Maybe Frames)
- read :: forall rate chan. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) => IO.FilePath -> Audio.AudioIO rate chan
- read44k :: IO.FilePath -> Audio.AudioIO 44100 2
- readUnknown :: IO.FilePath -> IO.IO (Format, Audio.UnknownAudioIO)
- readFrom :: forall rate chan. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) => Frames -> IO.FilePath -> Audio.AudioIO rate chan
- readFromClose :: forall rate chan. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) => Frames -> IO.FilePath -> IO.IO (IO.IO (), Audio.AudioIO rate chan)
- concat :: forall rate chan. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) => [IO.FilePath] -> Audio.AudioIO rate chan
- readCheckpoints :: forall rate chan. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) => Frames -> [IO.FilePath] -> Audio.AudioIO rate chan
- readCheckpointsFrom :: forall rate chan. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) => Frames -> (IO.FilePath -> IO.IO ()) -> Frames -> [IO.FilePath] -> Audio.AudioIO rate chan
- write :: forall rate chan. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) => Format -> IO.FilePath -> Audio.AudioIO rate chan -> Resource.ResourceT IO.IO ()
- writeHandle :: MonadIO m => IO.Handle -> Audio.Audio m rate chan -> m ()
- writeCheckpoints :: forall rate chan state. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) => Frames -> (state -> IO.IO IO.FilePath) -> (IO.FilePath -> IO.IO ()) -> Format -> [state] -> Audio.AudioIO rate chan -> Resource.ResourceT IO.IO Int
- wavFormat :: Format
- throwEnoent :: IO.FilePath -> Maybe a -> IO.IO a
read
check :: forall rate chan. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) => Proxy rate -> Proxy chan -> IO.FilePath -> IO.IO (Maybe String) Source #
Check if rate and channels match the file.
checkA :: forall m rate chan. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) => Proxy (Audio.Audio m rate chan) -> IO.FilePath -> IO.IO (Maybe String) Source #
Like check
, but take Audio.Audio
instead of Proxy.
read :: forall rate chan. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) => IO.FilePath -> Audio.AudioIO rate chan Source #
Since the file is opened only when samples are demanded, a sample rate or channels mismatch will turn into an exception then, not when this is called.
As a special case, if the file channels is 1, it will be expanded to fit whatever channel count was requested.
read44k :: IO.FilePath -> Audio.AudioIO 44100 2 Source #
readUnknown :: IO.FilePath -> IO.IO (Format, Audio.UnknownAudioIO) Source #
readFrom :: forall rate chan. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) => Frames -> IO.FilePath -> Audio.AudioIO rate chan Source #
readFromClose :: forall rate chan. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) => Frames -> IO.FilePath -> IO.IO (IO.IO (), Audio.AudioIO rate chan) Source #
Like readFrom
, but return an action that closes the handle. This is
for Audio.takeClose, so it can close the file early if it terminates the
stream early.
concat :: forall rate chan. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) => [IO.FilePath] -> Audio.AudioIO rate chan Source #
Concatenate multiple files.
readCheckpoints :: forall rate chan. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) => Frames -> [IO.FilePath] -> Audio.AudioIO rate chan Source #
readCheckpointsFrom :: forall rate chan. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) => Frames -> (IO.FilePath -> IO.IO ()) -> Frames -> [IO.FilePath] -> Audio.AudioIO rate chan Source #
This is like concat
, but it understands the 0-duration files written
by writeCheckpoints
, and turns them back into silence.
write
write :: forall rate chan. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) => Format -> IO.FilePath -> Audio.AudioIO rate chan -> Resource.ResourceT IO.IO () Source #
writeHandle :: MonadIO m => IO.Handle -> Audio.Audio m rate chan -> m () Source #
Unlike readHandle
, this writes to a plain IO.Handle instead of a
Sndfile.Handle. Since the plain handle is untyped, the sink will get
interleaved Floats.
:: forall rate chan state. (TypeLits.KnownNat rate, TypeLits.KnownNat chan) | |
=> Frames | |
-> (state -> IO.IO IO.FilePath) | get filename for this state |
-> (IO.FilePath -> IO.IO ()) | write state after the computation |
-> Format | |
-> [state] | Some render-specific state for each checkpoint. Shouldn't run out before the audio runs out. |
-> Audio.AudioIO rate chan | |
-> Resource.ResourceT IO.IO Int | number of checkpoints written |
Write files in chunks to the given directory. Run actions before and after writing each chunk.
misc
throwEnoent :: IO.FilePath -> Maybe a -> IO.IO a Source #