Karya, built on 2020-11-26T21:03:17 (patch 23b5be2d53a9e8e7d6136cda5aae2849abe5cded)
Safe HaskellNone

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. (KnownNat rate, KnownNat chan) => Proxy rate -> Proxy chan -> FilePath -> IO (Maybe String) Source #

Check if rate and channels match the file.

checkA :: forall m rate chan. (KnownNat rate, KnownNat chan) => Proxy (Audio.Audio m rate chan) -> FilePath -> IO (Maybe String) Source #

Like check, but take Audio.Audio instead of Proxy.

read :: forall rate chan. (KnownNat rate, KnownNat chan) => 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. (KnownNat rate, KnownNat chan) => Frames -> FilePath -> Audio.AudioIO rate chan Source #

readFromClose :: forall rate chan. (KnownNat rate, KnownNat chan) => Frames -> FilePath -> 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. (KnownNat rate, KnownNat chan) => [FilePath] -> Audio.AudioIO rate chan Source #

Concatenate multiple files.

readCheckpoints :: forall rate chan. (KnownNat rate, KnownNat chan) => Frames -> [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. (KnownNat rate, KnownNat chan) => Format -> FilePath -> Audio.AudioIO rate chan -> Resource.ResourceT IO () Source #

writeCheckpoints Source #

Arguments

:: forall rate chan state. (KnownNat rate, KnownNat chan) 
=> Frames 
-> (state -> IO FilePath)

get filename for this state

-> (FilePath -> 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 Int

number of checkpoints written

Write files in chunks to the given directory. Run actions before and after writing each chunk.

misc