Karya, built on 2022-03-21T01:30:44 (patch 89d1651424c35e564138d93424a157ff87457245)
Safe HaskellSafe-Inferred

Util.Audio.File

Description

Functions to read and write audio files. This should be able to read all formats supported by libsndfile.

Synopsis

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.

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.

writeCheckpoints Source #

Arguments

:: 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